From 649e176ed669f95969ef560cb26fe77ba085833f Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Thu, 29 Apr 2010 09:18:32 +0000 Subject: [PATCH] SCORM MDL-22046 - show last completed attempt in gradebook - thanks to Bruce Cota for the report/fix merged from HEAD --- mod/scorm/locallib.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index eaecf5f544c..b80c3245263 100755 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -510,7 +510,7 @@ function scorm_grade_user($scorm, $userid, $time=false) { return scorm_grade_user_attempt($scorm, $userid, 1, $time); break; case LASTATTEMPT: - return scorm_grade_user_attempt($scorm, $userid, scorm_get_last_attempt($scorm->id, $userid), $time); + return scorm_grade_user_attempt($scorm, $userid, scorm_get_last_completed_attempt($scorm->id, $userid), $time); break; case HIGHESTATTEMPT: $maxscore = 0; @@ -584,6 +584,17 @@ function scorm_get_last_attempt($scormid, $userid) { } } +function scorm_get_last_completed_attempt($scormid, $userid) { +/// Find the last attempt number for the given user id and scorm id + if ($lastattempt = get_record('scorm_scoes_track', 'userid', $userid, 'scormid', $scormid, 'value', 'completed', 'max(attempt) as a')) { + if (empty($lastattempt->a)) { + return '1'; + } else { + return $lastattempt->a; + } + } +} + function scorm_course_format_display($user,$course) { global $CFG;