Permalink
Browse files

grade import: MDL-21987 Problem with repeated imports of the same grade.

The thanks to Petr (skodak).

Here is what I learned while working on this:

1. when explicitly setting the final grade (manual edit or import),
   it is important that ->overridden gets set, and it should get set
   to the time when the override was done.

2. but only on certainly sorts of grade item, and the condition for
   setting the flag is different when it is the feedback being changed
   or the grade being changed, hence the two different tests
   is_overridable_item and is_overridable_item_feedback.

3. but, if the grade and feedback is not actually changed, then the ->overridden
   timestamp should not be changed. (That was the bit that was buggy.)
  • Loading branch information...
1 parent dc2c925 commit 8bf6b5c2c84c1c36b9f0682c236fea0c134d91aa @timhunt timhunt committed Mar 31, 2010
Showing with 1 addition and 3 deletions.
  1. +1 −3 lib/grade/grade_item.php
@@ -1448,8 +1448,6 @@ function update_final_grade($userid, $finalgrade=false, $source=NULL, $feedback=
if ($finalgrade !== false) {
if ($this->is_overridable_item()) {
$grade->overridden = time();
- } else {
- $grade->overridden = 0;
}
$grade->finalgrade = $this->bounded_grade($finalgrade);
@@ -1474,7 +1472,7 @@ function update_final_grade($userid, $finalgrade=false, $source=NULL, $feedback=
} else if (grade_floats_different($grade->finalgrade, $oldgrade->finalgrade)
or $grade->feedback !== $oldgrade->feedback
or $grade->feedbackformat != $oldgrade->feedbackformat
- or $grade->overridden != $oldgrade->overridden) {
+ or ($oldgrade->overridden == 0 and $grade->overridden > 0)) {
$grade->timemodified = time(); // hack alert - date graded
$result = $grade->update($source);
} else {

0 comments on commit 8bf6b5c

Please sign in to comment.