From: piers Date: Fri, 22 Aug 2008 01:30:28 +0000 (+0000) Subject: MDL-16111 - SCORM grade not updated in Grader Report. Make sure that lastattempt... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7ce6eb873d50494b703e9cd6d0277b11c921bb1a;p=moodle.git MDL-16111 - SCORM grade not updated in Grader Report. Make sure that lastattempt does not exceed maxattempts. --- 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++) {