From 0fc48cbfa58975b9617433f65ac2e167eb8cf8c3 Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Sat, 22 Jan 2005 20:08:45 +0000 Subject: [PATCH] question.php now uses sesskey. This means that all question type plug-ins will have to add it to their edit forms. --- mod/quiz/question.php | 14 +- .../questiontypes/calculated/calculated.html | 1 + .../datasetdependent/questiondatasets.html | 1 + .../description/description.html | 80 +---------- mod/quiz/questiontypes/match/match.html | 109 +-------------- .../multianswer/multianswer.html | 54 +------- .../multichoice/multichoice.html | 1 + .../questiontypes/numerical/numerical.html | 1 + mod/quiz/questiontypes/random/random.html | 40 +----- .../randomsamatch/randomsamatch.html | 97 +------------ .../shortanswer/shortanswer.html | 131 +----------------- .../questiontypes/truefalse/truefalse.html | 102 +------------- 12 files changed, 18 insertions(+), 613 deletions(-) diff --git a/mod/quiz/question.php b/mod/quiz/question.php index 17bceee787..a8dc109f3d 100644 --- a/mod/quiz/question.php +++ b/mod/quiz/question.php @@ -5,12 +5,12 @@ require_once("locallib.php"); require_once("../../files/mimetypes.php"); - optional_variable($id); // question id + $id = optional_param('id'); // question id - optional_variable($qtype); - optional_variable($category); + $qtype = optional_param('qtype'); + $category = optional_param('category'); - optional_variable($copy, false); // true if a copy of the question should be created + $copy = optional_param('copy', false); // true if a copy of the question should be created if ($id) { if (! $question = get_record("quiz_questions", "id", $id)) { @@ -70,8 +70,8 @@ "wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes". " -> ".$strediting); - if (isset($delete)) { - if (isset($confirm)) { + if (isset($_REQUEST['delete'])) { + if (isset($confirm) and confirm_sesskey()) { if ($confirm == md5($delete)) { if (!delete_records("quiz_questions", "id", $question->id)) { error("An error occurred trying to delete question (id $question->id)"); @@ -128,7 +128,7 @@ } } - if ($form = data_submitted()) { + if ($form = data_submitted() and confirm_sesskey()) { $question = $QUIZ_QTYPES[$qtype]->save_question($question, $form, $course); } diff --git a/mod/quiz/questiontypes/calculated/calculated.html b/mod/quiz/questiontypes/calculated/calculated.html index 397b690e56..01b22ef894 100644 --- a/mod/quiz/questiontypes/calculated/calculated.html +++ b/mod/quiz/questiontypes/calculated/calculated.html @@ -147,6 +147,7 @@ for ($i=1; $i + " /> diff --git a/mod/quiz/questiontypes/datasetdependent/questiondatasets.html b/mod/quiz/questiontypes/datasetdependent/questiondatasets.html index f9a19d1075..952295903b 100644 --- a/mod/quiz/questiontypes/datasetdependent/questiondatasets.html +++ b/mod/quiz/questiontypes/datasetdependent/questiondatasets.html @@ -29,6 +29,7 @@ + diff --git a/mod/quiz/questiontypes/description/description.html b/mod/quiz/questiontypes/description/description.html index 8bc406257e..40ffee3d09 100644 --- a/mod/quiz/questiontypes/description/description.html +++ b/mod/quiz/questiontypes/description/description.html @@ -1,150 +1,72 @@
-
- - - - - - - - - - - - - - - - - -
: - id, true, true, $question->category); ?> -
: - " /> - -
: -
-
-
- - - -
- "; - } - - - print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext); - - - if ($usehtmleditor) { - echo ''; - } else { - echo "
"; - print_string("formattexttype"); - echo ": "; - if (!isset($question->questiontextformat)) { - $question->questiontextformat = FORMAT_MOODLE; - } - choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, ""); - helpbutton("textformat", get_string("helpformatting")); - echo "
"; - } - ?> -
: - image", get_string("none"),"",""); - } - ?> -
- - - + - - - " /> - - -
-
- diff --git a/mod/quiz/questiontypes/match/match.html b/mod/quiz/questiontypes/match/match.html index bc2de4d3aa..0e9f8e329d 100644 --- a/mod/quiz/questiontypes/match/match.html +++ b/mod/quiz/questiontypes/match/match.html @@ -1,198 +1,91 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
: - id, true, true, $question->category); ?> -
: - " /> - -
: -
-
-
- - - -
- "; - } - - - print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext); - - - if ($usehtmleditor) { - echo ''; - } else { - echo "
"; - print_string("formattexttype"); - echo ": "; - if (!isset($question->questiontextformat)) { - $question->questiontextformat = FORMAT_MOODLE; - } - choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, ""); - helpbutton("textformat", get_string("helpformatting")); - echo "
"; - } - ?> -
: - image", get_string("none"),"",""); - } - ?> -
: -
: - -
-    - " /> -
- - - + - - " /> - - -
-
- diff --git a/mod/quiz/questiontypes/multianswer/multianswer.html b/mod/quiz/questiontypes/multianswer/multianswer.html index 1935a76a1e..8f892e4705 100644 --- a/mod/quiz/questiontypes/multianswer/multianswer.html +++ b/mod/quiz/questiontypes/multianswer/multianswer.html @@ -1,103 +1,51 @@
-
- - - - - - - - - - - - - - - - - -
: - id, true, true, $question->category); ?> -
: - " /> - -
: - "; - } - print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext); - if ($usehtmleditor) { - helpbutton("richtext", get_string("helprichtext"), "moodle"); - } else { - helpbutton("text", get_string("helptext"), "moodle"); - } - ?> -
: - image", get_string("none"),"",""); - } - ?> -
- - - + - - - " /> - - -
-
diff --git a/mod/quiz/questiontypes/multichoice/multichoice.html b/mod/quiz/questiontypes/multichoice/multichoice.html index 5095ee72d6..42858f1f8e 100644 --- a/mod/quiz/questiontypes/multichoice/multichoice.html +++ b/mod/quiz/questiontypes/multichoice/multichoice.html @@ -126,6 +126,7 @@ ?> + " /> diff --git a/mod/quiz/questiontypes/numerical/numerical.html b/mod/quiz/questiontypes/numerical/numerical.html index 92f0d42032..8fce32ed7c 100644 --- a/mod/quiz/questiontypes/numerical/numerical.html +++ b/mod/quiz/questiontypes/numerical/numerical.html @@ -135,6 +135,7 @@ for ($i=1; $i + " /> diff --git a/mod/quiz/questiontypes/random/random.html b/mod/quiz/questiontypes/random/random.html index 36d529d463..be8e851bed 100644 --- a/mod/quiz/questiontypes/random/random.html +++ b/mod/quiz/questiontypes/random/random.html @@ -1,75 +1,37 @@
-
- - - - - - - - - - - - - - - -
: - id, true, true, $question->category); ?> -
: - name)) { - $question->name = get_string("random", "quiz"); - } ?> - " /> - -
: questiontext)) { - $question->questiontext = "0"; - } ?> - questiontext == "1") ? 'checked="checked"' : '' ?> /> -
- + - - - - " /> -
-
- - - diff --git a/mod/quiz/questiontypes/randomsamatch/randomsamatch.html b/mod/quiz/questiontypes/randomsamatch/randomsamatch.html index bd5c6f51ef..a2659fff9c 100644 --- a/mod/quiz/questiontypes/randomsamatch/randomsamatch.html +++ b/mod/quiz/questiontypes/randomsamatch/randomsamatch.html @@ -1,182 +1,87 @@
-
- - - - - - - - - - - - - - - - - -

