Right, so thinking about how to solve this, I propose the following pragmatic solution for the 1.9 branch, pending bigger changes in HEAD.
1. We should just delete the code that Petr objects to. He is right, it has no place there.
2. We should adopt the policy that, if stuff is locked in the gradebook, then, we just update information in the quiz, and don't synchronise to the gradebook. That is not ideal, but...
3. We try to find all the places in the quiz where grades can changes, in when the gradeitem is locked, we disable as many as possible. (With a message explaining why.)
4. To that end, I will make a new function quiz_grade_locked($quiz, $userid = null);
More specifically (3) when the grade item is locked we disable:
A. the Grading method and Apply penalties options on the quiz settings form.
B. the Manual grading links on the quiz review page.
C. the ability to delete student attempts in the overview report.
D. the ability to regrade attempts.
E. the manual grading report.
F. the ability to adjust individual question grades, or the total quiz grade, on the editing tab.
However, we do not prevent students from completing or continuing attempts.
I think the quiz_grade_locked function looks like: (not tested yet)
function quiz_grade_locked($quiz, $userid = null) {
$gradebook_grades = grade_get_grades($quiz->course, 'mod', 'quiz', $quiz->id, $userid);
if (empty($gradebook_grades->items)) {
return false;
}
$grade_item = $gradebook_grades->items[0];
if ($grade_item->locked) {
return true;
} else if (!is_null($userid)) {
return $grade_item->grades[$userid]->locked;
} else { return false; } }
}
I would appreciate comments on this, and I'm afraid that I would like them ASAP, because I would like to try to make a patch on Monday. Thanks.
Quick fix checked in. Petr, please review.