MDL-36167: Assignment quickgrading fix when there is no grade (ensure feedback still saves)
This patch modifies the previous on by Luke Tucker so that the lastmodified hidden field is always added to the quickgrading form even if there is no grade for the assignment. This ensures that the lastmodified checks still work (to prevent teachers overwriting each others feedback) and feedback is saved when there is no grade.
This commit is contained in:
committed by
Dan Poltawski
parent
a13a1707bc
commit
3b7a18f2e5
+20
-13
@@ -1022,6 +1022,8 @@ class assign {
|
||||
|
||||
static $scalegrades = array();
|
||||
|
||||
$o = '';
|
||||
|
||||
if ($this->get_instance()->grade >= 0) {
|
||||
// Normal number
|
||||
if ($editing && $this->get_instance()->grade > 0) {
|
||||
@@ -1030,17 +1032,20 @@ class assign {
|
||||
} else {
|
||||
$displaygrade = format_float($grade);
|
||||
}
|
||||
$o = '<label class="accesshide" for="quickgrade_' . $userid . '">' . get_string('usergrade', 'assign') . '</label>';
|
||||
$o .= '<input type="text" id="quickgrade_' . $userid . '" name="quickgrade_' . $userid . '" value="' . $displaygrade
|
||||
. '" size="6" maxlength="10" class="quickgrade"/>';
|
||||
$o .= '<label class="accesshide" for="quickgrade_' . $userid . '">' . get_string('usergrade', 'assign') . '</label>';
|
||||
$o .= '<input type="text" id="quickgrade_' . $userid . '" name="quickgrade_' . $userid . '" value="' .
|
||||
$displaygrade . '" size="6" maxlength="10" class="quickgrade"/>';
|
||||
$o .= ' / ' . format_float($this->get_instance()->grade,2);
|
||||
$o .= '<input type="hidden" name="grademodified_' . $userid . '" value="' . $modified . '"/>';
|
||||
return $o;
|
||||
} else {
|
||||
$o .= '<input type="hidden" name="grademodified_' . $userid . '" value="' . $modified . '"/>';
|
||||
if ($grade == -1 || $grade === null) {
|
||||
return '-';
|
||||
$o .= '-';
|
||||
return $o;
|
||||
} else {
|
||||
return format_float(($grade),2) .' / '. format_float($this->get_instance()->grade,2);
|
||||
$o .= format_float(($grade),2) .' / '. format_float($this->get_instance()->grade,2);
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1050,11 +1055,12 @@ class assign {
|
||||
if ($scale = $DB->get_record('scale', array('id'=>-($this->get_instance()->grade)))) {
|
||||
$this->cache['scale'] = make_menu_from_list($scale->scale);
|
||||
} else {
|
||||
return '-';
|
||||
$o .= '-';
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
if ($editing) {
|
||||
$o = '<label class="accesshide" for="quickgrade_' . $userid . '">' . get_string('usergrade', 'assign') . '</label>';
|
||||
$o .= '<label class="accesshide" for="quickgrade_' . $userid . '">' . get_string('usergrade', 'assign') . '</label>';
|
||||
$o .= '<select name="quickgrade_' . $userid . '" class="quickgrade">';
|
||||
$o .= '<option value="-1">' . get_string('nograde') . '</option>';
|
||||
foreach ($this->cache['scale'] as $optionid => $option) {
|
||||
@@ -1070,9 +1076,11 @@ class assign {
|
||||
} else {
|
||||
$scaleid = (int)$grade;
|
||||
if (isset($this->cache['scale'][$scaleid])) {
|
||||
return $this->cache['scale'][$scaleid];
|
||||
$o .= $this->cache['scale'][$scaleid];
|
||||
return $o;
|
||||
}
|
||||
return '-';
|
||||
$o .= '-';
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3448,12 +3456,12 @@ class assign {
|
||||
// gets a list of possible users and look for values based upon that.
|
||||
foreach ($participants as $userid => $unused) {
|
||||
$modified = optional_param('grademodified_' . $userid, -1, PARAM_INT);
|
||||
// gather the userid, updated grade and last modified value
|
||||
// Gather the userid, updated grade and last modified value.
|
||||
$record = new stdClass();
|
||||
$record->userid = $userid;
|
||||
$gradevalue = optional_param('quickgrade_' . $userid, '', PARAM_TEXT);
|
||||
if($modified >= 0) {
|
||||
$record->grade = unformat_float(required_param('quickgrade_' . $record->userid, PARAM_TEXT));
|
||||
$record->grade = unformat_float(optional_param('quickgrade_' . $record->userid, -1, PARAM_TEXT));
|
||||
}
|
||||
$record->lastmodified = $modified;
|
||||
$record->gradinginfo = grade_get_grades($this->get_course()->id, 'mod', 'assign', $this->get_instance()->id, array($userid));
|
||||
@@ -3491,8 +3499,7 @@ class assign {
|
||||
foreach ($this->feedbackplugins as $plugin) {
|
||||
if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->supports_quickgrading()) {
|
||||
if ($plugin->is_quickgrading_modified($modified->userid, $grade)) {
|
||||
if ($modified->lastmodified >= 0 &&
|
||||
(int)$current->lastmodified > (int)$modified->lastmodified) {
|
||||
if ((int)$current->lastmodified > (int)$modified->lastmodified) {
|
||||
return get_string('errorrecordmodified', 'assign');
|
||||
} else {
|
||||
$modifiedusers[$modified->userid] = $modified;
|
||||
|
||||
Reference in New Issue
Block a user