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

Can't display quiz attempt when question has been deleted

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.1, 2.2
    • Fix Version/s: 2.1.2
    • Component/s: Questions
    • Labels:
    • Testing Instructions:
      Hide

      1. Create a quiz containing at least two questions, and attempt at as a student.
      2. Go into the database, and delete one of the questions used. (That is, delete the row from the mdl_question table. Ideally also delete the linked data in other tables.)
      3. Review the quiz attempt using that question. Of course, you cannot expect to see the deleted questions, but as much as possible of the remaining information should still be visible and usable.

      (A less destructive way to do step 2. is just to edit the id in the mdl_question table. E.g. change id 123 to id 100123. Then you can easily put it back once you have finished testing.)

      Show
      1. Create a quiz containing at least two questions, and attempt at as a student. 2. Go into the database, and delete one of the questions used. (That is, delete the row from the mdl_question table. Ideally also delete the linked data in other tables.) 3. Review the quiz attempt using that question. Of course, you cannot expect to see the deleted questions, but as much as possible of the remaining information should still be visible and usable. (A less destructive way to do step 2. is just to edit the id in the mdl_question table. E.g. change id 123 to id 100123. Then you can easily put it back once you have finished testing.)
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      Sorry, I need to file another question-related problem. Not sure whether this is only related to data migration.

      When a quiz attempt contains a deleted question, viewing the quiz attempt (mod/quiz/review.php) fails with an error message as below. The remainder of the page is not shown.

      Category ID is invalid

      More information about this error
      Stack trace:

      • line 429 of /lib/setuplib.php: moodle_exception thrown
      • line 1349 of /lib/questionlib.php: call to print_error()
      • line 696 of /mod/quiz/attemptlib.php: call to question_has_capability_on()
      • line 951 of /mod/quiz/attemptlib.php: call to quiz_attempt->get_display_options_with_edit_link()
      • line 182 of /mod/quiz/renderer.php: call to quiz_attempt->render_question()
      • line 54 of /mod/quiz/renderer.php: call to mod_quiz_renderer->questions()
      • line 259 of /mod/quiz/review.php: call to mod_quiz_renderer->review_page()

      This comes about as follows. In qtype_missingtype::make_deleted_instance(), the category id of the "fake" question is set to NULL. However, in lib/questionlib.php, function question_has_capability_on(), the question is tested on having a valid category. None is found, so an error is encountered.

      So far, I was able to reproduce this with migrated data only. Is Moodle 2.1 expected to deal with "deleted questions" or is this a problem of the migration process?

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Oct/11