-
Bug
-
Resolution: Fixed
-
Minor
-
3.2.6, 3.3.3, 3.4
-
MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE
-
MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
-
MDL-61033-master -
Steps to reproduce:
- As teacher. create a quiz.
- Go to the Edit quiz page and add two true-false questions.
- In a second browser tab, start a preview of the quiz.
- In the first browser tab delete one of the questions from the quiz (or edit the quiz settings, or various other things).
- In the second browser tab, click 'Next' (or do almost anything else related to attempting the quiz).
Actual result: Error "Can not find data record in database table quiz_attempts." Clicking continue takes you to the home page.
Expected result: A meaningful error message that explains what happened. Continue button goes to .../mod/quiz/view.php for this quiz, so that a new preview can be started.
Explanation: Many actions (in mod/quiz/edit.php and edit_rest.php) call quiz_delete_previews(). This is correct behaviour.
However, during a quiz attempt (real, or preview) the URL looks like .../mod/quiz/attempt.php?attempt=2. Therefore, if the preview has been deleted there is no way to work out which quiz this related to.
A similar situation could also happen if the teacher deletes a student's quiz attempt (using the quiz repors) while a student is working on it. Any on-screen messages should handle that case as well.
- Technical reference:
- In preview, attempt, it will load data from mdl_quiz_attempts table:
mod/quiz/attempt.php: line 43 $attemptobj = quiz_attempt::create($attemptid);
mod/quiz/attemptlib.php: in function create_helper
It load attempt data: $attempt = $DB->get_record('quiz_attempts', $conditions, '*', MUST_EXIST);
It will throw Moodle exception here.
- When edit quiz, it will remove all quiz attempts data:
mod/quiz/edit.php
mod/quiz/edit_rest.php
Any action, it will call quiz_delete_previews function
mod/quiz/locallib.php
In quiz_delete_previews function, call quiz_delete_attempt to delete all attempt.