]> git.mjollnir.org Git - moodle.git/commitdiff
Renaming constants QUIZ_ADAPTIVE and QUIZ_IGNORE_DUPRESP to QUESTION_..... and moved...
authorgustav_delius <gustav_delius>
Mon, 20 Mar 2006 20:45:55 +0000 (20:45 +0000)
committergustav_delius <gustav_delius>
Mon, 20 Mar 2006 20:45:55 +0000 (20:45 +0000)
lib/questionlib.php
mod/quiz/attempt.php
mod/quiz/config.html
mod/quiz/constants.php
mod/quiz/defaults.php
mod/quiz/lib.php
mod/quiz/mod.html
question/questiontypes/questiontype.php
question/questiontypes/rqp/questiontype.php

index 3e22162d7ec89432520b9834103c0e57bf0f6e50..2966080af73ebbb78d0eca07a39309444d3969c0 100644 (file)
@@ -1,27 +1,29 @@
 <?php  // $Id$
 /**
-* Code for handling and processing questions
-*
-* This is code that is module independent, i.e., can be used by any module that
-* uses questions, like quiz, lesson, ..
-* This script also loads the questiontype classes
-* Code for handling the editing of questions is in {@link editlib.php}
-*
-* TODO: separate those functions which form part of the API
-*       from the helper functions.
-*
-* @version $Id$
-* @author Martin Dougiamas and many others. This has recently been completely
-*         rewritten by Alex Smith, Julian Sedding and Gustav Delius as part of
-*         the Serving Mathematics project
-*         {@link http://maths.york.ac.uk/serving_maths}
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package question
-*/
+ * Code for handling and processing questions
+ *
+ * This is code that is module independent, i.e., can be used by any module that
+ * uses questions, like quiz, lesson, ..
+ * This script also loads the questiontype classes
+ * Code for handling the editing of questions is in {@link question/editlib.php}
+ *
+ * TODO: separate those functions which form part of the API
+ *       from the helper functions.
+ *
+ * @version $Id$
+ * @author Martin Dougiamas and many others. This has recently been completely
+ *         rewritten by Alex Smith, Julian Sedding and Gustav Delius as part of
+ *         the Serving Mathematics project
+ *         {@link http://maths.york.ac.uk/serving_maths}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package question
+ */
+
+/// CONSTANTS ///////////////////////////////////
 
 /**#@+
-* The different types of events that can create question states
-*/
+ * The different types of events that can create question states
+ */
 define('QUESTION_EVENTOPEN', '0');      // The state was created by Moodle
 define('QUESTION_EVENTNAVIGATE', '1');  // The responses were saved because the student navigated to another page (this is not currently used)
 define('QUESTION_EVENTSAVE', '2');      // The student has requested that the responses should be saved but not submitted or validated
@@ -34,8 +36,8 @@ define('QUESTION_EVENTCLOSE', '8');     // The response has been submitted and t
 /**#@-*/
 
 /**#@+
-* The core question types
-*/
+ * The core question types
+ */
 define("SHORTANSWER",   "1");
 define("TRUEFALSE",     "2");
 define("MULTICHOICE",   "3");
@@ -50,24 +52,50 @@ define("RQP",          "11");
 define("ESSAY",        "12");
 /**#@-*/
 
+/**
+ * Constant determines the number of answer boxes supplied in the editing
+ * form for multiple choice and similar question types.
+ */
 define("QUESTION_NUMANS", "10");
 
 
+/**#@+
+ * Option flags for ->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
index 131c7d10903fb4de4c7027b5ded5853c7f55905e..b5659d96ecc22d5896cb35d6e581a7835fc44cd9 100644 (file)
     echo "<center>\n";
 
     echo "<input type=\"submit\" name=\"saveattempt\" value=\"".get_string("savenosubmit", "quiz")."\" />\n";
-    if ($quiz->optionflags & QUIZ_ADAPTIVE) {
+    if ($quiz->optionflags & QUESTION_ADAPTIVE) {
         echo "<input type=\"submit\" name=\"markall\" value=\"".get_string("markall", "quiz")."\" />\n";
     }
     echo "<input type=\"submit\" name=\"finishattempt\" value=\"".get_string("finishattempt", "quiz")."\" onclick=\"$onclick\" />\n";
index 4fc0483bd681fb16b68d0e694f312ab2c056dcda..77f3356c4ac742f8c24c91ff3e42bf68c00e25ed 100644 (file)
   <td align="right"><b><?php print_string("adaptive", "quiz") ?>:</b></td>
   <td>
     <?php
-        choose_from_menu($yesnooptions, "adaptive", ($CFG->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");
     ?>
   </td>
index bca1ae20c6cab0ac8e0a1541c53283bb83238579..f626064139a013575f14f0a10e3f6bf3c2116271 100644 (file)
 
 /// 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
index b56b596f9f796d9b998c36c969747fe2e5e81178..354f5f440ba78a383098e73b566c457ca5e41b04 100644 (file)
@@ -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,
 
index f133d8ac55a869818221c0519fd35537edab5dc5..ebc8eed8db6198e7929b24dfdea9d6526f614b3c 100644 (file)
@@ -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)) {
index ef2f0d558f065ce4e90ee28515f143a6842f9b36..16f996b4c853077ea823339ea355d5f2e10cfc9d 100644 (file)
         <td align="right"><b><?php print_string("adaptive", "quiz") ?>:</b></td>
          <td align="left">
         <?php
-            choose_from_menu($yesnooptions, "adaptive", ($form->optionflags & QUIZ_ADAPTIVE) ? 1 : 0, "");
+            choose_from_menu($yesnooptions, "adaptive", ($form->optionflags & QUESTION_ADAPTIVE) ? 1 : 0, "");
             helpbutton("adaptive", get_string("adaptive","quiz"), "quiz");
          ?>
         </td>
         <td align="right"><b><?php print_string("adaptive", "quiz") ?>:</b></td>
          <td align="left">
         <?php
-            choose_from_menu($yesnooptions, "adaptive", ($form->optionflags & QUIZ_ADAPTIVE) ? 1 : 0, "");
+            choose_from_menu($yesnooptions, "adaptive", ($form->optionflags & QUESTION_ADAPTIVE) ? 1 : 0, "");
             helpbutton("adaptive", get_string("adaptive","quiz"), "quiz");
          ?>
         </td>
index 0df233d2eb83efc5c231dbebdb589e9af1de6974..648944551aec4621586f0533b208e88cc0628f50 100644 (file)
@@ -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 '<input type="submit" name="';
             echo $question->name_prefix;
             echo 'mark" value="';
index 0d46a0099a08430c603d3560527f99fb4e7ef46f..8b18c7982d58edb0e7ed9f49fb193c2bebc526c9 100644 (file)
@@ -345,7 +345,7 @@ class question_rqp_qtype extends quiz_default_questiontype {
         echo 'validate" value="';
         print_string('validate', 'quiz');
         echo '" />&nbsp;';
-        if ($cmoptions->optionflags & QUIZ_ADAPTIVE) {
+        if ($cmoptions->optionflags & QUESTION_ADAPTIVE) {
             echo '<input type="submit" name="';
             echo $question->name_prefix;
             echo 'mark" value="';