diff --git a/grade/grading/form/rubric/lang/en/gradingform_rubric.php b/grade/grading/form/rubric/lang/en/gradingform_rubric.php index cf9455d4bab..dacd5ddaf58 100644 --- a/grade/grading/form/rubric/lang/en/gradingform_rubric.php +++ b/grade/grading/form/rubric/lang/en/gradingform_rubric.php @@ -44,6 +44,7 @@ $string['err_mintwolevels'] = 'Each criterion must have at least two levels'; $string['err_nocriteria'] = 'Rubric must contain at least one criterion'; $string['err_nodefinition'] = 'Level definition can not be empty'; $string['err_nodescription'] = 'Criterion description can not be empty'; +$string['err_novariations'] = 'Criterion levels cannot all be worth the same number of points'; $string['err_scoreformat'] = 'Number of points for each level must be a valid non-negative number'; $string['err_totalscore'] = 'Maximum number of points possible when graded by the rubric must be more than zero'; $string['gradingof'] = '{$a} grading'; @@ -82,4 +83,6 @@ $string['showscorestudent'] = 'Display points for each level to those being grad $string['showscoreteacher'] = 'Display points for each level during evaluation'; $string['sortlevelsasc'] = 'Sort order for levels:'; $string['sortlevelsasc0'] = 'Descending by number of points'; -$string['sortlevelsasc1'] = 'Ascending by number of points'; \ No newline at end of file +$string['sortlevelsasc1'] = 'Ascending by number of points'; +$string['zerolevelsabsent'] = 'Warning: The minimum possible score for this rubric is not 0; this can result in unexpected grades for the activity. To avoid this, each criterion should have a level with 0 points.
+This warning may be ignored if a scale is used for grading, and the minimum levels in the rubric correspond to the minimum value of the scale.'; diff --git a/grade/grading/form/rubric/renderer.php b/grade/grading/form/rubric/renderer.php index 72b6b6052d6..dbaa6661f14 100644 --- a/grade/grading/form/rubric/renderer.php +++ b/grade/grading/form/rubric/renderer.php @@ -633,6 +633,9 @@ class gradingform_rubric_renderer extends plugin_renderer_base { if (!$scores) { return $html; } + if ($scores['minscore'] <> 0) { + $html .= $this->output->notification(get_string('zerolevelsabsent', 'gradingform_rubric'), 'error'); + } $html .= $this->box( html_writer::tag('h4', get_string('rubricmapping', 'gradingform_rubric')). html_writer::tag('div', get_string('rubricmappingexplained', 'gradingform_rubric', (object)$scores)) diff --git a/grade/grading/form/rubric/rubriceditor.php b/grade/grading/form/rubric/rubriceditor.php index 54601b51090..49b0193446f 100644 --- a/grade/grading/form/rubric/rubriceditor.php +++ b/grade/grading/form/rubric/rubriceditor.php @@ -197,6 +197,7 @@ class MoodleQuickForm_rubriceditor extends HTML_QuickForm_input { // iterate through criteria $lastaction = null; $lastid = null; + $overallminscore = $overallmaxscore = 0; foreach ($value['criteria'] as $id => $criterion) { if ($id == 'addcriterion') { $id = $this->get_next_id(array_keys($value['criteria'])); @@ -221,7 +222,7 @@ class MoodleQuickForm_rubriceditor extends HTML_QuickForm_input { $this->nonjsbuttonpressed = true; } $levels = array(); - $maxscore = null; + $minscore = $maxscore = null; if (array_key_exists('levels', $criterion)) { foreach ($criterion['levels'] as $levelid => $level) { if ($levelid == 'addlevel') { @@ -249,6 +250,9 @@ class MoodleQuickForm_rubriceditor extends HTML_QuickForm_input { } } $levels[$levelid] = $level; + if ($minscore === null || (float)$level['score'] < $minscore) { + $minscore = (float)$level['score']; + } if ($maxscore === null || (float)$level['score'] > $maxscore) { $maxscore = (float)$level['score']; } @@ -268,6 +272,8 @@ class MoodleQuickForm_rubriceditor extends HTML_QuickForm_input { $errors['err_nodescription'] = 1; $criterion['error_description'] = true; } + $overallmaxscore += $maxscore; + $overallminscore += $minscore; } if (array_key_exists('moveup', $criterion) || $lastaction == 'movedown') { unset($criterion['moveup']); @@ -307,6 +313,9 @@ class MoodleQuickForm_rubriceditor extends HTML_QuickForm_input { // create validation error string (if needed) if ($withvalidation) { + if ($overallminscore == $overallmaxscore) { + $errors['err_novariations'] = 1; + } if (count($errors)) { $rv = array(); foreach ($errors as $error => $v) {