From 7ce6eb873d50494b703e9cd6d0277b11c921bb1a Mon Sep 17 00:00:00 2001 From: piers Date: Fri, 22 Aug 2008 01:30:28 +0000 Subject: [PATCH] MDL-16111 - SCORM grade not updated in Grader Report. Make sure that lastattempt does not exceed maxattempts. --- mod/scorm/locallib.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index 035b670d9e..a2b89bfd2a 100755 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -336,6 +336,9 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1, $time=false) { return NULL; } + // this treatment is necessary as the whatgrade field was not in the DB + // and so whatgrade and grademethod are combined in grademethod 10s are whatgrade + // and 1s are grademethod $grademethod = $scorm->grademethod % 10; foreach ($scoes as $sco) { @@ -388,9 +391,17 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1, $time=false) { } function scorm_grade_user($scorm, $userid, $time=false) { - + // this treatment is necessary as the whatgrade field was not in the DB + // and so whatgrade and grademethod are combined in grademethod 10s are whatgrade + // and 1s are grademethod $whatgrade = intval($scorm->grademethod / 10); + // insure we dont grade user beyond $scorm->maxattempt settings + $lastattempt = scorm_get_last_attempt($scorm->id, $userid); + if($scorm->maxattempt != 0 && $lastattempt >= $scorm->maxattempt){ + $lastattempt = $scorm->maxattempt; + } + switch ($whatgrade) { case FIRSTATTEMPT: return scorm_grade_user_attempt($scorm, $userid, 1, $time); @@ -399,7 +410,6 @@ function scorm_grade_user($scorm, $userid, $time=false) { return scorm_grade_user_attempt($scorm, $userid, scorm_get_last_attempt($scorm->id, $userid), $time); break; case HIGHESTATTEMPT: - $lastattempt = scorm_get_last_attempt($scorm->id, $userid); $maxscore = 0; $attempttime = 0; for ($attempt = 1; $attempt <= $lastattempt; $attempt++) { -- 2.39.5