From a5c0990e5d5477f743dddd234312e0cf5223e22e Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Thu, 23 Dec 2004 07:09:33 +0000 Subject: [PATCH] New quiz config page to allow admin to set defaults and hide options on the quiz setup page. --- lang/en/help/fixdefaults.html | 1 + lang/en/moodle.php | 3 + lib/adminlib.php | 11 + lib/weblib.php | 4 +- mod/quiz/config.html | 233 ++++++++++++++++++++ mod/quiz/defaults.php | 36 +++ mod/quiz/mod.html | 400 ++++++++++++++++++++-------------- 7 files changed, 520 insertions(+), 168 deletions(-) create mode 100644 lang/en/help/fixdefaults.html create mode 100644 mod/quiz/config.html create mode 100644 mod/quiz/defaults.php diff --git a/lang/en/help/fixdefaults.html b/lang/en/help/fixdefaults.html new file mode 100644 index 0000000000..1fd14298ac --- /dev/null +++ b/lang/en/help/fixdefaults.html @@ -0,0 +1 @@ +

Fix site defaults

If you check these boxes then the default value that you choose here will be fixed for all new instances. The setup screen that the teacher sees will be simplified because it will not display the option.

\ No newline at end of file diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 41c65c2c5e..a5272f0a7e 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -461,6 +461,7 @@ $string['existingcoursedeleting'] = 'Existing course, deleting it first'; $string['existingcreators'] = 'Existing course creators'; $string['existingstudents'] = 'Enrolled students'; $string['existingteachers'] = 'Existing teachers'; +$string['explanation'] = 'Explanation'; $string['failedloginattempts'] = '$a->attempts failed logins since your last login'; $string['failedloginattemptsall'] = '$a->attempts failed logins for $a->accounts accounts'; $string['feedback'] = 'Feedback'; @@ -473,6 +474,7 @@ $string['findmorecourses'] = 'Find more courses...'; $string['firstdayofweek'] = '0'; $string['firstname'] = 'First name'; $string['firsttime'] = 'Is this your first time here?'; +$string['fix'] = 'Fix'; $string['followingoptional'] = 'The following items are optional'; $string['followingrequired'] = 'The following items are required'; $string['force'] = 'Force'; @@ -942,6 +944,7 @@ $string['showtheselogs'] = 'Show these logs'; $string['since'] = 'Since'; $string['sincelast'] = ' since last login'; $string['site'] = 'Site'; +$string['sitedefault'] = 'Site Default'; $string['siteerrors'] = 'Site errors'; $string['sitefiles'] = 'Site files'; $string['sitelogs'] = 'Site logs'; diff --git a/lib/adminlib.php b/lib/adminlib.php index 72003ef8d4..c19d1f34eb 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -213,6 +213,17 @@ function upgrade_activity_modules($return) { error($module->name .' tables could NOT be set up successfully!'); } } + + if ( is_readable($fullmod .'/defaults.php')) { + // Insert default values for any important configuration variables + include_once($fullmod .'/defaults.php'); + foreach ($defaults as $name => $value) { + if (!isset($CFG->$name)) { + $CFG->$name = $value; + set_config($name, $value); + } + } + } } if (!empty($updated_modules)) { diff --git a/lib/weblib.php b/lib/weblib.php index b845c7e968..64369eaaf5 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2880,7 +2880,7 @@ function print_time_selector($hour, $minute, $currenttime=0, $step=5) { * @param string $unit ? * @todo Finish documenting this function */ -function print_timer_selector($timelimit = 0, $unit = '') { +function print_timer_selector($timelimit = 0, $unit = '', $name = 'timelimit') { global $CFG; @@ -2894,7 +2894,7 @@ function print_timer_selector($timelimit = 0, $unit = '') { for ($i=1; $i<=$maxvalue; $i++) { $minutes[$i] = $i.$unit; } - choose_from_menu($minutes, 'timelimit', $timelimit, get_string('none')); + choose_from_menu($minutes, $name, $timelimit, get_string('none')); } /** diff --git a/mod/quiz/config.html b/mod/quiz/config.html new file mode 100644 index 0000000000..d26a22f7fb --- /dev/null +++ b/mod/quiz/config.html @@ -0,0 +1,233 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  + + + +
: + quiz_timelimit, get_string("minutes","quiz"), 'quiz_timelimit'); + helpbutton("timelimit", get_string("quiztimer","quiz"), "quiz"); + ?> + + + quiz_fix_timelimit ? "checked" : "") ?> /> +
: + quiz_shufflequestions, "", "", ""); + helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz"); + ?> + + + quiz_fix_shufflequestions ? "checked" : "") ?> /> +
: + quiz_shuffleanswers, "", "", ""); + helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz"); + ?> + + + quiz_fix_shuffleanswers ? "checked" : "") ?> /> +
: + quiz_attempts, "", "", ""); + helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz"); + ?> + + + quiz_fix_attempts ? "checked" : "") ?> /> +
: + quiz_attemptonlast, "", "", ""); + helpbutton("repeatattempts", get_string("eachattemptbuildsonthelast", "quiz"), "quiz"); + ?> + + + quiz_fix_attemptonlast ? "checked" : "") ?> /> +
: + quiz_grademethod, "", "", ""); + helpbutton("grademethod", get_string("grademethod","quiz"), "quiz"); + ?> + + + quiz_fix_grademethod ? "checked" : "") ?> /> +
: + quiz_showfeedback, "", "", ""); + helpbutton("feedback", get_string("showfeedback","quiz"), "quiz"); + ?> + + + quiz_fix_showfeedback ? "checked" : "") ?> /> +
: + quiz_showanswer, "", "", ""); + helpbutton("correctanswers", get_string("showcorrectanswer","quiz"), "quiz"); + ?> + + + quiz_fix_showanswer ? "checked" : "") ?> /> +
: + quiz_allowreview, "", "", ""); + helpbutton("review", get_string("allowreview","quiz"), "quiz"); + ?> + + + quiz_fix_allowreview ? "checked" : "") ?> /> +
: + =1; $i--) { + $grades[$i] = $i; + } + $grades[0] = get_string("nograde"); + choose_from_menu ($grades, "quiz_maximumgrade", $CFG->quiz_maximumgrade, "", "", ""); + helpbutton("maxgrade", get_string("maximumgrade"), "quiz"); + ?> + + + quiz_fix_maximumgrade ? "checked" : "") ?> /> +
: + quiz_popup, "", "", ""); + helpbutton("popup", get_string("popup","quiz"), "quiz"); + ?> + + + quiz_fix_popup ? "checked" : "") ?> /> +
: + + + + + quiz_fix_password ? "checked" : "") ?> /> +
: + + + + + quiz_fix_subnet ? "checked" : "") ?> /> +
+ " /> +
+ +
diff --git a/mod/quiz/defaults.php b/mod/quiz/defaults.php new file mode 100644 index 0000000000..8adf770e76 --- /dev/null +++ b/mod/quiz/defaults.php @@ -0,0 +1,36 @@ + 0, + 'quiz_attemptonlast' => 0, + 'quiz_attempts' => 0, + 'quiz_grademethod' => '', + 'quiz_maximumgrade' => 0, + 'quiz_password' => '', + 'quiz_popup' => 0, + 'quiz_showanswer' => '', + 'quiz_showfeedback' => '', + 'quiz_shuffleanswers' => 1, + 'quiz_shufflequestions' => 0, + 'quiz_subnet' => '', + 'quiz_timelimit' => 0, + + 'quiz_fix_allowreview' => 0, + 'quiz_fix_attemptonlast' => 0, + 'quiz_fix_attempts' => 0, + 'quiz_fix_grademethod' => 0, + 'quiz_fix_maximumgrade' => 0, + 'quiz_fix_password' => 0, + 'quiz_fix_popup' => 0, + 'quiz_fix_showanswer' => 0, + 'quiz_fix_showfeedback' => 0, + 'quiz_fix_shuffleanswers' => 0, + 'quiz_fix_shufflequestions' => 0, + 'quiz_fix_subnet' => 0, + 'quiz_fix_timelimit' => 0 + ); + +?> diff --git a/mod/quiz/mod.html b/mod/quiz/mod.html index ebb5496191..e194679113 100644 --- a/mod/quiz/mod.html +++ b/mod/quiz/mod.html @@ -17,60 +17,61 @@ $form->timeclose = ""; } if (!isset($form->attempts)) { - $form->attempts = 0; + $form->attempts = $CFG->quiz_attempts; } if (!isset($form->attemptonlast)) { - $form->attemptonlast = 0; + $form->attemptonlast = $CFG->quiz_attemptonlast; } if (!isset($form->grademethod)) { - $form->grademethod = ""; + $form->grademethod = $CFG->quiz_grademethod; } if (!isset($form->feedback)) { - $form->feedback = ""; + $form->feedback = $CFG->quiz_showfeedback; } if (!isset($form->correctanswers)) { - $form->correctanswers = ""; + $form->correctanswers = $CFG->quiz_showanswer; } if (!isset($form->review)) { - $form->review = 0; + $form->review = $CFG->quiz_allowreview; } if (!isset($form->shufflequestions)) { - $form->shufflequestions = 0; + $form->shufflequestions = $CFG->quiz_shufflequestions; } if (!isset($form->shuffleanswers)) { - $form->shuffleanswers = 1; + $form->shuffleanswers = $CFG->quiz_shuffleanswers; } if (!isset($form->grade)) { - $form->grade = 0; + $form->grade = $CFG->quiz_maximumgrade; } if (!isset($form->questions)) { $form->questions = ""; } if (!isset($form->password)) { - $form->password = ""; + $form->password = $CFG->quiz_password; } if (!isset($form->subnet)) { - $form->subnet = ""; + $form->subnet = $CFG->quiz_subnet; } if (!isset($form->timelimit)) { - $form->timelimit = 0; + $form->timelimit = $CFG->quiz_timelimit; } if (!isset($form->popup)) { - $form->popup = 0; + $form->popup = $CFG->quiz_popup; } ?> -
+ + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +quiz_fix_timelimit) { ?> + + + + + + + + +quiz_fix_shufflequestions) { ?> + + + + + + + + +quiz_fix_shuffleanswers) { ?> + + + + + + + + +quiz_fix_attempts) { ?> + + + + + + + + +quiz_fix_attemptonlast) { ?> + + + + + + + + +quiz_fix_grademethod) { ?> + + + + + + + + +quiz_fix_showfeedback) { ?> + + + + + + + + +quiz_fix_showanswer) { ?> + + + + + + + + +quiz_fix_allowreview) { ?> + + + + + + + + +quiz_fix_maximumgrade) { ?> + + + + + + + + +quiz_fix_popup) { ?> + + + + + + + + +quiz_fix_password) { ?> + + + + + + + + +quiz_fix_subnet) { ?> + + + + + + +
:
:
@@ -94,6 +95,7 @@ ?>
: @@ -107,6 +109,7 @@ ?>
: @@ -120,159 +123,224 @@ ?>
: - timelimit, get_string("minutes","quiz")); - helpbutton("timelimit", get_string("quiztimer","quiz"), "quiz"); - ?> -
: - shufflequestions", ""); - helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz"); - ?> -
: - shuffleanswers", ""); - helpbutton("shuffleanswers", get_string("shuffleanswers","quiz"), "quiz"); - ?> -
: - attempts", ""); - helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz"); - ?> -
: - attemptonlast", ""); - helpbutton("repeatattempts", - get_string("eachattemptbuildsonthelast", "quiz"), - "quiz"); - ?> -
: - grademethod", ""); - helpbutton("grademethod", get_string("grademethod","quiz"), "quiz"); - ?> -
: - feedback", ""); - helpbutton("feedback", get_string("showfeedback","quiz"), "quiz"); - ?> -
: - correctanswers", ""); - helpbutton("correctanswers", get_string("showcorrectanswer","quiz"), "quiz"); - ?> -
: - review", ""); - helpbutton("review", get_string("allowreview","quiz"), "quiz"); - ?> -
: - =1; $i--) { - $grades[$i] = $i; - } - $grades[0] = get_string("nograde"); - choose_from_menu($grades, "grade", "$form->grade", ""); - helpbutton("maxgrade", get_string("maximumgrade"), "quiz"); - ?> -
: - popup", ""); - helpbutton("popup", get_string("popup","quiz"), "quiz"); - ?> -
: - - -
: - - -
: + timelimit, get_string("minutes","quiz")); + helpbutton("timelimit", get_string("quiztimer","quiz"), "quiz"); + ?> +
: + shufflequestions", ""); + helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz"); + ?> +
: + shuffleanswers", ""); + helpbutton("shuffleanswers", get_string("shuffleanswers","quiz"), "quiz"); + ?> +
: + attempts", ""); + helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz"); + ?> +
: + attemptonlast", ""); + helpbutton("repeatattempts", + get_string("eachattemptbuildsonthelast", "quiz"), + "quiz"); + ?> +
: + grademethod", ""); + helpbutton("grademethod", get_string("grademethod","quiz"), "quiz"); + ?> +
: + feedback", ""); + helpbutton("feedback", get_string("showfeedback","quiz"), "quiz"); + ?> +
: + correctanswers", ""); + helpbutton("correctanswers", get_string("showcorrectanswer","quiz"), "quiz"); + ?> +
: + review", ""); + helpbutton("review", get_string("allowreview","quiz"), "quiz"); + ?> +
: + =1; $i--) { + $grades[$i] = $i; + } + $grades[0] = get_string("nograde"); + + choose_from_menu($grades, "grade", "$form->grade", ""); + helpbutton("maxgrade", get_string("maximumgrade"), "quiz"); + ?> +
: + popup", ""); + helpbutton("popup", get_string("popup","quiz"), "quiz"); + ?> +
: + + +
: + + +
-- 2.39.5