From: gustav_delius Date: Mon, 17 Apr 2006 05:31:21 +0000 (+0000) Subject: Moved all question deletion code to showbank.php. Fixed bug 5186 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=54b3626b9f23647e6ff51a0de234acb853bf0798;p=moodle.git Moved all question deletion code to showbank.php. Fixed bug 5186 --- diff --git a/question/editlib.php b/question/editlib.php index d8790e0a5b..dd8afaac9f 100644 --- a/question/editlib.php +++ b/question/editlib.php @@ -227,10 +227,10 @@ function question_list($course, $categoryid, $quizid=0, src=\"$CFG->pixpath/t/edit.gif\" border=\"0\" alt=\"$stredit\" /> "; // hide-feature if($question->hidden) { - echo "wwwroot/question/question.php?id=$question->id&hide=0&sesskey=$USER->sesskey\">id&unhide=$question->id&sesskey=$USER->sesskey\">pixpath/t/restore.gif\" border=\"0\" alt=\"$strrestore\" />"; } else { - echo "wwwroot/question/question.php?id=$question->id&delete=$question->id\">id&deleteselected=$question->id&q$question->id=1\">pixpath/t/delete.gif\" border=\"0\" alt=\"$strdelete\" />"; } } diff --git a/question/question.php b/question/question.php index 514ae770c3..87e649cfdc 100644 --- a/question/question.php +++ b/question/question.php @@ -5,14 +5,10 @@ * This page shows the question editing form or processes the following actions: * - create new question (category, qtype) * - edit question (id, contextquiz (optional)) -* - delete question from quiz (delete, sesskey) -* - delete question (in two steps) -* - if question is in use: display this conflict (allow to hide the question?) -* - else: confirm deletion and delete from database (sesskey, id, delete, confirm) * - cancel (cancel) * -* TODO: currently this still treats the quiz as special, for example it sometimes redirects -* to mod/quiz/edit.php. +* TODO: currently this still treats the quiz as special +* TODO: question versioning is not currently enabled * * @version $Id$ * @author Martin Dougiamas and many others. This has recently been extensively @@ -30,9 +26,6 @@ $qtype = optional_param('qtype', '', PARAM_FILE); $category = optional_param('category', 0, PARAM_INT); - - $delete = optional_param('delete', 0, PARAM_INT); - $confirm = optional_param('confirm', 0, PARAM_ALPHANUM); // rqp questions set the type to rqp_nn where nn is the rqp_type id if (substr($qtype, 0, 4) == 'rqp_') { @@ -85,14 +78,6 @@ redirect($SESSION->returnurl); } - if(!empty($id) && isset($_REQUEST['hide']) && confirm_sesskey()) { - $hide = required_param('hide', PARAM_INT); - if(!set_field('question', 'hidden', $hide, 'id', $id)) { - error("Faild to hide the question."); - } - redirect($SESSION->returnurl); - } - if (empty($qtype)) { error("No question type was specified!"); } else if (!isset($QTYPES[$qtype])) { @@ -117,42 +102,6 @@ print_header_simple("$streditingquestion", "", $strediting); - if ($delete) { - if ($confirm and confirm_sesskey()) { - if ($confirm == md5($delete)) { - if (record_exists('quiz_question_instances', 'question', $question->id) or - record_exists('question_states', 'originalquestion', $question->id)) { - if (!set_field('question', 'hidden', 1, 'id', $delete)) { - error('Was not able to hide question'); - } - } else { - if (!delete_records("question", "id", $question->id)) { - error("An error occurred trying to delete question (id $question->id)"); - } - if (!delete_records("question", "parent", $question->id)) { - error("An error occurred trying to delete question (id $question->id)"); - } - } - redirect($SESSION->returnurl); - } else { - error("Confirmation string was incorrect"); - } - - } else { - // TODO: check for other modules using this question - if ($quiznames = question_list_instances($id)) { - $a->questionname = $question->name; - $a->quiznames = implode(', ', $quiznames); - notify(get_string('questioninuse', 'quiz', $a)); - } - - notice_yesno(get_string("deletequestioncheck", "quiz", $question->name), - "question.php?sesskey=$USER->sesskey&id=$question->id&delete=$delete&confirm=".md5($delete), $SESSION->returnurl); - } - print_footer($course); - exit; - } - if ($form = data_submitted() and confirm_sesskey()) { if (isset($form->versioning) && isset($question->id) and false) { // disable versioning until it is fixed. diff --git a/question/showbank.php b/question/showbank.php index 6aa27b86db..3ffcafdc61 100644 --- a/question/showbank.php +++ b/question/showbank.php @@ -44,7 +44,7 @@ error('Invalid category'); } if (!isteacheredit($tocategory->course)) { - error(get_string('categorynoedit', 'quiz', $tocategory->name), 'edit.php'); + error(get_string('categorynoedit', 'quiz', $tocategory->name), 'edit.php?courseid=$course->id'); } foreach ($_POST as $key => $value) { // Parse input for question ids if (substr($key, 0, 1) == "q") { @@ -81,7 +81,7 @@ } else { // teacher still has to confirm // make a list of all the questions that are selected - $rawquestions = $_POST; + $rawquestions = $_REQUEST; $questionlist = ''; // comma separated list of ids of questions to be deleted $questionnames = ''; // string with names of questions separated by
with // an asterix in front of those that are in use @@ -107,15 +107,22 @@ if ($inuse) { $questionnames .= get_string('questionsinuse', 'quiz'); } - print_header_simple($streditingquestions, '', - "$streditingquestions"); notice_yesno(get_string("deletequestionscheck", "quiz", $questionnames), - "edit.php?courseid=$course->id&sesskey=$USER->sesskey&deleteselected=$questionlist&confirm=".md5($questionlist), "edit.php"); + "edit.php?courseid=$course->id&sesskey=$USER->sesskey&deleteselected=$questionlist&confirm=".md5($questionlist), "edit.php?courseid=$course->id"); print_footer($course); exit; } } + // Unhide a question + if(isset($_REQUEST['unhide']) && confirm_sesskey()) { + $unhide = required_param('unhide', PARAM_INT); + if(!set_field('question', 'hidden', 0, 'id', $unhide)) { + error("Failed to unhide the question."); + } + redirect("edit.php?courseid=$course->id"); + } + if (isset($_REQUEST['cat'])) { /// coming from category selection drop-down menu $SESSION->questioncat = required_param('cat', PARAM_INT); $page = 0;