Permalink
Browse files

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.

Conflicts:

	mod/assign/locallib.php
  • Loading branch information...
1 parent 9e49423 commit 7cc72770649ed813e09458a52f2773864125be56 Damyon Wiese committed Nov 21, 2012
Showing with 18 additions and 11 deletions.
  1. +18 −11 mod/assign/locallib.php
View
@@ -966,6 +966,8 @@ public function display_grade($grade, $editing, $userid=0, $modified=0) {
static $scalegrades = array();
+ $o = '';
+
if ($this->get_instance()->grade >= 0) {
// Normal number
if ($editing && $this->get_instance()->grade > 0) {
@@ -974,15 +976,18 @@ public function display_grade($grade, $editing, $userid=0, $modified=0) {
} else {
$displaygrade = format_float($grade);
}
- $o = '<input type="text" name="quickgrade_' . $userid . '" value="' . $displaygrade . '" size="6" maxlength="10" class="quickgrade"/>';
+ $o .= '<input type="text" name="quickgrade_' . $userid . '" value="' . $displaygrade . '" size="6" maxlength="10" class="quickgrade"/>';
$o .= '&nbsp;/&nbsp;' . 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) .'&nbsp;/&nbsp;'. format_float($this->get_instance()->grade,2);
+ $o .= format_float(($grade),2) .'&nbsp;/&nbsp;'. format_float($this->get_instance()->grade,2);
+ return $o;
}
}
@@ -992,11 +997,12 @@ public function display_grade($grade, $editing, $userid=0, $modified=0) {
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 = '<select name="quickgrade_' . $userid . '" class="quickgrade">';
+ $o .= '<select name="quickgrade_' . $userid . '" class="quickgrade">';
$o .= '<option value="-1">' . get_string('nograde') . '</option>';
foreach ($this->cache['scale'] as $optionid => $option) {
$selected = '';
@@ -1011,9 +1017,11 @@ public function display_grade($grade, $editing, $userid=0, $modified=0) {
} 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;
}
}
}
@@ -2613,12 +2621,12 @@ private function process_save_quick_grades() {
// 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));
@@ -2656,8 +2664,7 @@ private function process_save_quick_grades() {
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;

0 comments on commit 7cc7277

Please sign in to comment.