mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
Moved all question deletion code to showbank.php. Fixed bug 5186
This commit is contained in:
parent
402e1a9643
commit
54b3626b9f
@ -227,10 +227,10 @@ function question_list($course, $categoryid, $quizid=0,
|
||||
src=\"$CFG->pixpath/t/edit.gif\" border=\"0\" alt=\"$stredit\" /></a> ";
|
||||
// hide-feature
|
||||
if($question->hidden) {
|
||||
echo "<a title=\"$strrestore\" href=\"$CFG->wwwroot/question/question.php?id=$question->id&hide=0&sesskey=$USER->sesskey\"><img
|
||||
echo "<a title=\"$strrestore\" href=\"edit.php?courseid=$course->id&unhide=$question->id&sesskey=$USER->sesskey\"><img
|
||||
src=\"$CFG->pixpath/t/restore.gif\" border=\"0\" alt=\"$strrestore\" /></a>";
|
||||
} else {
|
||||
echo "<a title=\"$strdelete\" href=\"$CFG->wwwroot/question/question.php?id=$question->id&delete=$question->id\"><img
|
||||
echo "<a title=\"$strdelete\" href=\"edit.php?courseid=$course->id&deleteselected=$question->id&q$question->id=1\"><img
|
||||
src=\"$CFG->pixpath/t/delete.gif\" border=\"0\" alt=\"$strdelete\" /></a>";
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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 <br /> 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user