MDL-38489 SCORM: use course_get_format to obtain info
authorDan Marsden <dan@danmarsden.com>
Thu, 29 Aug 2013 02:44:36 +0000 (14:44 +1200)
committerDan Marsden <dan@danmarsden.com>
Sun, 15 Sep 2013 22:17:51 +0000 (10:17 +1200)
mod/scorm/view.js
mod/scorm/view.php

index c170998..9884d0a 100644 (file)
@@ -4,14 +4,12 @@ M.mod_scormform.init = function(Y) {
     var cwidth = scormplayerdata.cwidth;
     var cheight = scormplayerdata.cheight;
     var poptions = scormplayerdata.popupoptions;
-    var courseid = scormplayerdata.courseid;
-    var sectionid = scormplayerdata.sectionid;
     var launch = scormplayerdata.launch;
     var currentorg = scormplayerdata.currentorg;
     var sco = scormplayerdata.sco;
     var scorm = scormplayerdata.scorm;
     var launch_url = M.cfg.wwwroot+"/mod/scorm/player.php?a="+scorm+"&currentorg="+currentorg+"&scoid="+sco+"&sesskey="+M.cfg.sesskey;
-    var course_url = M.cfg.wwwroot+"/course/view.php?id="+courseid+"&sectionid="+sectionid+"&sesskey="+M.cfg.sesskey;
+    var course_url = scormplayerdata.courseurl;
 
     if ((cwidth==100) && (cheight==100)) {
         poptions = poptions+',width='+screen.availWidth+',height='+screen.availHeight+',left=0,top=0';
index d0bb257..24d0364 100644 (file)
@@ -83,26 +83,19 @@ if (!empty($scorm->popup)) {
             $launch = true;
         }
     }
-
     // Redirect back to the section with one section per page ?
-    if (! $coursedisplay = $DB->get_record('course_format_options', array('courseid'=>$scorm->course, 'name'=>'coursedisplay'))) {
-        print_error('courseformatnotfound', 'error', null, 'coursedisplay');
-    }
 
-    if ($coursedisplay->value == COURSE_DISPLAY_MULTIPAGE) {
-        // $cm->section references course_sections(id) NOT course_sections(section).
-        // Better to use this since this takes priority in course view.php.
+    $courseformat = course_get_format($course)->get_course();
+    $sectionid = '';
+    if (isset($courseformat->coursedisplay) && $courseformat->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
         $sectionid = $cm->section;
-    } else {
-        $sectionid = '';
     }
 
     $PAGE->requires->data_for_js('scormplayerdata', Array('launch' => $launch,
                                                            'currentorg' => $orgidentifier,
                                                            'sco' => $scoid,
                                                            'scorm' => $scorm->id,
-                                                           'courseid' => $scorm->course,
-                                                           'sectionid' => $sectionid,
+                                                           'courseurl' => course_get_url($course, $sectionid)->out(false),
                                                            'cwidth' => $scorm->width,
                                                            'cheight' => $scorm->height,
                                                            'popupoptions' => $scorm->options), true);