Issue Details (XML | Word | Printable)

Key: MDL-11211
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Tim Hunt
Reporter: Dean Thayer
Votes: 1
Watchers: 2
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

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

Created: 12/Sep/07 12:03 AM   Updated: 27/Sep/07 03:25 PM
Return to search
Component/s: Questions, Quiz
Affects Version/s: 1.8.2
Fix Version/s: 1.6.6, 1.7.3, 1.8.3, 1.9

Environment: Linux (Fedora Core 5), MySQL 4.1.20, PHP 4.3.8
Issue Links:
Dependency
 
Duplicate
 

Database: Any
Participants: Dean Thayer, Olli Salo and Tim Hunt
Security Level: None
Resolved date: 22/Sep/07
Affected Branches: MOODLE_18_STABLE
Fixed Branches: MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE


 Description  « Hide
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.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
tjhunt committed 1 file to 'Moodle CVS' on branch 'MOODLE_16_STABLE' - 14/Sep/07 01:28 AM
MDL-11081 and MDL-11211 - Implement quiz_question_list_instances. The lach of this function was causing a horrible dataloss bug: MDL-11211. Fix thanks to Janne Mikkonen, refined by me.
MODIFY mod/quiz/lib.php   Rev. 1.245.6.2    (+17 -3 lines)
tjhunt committed 1 file to 'Moodle CVS' on branch 'MOODLE_17_STABLE' - 14/Sep/07 01:29 AM
MDL-11081 and MDL-11211 - Implement quiz_question_list_instances. The lach of this function was causing a horrible dataloss bug: MDL-11211. Fix thanks to Janne Mikkonen, refined by me. Merged from MOODLE_16_STABLE.
MODIFY mod/quiz/lib.php   Rev. 1.255.2.5    (+16 -2 lines)
tjhunt committed 1 file to 'Moodle CVS' - 14/Sep/07 01:29 AM
MDL-11081 and MDL-11211 - Implement quiz_question_list_instances. The lach of this function was causing a horrible dataloss bug: MDL-11211. Fix thanks to Janne Mikkonen, refined by me. Merged from MOODLE_16_STABLE.
MODIFY mod/quiz/lib.php   Rev. 1.277    (+16 -2 lines)
tjhunt committed 1 file to 'Moodle CVS' on branch 'MOODLE_18_STABLE' - 14/Sep/07 01:29 AM
MDL-11081 and MDL-11211 - Implement quiz_question_list_instances. The lach of this function was causing a horrible dataloss bug: MDL-11211. Fix thanks to Janne Mikkonen, refined by me. Merged from MOODLE_16_STABLE.
MODIFY mod/quiz/lib.php   Rev. 1.261.2.8    (+16 -2 lines)