]> git.mjollnir.org Git - moodle.git/commitdiff
Avoiding warning in last commit:
authormjollnir_ <mjollnir_>
Tue, 18 Apr 2006 22:57:28 +0000 (22:57 +0000)
committermjollnir_ <mjollnir_>
Tue, 18 Apr 2006 22:57:28 +0000 (22:57 +0000)
mod/quiz/index changes to only display quiz grades when teacher allows
Changes to index.php to only allow student to view overall quiz scores when
teacher has not set options forbidding this, and it can't give away what
scores were for attempts where results should still be hidden.
Credit: Peter Bulmer peterbulmer@catalyst.net.nz

mod/quiz/locallib.php

index afd7670858186bee20f655251f21fac59e9f8630..439aa899e2ca1174de0d347fe931e848d207b6ab 100644 (file)
@@ -565,13 +565,14 @@ function all_attempt_results_visible($quiz, $user) {
     $sql = 'SELECT timefinish, preview FROM '.$CFG->prefix.'quiz_attempts qa'.
         ' WHERE qa.quiz='.$quiz->id.' AND qa.userid='.$user->id.
         ' ORDER BY id DESC';
-    $attempts = get_records_sql($sql);
-    foreach ($attempts as $attempt) {            
-        $attemptoptions = quiz_get_reviewoptions($quiz, $attempt);
-        //if any attempt has scores option not set, not all attempt results are
-        //visible
-        if (!$attemptoptions->scores) {
-           return false;
+    if ($attempts = get_records_sql($sql)) {
+        foreach ($attempts as $attempt) {            
+            $attemptoptions = quiz_get_reviewoptions($quiz, $attempt);
+            //if any attempt has scores option not set, not all attempt results are
+            //visible
+            if (!$attemptoptions->scores) {
+                return false;
+            }
         }
     }
     return true;