mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
question bank: MDL-17078 Error after deleting a question category.
This commit is contained in:
parent
9f64eef7fd
commit
21cbf9da8b
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user