Merge branch 'master_MDL-28542'
authorPetr Skoda <commits@skodak.org>
Tue, 2 Aug 2011 12:30:20 +0000 (14:30 +0200)
committerPetr Skoda <commits@skodak.org>
Tue, 2 Aug 2011 12:30:20 +0000 (14:30 +0200)
mod/scorm/locallib.php
mod/scorm/view.php

index 982329f..51248fd 100644 (file)
@@ -678,6 +678,10 @@ function scorm_course_format_display($user, $course) {
         if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
             print_error('invalidcoursemodule');
         }
+        $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
+        if ((has_capability('mod/scorm:skipview', $contextmodule))) {
+            scorm_simple_play($scorm, $user, $contextmodule);
+        }
         $colspan = '';
         $headertext = '<table width="100%"><tr><td class="title">'.get_string('name').': <b>'.format_string($scorm->name).'</b>';
         if (has_capability('moodle/course:manageactivities', $context)) {
@@ -832,12 +836,11 @@ function scorm_simple_play($scorm, $user, $context) {
         }
         if ($scorm->skipview >= 1) {
             $sco = current($scoes);
-            if (scorm_get_tracks($sco->id, $user->id) === false) {
-                header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id.'&currentorg='.$orgidentifier);
-                $result = true;
-            } else if ($scorm->skipview == 2) {
-                header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id.'&currentorg='.$orgidentifier);
-                $result = true;
+            $url = new moodle_url('/mod/scorm/player.php', array('a' => $scorm->id,
+                                                                'currentorg'=>$orgidentifier,
+                                                                'scoid'=>$sco->id));
+            if ($scorm->skipview == 2 || scorm_get_tracks($sco->id, $user->id) === false) {
+                redirect($url);
             }
         }
     }
index 7e6490d..42c5c58 100644 (file)
@@ -71,8 +71,8 @@ $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)) {
-    exit;
+if ((has_capability('mod/scorm:skipview', $contextmodule))) {
+    scorm_simple_play($scorm, $USER, $contextmodule);
 }
 
 //