Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-61033

Editing a quiz while a preview is open in another browser tab can leads to a cryptic error that is hard to recover from

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.3.6, 3.4.3, 3.5
    • 3.2.6, 3.3.3, 3.4
    • Quiz
    • MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE
    • MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
    • MDL-61033-master
    • Hide
      1. Login as a teacher
      2. Open a course
      3. Turn editing on
      4. Create a quiz
      5. Click "Edit quiz"
      6. Add two true-false questions.
      7. Open the quiz again in a new tab of the browser (same user logged in)
      8. Start a preview of the quiz
      9. In the first browser tab delete one of the questions from the quiz (or edit the quiz settings, or various other things).
      10. In the second browser tab, click 'Next' (or do almost anything else related to attempting the quiz).
        1. Confirm that a meaningful error message explaining the error was shown
      11. Click the Continue button
        1. Confirm that it takes you back to the quiz/view.php page where it is possible to start a new preview
      Show
      Login as a teacher Open a course Turn editing on Create a quiz Click " Edit quiz " Add two true-false questions. Open the quiz again in a new tab of the browser (same user logged in) 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). Confirm that a meaningful error message explaining the error was shown Click the Continue button Confirm that it takes you back to the quiz/view.php page where it is possible to start a new preview

      Steps to reproduce:

      1. As teacher. create a quiz.
      2. Go to the Edit quiz page and add two true-false questions.
      3. In a second browser tab, start a preview of the quiz.
      4. In the first browser tab delete one of the questions from the quiz (or edit the quiz settings, or various other things).
      5. 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.

       

      1. 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.

        1. Step 10_verified_MDL-61033.PNG
          51 kB
          Anna Carissa Sadia
        2. Step 11_verified_MDL-61033.PNG
          44 kB
          Anna Carissa Sadia

            ndloc1905 Loc Nguyen Dinh
            ndloc1905 Loc Nguyen Dinh
            Tim Hunt Tim Hunt
            Andrew Lyons Andrew Lyons
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 30 minutes
                1h 30m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.