]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9519 - incorrectuse of language strings in quiz. Merged from MOODLE_18_STABLE.
authortjhunt <tjhunt>
Mon, 6 Aug 2007 13:22:59 +0000 (13:22 +0000)
committertjhunt <tjhunt>
Mon, 6 Aug 2007 13:22:59 +0000 (13:22 +0000)
mod/quiz/config.html
mod/quiz/locallib.php
mod/quiz/mod_form.php
mod/quiz/view.php

index da47c135a71e75d2b81d4621e7425e36393b0843..2771fae3002a3d1b1d911d6697debf5a297be7d6 100644 (file)
   <td align="right"><b><?php print_string("grademethod", "quiz") ?>:</b></td>
   <td>
     <?php
-       choose_from_menu ($QUIZ_GRADE_METHOD, "grademethod", $form->grademethod, "", "", "");
+       choose_from_menu (quiz_get_grading_options(), "grademethod", $form->grademethod, "", "", "");
        helpbutton("grademethod", get_string("grademethod","quiz"), "quiz");
     ?>
   </td>
index bf4efc9c34206c16fb9e52b9f1a1d3349d104763..d0ef3ec790e07e74d8ef493f469eb2f2aca89a87 100644 (file)
@@ -32,12 +32,6 @@ define("QUIZ_GRADEHIGHEST", "1");
 define("QUIZ_GRADEAVERAGE", "2");
 define("QUIZ_ATTEMPTFIRST", "3");
 define("QUIZ_ATTEMPTLAST",  "4");
-$QUIZ_GRADE_METHOD = array(
-        QUIZ_GRADEHIGHEST => get_string("gradehighest", "quiz"),
-        QUIZ_GRADEAVERAGE => get_string("gradeaverage", "quiz"),
-        QUIZ_ATTEMPTFIRST => get_string("attemptfirst", "quiz"),
-        QUIZ_ATTEMPTLAST  => get_string("attemptlast", "quiz")
-);
 /**#@-*/
 
 /// Functions related to attempts /////////////////////////////////////////
@@ -568,6 +562,26 @@ function quiz_calculate_best_attempt($quiz, $attempts) {
     }
 }
 
+/**
+ * @return the options for calculating the quiz grade from the individual attempt grades.
+ */
+function quiz_get_grading_options() {
+    return array (
+            QUIZ_GRADEHIGHEST => get_string('gradehighest', 'quiz'),
+            QUIZ_GRADEAVERAGE => get_string('gradeaverage', 'quiz'),
+            QUIZ_ATTEMPTFIRST => get_string('attemptfirst', 'quiz'),
+            QUIZ_ATTEMPTLAST  => get_string('attemptlast', 'quiz'));
+}
+
+/**
+ * @param int $option one of the values QUIZ_GRADEHIGHEST, QUIZ_GRADEAVERAGE, QUIZ_ATTEMPTFIRST or QUIZ_ATTEMPTLAST.
+ * @return the lang string for that option.
+ */
+function quiz_get_grading_option_name($option) {
+    $strings = quiz_get_grading_options();
+    return $strings[$option];
+}
+
 /// Other quiz functions ////////////////////////////////////////////////////
 
 /**
index 588ca573ea56a8db6e9b3b8acfa8af3f6e3089bb..2f395324ba3405ddd2d31d98b470a76c8c7337a5 100644 (file)
@@ -8,7 +8,7 @@ class mod_quiz_mod_form extends moodleform_mod {
 
     function definition() {
 
-        global $COURSE, $CFG, $QUIZ_GRADE_METHOD;
+        global $COURSE, $CFG;
         $mform    =& $this->_form;
 
 //-------------------------------------------------------------------------------
@@ -117,7 +117,7 @@ class mod_quiz_mod_form extends moodleform_mod {
 
 //-------------------------------------------------------------------------------
         $mform->addElement('header', 'gradeshdr', get_string('grades', 'grades'));
-        $mform->addElement('select', 'grademethod', get_string("grademethod", "quiz"), $QUIZ_GRADE_METHOD);
+        $mform->addElement('select', 'grademethod', get_string("grademethod", "quiz"), quiz_get_grading_options());
         $mform->setHelpButton('grademethod', array("grademethod", get_string("grademethod","quiz"), "quiz"));
         $mform->setAdvanced('grademethod', $CFG->quiz_fix_grademethod);
         $mform->setDefault('grademethod', $CFG->quiz_grademethod);
index afb5ce99875f67cd1093206d300ce6537f83911f..25dc6dc4530ef2af8ca741deb288d0d8661f67ae 100644 (file)
             echo "<p>".get_string("attemptsallowed", "quiz").": $quiz->attempts</p>";
         }
         if ($quiz->attempts != 1) {
-            echo "<p>".get_string("grademethod", "quiz").": ".$QUIZ_GRADE_METHOD[$quiz->grademethod]."</p>";
+            echo "<p>".get_string("grademethod", "quiz").": ".quiz_get_grading_option_name($quiz->grademethod)."</p>";
         }
 
         // Print information about timings.
             if ($overallstats) {
                 if ($available && $moreattempts) {
                     $a = new stdClass;
-                    $a->method = $QUIZ_GRADE_METHOD[$quiz->grademethod];
+                    $a->method = quiz_get_grading_option_name($quiz->grademethod);
                     $a->mygrade = $mygrade;
                     $a->quizgrade = $quiz->grade;
                     print_heading(get_string('gradesofar', 'quiz', $a));