Issue Details (XML | Word | Printable)

Key: MDL-15605
Type: Task Task
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Tim Hunt
Reporter: Tim Hunt
Votes: 0
Watchers: 2
Operations

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

Convert question bank consistency checks described in MoodleDocs to health centre checks

Created: 10/Jul/08 09:06 PM   Updated: 01/Sep/08 01:29 PM
Component/s: Questions
Affects Version/s: 2.0
Fix Version/s: 1.7.6, 1.8.7, 1.9.3, 2.0

File Attachments: 1. Text File health.php.diff.txt (3 kB)


Participants: Matthew Davidson and Tim Hunt
Security Level: None
Resolved date: 01/Sep/08
Affected Branches: MOODLE_20_STABLE
Fixed Branches: MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE



 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Tim Hunt added a comment - 20/Aug/08 04:53 PM
Not all of the checks apply before 1.9, so the back-porting was selective.

Matthew Davidson added a comment - 28/Aug/08 10:14 PM
fixed some SQL problems in a solution for questions and categories without valid contexts. example(in MySQL the EXISTS function is misspelled as EXIST and it cannot work in a DELETE statement). Also sensed if questions exist in these orphaned categories and gave the SQL to delete these questions before deleting the categories. See attached .diff

Matthew Davidson added a comment - 28/Aug/08 10:15 PM
fix

Tim Hunt added a comment - 29/Aug/08 11:29 AM
Reopening so I can apply the fix.

Matthew, you cannot delete questions like that. Look at the delete_question function in lib/questionlib.php to see some of the issues involved. In particular, note that it does not actually delete questions if they are still in use by a quiz, because that would break the display of past quiz results, which would be a very bad thing in an educational context.

It is better to put up with lack of referential integrity in the database than to do that. For categories with questions, it would be better to move them to a valid category, and maybe change the category name or info to explain what happened. Have a look at the logic in question_save_from_deletion, which is called from question_delete_course_category if you really want to go at fixing this issue properly.


Matthew Davidson added a comment - 29/Aug/08 08:23 PM
Tim can I ask how a question or a category can lose it's context and still be used somewhere? I don't understand how this situation could happen. Also, a small amount of my fix should still apply since the SQL that I posted works and the previous SQL solution didn't.

Tim Hunt added a comment - 01/Sep/08 11:36 AM
For storing and organising questions, the key links are question -> question_category -> context.

However, when questions are used, you get links quiz -> quiz_question_instances -> questions. And when random questions are involved, you get really hard-to-find links, which is something that has to be improved some day.

Also, it is, unfortunately, possible to add questions to a quiz in one course, the move things around in the question bank, so the question ends up in somewhere unrelated to the quiz. That nasty possibility is something that was only realised recently: MDL-14802.

However, I will apply the SQL syntax fix. Thanks for that.


Tim Hunt added a comment - 01/Sep/08 01:07 PM
By the way, what diff format is that? It would be much easier if you could generate standard unified diffs. http://docs.moodle.org/en/Development:How_to_create_a_patch. Don't worry about regenerating this patch, but in future ...

Tim Hunt added a comment - 01/Sep/08 01:29 PM
SQL fix applied. Thanks.