From 0675e5eb8fce362cb98d062ac34d6224a095f862 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Mon, 6 Aug 2007 13:22:59 +0000 Subject: [PATCH] MDL-9519 - incorrectuse of language strings in quiz. Merged from MOODLE_18_STABLE. --- mod/quiz/config.html | 2 +- mod/quiz/locallib.php | 26 ++++++++++++++++++++------ mod/quiz/mod_form.php | 4 ++-- mod/quiz/view.php | 4 ++-- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/mod/quiz/config.html b/mod/quiz/config.html index da47c135a7..2771fae300 100644 --- a/mod/quiz/config.html +++ b/mod/quiz/config.html @@ -224,7 +224,7 @@ : grademethod, "", "", ""); + choose_from_menu (quiz_get_grading_options(), "grademethod", $form->grademethod, "", "", ""); helpbutton("grademethod", get_string("grademethod","quiz"), "quiz"); ?> diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index bf4efc9c34..d0ef3ec790 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -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 //////////////////////////////////////////////////// /** diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php index 588ca573ea..2f395324ba 100644 --- a/mod/quiz/mod_form.php +++ b/mod/quiz/mod_form.php @@ -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); diff --git a/mod/quiz/view.php b/mod/quiz/view.php index afb5ce9987..25dc6dc453 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -101,7 +101,7 @@ echo "

".get_string("attemptsallowed", "quiz").": $quiz->attempts

"; } if ($quiz->attempts != 1) { - echo "

".get_string("grademethod", "quiz").": ".$QUIZ_GRADE_METHOD[$quiz->grademethod]."

"; + echo "

".get_string("grademethod", "quiz").": ".quiz_get_grading_option_name($quiz->grademethod)."

"; } // Print information about timings. @@ -299,7 +299,7 @@ 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)); -- 2.39.5