Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.6.1
-
Fix Version/s: None
-
Component/s: Questions
-
Labels:None
-
Environment:Linux
-
Database:MySQL
-
Affected Branches:MOODLE_16_STABLE
Description
Deleting a course failed while trying to delete associated questions. The delete_question function searches for child questions and then is recursively called to delete each of those.
Some way I have yet to figure out, a number of questions in the mdl_question table had id == parent. Delete courses would be working on question id 15, ask for it's children via:
$children = get_records('question', 'parent', $questionid)
and receive a children array with 15 in it. delete_question would be called again with the original 15 id, find 15 as a child again until php croaked.
I realize this may be a problem with question creation rather than the delete function, but I haven't had a chance to dig into that too much (we're deploying Moodle for the first time this fall so everything is a bit new to me). I've patched the delete_question function so what in 1.6.1 was:
376 // Now recursively delete all child questions
377 if ($children = get_records('question', 'parent', $questionid)) {
378 foreach ($children as $child) { 379 delete_question($child->id); 380 }
381 }
is now
376 // Now recursively delete all child questions
377 if ($children = get_records('question', 'parent', $questionid)) {
378 foreach ($children as $child) {
379 if($child->id != $questionid){ delete_question($child->id); }
380 }
381 }
If someone is interested in the question creation issue, here's a snapshot of mdl_question where id == parent:
mysql> select * from mdl_question where id = parent ;
------------------------------------------------------------------------------------------------------------------------------------------------------------------+
/ id / category / parent / name / questiontext / questiontextformat / image / defaultgrade / penalty / qtype / length / stamp / version / hidden /
------------------------------------------------------------------------------------------------------------------------------------------------------------------+
/ 7 / 3 / 7 / Random Question (Default) / 1 / 0 / / 1 / 0 / random / 1 / moodle.carleton.edu+051130175403+RBFDlE / 1 / 0 /
/ 13 / 4 / 13 / Random Question (Default) / 1 / 0 / / 1 / 0 / random / 1 / moodle.carleton.edu+051209201342+1rRzcS / 1 / 0 /
/ 15 / 5 / 15 / Random Question (Default) / 1 / 0 / / 1 / 0 / random / 1 / moodle.carleton.edu+051209202059+iJ5x5q / 1 / 0 /
/ 16 / 5 / 16 / Random Question (Default) / 1 / 0 / / 1 / 0 / random / 1 / moodle.carleton.edu+051209202340+rXiDf3 / 1 / 0 /
/ 17 / 5 / 17 / Random Question (Default) / 1 / 0 / / 1 / 0 / random / 1 / moodle.carleton.edu+051209202340+aqI8mi / 1 / 0 /
/ 21 / 7 / 21 / My Random Question / — / 0 / / 1 / 0.1 / random / 1 / moodle.org+040624053947+2j01vC / 1 / 1 /
/ 144 / 11 / 144 / Random Question (Default) / 1 / 0 / / 1 / 0 / random / 1 / moodle.carleton.edu+060310173047+MguClP / 2 / 0 /
------------------------------------------------------------------------------------------------------------------------------------------------------------------+
hopefully that won't get too mangled in the textarea.
Thanks!
Issue Links
| This issue will be resolved by: | ||||
| MDL-6265 | Perfomance deleting course |
|
|
|
Activity
- All
- Comments
- History
- Activity
- Source
- Test Sessions
From Tim Hunt (T.J.Hunt at open.ac.uk) Thursday, 17 August 2006, 12:17 AM:
Thanks for the report and the solution. The parent = id thing is a nasty hack used by the random question type.
Fix checked in to 1.7dev and 1.6.1+.