SCORM MDL-24734 - fix display of grade information on view.php page - also fixes some XHTML in the same function.

This commit is contained in:
Dan Marsden 2011-04-16 19:32:11 +12:00
parent 91787c37e1
commit 4f4a8acf3b

View file

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