]> git.mjollnir.org Git - moodle.git/commitdiff
Further changes to tidy up reports
authormoodler <moodler>
Thu, 24 Jul 2003 16:48:10 +0000 (16:48 +0000)
committermoodler <moodler>
Thu, 24 Jul 2003 16:48:10 +0000 (16:48 +0000)
mod/quiz/lib.php
mod/quiz/report.php
mod/quiz/view.php

index 606e56687125d959b590a33f8aa5fde7f6b730ad..ce6c8c5793dcce1ac1d850755e9cc4248d8231e7 100644 (file)
@@ -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);
index 24078a9a0759b4aab63b2d7320ff83472c41f189..753c17dd545531f99950c26c57c5f7a253f9e988 100644 (file)
@@ -73,7 +73,7 @@
             echo "<td><a href=\"report.php?id=$cm->id&mode=$report\">$strreport</a></td>";
         }
     }
-    echo "</tr></table><br /><br />";
+    echo "</tr></table><hr size=\"1\" noshade=\"noshade\" />";
 
 
 /// Open the selected quiz report and display it
index 5494fd6d1052fd5bdd01e2169d58f4a59dcb124a..64ba336a8250e5b47a9e82ca7d5fcdaa9bc0a614 100644 (file)
     }
 
     if ($quiz->attempts > 1) {
-        echo "<P ALIGN=CENTER>".get_string("attemptsallowed", "quiz").": $quiz->attempts</P>";
-        echo "<P ALIGN=CENTER>".get_string("grademethod", "quiz").": ".$QUIZ_GRADE_METHOD[$quiz->grademethod]."</P>";
+        echo "<p align=center>".get_string("attemptsallowed", "quiz").": $quiz->attempts</p>";
+        echo "<p align=center>".get_string("grademethod", "quiz").": ".$QUIZ_GRADE_METHOD[$quiz->grademethod]."</p>";
     } else {
-        echo "<BR>";
+        echo "<br />";
     }
 
     $strattempt       = get_string("attempt", "quiz");