From 6b11a0e863a7bd0f4269140691d4ff10e1cb2dbf Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Mon, 20 Mar 2006 20:45:55 +0000 Subject: [PATCH] Renaming constants QUIZ_ADAPTIVE and QUIZ_IGNORE_DUPRESP to QUESTION_..... and moved them to lib/questionlib.php because they are used for question-level options. --- lib/questionlib.php | 119 ++++++++++++-------- mod/quiz/attempt.php | 2 +- mod/quiz/config.html | 2 +- mod/quiz/constants.php | 22 ---- mod/quiz/defaults.php | 2 +- mod/quiz/lib.php | 2 +- mod/quiz/mod.html | 4 +- question/questiontypes/questiontype.php | 4 +- question/questiontypes/rqp/questiontype.php | 2 +- 9 files changed, 79 insertions(+), 80 deletions(-) diff --git a/lib/questionlib.php b/lib/questionlib.php index 3e22162d7e..2966080af7 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -1,27 +1,29 @@ optionflags + * The options are read out via bitwise operation using these constants + */ +/** + * Whether the questions is to be run in adaptive mode. If this is not set then + * a question closes immediately after the first submission of responses. This + * is how question is Moodle always worked before version 1.5 + */ +define('QUESTION_ADAPTIVE', 1); + +/** When processing responses the code checks that the new responses at + * a question differ from those given on the previous submission. If + * furthermore this flag is set to true + * then the code goes through the whole history of responses and checks if + * ANY of them are identical to the current response in which case the + * current response is ignored. + */ +define('QUESTION_IGNORE_DUPRESP', 2); + +/**#@-*/ + /// QTYPES INITIATION ////////////////// /** -* Array holding question type objects -*/ + * Array holding question type objects + */ global $QTYPES; -$QTYPES = array(); // This array will be populated when the questiontype.php files are loaded +$QTYPES = array(); // This array will be populated when the questiontype.php files are loaded below /** -* Array of question types names translated to the user's language -* -* The $QTYPE_MENU array holds the names of all the question types that the user should -* be able to create directly. Some internal question types like random questions are excluded. -* The complete list of question types can be found in {@link $QTYPES}. -*/ + * Array of question types names translated to the user's language + * + * The $QTYPE_MENU array holds the names of all the question types that the user should + * be able to create directly. Some internal question types like random questions are excluded. + * The complete list of question types can be found in {@link $QTYPES}. + */ $QTYPE_MENU = array(); // This array will be populated when the questiontype.php files are loaded require_once("$CFG->dirroot/question/questiontypes/questiontype.php"); @@ -91,8 +119,8 @@ foreach($qtypenames as $qtypename) { /// OTHER CLASSES ///////////////////////////////////////////////////////// /** -* This holds the options that are determined by the course module -*/ + * This holds the options that are set by the course module + */ class cmoptions { /** * Whether a new attempt should be based on the previous one. If true @@ -105,7 +133,7 @@ class cmoptions { * Various option flags. The flags are accessed via bitwise operations * using the constants defined in the CONSTANTS section above. */ - var $optionflags = QUIZ_ADAPTIVE; + var $optionflags = QUESTION_ADAPTIVE; /** * Determines whether in the calculation of the score for a question @@ -142,13 +170,6 @@ class cmoptions { * The number of decimals to be shown when scores are printed */ var $decimalpoints = 2; - - /** - * Determines when a student is allowed to review. The information is read - * out from the bits with the help of the constants defined earlier - * We initialise this to allow the student to see everything (all bits set) - */ - var $review = 16777215; } @@ -157,12 +178,12 @@ class cmoptions { /** -* Deletes question and all associated data from the database -* -* TODO: remove quiz dependence -* -* @param object $question The question being deleted -*/ + * Deletes question and all associated data from the database + * + * TODO: remove quiz dependence + * + * @param object $question The question being deleted + */ function delete_question($question) { global $QTYPES; if (isset($QTYPES[$question->qtype])) { @@ -673,7 +694,7 @@ function question_process_responses(&$question, &$state, $action, $cmoptions, &$ $question, $state, $state->last_graded)) { $state->event = QUESTION_EVENTDUPLICATE; } else { - if ($cmoptions->optionflags & QUIZ_IGNORE_DUPRESP) { + if ($cmoptions->optionflags & QUESTION_IGNORE_DUPRESP) { /* Walk back through the previous graded states looking for one where the responses are equivalent to the current responses. If such a state is found, set the current grading @@ -737,7 +758,7 @@ function question_isgradingevent($event) { * This is used by {@link question_process_responses()} to determine whether * to ignore the marking request for the current response. However this * check against all previous graded responses is only performed if -* the QUIZ_IGNORE_DUPRESP bit in $cmoptions->optionflags is set +* the QUESTION_IGNORE_DUPRESP bit in $cmoptions->optionflags is set * If the current response is a duplicate of a previously graded response then * $STATE->event is set to QUESTION_EVENTDUPLICATE. * @return boolean Indicates if a state with duplicate responses was diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index 131c7d1090..b5659d96ec 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -481,7 +481,7 @@ echo "
\n"; echo "\n"; - if ($quiz->optionflags & QUIZ_ADAPTIVE) { + if ($quiz->optionflags & QUESTION_ADAPTIVE) { echo "\n"; } echo "\n"; diff --git a/mod/quiz/config.html b/mod/quiz/config.html index 4fc0483bd6..77f3356c4a 100644 --- a/mod/quiz/config.html +++ b/mod/quiz/config.html @@ -235,7 +235,7 @@ : quiz_optionflags & QUIZ_ADAPTIVE) ? 1 : 0, ""); + choose_from_menu($yesnooptions, "adaptive", ($CFG->quiz_optionflags & QUESTION_ADAPTIVE) ? 1 : 0, ""); helpbutton("adaptive", get_string("adaptive","quiz"), "quiz"); ?> diff --git a/mod/quiz/constants.php b/mod/quiz/constants.php index bca1ae20c6..f626064139 100644 --- a/mod/quiz/constants.php +++ b/mod/quiz/constants.php @@ -14,28 +14,6 @@ /// CONSTANTS /////////////////////////////////////////////////////////////////// -/**#@+ -* Option flags for ->optionflags -* The options are read out via bitwise operation using these constants -*/ -/** -* Whether the questions to be run in adaptive mode. If this is not set then -* a question closes immediately after the first submission of responses. This -* is how Moodle worked before version 1.5 -*/ -define('QUIZ_ADAPTIVE', 1); - -/** When processing responses the code checks that the new responses at -* a question differ from those given on the previous submission. If -* furthermore $ignoredupresp (ignore duplicate responses) is set to true -* then the code goes through the whole history of attempts and checks if -* ANY of them are identical to the current response in which case the -* current response is ignored. -*/ -define('QUIZ_IGNORE_DUPRESP', 2); - -/**#@-*/ - /**#@+ * The different review options are stored in the bits of $quiz->review * These constants help to extract the options diff --git a/mod/quiz/defaults.php b/mod/quiz/defaults.php index b56b596f9f..354f5f440b 100644 --- a/mod/quiz/defaults.php +++ b/mod/quiz/defaults.php @@ -19,7 +19,7 @@ 'quiz_timelimit' => 0, 'quiz_optionflags' => 1, 'quiz_penaltyscheme' => 1, - 'quiz_adaptive' => QUIZ_ADAPTIVE, + 'QUESTION_ADAPTIVE' => QUESTION_ADAPTIVE, 'quiz_delay1' => 0, 'quiz_delay2' => 0, diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index f133d8ac55..ebc8eed8db 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -671,7 +671,7 @@ function quiz_process_options(&$form) { $review = 0; if (!empty($form->adaptive)) { - $optionflags |= QUIZ_ADAPTIVE; + $optionflags |= QUESTION_ADAPTIVE; } if (isset($form->responsesimmediately)) { diff --git a/mod/quiz/mod.html b/mod/quiz/mod.html index ef2f0d558f..16f996b4c8 100644 --- a/mod/quiz/mod.html +++ b/mod/quiz/mod.html @@ -285,7 +285,7 @@ : optionflags & QUIZ_ADAPTIVE) ? 1 : 0, ""); + choose_from_menu($yesnooptions, "adaptive", ($form->optionflags & QUESTION_ADAPTIVE) ? 1 : 0, ""); helpbutton("adaptive", get_string("adaptive","quiz"), "quiz"); ?> @@ -537,7 +537,7 @@ : optionflags & QUIZ_ADAPTIVE) ? 1 : 0, ""); + choose_from_menu($yesnooptions, "adaptive", ($form->optionflags & QUESTION_ADAPTIVE) ? 1 : 0, ""); helpbutton("adaptive", get_string("adaptive","quiz"), "quiz"); ?> diff --git a/question/questiontypes/questiontype.php b/question/questiontypes/questiontype.php index 0df233d2eb..648944551a 100644 --- a/question/questiontypes/questiontype.php +++ b/question/questiontypes/questiontype.php @@ -457,7 +457,7 @@ class quiz_default_questiontype { $grade = ''; if ($question->maxgrade and $options->scores) { - if ($cmoptions->optionflags & QUIZ_ADAPTIVE) { + if ($cmoptions->optionflags & QUESTION_ADAPTIVE) { $grade = (!question_state_is_graded($state->last_graded)) ? '--/' : round($state->last_graded->grade, $cmoptions->decimalpoints).'/'; } $grade .= $question->maxgrade; @@ -644,7 +644,7 @@ class quiz_default_questiontype { types. It prints a mark button in the case where individual marking is allowed. */ - if (($cmoptions->optionflags & QUIZ_ADAPTIVE) and !$options->readonly) { + if (($cmoptions->optionflags & QUESTION_ADAPTIVE) and !$options->readonly) { echo ' '; - if ($cmoptions->optionflags & QUIZ_ADAPTIVE) { + if ($cmoptions->optionflags & QUESTION_ADAPTIVE) { echo '