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

Deletion of a course with published questions destroys quizzes in other courses that have used those questions.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.8.2
    • Fix Version/s: 1.6.6, 1.7.3, 1.8.3, 1.9
    • Component/s: Questions, Quiz
    • Labels:
      None
    • Environment:
      Linux (Fedora Core 5), MySQL 4.1.20, PHP 4.3.8
    • Database:
      Any
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE

      Description

      How to reproduce this problem (see http://moodle.org/mod/forum/discuss.php?d=61665#p351718) :

      1. Create a course (C1).
      2. Create a quiz (Z1) in C1.
      3. Create a question (Q1) in Default category and add it to Z1.
      4. Publish Q1.
      5. Create a course (C2).
      6. Create a quiz (Z2) in C2.
      7. Add Q1 to Z2.
      8. Delete C2.
      9. View Z1. It will have been destroyed.

      I've been studying this problem for several hours and it seems to me that there is a problem with the data model for quizzes and questions which causes this bug. Of course, I might not have an accurate picture of how the data model works. The use of comma separated question ids in the questions column of the quiz table implies to me that quiz/question relationships are maintained at the application layer instead of in the data model. The quiz_question_instances table implies by name and indicates in documentation (http://docs.moodle.org/en/Quiz_database_structure#quiz_question_instances) that it can be used to link questions to quizzes, but my experimentation has led me to conclude that it is the comma separated values in quiz.questions that define the relationship. If that is the case, I would humbly suggest that we reorganize the data model for quizzes and questions to facilitate relational integrity preservation at the database level, and allow for more efficient queries of quiz/question data. At least we could let quiz_question_instances define the relationships instead of quiz.questions. This would require a substantial amount of code changes, but I think it would be well worth it.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                timhunt Tim Hunt
                Reporter:
                deanthayer Dean Thayer
                Tester:
                Nobody
                Participants:
                Component watchers:
                Tim Hunt, Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze, Tim Hunt, Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

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