// It is used from /course/mod.php. The whole instance is available as $form. --> require_once("$CFG->dirroot/mod/quiz/locallib.php"); // Set any form variables that have not been initialized to their default value. if (!isset($form->name)) { $form->name = ""; } if (!isset($form->intro)) { $form->intro = ""; } if (!isset($form->timeopen)) { $form->timeopen = ""; } if (!isset($form->timeclose)) { $form->timeclose = ""; } if (!isset($form->attempts)) { $form->attempts = $CFG->quiz_attempts; } if (!isset($form->attemptonlast)) { $form->attemptonlast = $CFG->quiz_attemptonlast; } if (!isset($form->grademethod)) { $form->grademethod = $CFG->quiz_grademethod; } if (!isset($form->decimalpoints)) { $form->decimalpoints = $CFG->quiz_decimalpoints; } if (!isset($form->review)) { $form->review = $CFG->quiz_review; } if (!isset($form->questionsperpage)) { $form->questionsperpage = $CFG->quiz_questionsperpage; } if (!isset($form->shufflequestions)) { $form->shufflequestions = $CFG->quiz_shufflequestions; } if (!isset($form->shuffleanswers)) { $form->shuffleanswers = $CFG->quiz_shuffleanswers; } if (!isset($form->grade)) { $form->grade = $CFG->quiz_maximumgrade; } if (!isset($form->questions)) { $form->questions = ""; } if (!isset($form->password)) { $form->password = $CFG->quiz_password; } if (!isset($form->subnet)) { $form->subnet = $CFG->quiz_subnet; } if (!isset($form->timelimit)) { $form->timelimit = $CFG->quiz_timelimit; } if (!isset($form->popup)) { $form->popup = $CFG->quiz_popup; } if (!isset($form->optionflags)) { $form->optionflags = $CFG->quiz_optionflags; } if (!isset($form->penaltyscheme)) { $form->penaltyscheme = $CFG->quiz_penaltyscheme; } if (empty($form->timedue)) { $form->timedue = ""; } //enforced time delay between quiz attempts //delay1: time delay between first and second attempt //delay2: time delay between second and additional quiz attempt if (!isset($form->delay1)) { $form->delay1 = $CFG->quiz_delay1; } if (!isset($form->delay2)) { $form->delay2 = $CFG->quiz_delay2; } // Get any existing feedback text out of the database. if (!empty($form->id)) { $feedbacks = get_records('quiz_feedback', 'quizid', $form->id, 'mingrade DESC'); } else { $feedbacks = array(); } $form->feedbacktext = array(); $form->feedbackboundaries = array(); foreach ($feedbacks as $feedback) { $form->feedbacktext[] = $feedback->feedbacktext; if ($feedback->mingrade > 0) { $form->feedbackboundaries[] = (100.0 * $feedback->mingrade / $form->grade) . '%'; } } // Make sure there are at least 5 feedbacktexts, or a bit more than the current nubmer. $numfeedbacks = max( count($form->feedbacktext) * 1.5, count($form->feedbackboundaries) * 1.5, 5 ); for ($i = 0; $i < $numfeedbacks; $i += 1) { if (!array_key_exists($i, $form->feedbacktext)) { $form->feedbacktext[$i] = ''; } if (!array_key_exists($i, $form->feedbackboundaries)) { $form->feedbackboundaries[$i] = ''; } } // The following are used for drop-down menus $yesnooptions = array(get_string("no"), get_string("yes")); $attemptoptions = array(); $attemptoptions[0] = get_string("attemptsunlimited", "quiz"); $attemptoptions[1] = "1 ".strtolower(get_string("attempt", "quiz")); for ($i=2;$i<=6;$i++) { $attemptoptions[$i] = "$i ".strtolower(get_string("attempts", "quiz")); } //enforced time delay between quiz attempts add-on $timedelayoptions = array(); $timedelayoptions[0] = get_string('none'); $timedelayoptions[1800] = get_string('numminutes', '', 30); $timedelayoptions[3600] = get_string('numminutes', '', 60); for($i=2; $i<=23; $i++) { $seconds = $i*3600; $timedelayoptions[$seconds] = get_string('numhours', '', $i); } $timedelayoptions[86400] = get_string('numhours', '', 24); for($i=2; $i<=7; $i++) { $seconds = $i*86400; $timedelayoptions[$seconds] = get_string('numdays', '', $i); } ?>
feedbacktext); $i = $i + 1) { ?> feedbacktext) - 1) { ?>
:
:

'; emoticonhelpbutton("form", "description"); echo '
'; } ?>
intro); ?>
: " onclick="return lockoptions('form', 'availableenable', availableitems)" timeopen) echo 'checked="checked"' ?> /> timeopen); echo " - "; print_time_selector("availablehour", "availableminute", $form->timeopen); helpbutton('timeopen', get_string('quizopens', 'quiz'), 'quiz'); ?>
: " onclick="return lockoptions('form', 'dueenable', dueitems)" timeclose) echo 'checked="checked"' ?> /> timeclose); echo " - "; print_time_selector("duehour", "dueminute", $form->timeclose); helpbutton('timeopen', get_string('quizcloses', 'quiz'), 'quiz'); ?>
: 100%
:
:
: 0%
:

