question.php now uses sesskey. This means that all question type plug-ins will have to add it to their edit forms.

This commit is contained in:
gustav_delius
2005-01-22 20:08:45 +00:00
parent 4e27a2b92e
commit 0fc48cbfa5
12 changed files with 18 additions and 613 deletions
+7 -7
View File
@@ -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 @@
"<a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a>".
" -> ".$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);
}
@@ -147,6 +147,7 @@ for ($i=1; $i<count($units); $i++) {
?>
</table>
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
<input type="hidden" name="id" value="<?php p($question->id) ?>" />
<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
<input type="submit" onclick="return determineMinAndMax();" value="<?php print_string("savechanges") ?>" />
@@ -29,6 +29,7 @@
<td/>
<td/>
<td>
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
<input type="hidden" name="name" value="<?php p($question->name) ?>" />
<input type="hidden" name="questiontext" value="<?php p($question->questiontext) ?>" />
<input type="hidden" name="questiontextformat" value="<?php p($question->questiontextformat) ?>" />
@@ -1,150 +1,72 @@
<form name="theform" method="post" action="question.php">
<center>
<table cellpadding="5">
<tr valign="top">
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
<td>
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
<td>
<input type="text" name="name" size="40" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
<?php if (isset($err["name"])) formerr($err["name"]); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("question", "quiz") ?>:</b>
<br />
<br />
<br />
<font size="1">
<?php
if ($usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
helpbutton("text", get_string("helptext"), "moodle", true, true);
}
?>
</font>
</td>
<td>
<?php if (isset($err["questiontext"])) {
formerr($err["questiontext"]);
echo "<br />";
}
print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
if ($usehtmleditor) {
echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
} else {
echo "<div align=\"right\">";
print_string("formattexttype");
echo ":&nbsp;";
if (!isset($question->questiontextformat)) {
$question->questiontextformat = FORMAT_MOODLE;
}
choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
helpbutton("textformat", get_string("helpformatting"));
echo "</div>";
}
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
<td>
<?php if (empty($images)) {
print_string("noimagesyet");
} else {
choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
}
?>
</td>
</tr>
</table>
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
<input type="hidden" name="id" value="<?php p($question->id) ?>" />
<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
<input type="hidden" name="defaultgrade" value="0" />
<input type="submit" value="<?php print_string("savechanges") ?>" />
</center>
</form>
+1 -108
View File
@@ -1,198 +1,91 @@
<form name="theform" method="post" action="question.php">
<center>
<table cellpadding="5">
<tr valign="top">
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
<td>
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
<td>
<input type="text" name="name" size="40" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
<?php if (isset($err["name"])) formerr($err["name"]); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("question", "quiz") ?>:</b>
<br />
<br />
<br />
<font size="1">
<?php
if ($usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
helpbutton("text", get_string("helptext"), "moodle", true, true);
}
?>
</font>
</td>
<td>
<?php if (isset($err["questiontext"])) {
formerr($err["questiontext"]);
echo "<br />";
}
print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
if ($usehtmleditor) {
echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
} else {
echo "<div align=\"right\">";
print_string("formattexttype");
echo ":&nbsp;";
if (!isset($question->questiontextformat)) {
$question->questiontextformat = FORMAT_MOODLE;
}
choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
helpbutton("textformat", get_string("helpformatting"));
echo "</div>";
}
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
<td>
<?php if (empty($images)) {
print_string("noimagesyet");
} else {
choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
}
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("choices", "quiz") ?></b>:</td>
<td><?php print_string("filloutthreequestions", "quiz") ?>
</td>
</tr>
<?php
for ($i=1; $i<=QUIZ_MAX_NUMBER_ANSWERS; $i++) {
?>
<tr valign="top">
<td align="right"><b><?php echo get_string("question", "quiz")." $i"; ?> :</b></td>
<td>
<textarea name="subquestions[]" rows="5" cols="50"><?php p($subquestions[$i-1]) ?></textarea>
<br />
<?php echo get_string("matchanswer", "quiz")." $i"; ?>&nbsp;&nbsp;
<input type="text" name="subanswers[]" size="50" value="<?php p($subanswers[$i-1]) ?>" alt="<?php echo get_string("matchanswer", "quiz")." $i"; ?>" />
</td>
</tr>
<?php
}
?>
</table>
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
<input type="hidden" name="id" value="<?php p($question->id) ?>" />
<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
<input type="submit" value="<?php print_string("savechanges") ?>" />
</center>
</form>
@@ -1,103 +1,51 @@
<form name="theform" method="post" action="question.php">
<center>
<table cellpadding="5">
<tr valign="top">
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
<td>
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
<td>
<input type="text" name="name" size="40" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
<?php if (isset($err["name"])) formerr($err["name"]); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("question", "quiz") ?>:</b></td>
<td>
<?php if (isset($err["questiontext"])) {
formerr($err["questiontext"]);
echo "<br />";
}
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");
}
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
<td>
<?php if (empty($images)) {
print_string("noimagesyet");
} else {
choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
}
?>
</td>
</tr>
</table>
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
<input type="hidden" name="id" value="<?php p($question->id) ?>" />
<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
<input type="hidden" name="defaultgrade" value="<?php p($question->defaultgrade) ?>" />
<input type="submit" value="<?php print_string("savechanges") ?>" />
</center>
</form>
@@ -126,6 +126,7 @@
?>
</table>
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
<input type="hidden" name="id" value="<?php p($question->id) ?>" />
<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
<input type="submit" value="<?php print_string("savechanges") ?>" />
@@ -135,6 +135,7 @@ for ($i=1; $i<count($units); $i++) {
?>
</table>
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
<input type="hidden" name="id" value="<?php p($question->id) ?>" />
<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
<input type="submit" onclick="return determineMinAndMax();" value="<?php print_string("savechanges") ?>" />
+1 -39
View File
@@ -1,75 +1,37 @@
<center>
<form name="theform" method="post" action="question.php">
<table cellpadding="5">
<tr valign="top">
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
<td>
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
<td>
<?php if (empty($question->name)) {
$question->name = get_string("random", "quiz");
} ?>
<input type="text" name="name" size="40" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
<?php if (isset($err["name"])) formerr($err["name"]); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("recurse", "quiz") ?>:</b></td>
<td>
<?php if (!isset($question->questiontext)) {
$question->questiontext = "0";
} ?>
<input type="hidden" name="questiontext" value="0" />
<input type="checkbox" name="questiontext" value="1" <?php echo ($question->questiontext == "1") ? 'checked="checked"' : '' ?> />
</td>
</tr>
</table>
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
<input type="hidden" name="questiontextformat" value="0" />
<input type="hidden" name="id" value="<?php p($question->id) ?>" />
<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
<input type="submit" value="<?php print_string("savechanges") ?>" />
</form>
</center>
@@ -1,182 +1,87 @@
<form name="theform" method="post" action="question.php">
<center>
<table cellpadding="5">
<tr valign="top">
<td align="right"><p><b><?php print_string("category", "quiz") ?>:</b></p></td>
<td>
<?php echo $categories[$question->category]; ?>
<input type="hidden" name="category" value="<?php echo "$question->category"; ?>" />
</td>
</tr>
<tr valign="top">
<td align="right"><p><b><?php print_string("questionname", "quiz") ?>:</b></p></td>
<td>
<?php
if (empty($question->name)) {
$question->name = get_string("randomsamatch", "quiz");
}
?>
<input type="text" name="name" size="40" value="<?php p($question->name) ?>" />
<?php if (isset($err["name"])) formerr($err["name"]); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p><b><?php print_string("introduction", "quiz") ?>:</b></p>
<br />
<p><font size="1">
<?php
if ($usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
helpbutton("text", get_string("helptext"), "moodle", true, true);
}
?>
</font></p>
</td>
<td>
<?php if (isset($err["questiontext"])) {
formerr($err["questiontext"]);
echo "<br />";
}
if (empty($question->questiontext)) {
$question->questiontext = get_string("randomsamatchintro", "quiz");
}
print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
if ($usehtmleditor) {
echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
} else {
echo '<div align="right">';
print_string("formattexttype");
echo ":&nbsp;";
if (!$question->questiontextformat) {
$question->questiontextformat = FORMAT_MOODLE;
}
choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
helpbutton("textformat", get_string("helpformatting"));
echo "</div>";
}
?>
</td>
</tr>
<tr valign="top">
<td align="right"><p><b><?php print_string("randomsamatchnumber", "quiz") ?>:</b></p></td>
<td>
<?php
if ($numberavailable < 2) {
echo get_string('createfirst', 'quiz');
$maxrandom=2;
} else if ($numberavailable < 6) {
$maxrandom = $numberavailable;
} else {
$maxrandom = QUIZ_MAX_NUMBER_ANSWERS;
}
for ($i=2;$i<=$maxrandom;$i++) {
$menu[$i] = $i;
}
choose_from_menu($menu, "choose", "$options->choose", "");
unset($menu);
?>
</td>
</tr>
</table>
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
<input type="hidden" name="id" value="<?php p($question->id) ?>" />
<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
<input type="submit" value="<?php print_string("savechanges") ?>" />
</center>
</form>
@@ -1,242 +1,113 @@
<form name="theform" method="post" action="question.php">
<center>
<table cellpadding="5">
<tr valign="top">
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
<td>
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
<td>
<input type="text" name="name" size="50" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>" />
<?php if (isset($err["name"])) formerr($err["name"]); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("question", "quiz") ?>:</b>
<br />
<br />
<br />
<font size="1">
<?php
if ($usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
helpbutton("text", get_string("helptext"), "moodle", true, true);
}
?>
</font>
</td>
<td>
<?php if (isset($err["questiontext"])) {
formerr($err["questiontext"]);
echo "<br />";
}
print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
if ($usehtmleditor) {
echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
} else {
echo "<div align=\"right\">";
print_string("formattexttype");
echo ":&nbsp;";
if (!isset($question->questiontextformat)) {
$question->questiontextformat = FORMAT_MOODLE;
}
choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
helpbutton("textformat", get_string("helpformatting"));
echo "</div>";
}
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
<td>
<?php if (empty($images)) {
print_string("noimagesyet");
} else {
choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
}
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("casesensitive", "quiz") ?>:</b></td>
<td>
<?php
unset($menu);
$menu[0] = get_string("caseno", "quiz");
$menu[1] = get_string("caseyes", "quiz");
choose_from_menu($menu, "usecase", "$options->usecase", "");
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("correctanswers", "quiz") ?></b>:</td>
<td>
<?php print_string("filloutoneanswer", "quiz") ?>
</td>
</tr>
<?php
for ($i=1; $i<=QUIZ_MAX_NUMBER_ANSWERS; $i++) {
?>
<tr valign="top">
<td align="right"><b><?php echo get_string("answer", "quiz")." $i"; ?>:</b></td>
<td>
<input type="text" name="answer[]" size="50" value="<?php p($answers[$i-1]->answer) ?>" alt="<?php echo get_string("answer", "quiz")." $i"; ?>" />&nbsp;&nbsp;
<?php print_string("grade");
echo ":&nbsp;";
choose_from_menu($gradeoptions, "fraction[]", $answers[$i-1]->fraction,""); ?>
<br />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("feedback", "quiz") ?>:</b></td>
<td>
<textarea name="feedback[]" rows="2" cols="50"><?php p($answers[$i-1]->feedback) ?></textarea>
</td>
</tr>
<tr valign="top">
<td colspan="2">&nbsp;</td>
</tr>
<?php
}
?>
</table>
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
<input type="hidden" name="id" value="<?php p($question->id) ?>" />
<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
<input type="submit" value="<?php print_string("savechanges") ?>" />
</center>
</form>
+1 -101
View File
@@ -1,192 +1,92 @@
<form name="theform" method="post" action="question.php">
<center>
<table cellpadding="5">
<tr valign="top">
<td align="right"><b><?php print_string("category", "quiz") ?>:</b></td>
<td>
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("questionname", "quiz") ?>:</b></td>
<td>
<input type="text" name="name" size="50" value="<?php p($question->name) ?>" alt="<?php print_string("questionname", "quiz") ?>"/>
<?php if (isset($err["name"])) formerr($err["name"]); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("question", "quiz") ?>:</b>
<br />
<br />
<br />
<font size="1">
<?php
if ($usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
helpbutton("text", get_string("helptext"), "moodle", true, true);
}
?>
</font>
</td>
<td>
<?php if (isset($err["questiontext"])) {
formerr($err["questiontext"]);
echo "<br />";
}
print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
if ($usehtmleditor) {
echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'" />';
} else {
echo "<div align=\"right\">";
print_string("formattexttype");
echo ":&nbsp;";
if (!isset($question->questiontextformat)) {
$question->questiontextformat = FORMAT_MOODLE;
}
choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
helpbutton("textformat", get_string("helpformatting"));
echo "</div>";
}
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("imagedisplay", "quiz") ?>:</b></td>
<td>
<?php if (empty($images)) {
print_string("noimagesyet");
} else {
choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
}
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("correctanswer", "quiz") ?>:</b></td>
<td>
<?php $menu[0] = get_string("false", "quiz");
$menu[1] = get_string("true", "quiz");
choose_from_menu($menu, "answer", "$question->answer", ""); ?>
<br />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("feedback", "quiz") ?> (<?php print_string("true", "quiz") ?>):</b></td>
<td>
<textarea name="feedbacktrue" rows="2" cols="50" wrap="virtual"><?php p($true->feedback) ?></textarea>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("feedback", "quiz") ?> (<?php print_string("false", "quiz") ?>):</b></td>
<td>
<textarea name="feedbackfalse" rows="2" cols="50"><?php p($false->feedback) ?></textarea>
</td>
</tr>
</table>
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey; ?>" />
<input type="hidden" name="id" value="<?php p($question->id) ?>" />
<input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
<input type="submit" value="<?php print_string("savechanges") ?>" />
</center>
</form>