:

- category]; ?> - category"; ?>" /> -

:

- name)) { - $question->name = get_string("randomsamatch", "quiz"); - } - ?> - - -

:

-
-

- -

-
- "; - } - - - if (empty($question->questiontext)) { - $question->questiontext = get_string("randomsamatchintro", "quiz"); - } - print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext); - - - if ($usehtmleditor) { - echo ''; - } else { - echo '
'; - print_string("formattexttype"); - echo ": "; - if (!$question->questiontextformat) { - $question->questiontextformat = FORMAT_MOODLE; - } - choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, ""); - helpbutton("textformat", get_string("helpformatting")); - echo "
"; - } - ?> -

:

- choose", ""); - unset($menu); - ?> -
- - - + - - " /> - - -
-
- diff --git a/mod/quiz/questiontypes/shortanswer/shortanswer.html b/mod/quiz/questiontypes/shortanswer/shortanswer.html index 5b218e2925..9a1e872fa3 100644 --- a/mod/quiz/questiontypes/shortanswer/shortanswer.html +++ b/mod/quiz/questiontypes/shortanswer/shortanswer.html @@ -1,242 +1,113 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
: - id, true, true, $question->category); ?> -
: - " /> - -
: -
-
-
- - - -
- "; - } - - - print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext); - - - if ($usehtmleditor) { - echo ''; - } else { - echo "
"; - print_string("formattexttype"); - echo ": "; - if (!isset($question->questiontextformat)) { - $question->questiontextformat = FORMAT_MOODLE; - } - choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, ""); - helpbutton("textformat", get_string("helpformatting")); - echo "
"; - } - ?> -
: - image", get_string("none"),"",""); - } - ?> -
: - usecase", ""); - ?> -
: - -
: - " />   - fraction,""); ?> -
-
: - -
 
- - - + - - " /> - - -
-
- diff --git a/mod/quiz/questiontypes/truefalse/truefalse.html b/mod/quiz/questiontypes/truefalse/truefalse.html index 1125e63ea1..7af55213dd 100644 --- a/mod/quiz/questiontypes/truefalse/truefalse.html +++ b/mod/quiz/questiontypes/truefalse/truefalse.html @@ -1,192 +1,92 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
: - id, true, true, $question->category); ?> -
: - "/> - -
: -
-
-
- - - -
- "; - } - - - print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext); - - - if ($usehtmleditor) { - echo ''; - } else { - echo "
"; - print_string("formattexttype"); - echo ": "; - if (!isset($question->questiontextformat)) { - $question->questiontextformat = FORMAT_MOODLE; - } - choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, ""); - helpbutton("textformat", get_string("helpformatting")); - echo "
"; - } - ?> -
: - image", get_string("none"),"",""); - } - ?> -
: - answer", ""); ?> -
-
(): - -
(): - -
- - - + - - " /> - - -
-
- -- 2.39.5