]> git.mjollnir.org Git - moodle.git/commitdiff
question bank: MDL-17078 Error after deleting a question category.
authortjhunt <tjhunt>
Thu, 27 Nov 2008 07:30:17 +0000 (07:30 +0000)
committertjhunt <tjhunt>
Thu, 27 Nov 2008 07:30:17 +0000 (07:30 +0000)
question/category.php
question/category_class.php

index 728ecac0d574922ef38a148ace5a683548b199c2..29c032707cc8f9fde8b780f9bbb2b2483c36e7aa 100644 (file)
             /// 'confirm' is the category to move existing questions to
             list($tocategoryid, $tocontextid) = explode(',', $formdata->category);
             $qcobject->move_questions_and_delete_category($formdata->delete, $tocategoryid);
-            $thispageurl->remove_params('cat');
-            $thispageurl->remove_params('category');
+            $thispageurl->remove_params('cat', 'category');
             redirect($thispageurl->out());
         }
     } else {
         $questionstomove = 0;
     }
-    if ($qcobject->catform->is_cancelled()){
+    if ($qcobject->catform->is_cancelled()) {
         redirect($thispageurl->out());
-    }elseif ($catformdata = $qcobject->catform->get_data()) {
+    } else if ($catformdata = $qcobject->catform->get_data()) {
         if (!$catformdata->id) {//new category
             $qcobject->add_category($catformdata->parent, $catformdata->name, $catformdata->info);
         } else {
             $qcobject->update_category($catformdata->id, $catformdata->parent, $catformdata->name, $catformdata->info);
         }
         redirect($thispageurl->out());
-    } elseif ((!empty($param->delete) and (!$questionstomove) and confirm_sesskey()))  {
-        $thispageurl->remove_params('cat');
-        $thispageurl->remove_params('category');
+    } else if ((!empty($param->delete) and (!$questionstomove) and confirm_sesskey())) {
         $qcobject->delete_category($param->delete);//delete the category now no questions to move
+        $thispageurl->remove_params('cat', 'category');
+        redirect($thispageurl->out());
     }
     $navlinks = array();
     if ($cm!==null) {
index 4c8fed8eca7a02dd811b49a9f30404655610a2cf..38ec74c850bbbf6640b858ac5688cfe4d183963a 100644 (file)
@@ -348,7 +348,7 @@ class question_category_object {
     /**
      * Deletes an existing question category
      *
-     * @param    int deletecat  id of category to delete
+     * @param int deletecat id of category to delete
      */
     public function delete_category($categoryid) {
         global $CFG, $DB;
@@ -362,11 +362,9 @@ class question_category_object {
         }
 
         /// Finally delete the category itself
-        if ($DB->delete_records("question_categories", array("id" => $category->id))) {
-            notify(get_string("categorydeleted", "quiz", format_string($category->name)), 'notifysuccess');
-            redirect($this->pageurl->out());//always redirect after successful action
-        }
+        $DB->delete_records("question_categories", array("id" => $category->id));
     }
+
     public function move_questions_and_delete_category($oldcat, $newcat){
         question_can_delete_cat($oldcat);
         $this->move_questions($oldcat, $newcat);