MDL-32245 question bank: fix moving categories between contexts.

This commit is contained in:
Thanh Le 2012-10-15 11:13:39 +01:00 committed by Tim Hunt
parent 7d2c5cd0a0
commit 99231022af

View file

@ -61,11 +61,18 @@ $qcobject = new question_category_object($pagevars['cpage'], $thispageurl, $cont
$streditingcategories = get_string('editcategories', 'question');
if ($param->left || $param->right || $param->moveup || $param->movedown|| $param->moveupcontext || $param->movedowncontext){
require_sesskey();
if ($param->moveupcontext || $param->movedowncontext) {
$catid = ($param->moveupcontext > 0) ? $param->moveupcontext : $param->movedowncontext;
$oldcat = $DB->get_record('question_categories', array('id' => $catid));
$qcobject->update_category($catid, '0,'.$param->tocontext, $oldcat->name, $oldcat->info);
} else {
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,
$param->moveupcontext, $param->movedowncontext, $param->tocontext);
}
}
}
if ($param->delete && ($questionstomove = $DB->count_records("question", array("category" => $param->delete)))){
if (!$category = $DB->get_record("question_categories", array("id" => $param->delete))) { // security