Details
Description
These are the things that I have had to do to reproduce the bug:
Have a quiz that has a date range and is currently open.
At least one student has to have made an attempt.
Login as course instructor and view /my/
You will get a 'Incorrect course id in cm' error.
What is happening:
In quiz_print_overview (mod/quiz/lib.php), it iterates through each quiz. If you have the 'mod/quiz:viewreports' capability, then it attempts to print the number of attempts by calling quiz_num_attempt_summary($quiz, $cm, $returnzero = false, $currentgroup = 0) (also in mod/quiz/lib.php).
In the comments just above this call it notes that 'The $quiz objects returned by get_all_instances_in_course have the necessary $cm fields set to make the following call work.', which appears to be true. But, it passes ($quiz, true). quiz_num_attempt_summary does not check for $cm being 'true' (or 1), it assumes it is going to be a coursemodule object and passes it to groups_get_activity_groupmode, which also assumes it is going to be a cm object, and then throws the error because it is not an object.
My proposed fix is to change line 1065 in mod/quiz/lib.php from:
$str .= '<div class="info">' . quiz_num_attempt_summary($quiz, true) . '</div>';
to:
$str .= '<div class="info">' . quiz_num_attempt_summary($quiz, $quiz) . '</div>';
The other option is to add something like this to quiz_num_attempt_summary():
if ($cm == 1) {
$cm = $quiz;
}
-eric