From 0353801a2b52e66456d4b76531f045a7ac278412 Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Sat, 22 Jan 2005 22:27:16 +0000 Subject: [PATCH] There is now a mechanism by which question types can have their own setup options. Because this does not change anything unless it is used I hope it is o.k. that I am submitting this without asking first. This is based on code by Mad Alex. --- lang/en/quiz.php | 1 + mod/quiz/config.html | 76 ++++++++++++++++++++++++++++++++++++++++++- mod/quiz/locallib.php | 33 +++++++++++++++++++ 3 files changed, 109 insertions(+), 1 deletion(-) diff --git a/lang/en/quiz.php b/lang/en/quiz.php index d746ad0795..79925e8a1f 100644 --- a/lang/en/quiz.php +++ b/lang/en/quiz.php @@ -203,6 +203,7 @@ $string['questionname'] = 'Question name'; $string['questionnametoolong'] = 'Question name too long at line $a (255 char. max). It has been truncated.'; $string['questions'] = 'Questions'; $string['questionsperpage'] = 'Max number of questions per page'; +$string['questiontypesetupoptions'] = 'Setup options for question types:'; $string['quizavailable'] = 'The quiz is available until: $a'; $string['quizclose'] = 'Close the quiz'; $string['quizclosed'] = 'This quiz closed on $a'; diff --git a/mod/quiz/config.html b/mod/quiz/config.html index 8345cb1f6d..c3def0612e 100644 --- a/mod/quiz/config.html +++ b/mod/quiz/config.html @@ -1,7 +1,81 @@ +dirroot . '/mod/quiz/locallib.php'); +?>
- + + +get_config_options(); + if ($options) { + // Temporary code + if (!$table_created) { + echo "
\n"; + echo '\n"; + $table_created = true; + } + $typename = $type->name(); + $strtype = get_string($typename, 'quiz'); + echo "\n"; + echo '\n"; + echo "\n"; + foreach ($options as $option) { + if (!isset($option->name)) { + continue; + } + echo "\n"; + if (!empty($option->link)) { + echo '\n"; + } + else { + if (!isset($option->code)) { + $option->code = ''; + } + echo '\n"; + echo '\n"; + if (empty($option->help)) { + echo "\n"; + } + else { + echo '\n"; + } + $submitbutton = 'true'; + } + echo "\n"; + } + } + } + if ($submitbutton) { +?> + + + +
'; + print_heading(get_string('questiontypesetupoptions', 'quiz')); + echo "
' . $strtype . "
' . get_string($option->name, 'quiz') . "'; + print_string($option->name, 'quiz'); + echo ":' . $option->code . "' . get_string($option->help, 'quiz') . "
+ " /> +
+'; + print_simple_box_end(); + echo '
'; + print_simple_box_start("center", "", "$THEME->cellheading"); + } +?> + + + + + diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index 4dae361e3e..e3d4540bb5 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -312,6 +312,39 @@ class quiz_default_questiontype { error('grade_response has not been implemented for question type ' .$this->name()); } + + function get_config_options() { + // Returns an array of objects describing the options for the question type + // to be included on the quiz module admin page + // + // Configuration options can be included by setting the following fields in + // the object: + // ->name (The name of the option within this question type + // - the full option name will be constructed as + // "quiz_{$this->name()}_$name", the human readable name + // will be displayed with get_string($name, 'quiz')) + // ->code (The code to display the form element, help button, etc. + // i.e. the content for the central table cell. Be sure + // to name the element "quiz_{$this->name()}_$name" and + // set the value to $CFG->{"quiz_{$this->name()}_$name"}) + // ->help (Name of the string from the quiz module language file + // to be used for the help message in the third column of + // the table. An empty string (or the field not set) + // means to leave the box empty) + // + // Links to custom settings pages can be included by setting the following + // fields in the object: + // ->name (The name of the link text string - + // get_string($name, 'quiz') will be called) + // ->link (The filename part of the URL for the link + // - the full URL is contructed as + // "$CFG->wwwroot/mod/quiz/questiontypes/{$this->name()}/$link?sesskey=$sesskey" + // [but with the relavant calls to the s and rawurlencode + // functions] where $sesskey is the sesskey for the user) + + // No options by default + return false; + } } quiz_load_questiontypes(); -- 2.39.5