MDL-66897 mod_assign: Properly display error messages in quick grading

This commit is contained in:
Mihail Geshoski 2020-01-22 13:37:07 +08:00
parent fd126006b0
commit 9f9a3ddebe

View File

@ -3420,11 +3420,12 @@ class assign {
$this->show_intro(),
$this->get_course_module()->id,
get_string('quickgradingresult', 'assign')));
$gradingerror = in_array($message, $this->get_error_messages());
$lastpage = optional_param('lastpage', null, PARAM_INT);
$gradingresult = new assign_gradingmessage(get_string('quickgradingresult', 'assign'),
$message,
$this->get_course_module()->id,
false,
$gradingerror,
$lastpage);
$o .= $this->get_renderer()->render($gradingresult);
$o .= $this->view_footer();
@ -6772,7 +6773,9 @@ class assign {
$gradingmanager = get_grading_manager($this->get_context(), 'mod_assign', 'submissions');
$controller = $gradingmanager->get_active_controller();
if (!empty($controller)) {
return get_string('errorquickgradingvsadvancedgrading', 'assign');
$message = get_string('errorquickgradingvsadvancedgrading', 'assign');
$this->set_error_message($message);
return $message;
}
$users = array();
@ -6806,7 +6809,9 @@ class assign {
}
if (empty($users)) {
return get_string('nousersselected', 'assign');
$message = get_string('nousersselected', 'assign');
$this->set_error_message($message);
return $message;
}
list($userids, $params) = $DB->get_in_or_equal(array_keys($users), SQL_PARAMS_NAMED);
@ -6860,7 +6865,9 @@ class assign {
// handle hidden columns.
if ($plugin->is_quickgrading_modified($modified->userid, $grade)) {
if ((int)$current->lastmodified > (int)$modified->lastmodified) {
return get_string('errorrecordmodified', 'assign');
$message = get_string('errorrecordmodified', 'assign');
$this->set_error_message($message);
return $message;
} else {
$modifiedusers[$modified->userid] = $modified;
continue;
@ -6895,7 +6902,9 @@ class assign {
$badattempt = (int)$current->attemptnumber != (int)$modified->attemptnumber;
if ($badmodified || $badattempt) {
// Error - record has been modified since viewing the page.
return get_string('errorrecordmodified', 'assign');
$message = get_string('errorrecordmodified', 'assign');
$this->set_error_message($message);
return $message;
} else {
$modifiedusers[$modified->userid] = $modified;
}