Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

SCORM MDL-25781 fix links in TOC on view.php

  • Loading branch information...
commit 08868f58e4e44c05b955db909ab9f40e75812c4e 1 parent 8cdc85a
Dan Marsden authored January 28, 2011
22  mod/scorm/datamodels/aicclib.php
@@ -330,7 +330,7 @@ function scorm_parse_aicc($scorm) {
330 330
     return true;
331 331
 }
332 332
 
333  
-function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
  333
+function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
334 334
     global $CFG, $DB, $PAGE, $OUTPUT;
335 335
 
336 336
     $strexpand = get_string('expcoll','scorm');
@@ -515,17 +515,19 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
515 515
                         if ($sco->id == $scoid) {
516 516
                             $result->prerequisites = true;
517 517
                         }
518  
-                        $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr.'&scoid='.$sco->id;
  518
+
519 519
                         $thisscoidstr = '&scoid='.$sco->id;
520  
-                        //$link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr;
521 520
                         $link = 'a='.$scorm->id.$thisscoidstr.'&currentorg='.$currentorg.$modestr.'&attempt='.$attempt;
522  
-                        //$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
523  
-                        //$result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
524  
-                        if ($sco->launch) {
525  
-                            $result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
526  
-                        }
527  
-                        else {
528  
-                            $result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
  521
+
  522
+                        if ($toclink == TOCFULLURL) { //display toc with urls for structure page
  523
+                            $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
  524
+                            $result->toc .= $statusicon.'&nbsp;<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score."\n";
  525
+                        } else {
  526
+                            if ($sco->launch) {
  527
+                                $result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
  528
+                            } else {
  529
+                                $result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
  530
+                            }
529 531
                         }
530 532
                         $tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
531 533
                     } else {
20  mod/scorm/datamodels/scorm_12lib.php
@@ -106,7 +106,7 @@ function scorm_eval_prerequisites($prerequisites, $usertracks) {
106 106
     return eval('return '.implode($stack).';');
107 107
 }
108 108
 
109  
-function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
  109
+function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
110 110
     global $CFG, $DB, $PAGE, $OUTPUT;
111 111
 
112 112
     $strexpand = get_string('expcoll','scorm');
@@ -293,18 +293,18 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
293 293
                         if ($sco->id == $scoid) {
294 294
                             $result->prerequisites = true;
295 295
                         }
296  
-                       // $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
297 296
                         $thisscoidstr = '&scoid='.$sco->id;
298  
-                        //$link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr;
299 297
                         $link = 'a='.$scorm->id.$thisscoidstr.'&currentorg='.$currentorg.$modestr.'&attempt='.$attempt;
300 298
 
301  
-                        //$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."\n";
302  
-                        //$result->toc .= $startbold.'<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>'.$endbold."\n";
303  
-                        if ($sco->launch) {
304  
-                            $result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
305  
-                        }
306  
-                        else {
307  
-                            $result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
  299
+                        if ($toclink == TOCFULLURL) { //display toc with urls for structure page
  300
+                            $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
  301
+                            $result->toc .= $statusicon.'&nbsp;<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score."\n";
  302
+                        } else { //display toc for inside scorm player
  303
+                            if ($sco->launch) {
  304
+                                $result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
  305
+                            } else {
  306
+                                $result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
  307
+                            }
308 308
                         }
309 309
                         $tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
310 310
                     } else {
18  mod/scorm/datamodels/scorm_13lib.php
... ...
@@ -1,6 +1,6 @@
1 1
 <?php
2 2
 
3  
-function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
  3
+function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
4 4
     global $CFG, $DB, $PAGE, $OUTPUT;
5 5
 
6 6
     $strexpand = get_string('expcoll','scorm');
@@ -185,19 +185,19 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
185 185
                         if ($sco->id == $scoid) {
186 186
                             $result->prerequisites = true;
187 187
                         }
  188
+
  189
+                        if ($toclink == TOCFULLURL) { //display toc with urls for structure page
188 190
                             $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
189  
-                            $thisscoidstr = '&scoid='.$sco->id;
190  
-                            //$link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr;
191  
-                            $link = 'a='.$scorm->id.$thisscoidstr.'&currentorg='.$currentorg.$modestr.'&attempt='.$attempt;
192  
-                            //$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
193  
-                            //$result->toc .= '<li><a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>'."</li>\n";
  191
+                            $result->toc .= $statusicon.'&nbsp;<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score."\n";
  192
+                        } else {
194 193
                             if ($sco->launch) {
  194
+                                $link = 'a='.$scorm->id.'&scoid='.$sco->id.'&currentorg='.$currentorg.$modestr.'&attempt='.$attempt;
195 195
                                 $result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
196  
-                            }
197  
-                            else {
  196
+                            } else {
198 197
                                 $result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
199 198
                             }
200  
-                            $tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
  199
+                        }
  200
+                        $tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
201 201
                     } else {
202 202
                         if ($sco->id == $scoid) {
203 203
                             $result->prerequisites = false;
5  mod/scorm/locallib.php
@@ -23,6 +23,9 @@
23 23
 define('FIRSTATTEMPT', '2');
24 24
 define('LASTATTEMPT', '3');
25 25
 
  26
+define('TOCJSLINK', 1);
  27
+define('TOCFULLURL', 2);
  28
+
26 29
 /// Local Library of functions for module scorm
27 30
 
28 31
 /**
@@ -759,7 +762,7 @@ function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') {
759 762
     }
760 763
     require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
761 764
 
762  
-    $result = scorm_get_toc($user,$scorm,'structlist',$orgidentifier);
  765
+    $result = scorm_get_toc($user,$scorm,TOCFULLURL,$orgidentifier);
763 766
     $incomplete = $result->incomplete;
764 767
 
765 768
     // do we want the TOC to be displayed?
2  mod/scorm/player.php
@@ -106,7 +106,7 @@
106 106
     }
107 107
     $attemptstr = '&amp;attempt=' . $attempt;
108 108
 
109  
-    $result = scorm_get_toc($USER, $scorm, 'structurelist', $currentorg, $scoid, $mode, $attempt, true, true);
  109
+    $result = scorm_get_toc($USER, $scorm, TOCJSLINK, $currentorg, $scoid, $mode, $attempt, true, true);
110 110
     $sco = $result->sco;
111 111
 
112 112
     if (($mode == 'browse') && ($scorm->hidebrowse == 1)) {
2  mod/scorm/prereqs.php
@@ -52,7 +52,7 @@
52 52
         $result = true;
53 53
         $request = null;
54 54
         if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE,$cm->id))) {
55  
-            $result = scorm_get_toc($USER,$scorm,'structurelist',$currentorg,$scoid,$mode,$attempt,true, false);
  55
+            $result = scorm_get_toc($USER,$scorm,TOCJSLINK,$currentorg,$scoid,$mode,$attempt,true, false);
56 56
             echo $result->toc;
57 57
         }
58 58
     }

0 notes on commit 08868f5

Please sign in to comment.
Something went wrong with that request. Please try again.