MDL-45145 mod_quiz: ensure quiz cmid is set before triggering the 'attempt_deleted' event

This commit is contained in:
Mark Nelson 2014-04-17 18:34:47 -07:00
parent a0461340ff
commit a97a7585ff
2 changed files with 7 additions and 0 deletions

View File

@ -372,6 +372,11 @@ function quiz_delete_attempt($attempt, $quiz) {
return;
}
if (!isset($quiz->cmid)) {
$cm = get_coursemodule_from_instance('quiz', $quiz->id, $quiz->course);
$quiz->cmid = $cm->id;
}
question_engine::delete_questions_usage_by_activity($attempt->uniqueid);
$DB->delete_records('quiz_attempts', array('id' => $attempt->id));

View File

@ -318,6 +318,8 @@ abstract class quiz_attempts_report extends quiz_default_report {
continue;
}
// Set the course module id before calling quiz_delete_attempt().
$quiz->cmid = $cm->id;
quiz_delete_attempt($attempt, $quiz);
}
}