Skip to content

Commit

Permalink
MDL-9519 - incorrectuse of language strings in quiz.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhunt committed Aug 6, 2007
1 parent caa413e commit 1221d87
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mod/quiz/config.html
Expand Up @@ -224,7 +224,7 @@
<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>
Expand Down
24 changes: 20 additions & 4 deletions mod/quiz/locallib.php
Expand Up @@ -33,10 +33,6 @@
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"));
/**#@-*/


Expand Down Expand Up @@ -533,6 +529,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 ////////////////////////////////////////////////////

Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/mod_form.php
Expand Up @@ -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;

//-------------------------------------------------------------------------------
Expand Down Expand Up @@ -117,7 +117,7 @@ function definition() {

//-------------------------------------------------------------------------------
$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);
Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/view.php
Expand Up @@ -97,7 +97,7 @@
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.
Expand Down Expand Up @@ -289,7 +289,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));
Expand Down

0 comments on commit 1221d87

Please sign in to comment.