if ($param->left || $param->right || $param->moveup || $param->movedown) { require_sesskey(); foreach ($qcobject->editlists as $list) { // Processing of these actions is handled in the method where appropriate and page redirects. $list->process_actions($param->left, $param->right, $param->moveup, $param->movedown); } } if ($param->moveupcontext || $param->movedowncontext) { require_sesskey(); if ($param->moveupcontext) { $catid = $param->moveupcontext; } else { $catid = $param->movedowncontext; } $oldcat = $DB->get_record('question_categories', array('id' => $catid), '*', MUST_EXIST); $qcobject->update_category($catid, '0,' . $param->tocontext, $oldcat->name, $oldcat->info); // The previous line does a redirect(). } if ($param->delete && ($questionstomove = $DB->count_records("question", array("category" => $param->delete)))) { if (!($category = $DB->get_record("question_categories", array("id" => $param->delete)))) { // security print_error('nocate', 'question', $thispageurl->out(), $param->delete); } $categorycontext = context::instance_by_id($category->contextid); $qcobject->moveform = new question_move_form($thispageurl, array('contexts' => array($categorycontext), 'currentcat' => $param->delete)); if ($qcobject->moveform->is_cancelled()) { redirect($thispageurl); } elseif ($formdata = $qcobject->moveform->get_data()) { /// 'confirm' is the category to move existing questions to list($tocategoryid, $tocontextid) = explode(',', $formdata->category); $qcobject->move_questions_and_delete_category($formdata->delete, $tocategoryid);
$qcobject->move_questions_and_delete_category($formdata->delete, $tocategoryid); $thispageurl->remove_params('cat', 'category'); redirect($thispageurl->out()); } } else { $questionstomove = 0; } if ($qcobject->catform->is_cancelled()) { redirect($thispageurl->out()); } 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()); } 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) { // Page header $strupdatemodule = has_capability('moodle/course:manageactivities', $contexts->lowest()) ? update_module_button($cm->id, $COURSE->id, get_string('modulename', $cm->modname)) : "";
$qcobject->publish_category(true, $param->publish); } else { if (!empty($param->addcategory)) { $param->newparent = required_param('newparent', PARAM_INT); $param->newcategory = required_param('newcategory', PARAM_NOTAGS); $param->newinfo = required_param('newinfo', PARAM_NOTAGS); $param->newpublish = required_param('newpublish', PARAM_INT); $qcobject->add_category($param->newparent, $param->newcategory, $param->newinfo, $param->newpublish, $course->id); } else { if (!empty($param->edit)) { $qcobject->edit_single_category($param->edit, $param->page); } else { if (!empty($param->updateid)) { $param->updateparent = required_param('updateparent', PARAM_INT); $param->updatename = required_param('updatename', PARAM_NOTAGS); $param->updateinfo = required_param('updateinfo', PARAM_NOTAGS); $param->updatepublish = required_param('updatepublish', PARAM_INT); $qcobject->update_category($param->updateid, $param->updateparent, $param->updatename, $param->updateinfo, $param->updatepublish, $course->id); } } } } } } } } } } // display the user interface $qcobject->display_user_interface($param->page); print_footer($course);