From: moodler Date: Thu, 24 Jul 2003 16:48:10 +0000 (+0000) Subject: Further changes to tidy up reports X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=40b1a221625a92fdaf8d21e94ff988aa55a13208;p=moodle.git Further changes to tidy up reports --- diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 606e566871..ce6c8c5793 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -285,7 +285,7 @@ function quiz_get_answers($question) { case MATCH: return get_records("quiz_match_sub", "question", $question->id); - break; + break; case RANDOMSAMATCH: // Could be any of many answers, return them all return get_records_sql("SELECT a.* @@ -1323,6 +1323,38 @@ function quiz_calculate_best_grade($quiz, $attempts) { } +function quiz_calculate_best_attempt($quiz, $attempts) { +/// Return the attempt with the best grade for a quiz + + switch ($quiz->grademethod) { + + case ATTEMPTFIRST: + foreach ($attempts as $attempt) { + return $attempt; + } + break; + + case GRADEAVERAGE: // need to do something with it :-) + case ATTEMPTLAST: + foreach ($attempts as $attempt) { + $final = $attempt; + } + return $final; + + default: + case GRADEHIGHEST: + $max = -1; + foreach ($attempts as $attempt) { + if ($attempt->sumgrades > $max) { + $max = $attempt->sumgrades; + $maxattempt = $attempt; + } + } + return $maxattempt; + } +} + + function quiz_save_attempt($quiz, $questions, $result, $attemptnum) { /// Given a quiz, a list of attempted questions and a total grade /// this function saves EVERYTHING so it can be reconstructed later @@ -1988,7 +2020,9 @@ function quiz_save_question_options($question) { function quiz_remove_unwanted_questions(&$questions, $quiz) { -/// Used by review.php +/// Given an array of questions, and a list of question IDs, +/// this function removes unwanted questions from the array +/// Used by review.php to counter changing quizzes $quizquestions = array(); $quizids = explode(",", $quiz->questions); diff --git a/mod/quiz/report.php b/mod/quiz/report.php index 24078a9a07..753c17dd54 100644 --- a/mod/quiz/report.php +++ b/mod/quiz/report.php @@ -73,7 +73,7 @@ echo "id&mode=$report\">$strreport"; } } - echo "

"; + echo "
"; /// Open the selected quiz report and display it diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 5494fd6d10..64ba336a82 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -86,10 +86,10 @@ } if ($quiz->attempts > 1) { - echo "

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

"; - echo "

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

"; + echo "

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

"; + echo "

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

"; } else { - echo "
"; + echo "
"; } $strattempt = get_string("attempt", "quiz");