From af2f92d0887507b92fc4dffd3f8e7b6abfcca614 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Mon, 1 Sep 2008 05:29:26 +0000 Subject: [PATCH] MDL-15605 - Fix solution SQL syntax for the "question categories must belong to a context that exists" check. --- admin/health.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/admin/health.php b/admin/health.php index 2ea0c6ae68..56d5d29416 100644 --- a/admin/health.php +++ b/admin/health.php @@ -645,13 +645,9 @@ class problem_000015 extends problem_base { ORDER BY numquestions DESC, qc.name"); $table = '' . "\n"; - $maxnumquestions = 0; foreach ($problemcategories as $cat) { - $table .= "\n"; - if ($maxnumquestions < $cat->numquestions) { - $maxnumquestions = $cat->numquestions; - } } $table .= '
Cat idCategory nameContext idNum Questions
$cat->id/td>" . s($cat->name) . "" . + $table .= "
$cat->id" . s($cat->name) . "" . $cat->contextid ."$cat->numquestions
'; return '

All question categories are linked to a context id, and, ' . @@ -663,10 +659,10 @@ class problem_000015 extends problem_base { function solution() { global $CFG; return '

You can delete the empty categories by executing the following SQL:

-DELETE FROM ' . $CFG->prefix . 'question_categories
+DELETE FROM ' . $CFG->prefix . 'question_categories qc
 WHERE
-    NOT EXIST (SELECT * FROM ' . $CFG->prefix . 'question q WHERE q.category = qc.id)
-AND NOT EXIST (SELECT * FROM ' . $CFG->prefix . 'context context WHERE qc.contextid = con.id)
+    NOT EXISTS (SELECT * FROM ' . $CFG->prefix . 'question q WHERE q.category = qc.id)
+AND NOT EXISTS (SELECT * FROM ' . $CFG->prefix . 'context con WHERE qc.contextid = con.id)
         

Any remaining categories that contain questions will require more thought. ' . 'People in the Quiz forum may be able to help.

'; } @@ -701,8 +697,8 @@ class problem_000016 extends problem_base { 'IdNameContext id' . "\n"; foreach ($problemcategories as $cat) { - $table .= "$cat->childid/td>" . s($cat->childname) . - "$cat->childcon$cat->parentid/td>" . s($cat->parentname) . + $table .= "$cat->childid" . s($cat->childname) . + "$cat->childcon$cat->parentid" . s($cat->parentname) . "$cat->parentcon\n"; } $table .= ''; -- 2.39.5