From 4e3487c59c4a43dfe2fd0acb33d863de4de01c7b Mon Sep 17 00:00:00 2001 From: tjhunt Date: Tue, 15 Aug 2006 15:29:38 +0000 Subject: [PATCH] Remove horrific code duplication in mod/quiz/mod.html. --- mod/quiz/mod.html | 433 ++++++++++++++-------------------------------- 1 file changed, 128 insertions(+), 305 deletions(-) diff --git a/mod/quiz/mod.html b/mod/quiz/mod.html index 21d6992bf4..9b19f92b86 100644 --- a/mod/quiz/mod.html +++ b/mod/quiz/mod.html @@ -3,7 +3,8 @@ dirroot/mod/quiz/locallib.php"); -/// Ensure that all form variables are initialized + + // Set any form variables that have not been initialized to their default value. if (!isset($form->name)) { $form->name = ""; } @@ -67,10 +68,9 @@ if (empty($form->timedue)) { $form->timedue = ""; } - //enforced time delay between quiz attempts add-on + //enforced time delay between quiz attempts //delay1: time delay between first and second attempt //delay2: time delay between second and additional quiz attempt - //enforced delay attempt between quiz if (!isset($form->delay1)) { $form->delay1 = $CFG->quiz_delay1; } @@ -78,14 +78,9 @@ $form->delay2 = $CFG->quiz_delay2; } - $fix = 0; // This will later be set to 1 if some of the variables have been fixed by the admin. - - // the following are used for drop-down menus + // The following are used for drop-down menus + $yesnooptions = array(get_string("no"), get_string("yes")); - $yesnooptions = array(); - $yesnooptions[0] = get_string("no"); - $yesnooptions[1] = get_string("yes"); - $attemptoptions = array(); $attemptoptions[0] = get_string("attemptsunlimited", "quiz"); $attemptoptions[1] = "1 ".strtolower(get_string("attempt", "quiz")); @@ -185,212 +180,18 @@ -quiz_fix_timelimit) { ?> - - : - - timelimit) echo 'checked="checked"' ?> /> - - - - - - - -quiz_fix_questionsperpage) { ?> - - : - - questionsperpage, ''); - helpbutton('questionsperpage', get_string('questionsperpage', 'quiz'), 'quiz'); - ?> - - - - -quiz_fix_shufflequestions) { ?> - - : - - shufflequestions", ""); - helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz"); - ?> - - - - -quiz_fix_shuffleanswers) { ?> - - : - - shuffleanswers", ""); - helpbutton("shufflewithin", get_string("shufflewithin","quiz"), "quiz"); - ?> - - - - -quiz_fix_attempts) { ?> - - : - - attempts", ""); - helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz"); - ?> - - - - -quiz_fix_attemptonlast) { ?> - - : - - attemptonlast", ""); - helpbutton("repeatattempts", - get_string("eachattemptbuildsonthelast", "quiz"), - "quiz"); - ?> - - - - -quiz_fix_grademethod) { ?> - - : - - grademethod", ""); - helpbutton("grademethod", get_string("grademethod","quiz"), "quiz"); - ?> - - - - -quiz_fix_adaptive) { ?> - - : - - optionflags & QUESTION_ADAPTIVE) ? 1 : 0, ""); - helpbutton("adaptive", get_string("adaptive","quiz"), "quiz"); - ?> - - - - -quiz_fix_penaltyscheme) { ?> - - : - - penaltyscheme", ""); - helpbutton("penaltyscheme", get_string("penaltyscheme","quiz"), "quiz"); - ?> - - - - -quiz_fix_decimalpoints) { ?> - - : - - decimalpoints", ""); - helpbutton("decimalpoints", get_string("decimaldigits","quiz"), "quiz"); - ?> - - - - -quiz_fix_review) { - echo ''; - include($CFG->dirroot . '/mod/quiz/reviewoptions.html'); - echo ''; -} else $fix=1 ?> - -quiz_fix_popup) { ?> - - : - - popup", ""); - helpbutton("popup", get_string("popup","quiz"), "quiz"); - ?> - - - - -quiz_fix_delay1) { ?> - - : - - delay1", ""); - helpbutton("timedelay1", get_string("delay1","quiz"), "quiz"); - ?> - - - - -quiz_fix_delay2) { ?> - - : - - delay2", ""); - helpbutton("timedelay2", get_string("delay2","quiz"), "quiz"); - ?> - - - - -quiz_fix_password) { ?> - - : - - - - - - - -quiz_fix_subnet) { ?> - - : - - - - - - - - - + + if ($fix) { + // Some options were fixed by the admin. Show them, but hidden behind an Advanced button. +?> : - -
- -quiz_fix_timelimit) { ?> + +
+ +
+ + + +
+ + + + + + + + + + + + +instance) { ?> +wwwroot/mod/quiz/edit.php?quizid=$form->instance") ?>" /> +" /> + +" /> + +" /> + + + + + + + +quiz_fix_timelimit == $showfixed) { ?> : timelimit) echo 'checked="checked"' ?> /> - - + -quiz_fix_questionsperpage) { ?> +quiz_fix_questionsperpage == $showfixed) { ?> : @@ -466,13 +324,13 @@ $perpage[0] = get_string('allinone', 'quiz'); choose_from_menu($perpage, 'questionsperpage', $form->questionsperpage, ''); - helpbutton('questionsperpage', get_string('questionsperpage'), 'quiz'); + helpbutton('questionsperpage', get_string('questionsperpage', 'quiz'), 'quiz'); ?> - + -quiz_fix_shufflequestions) { ?> +quiz_fix_shufflequestions == $showfixed) { ?> : @@ -482,9 +340,9 @@ ?> - + -quiz_fix_shuffleanswers) { ?> +quiz_fix_shuffleanswers == $showfixed) { ?> : @@ -494,9 +352,9 @@ ?> - + -quiz_fix_attempts) { ?> +quiz_fix_attempts == $showfixed) { ?> : @@ -506,8 +364,9 @@ ?> - -quiz_fix_attemptonlast) { ?> + + +quiz_fix_attemptonlast == $showfixed) { ?> : @@ -520,8 +379,9 @@ ?> - -quiz_fix_grademethod) { ?> + + +quiz_fix_grademethod == $showfixed) { ?> : @@ -531,9 +391,9 @@ ?> - + -quiz_fix_adaptive) { $fix = 1; ?> +quiz_fix_adaptive == $showfixed) { ?> : @@ -543,9 +403,9 @@ ?> - + -quiz_fix_penaltyscheme) { $fix = 1; ?> +quiz_fix_penaltyscheme == $showfixed) { ?> : @@ -555,9 +415,9 @@ ?> - + -quiz_fix_decimalpoints) { ?> +quiz_fix_decimalpoints == $showfixed) { ?> : @@ -572,15 +432,28 @@ ?> - + -quiz_fix_review) { +quiz_fix_review == $showfixed) { echo ''; include($CFG->dirroot . '/mod/quiz/reviewoptions.html'); echo ''; + $output = true; } ?> -quiz_fix_delay1) { ?> +quiz_fix_popup == $showfixed) { ?> + + : + + popup", ""); + helpbutton("popup", get_string("popup","quiz"), "quiz"); + ?> + + + + +quiz_fix_delay1 == $showfixed) { ?> : @@ -590,33 +463,21 @@ ?> - - -quiz_fix_delay2) { ?> - - : - - delay2", ""); - helpbutton("timedelay2", get_string("delay2","quiz"), "quiz"); - ?> - - - + -quiz_fix_popup) { ?> +quiz_fix_delay2 == $showfixed) { ?> - : - + : + popup", ""); - helpbutton("popup", get_string("popup","quiz"), "quiz"); - ?> + choose_from_menu($timedelayoptions, "delay2", "$form->delay2", ""); + helpbutton("timedelay2", get_string("delay2","quiz"), "quiz"); + ?> - - + + -quiz_fix_password) { ?> +quiz_fix_password == $showfixed) { ?> : @@ -624,9 +485,9 @@ - + -quiz_fix_subnet) { ?> +quiz_fix_subnet == $showfixed) { ?> : @@ -634,46 +495,8 @@ - - - - - - - - - - - -
- - - - - - - - - - - - -instance) { ?> -wwwroot/mod/quiz/edit.php?quizid=$form->instance") ?>" /> -" /> - -" /> - -" /> - - - - -- 2.39.5