commit adcc6d3139f5731ba8e2272e4e3c24605768c955 Author: Rushikesh Date: Thu Jan 14 21:16:11 2016 +0530 MDL-33663 Grading methods: Appropriate error message for negative grades diff --git a/grade/grading/form/guide/lang/en/gradingform_guide.php b/grade/grading/form/guide/lang/en/gradingform_guide.php index 87f7a11..38e9ca7 100644 --- a/grade/grading/form/guide/lang/en/gradingform_guide.php +++ b/grade/grading/form/guide/lang/en/gradingform_guide.php @@ -58,6 +58,7 @@ $string['err_nomaxscore'] = 'Criterion max score can not be empty'; $string['err_noshortname'] = 'Criterion name can not be empty'; $string['err_shortnametoolong'] = 'Criterion name must be less than 256 characters'; $string['err_scoreinvalid'] = 'The score given to {$a->criterianame} is not valid, the max score is: {$a->maxscore}'; +$string['err_scoreisnegative'] = 'The grade is invalid as it is negative and acceptable range is 0 - {$a->maxscore}'; $string['gradingof'] = '{$a} grading'; $string['guide'] = 'Marking guide'; $string['guidemappingexplained'] = 'WARNING: Your marking guide has a maximum grade of {$a->maxscore} points but the maximum grade set in your activity is {$a->modulegrade} The maximum score set in your marking guide will be scaled to the maximum grade in the module.
diff --git a/grade/grading/form/guide/lib.php b/grade/grading/form/guide/lib.php index a6c17eb..25c797e 100644 --- a/grade/grading/form/guide/lib.php +++ b/grade/grading/form/guide/lib.php @@ -795,7 +795,7 @@ class gradingform_guide_instance extends gradingform_instance { || $criterion['maxscore'] < $elementvalue['criteria'][$id]['score'] || !is_numeric($elementvalue['criteria'][$id]['score']) || $elementvalue['criteria'][$id]['score'] < 0) { - $this->validationerrors[$id]['score'] = $elementvalue['criteria'][$id]['score']; + $this->validationerrors[$id]['score'] = $elementvalue['criteria'][$id]['score']; } } if (!empty($this->validationerrors)) { @@ -943,8 +943,13 @@ class gradingform_guide_instance extends gradingform_instance { $a = new stdClass(); $a->criterianame = s($criteria[$id]['shortname']); $a->maxscore = $criteria[$id]['maxscore']; - $html .= html_writer::tag('div', get_string('err_scoreinvalid', 'gradingform_guide', $a), + if ($this->validationerrors[$id]['score'] < 0) { + $html .= html_writer::tag('div', get_string('err_scoreisnegative', 'gradingform_guide', $a), array('class' => 'gradingform_guide-error')); + } else { + $html .= html_writer::tag('div', get_string('err_scoreinvalid', 'gradingform_guide', $a), + array('class' => 'gradingform_guide-error')); + } } } }