MDL-34231 SCORM: calculate correct number of attemptsleft when entering an attempt.
authorDan Marsden <dan@danmarsden.com>
Wed, 30 Jan 2013 21:45:11 +0000 (10:45 +1300)
committerDan Marsden <dan@danmarsden.com>
Wed, 30 Jan 2013 21:45:11 +0000 (10:45 +1300)
mod/scorm/locallib.php

index 648c62b..2fb5dcd 100644 (file)
@@ -1580,7 +1580,8 @@ function scorm_format_toc_for_treeview($user, $scorm, $scoes, $usertracks, $cmid
     $result->incomplete = true;
 
     if (!$children) {
-        $result->attemptleft = $scorm->maxattempt == 0 ? 1 : $scorm->maxattempt - $attempt;
+        $attemptsmade = scorm_get_attempt_count($user->id, $scorm);
+        $result->attemptleft = $scorm->maxattempt == 0 ? 1 : $scorm->maxattempt - $attemptsmade;
     }
 
     if (!$children) {