From 309c0d55b2953c75119059e38cb35acbcf0ce797 Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Tue, 18 Apr 2006 22:54:10 +0000 Subject: [PATCH] mod/quiz/view changes to only display attempt grades when teacher allows. 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 | 1 + mod/quiz/view.php | 35 +++++++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lang/en_utf8/quiz.php b/lang/en_utf8/quiz.php index 2c6ff4f82b..ace0559e2b 100644 --- a/lang/en_utf8/quiz.php +++ b/lang/en_utf8/quiz.php @@ -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'; diff --git a/mod/quiz/view.php b/mod/quiz/view.php index daf9969748..868077e17e 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -168,11 +168,21 @@ 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'; @@ -239,13 +249,15 @@ $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 = "$attemptgrade"; } @@ -280,8 +292,17 @@ $attempt->attempt = "#$attempt->attempt"; } } - $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; @@ -297,7 +318,9 @@ 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) { -- 2.39.5