Merge branch 'master_MDL-28649' of git://github.com/danmarsden/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 16 Aug 2011 22:32:23 +0000 (00:32 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 16 Aug 2011 22:32:23 +0000 (00:32 +0200)
mod/scorm/locallib.php
mod/scorm/view.php

index ea1dda6..b9f2619 100644 (file)
@@ -680,7 +680,7 @@ function scorm_course_format_display($user, $course) {
         }
         $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
         if ((has_capability('mod/scorm:skipview', $contextmodule))) {
-            scorm_simple_play($scorm, $user, $contextmodule);
+            scorm_simple_play($scorm, $user, $contextmodule, $cm->id);
         }
         $colspan = '';
         $headertext = '<table width="100%"><tr><td class="title">'.get_string('name').': <b>'.format_string($scorm->name).'</b>';
@@ -811,7 +811,7 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
     }
 }
 
-function scorm_simple_play($scorm, $user, $context) {
+function scorm_simple_play($scorm, $user, $context, $cmid) {
     global $DB;
 
     $result = false;
@@ -840,6 +840,12 @@ function scorm_simple_play($scorm, $user, $context) {
                                                                 'currentorg'=>$orgidentifier,
                                                                 'scoid'=>$sco->id));
             if ($scorm->skipview == 2 || scorm_get_tracks($sco->id, $user->id) === false) {
+                if (!empty($scorm->forcenewattempt)) {
+                    $result = scorm_get_toc($user, $scorm, $cmid, TOCFULLURL, $orgidentifier);
+                    if ($result->incomplete === false) {
+                        $url->param('newattempt','on');
+                    }
+                }
                 redirect($url);
             }
         }
index 42c5c58..1b536b6 100644 (file)
@@ -72,7 +72,7 @@ $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
 add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id", $cm->id);
 
 if ((has_capability('mod/scorm:skipview', $contextmodule))) {
-    scorm_simple_play($scorm, $USER, $contextmodule);
+    scorm_simple_play($scorm, $USER, $contextmodule, $cm->id);
 }
 
 //