From: tjhunt Date: Thu, 27 Nov 2008 07:30:17 +0000 (+0000) Subject: question bank: MDL-17078 Error after deleting a question category. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=21cbf9da8b5f71f76bcb81e5cb5af2136139c909;p=moodle.git question bank: MDL-17078 Error after deleting a question category. --- diff --git a/question/category.php b/question/category.php index 728ecac0d5..29c032707c 100644 --- a/question/category.php +++ b/question/category.php @@ -59,26 +59,25 @@ /// '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) { diff --git a/question/category_class.php b/question/category_class.php index 4c8fed8eca..38ec74c850 100644 --- a/question/category_class.php +++ b/question/category_class.php @@ -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);