--- /dev/null
+<P ALIGN=CENTER><B>Shuffle answers</B></P>
+
+<p>If you enable this option, then the order of answers within
+ each question will be randinly shuffled each time a student
+ attempts this quiz.</p>
+
+<p>Of course, this only applies to questions that have multiple
+ answers displayed, such as Multiple Choice, or Matching Questions.</p>
+
+<p>The intention is simply to make it a little harder for students
+ to copy from each other.</p>
+
+<p>This option is not related to the use of Random Questions.</p>
--- /dev/null
+<P ALIGN=CENTER><B>Shuffle questions</B></P>
+
+<p>If you enable this option, then the order of questions in
+ the quiz will be randomly shuffled each time a student attempts
+ the quiz.</p>
+
+<p>This is not related to the use of Random Questions, this is only
+ about the displayed order of questions.</p>
+
+<p>The intention is to make it a little harder for students to copy from
+ each other.</p>
$string['show'] = "Show";
$string['showfeedback'] = "After answering, show feedback?";
$string['showcorrectanswer'] = "In feedback, show correct answers?";
+$string['shuffleanswers'] = "Shuffle answers";
+$string['shufflequestions'] = "Shuffle questions";
$string['time'] = "Time";
$string['timetaken'] = "Time taken";
$string['timecompleted'] = "Completed";
if ($oldversion < 2003030303) {
table_column("quiz_questions", "", "defaultgrade", "INTEGER", "6", "UNSIGNED", "1", "NOT NULL", "image");
}
+
if ($oldversion < 2003032601) {
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_answers` ADD INDEX(question) ");
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_attempts` ADD INDEX(quiz) ");
);");
}
+ if ($oldversion < 2003040901) {
+ table_column("quiz", "", "shufflequestions", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "review");
+ table_column("quiz", "", "shuffleanswers", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "shufflequestions");
+ }
+
return true;
}
`correctanswers` tinyint(4) NOT NULL default '1',
`grademethod` tinyint(4) NOT NULL default '1',
`review` tinyint(4) NOT NULL default '0',
+ `shufflequestions` tinyint(4) NOT NULL default '0',
+ `shuffleanswers` tinyint(4) NOT NULL default '0',
`questions` text NOT NULL,
`sumgrades` int(10) NOT NULL default '0',
`grade` int(10) NOT NULL default '0',
modify_database ("", "CREATE INDEX question_quiz_multichoice_idx ON prefix_quiz_multichoice (question);");
}
+ if ($oldversion < 2003040901) {
+ table_column("quiz", "", "shufflequestions", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "review");
+ table_column("quiz", "", "shuffleanswers", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "shufflequestions");
+ }
+
return true;
}
correctanswers integer NOT NULL default '1',
grademethod integer NOT NULL default '1',
review integer NOT NULL default '0',
+ shufflequestions integer NOT NULL default '0',
+ shuffleanswers integer NOT NULL default '0',
questions text NOT NULL default '',
sumgrades integer NOT NULL default '0',
grade integer NOT NULL default '0',
function quiz_print_question($number, $question, $grade, $courseid,
$feedback=NULL, $response=NULL, $actualgrade=NULL, $correct=NULL,
- $realquestion=NULL) {
+ $realquestion=NULL, $shuffleanswers=false) {
/// Prints a quiz question, any format
/// $question is provided as an object
echo "<P ALIGN=CENTER><FONT SIZE=1>$grade $strmarks</FONT></P>";
}
print_spacer(1,100);
- echo "<p align=\"center\">";
- quiz_print_question_icon($question, false);
- echo "</p></TD><TD VALIGN=TOP>";
+ echo "</TD><TD VALIGN=TOP>";
if (empty($realquestion)) {
$realquestion->id = $question->id;
echo "<TABLE>";
$answerids = explode(",", $options->answers);
+ if ($shuffleanswers) {
+ $answerids = swapshuffle($answerids);
+ }
+
foreach ($answerids as $key => $answerid) {
$answer = $answers[$answerid];
$qnumchar = chr(ord('a') + $key);
if (!$subquestions = get_records_list("quiz_match_sub", "id", $options->subquestions)) {
notify("Error: Missing subquestions for this question!");
}
+ if ($shuffleanswers) {
+ $subquestions = draw_rand_array($subquestions, count($subquestions));
+ }
echo text_to_html($question->questiontext);
if ($question->image) {
print_file_picture($question->image, $courseid, QUIZ_PICTURE_DEFAULT_HEIGHT);
notify("Error when reading questions from the database!");
return false;
}
+
+ if (!empty($quiz->shufflequestions)) {
+ $questions = swapshuffle_assoc($questions);
+ }
}
if (!$grades = get_records_list("quiz_question_grades", "question", $quiz->questions, "", "question,grade")) {
print_simple_box_start("CENTER", "90%");
quiz_print_question($count, $question, $grades[$question->id]->grade, $quiz->course,
- $feedback, $response, $actualgrades, $correct, $randomquestion);
+ $feedback, $response, $actualgrades, $correct,
+ $randomquestion, $quiz->shuffleanswers);
print_simple_box_end();
echo "<BR>";
}
<?PHP
require_once("$CFG->dirroot/mod/quiz/lib.php");
- if (empty($form->name)) {
+ if (!isset($form->name)) {
$form->name = "";
}
- if (empty($form->intro)) {
+ if (!isset($form->intro)) {
$form->intro = "";
}
- if (empty($form->timeopen)) {
+ if (!isset($form->timeopen)) {
$form->timeopen = "";
}
- if (empty($form->timeclose)) {
+ if (!isset($form->timeclose)) {
$form->timeclose = "";
}
- if (empty($form->attempts)) {
- $form->attempts = "0";
+ if (!isset($form->attempts)) {
+ $form->attempts = 0;
}
- if (empty($form->grademethod)) {
+ if (!isset($form->grademethod)) {
$form->grademethod = "";
}
- if (empty($form->feedback)) {
+ if (!isset($form->feedback)) {
$form->feedback = "";
}
- if (empty($form->correctanswers)) {
+ if (!isset($form->correctanswers)) {
$form->correctanswers = "";
}
- if (empty($form->review)) {
- $form->review = "";
+ if (!isset($form->review)) {
+ $form->review = 0;
}
- if (empty($form->grade)) {
+ if (!isset($form->shufflequestions)) {
+ $form->shufflequestions = 1;
+ }
+ if (!isset($form->shuffleanswers)) {
+ $form->shuffleanswers = 1;
+ }
+ if (!isset($form->grade)) {
$form->grade = "";
}
- if (empty($form->questions)) {
+ if (!isset($form->questions)) {
$form->questions = "";
}
?>
?>
</TD>
</TR>
+<TR valign=top>
+ <TD align=right><P><B><? print_string("shufflequestions", "quiz") ?>:</B></P></TD>
+ <TD>
+ <?
+ $options = array();
+ $options[0] = get_string("no");
+ $options[1] = get_string("yes");
+ choose_from_menu($options, "shufflequestions", "$form->shufflequestions", "");
+ helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz");
+ ?>
+ </TD>
+</TR>
+<TR valign=top>
+ <TD align=right><P><B><? print_string("shuffleanswers", "quiz") ?>:</B></P></TD>
+ <TD>
+ <?
+ $options = array();
+ $options[0] = get_string("no");
+ $options[1] = get_string("yes");
+ choose_from_menu($options, "shuffleanswers", "$form->shuffleanswers", "");
+ helpbutton("shuffleanswers", get_string("shuffleanswers","quiz"), "quiz");
+ ?>
+ </TD>
+</TR>
<TR valign=top>
<TD align=right><P><B><? print_string("maximumgrade") ?>:</B></P></TD>
<TD>
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2003033100; // The (date) version of this module
+$module->version = 2003040901; // The (date) version of this module
$module->cron = 0; // How often should cron check this module (seconds)?
?>