From 4f4a8acf3bcd49190945c4fbc87f4d3411c1e181 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Sat, 16 Apr 2011 19:32:11 +1200 Subject: [PATCH] SCORM MDL-24734 - fix display of grade information on view.php page - also fixes some XHTML in the same function. --- mod/scorm/locallib.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index 56f3d3567a7..525c4ddfa84 100644 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -1009,11 +1009,11 @@ function scorm_get_attempt_status($user, $scorm) { $result = '

'.get_string('noattemptsallowed', 'scorm').': '; if ($scorm->maxattempt > 0) { - $result .= $scorm->maxattempt . '
'; + $result .= $scorm->maxattempt . '
'; } else { - $result .= get_string('unlimited').'
'; + $result .= get_string('unlimited').'
'; } - $result .= get_string('noattemptsmade', 'scorm').': ' . $attemptcount . '
'; + $result .= get_string('noattemptsmade', 'scorm').': ' . $attemptcount . '
'; if ($scorm->maxattempt == 1) { switch ($scorm->grademethod) { @@ -1051,16 +1051,24 @@ function scorm_get_attempt_status($user, $scorm) { $i = 1; foreach($attempts as $attempt) { $gradereported = scorm_grade_user_attempt($scorm, $user->id, $attempt->attemptnumber); - $result .= get_string('gradeforattempt', 'scorm').' ' . $i . ': ' . $gradereported .'%
'; + if ($scorm->grademethod !== GRADESCOES && !empty($scorm->maxgrade)) { + $gradereported = $gradereported/$scorm->maxgrade; + $gradereported = number_format($gradereported*100, 0) .'%'; + } + $result .= get_string('gradeforattempt', 'scorm').' ' . $i . ': ' . $gradereported .'
'; $i++; } } $calculatedgrade = scorm_grade_user($scorm, $user->id); + if ($scorm->grademethod !== GRADESCOES && !empty($scorm->maxgrade)) { + $calculatedgrade = $calculatedgrade/$scorm->maxgrade; + $calculatedgrade = number_format($calculatedgrade*100, 0) .'%'; + } $result .= get_string('grademethod', 'scorm'). ': ' . $grademethod; if(empty($attempts)) { - $result .= '
' . get_string('gradereported','scorm') . ': ' . get_string('none') . '
'; + $result .= '
' . get_string('gradereported','scorm') . ': ' . get_string('none') . '
'; } else { - $result .= '
' . get_string('gradereported','scorm') . ': ' . $calculatedgrade . ($scorm->grademethod == GRADESCOES ? '' : '%') .'
'; + $result .= '
' . get_string('gradereported','scorm') . ': ' . $calculatedgrade . '
'; } $result .= '

'; if ($attemptcount >= $scorm->maxattempt and $scorm->maxattempt > 0) {