Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-31713 core_grade:added a unit test to replicate a raw grade max bug

  • Loading branch information...
commit 12091f27cf394af17cab9e957e30e319b19b8182 1 parent 5e00b9a
@andyjdavis andyjdavis authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 lib/grade/tests/grade_item_test.php
View
31 lib/grade/tests/grade_item_test.php
@@ -63,6 +63,7 @@ public function test_grade_item() {
$this->sub_test_grade_item_set_calculation();
$this->sub_test_grade_item_get_calculation();
$this->sub_test_grade_item_compute();
+ $this->sub_test_update_final_grade();
}
protected function sub_test_grade_item_construct() {
@@ -552,4 +553,34 @@ public function sub_test_grade_item_compute() {
$grade_grade = grade_grade::fetch(array('userid'=>$this->grade_grades[5]->userid, 'itemid'=>$this->grade_grades[5]->itemid));
$this->assertEquals($this->grade_grades[5]->finalgrade, $grade_grade->finalgrade);
}
+
+ protected function sub_test_update_final_grade() {
+
+ // MDL-31713 Check that min and max are set on the grade_grade instance
+ // if the grade is overridden before the activity has supplied a grade.
+ $min = 2;
+ $max = 8;
+
+ // Create a brand new grade item.
+ $grade_item = new grade_item();
+ $this->assertTrue(method_exists($grade_item, 'insert'));
+
+ $grade_item->courseid = $this->courseid;
+ $grade_item->categoryid = $this->grade_categories[1]->id;
+ $grade_item->itemname = 'brand new unit test grade item';
+ $grade_item->itemtype = 'mod';
+ $grade_item->itemmodule = 'quiz';
+ $grade_item->iteminfo = 'Grade item used for unit testing';
+ $grade_item->grademin = $min;
+ $grade_item->grademax = $max;
+ $grade_item->insert();
+
+ // Override the student grade.
+ $grade_item->update_final_grade($this->user[1]->id, 7, 'gradebook', '', FORMAT_MOODLE);
+
+ // Check the student's grade has the correct min and max grade.
+ $grade_grade = grade_grade::fetch(array('userid'=>$this->user[1]->id, 'itemid'=>$grade_item->id));
+ $this->assertEquals($min, $grade_grade->rawgrademin);
+ $this->assertEquals($max, $grade_grade->rawgrademax);
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.