]> git.mjollnir.org Git - moodle.git/commitdiff
mod/quiz/view changes to only display attempt grades when teacher allows.
authormjollnir_ <mjollnir_>
Tue, 18 Apr 2006 22:54:10 +0000 (22:54 +0000)
committermjollnir_ <mjollnir_>
Tue, 18 Apr 2006 22:54:10 +0000 (22:54 +0000)
Changed view.php to only display grades when the teacher has not set
options forbidding it.  Further, where there is some attempts that are
allowed to be displayed, and others not, highligting of the highest score,
and printing of the overall grade allocation has been disabled to ensure
the hidden grade is not revealed.
Credit: Peter Bulmer peterbulmer@catalyst.net.nz

lang/en_utf8/quiz.php
mod/quiz/view.php

index 2c6ff4f82bdfc67d65d0a1cc864699c25d2fb1b8..ace0559e2b14595ca0cab659f1f264b1c620891e 100644 (file)
@@ -490,6 +490,7 @@ $string['validate'] = 'Validate';
 $string['viewallanswers'] = 'View $a quiz attempts';
 $string['viewallreports'] = 'View reports for $a attempts';
 $string['warningsdetected'] = '$a warning(s) detected';
+$string['wheregrade'] = 'Where\'s my grade?';
 $string['webct'] = 'WebCT format';
 $string['wildcard'] = 'Wild card';
 $string['withselected'] = 'With selected';
index daf996974850eb7acfdeddd143ace5a3ee0ec79c..868077e17ee34185c61d7eb2c673801d4872ddb6 100644 (file)
 
     if ($attempts) {
                     
+        $gradecolumn=0;
+        $overallstats=1;
+        //step thru each attempt, checking there are any attempts
+        //for which the score can be displayed (need grade columns),
+        //and checking if overall grades can be displayed - no attempts for 
+        //which the score cannot be displayed
+        foreach ($attempts as $attempt) {            
+            $attemptoptions = quiz_get_reviewoptions($quiz, $attempt, $isteacher);
+            $attemptoptions->scores ? $gradecolumn=1 : $overallstats=0;                    
+        }
     /// prepare table header
         $table->head = array($strattempt, $strtimecompleted);
         $table->align = array("center", "left");
         $table->size = array("", "");
-        if ($quiz->grade and $quiz->sumgrades) { // Grades used so have more columns in table
+        if ($gradecolumn && $quiz->grade and $quiz->sumgrades) { // Grades used so have more columns in table
             if ($quiz->grade <> $quiz->sumgrades) {
                 $table->head[] = "$strmarks / $quiz->sumgrades";
                 $table->align[] = 'right';
                 $datecompleted = $quiz->timeclose ? userdate($quiz->timeclose) : '';
             }
 
+            $attemptoptions = quiz_get_reviewoptions($quiz, $attempt, $isteacher);
         /// prepare strings for attempt number, mark and grade
-            if ($quiz->grade and $quiz->sumgrades) {
+            //if attempt's score is allowed to be viewed, & qz->sumgrades and qz->sumgrades defined:
+            if ($attemptoptions->scores && $quiz->grade and $quiz->sumgrades) {
                 $attemptmark  = round($attempt->sumgrades,$quiz->decimalpoints);
                 $attemptgrade = round(($attempt->sumgrades/$quiz->sumgrades)*$quiz->grade,$quiz->decimalpoints);
 
                 // highlight the highest grade if appropriate
-                if ($attemptgrade == $mygrade and ($quiz->grademethod == QUIZ_GRADEHIGHEST)) {
+                if ($overallstats && $attemptgrade == $mygrade and ($quiz->grademethod == QUIZ_GRADEHIGHEST)) {
                     $attemptgrade = "<span class=\"highlight\">$attemptgrade</span>";
                 }
 
                         $attempt->attempt = "<a href=\"attempt.php?id=$id\">#$attempt->attempt</a>";
                     }
                 }
-                $table->data[] = array( $attempt->attempt,
-                                        $datecompleted);
+
+                $helpbutton=helpbutton('missing\ grade', get_string('wheregrade', 'quiz'), 'quiz', true, false, '',true);
+                if($gradecolumn) {
+                    $table->data[] = array( $attempt->attempt,
+                                            $datecompleted,
+                                            $helpbutton);
+                     
+                } else {
+                    $table->data[] = array( $attempt->attempt,
+                                            $datecompleted);
+                }
             }
             if (isset($quiz->showtimetaken)) {
                 $table->data[] = $timetaken;
           
             if ($available) {
                 $options["id"] = $cm->id;
-                if ($numattempts and $quiz->grade) {
+                //if overall stats are allowed (no attemps' grade not visible),
+                //and there is at least one attempt, and quiz->grade:
+                if ($overallstats and $numattempts and $quiz->grade) {
                     print_heading("$strbestgrade: $mygrade / $quiz->grade.");
                 }
                 if ($quiz->timelimit && !$quiz->attempts) {