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
This commit is contained in:
mjollnir_ 2006-04-18 22:54:10 +00:00
parent f7fccc0362
commit 309c0d55b2
2 changed files with 30 additions and 6 deletions

View 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';

View File

@ -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 = "<span class=\"highlight\">$attemptgrade</span>";
}
@ -280,8 +292,17 @@
$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;
@ -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) {