instance) { ?> wwwroot/mod/quiz/edit.php?quizid=$form->instance") ?>" /> " /> " /> " />
quiz_fix_timelimit == $showfixed) { ?> : timelimit) echo 'checked="checked"' ?> /> quiz_fix_questionsperpage == $showfixed) { ?> : questionsperpage, ''); helpbutton('questionsperpage', get_string('questionsperpage', 'quiz'), 'quiz'); ?> quiz_fix_shufflequestions == $showfixed) { ?> : shufflequestions", ""); helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz"); ?> quiz_fix_shuffleanswers == $showfixed) { ?> : shuffleanswers", ""); helpbutton("shufflewithin", get_string("shufflewithin","quiz"), "quiz"); ?> quiz_fix_attempts == $showfixed) { ?> : attempts", ""); helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz"); ?> quiz_fix_attemptonlast == $showfixed) { ?> : attemptonlast", ""); helpbutton("repeatattempts", get_string("eachattemptbuildsonthelast", "quiz"), "quiz"); ?> quiz_fix_grademethod == $showfixed) { ?> : grademethod", ""); helpbutton("grademethod", get_string("grademethod","quiz"), "quiz"); ?> quiz_fix_adaptive == $showfixed) { ?> : optionflags & QUESTION_ADAPTIVE) ? 1 : 0, ""); helpbutton("adaptive", get_string("adaptive","quiz"), "quiz"); ?> quiz_fix_penaltyscheme == $showfixed) { ?> : penaltyscheme", ""); helpbutton("penaltyscheme", get_string("penaltyscheme","quiz"), "quiz"); ?> quiz_fix_decimalpoints == $showfixed) { ?> : '0', 1 => '1', 2 => '2', 3 => '3' ); choose_from_menu($options, "decimalpoints", "$form->decimalpoints", ""); helpbutton("decimalpoints", get_string("decimaldigits","quiz"), "quiz"); ?> quiz_fix_review == $showfixed) { echo ''; include($CFG->dirroot . '/mod/quiz/reviewoptions.html'); echo ''; $output = true; } ?> quiz_fix_delay1 == $showfixed) { ?> : delay1", ""); helpbutton("timedelay1", get_string("delay1","quiz"), "quiz"); ?> quiz_fix_delay2 == $showfixed) { ?> : delay2", ""); helpbutton("timedelay2", get_string("delay2","quiz"), "quiz"); ?> quiz_fix_popup == $showfixed) { ?> : popup", ""); helpbutton("popup", get_string("popup","quiz"), "quiz"); ?> quiz_fix_password == $showfixed) { ?> : quiz_fix_subnet == $showfixed) { ?> :