Moodle

Problems in the quiz when the grade is locked in the gradebook

Details

  • Type: Bug Bug
  • Status: Reopened Reopened
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.9.3
  • Fix Version/s: STABLE backlog
  • Component/s: Gradebook, Quiz
  • Labels:
    None
  • Difficulty:
    Difficult
  • Affected Branches:
    MOODLE_19_STABLE

Description

To think, this whole mess started from:

Notice: Undefined offset: 0 in /var/www/html/tjh238/1.9/mod/quiz/lib.php on line 381

Notice: Trying to get property of non-object in /var/www/html/tjh238/1.9/mod/quiz/lib.php on line 382

Issue Links

Activity

Hide
Tim Hunt added a comment -

Quick fix checked in. Petr, please review.

Show
Tim Hunt added a comment - Quick fix checked in. Petr, please review.
Hide
Petr Škoda (skodak) added a comment -

Assigning to NIcolas, we definitely can not throw such

if ($grade_item->locked) {
$confirm_regrade = optional_param('confirm_regrade', 0, PARAM_INT);
if (!$confirm_regrade) { $message = get_string('gradeitemislocked', 'grades'); $back_link = $CFG->wwwroot . '/mod/quiz/report.php?q=' . $quiz->id . '&mode=overview'; $regrade_link = qualified_me() . '&confirm_regrade=1'; print_box_start('generalbox', 'notice'); echo '<p>'. $message .'</p>'; echo '<div class="buttons">'; print_single_button($regrade_link, null, get_string('regradeanyway', 'grades'), 'post', $CFG->framename); print_single_button($back_link, null, get_string('cancel'), 'post', $CFG->framename); echo '</div>'; print_box_end(); return GRADE_UPDATE_ITEM_LOCKED; }
}

interactive "confirmations" in the middle of function from lib.php which may be used from anywhere, this would break really soon

Please move it somewhere else asap.

Show
Petr Škoda (skodak) added a comment - Assigning to NIcolas, we definitely can not throw such if ($grade_item->locked) { $confirm_regrade = optional_param('confirm_regrade', 0, PARAM_INT); if (!$confirm_regrade) { $message = get_string('gradeitemislocked', 'grades'); $back_link = $CFG->wwwroot . '/mod/quiz/report.php?q=' . $quiz->id . '&mode=overview'; $regrade_link = qualified_me() . '&confirm_regrade=1'; print_box_start('generalbox', 'notice'); echo '<p>'. $message .'</p>'; echo '<div class="buttons">'; print_single_button($regrade_link, null, get_string('regradeanyway', 'grades'), 'post', $CFG->framename); print_single_button($back_link, null, get_string('cancel'), 'post', $CFG->framename); echo '</div>'; print_box_end(); return GRADE_UPDATE_ITEM_LOCKED; } } interactive "confirmations" in the middle of function from lib.php which may be used from anywhere, this would break really soon Please move it somewhere else asap.
Hide
Nicolas Connault added a comment -

Here is my very extensive patch (considering the smallness of the original report). Please review carefully, it goes into the tripes in order to give the module more responsibility over the handling of errors (particularly locking status) coming from the gradebook.

Show
Nicolas Connault added a comment - Here is my very extensive patch (considering the smallness of the original report). Please review carefully, it goes into the tripes in order to give the module more responsibility over the handling of errors (particularly locking status) coming from the gradebook.
Hide
Tim Hunt added a comment -

Note, large chunks of this patch no longer apply, so it is not possible to review. What do we want to do about this?

Show
Tim Hunt added a comment - Note, large chunks of this patch no longer apply, so it is not possible to review. What do we want to do about this?
Hide
Tim Hunt added a comment -

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.

Show
Tim Hunt added a comment - 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.

People

Vote (2)
Watch (9)

Dates

  • Created:
    Updated: