Skip to content

Commit

Permalink
MDL-32245 question bank: fix coding style in categories.php
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Dec 15, 2012
1 parent 87bee3b commit e4ca118
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions question/category.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) = list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
question_edit_setup('categories', '/question/category.php'); question_edit_setup('categories', '/question/category.php');


// get values from form for actions on this page // Get values from form for actions on this page.
$param = new stdClass(); $param = new stdClass();
$param->moveup = optional_param('moveup', 0, PARAM_INT); $param->moveup = optional_param('moveup', 0, PARAM_INT);
$param->movedown = optional_param('movedown', 0, PARAM_INT); $param->movedown = optional_param('movedown', 0, PARAM_INT);
Expand All @@ -55,26 +55,33 @@
} }
$PAGE->set_url($url); $PAGE->set_url($url);


$qcobject = new question_category_object($pagevars['cpage'], $thispageurl, $contexts->having_one_edit_tab_cap('categories'), $param->edit, $pagevars['cat'], $param->delete, $qcobject = new question_category_object($pagevars['cpage'], $thispageurl,
$contexts->having_cap('moodle/question:add')); $contexts->having_one_edit_tab_cap('categories'), $param->edit,
$pagevars['cat'], $param->delete, $contexts->having_cap('moodle/question:add'));


$streditingcategories = get_string('editcategories', 'question'); if ($param->left || $param->right || $param->moveup || $param->movedown) {
if ($param->left || $param->right || $param->moveup || $param->movedown|| $param->moveupcontext || $param->movedowncontext){
require_sesskey(); require_sesskey();


if ($param->moveupcontext || $param->movedowncontext) { foreach ($qcobject->editlists as $list) {
$catid = ($param->moveupcontext > 0) ? $param->moveupcontext : $param->movedowncontext; // Processing of these actions is handled in the method where appropriate and page redirects.
$oldcat = $DB->get_record('question_categories', array('id' => $catid)); $list->process_actions($param->left, $param->right, $param->moveup, $param->movedown);
$qcobject->update_category($catid, '0,'.$param->tocontext, $oldcat->name, $oldcat->info); }
}

if ($param->moveupcontext || $param->movedowncontext) {
require_sesskey();

if ($param->moveupcontext) {
$catid = $param->moveupcontext;
} else { } else {
foreach ($qcobject->editlists as $list){ $catid = $param->movedowncontext;
//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);
}
} }
$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 ($param->delete && ($questionstomove = $DB->count_records("question", array("category" => $param->delete)))) {
if (!$category = $DB->get_record("question_categories", array("id" => $param->delete))) { // security if (!$category = $DB->get_record("question_categories", array("id" => $param->delete))) { // security
print_error('nocate', 'question', $thispageurl->out(), $param->delete); print_error('nocate', 'question', $thispageurl->out(), $param->delete);
} }
Expand All @@ -93,6 +100,7 @@
} else { } else {
$questionstomove = 0; $questionstomove = 0;
} }

if ($qcobject->catform->is_cancelled()) { if ($qcobject->catform->is_cancelled()) {
redirect($thispageurl); redirect($thispageurl);
} else if ($catformdata = $qcobject->catform->get_data()) { } else if ($catformdata = $qcobject->catform->get_data()) {
Expand All @@ -108,21 +116,21 @@
redirect($thispageurl); redirect($thispageurl);
} }


if ($param->edit){ if ($param->edit) {
$PAGE->navbar->add(get_string('editingcategory', 'question')); $PAGE->navbar->add(get_string('editingcategory', 'question'));
} }


$PAGE->set_title($streditingcategories); $PAGE->set_title(get_string('editcategories', 'question'));
$PAGE->set_heading($COURSE->fullname); $PAGE->set_heading($COURSE->fullname);
echo $OUTPUT->header(); echo $OUTPUT->header();


// display UI // Display the UI.
if (!empty($param->edit)) { if (!empty($param->edit)) {
$qcobject->edit_single_category($param->edit); $qcobject->edit_single_category($param->edit);
} else if ($questionstomove){ } else if ($questionstomove){
$qcobject->display_move_form($questionstomove, $category); $qcobject->display_move_form($questionstomove, $category);
} else { } else {
// display the user interface // Display the user interface.
$qcobject->display_user_interface(); $qcobject->display_user_interface();
} }
echo $OUTPUT->footer(); echo $OUTPUT->footer();

0 comments on commit e4ca118

Please sign in to comment.