From 08868f58e4e44c05b955db909ab9f40e75812c4e Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Fri, 28 Jan 2011 22:38:08 +1300 Subject: [PATCH] SCORM MDL-25781 fix links in TOC on view.php --- mod/scorm/datamodels/aicclib.php | 22 ++++++++++++---------- mod/scorm/datamodels/scorm_12lib.php | 20 ++++++++++---------- mod/scorm/datamodels/scorm_13lib.php | 18 +++++++++--------- mod/scorm/locallib.php | 5 ++++- mod/scorm/player.php | 2 +- mod/scorm/prereqs.php | 2 +- 6 files changed, 37 insertions(+), 32 deletions(-) diff --git a/mod/scorm/datamodels/aicclib.php b/mod/scorm/datamodels/aicclib.php index e5d633e4700..f1cb198acde 100644 --- a/mod/scorm/datamodels/aicclib.php +++ b/mod/scorm/datamodels/aicclib.php @@ -330,7 +330,7 @@ function scorm_parse_aicc($scorm) { return true; } -function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) { +function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) { global $CFG, $DB, $PAGE, $OUTPUT; $strexpand = get_string('expcoll','scorm'); @@ -515,17 +515,19 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n if ($sco->id == $scoid) { $result->prerequisites = true; } - $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr.'&scoid='.$sco->id; + $thisscoidstr = '&scoid='.$sco->id; - //$link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr; $link = 'a='.$scorm->id.$thisscoidstr.'¤torg='.$currentorg.$modestr.'&attempt='.$attempt; - //$result->toc .= $statusicon.' '.$startbold.''.format_string($sco->title).''.$score.$endbold."\n"; - //$result->toc .= ''.$statusicon.' '.format_string($sco->title).' '.$score.''; - if ($sco->launch) { - $result->toc .= ''.$statusicon.' '.format_string($sco->title).' '.$score.''; - } - else { - $result->toc .= ''.$statusicon.' '.format_string($sco->title).''; + + if ($toclink == TOCFULLURL) { //display toc with urls for structure page + $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr.'&scoid='.$sco->id; + $result->toc .= $statusicon.' '.format_string($sco->title).''.$score."\n"; + } else { + if ($sco->launch) { + $result->toc .= ''.$statusicon.' '.format_string($sco->title).' '.$score.''; + } else { + $result->toc .= ''.$statusicon.' '.format_string($sco->title).''; + } } $tocmenus[$sco->id] = scorm_repeater('−',$level) . '>' . format_string($sco->title); } else { diff --git a/mod/scorm/datamodels/scorm_12lib.php b/mod/scorm/datamodels/scorm_12lib.php index 7944f4e55ff..a2bb0323e19 100644 --- a/mod/scorm/datamodels/scorm_12lib.php +++ b/mod/scorm/datamodels/scorm_12lib.php @@ -106,7 +106,7 @@ function scorm_eval_prerequisites($prerequisites, $usertracks) { return eval('return '.implode($stack).';'); } -function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) { +function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) { global $CFG, $DB, $PAGE, $OUTPUT; $strexpand = get_string('expcoll','scorm'); @@ -293,18 +293,18 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n if ($sco->id == $scoid) { $result->prerequisites = true; } - // $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr.'&scoid='.$sco->id; $thisscoidstr = '&scoid='.$sco->id; - //$link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr; $link = 'a='.$scorm->id.$thisscoidstr.'¤torg='.$currentorg.$modestr.'&attempt='.$attempt; - //$result->toc .= $statusicon.' '.$startbold.''.format_string($sco->title).''.$score.$endbold."\n"; - //$result->toc .= $startbold.''.$statusicon.' '.format_string($sco->title).' '.$score.''.$endbold."\n"; - if ($sco->launch) { - $result->toc .= ''.$statusicon.' '.format_string($sco->title).' '.$score.''; - } - else { - $result->toc .= ''.$statusicon.' '.format_string($sco->title).''; + if ($toclink == TOCFULLURL) { //display toc with urls for structure page + $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr.'&scoid='.$sco->id; + $result->toc .= $statusicon.' '.format_string($sco->title).''.$score."\n"; + } else { //display toc for inside scorm player + if ($sco->launch) { + $result->toc .= ''.$statusicon.' '.format_string($sco->title).' '.$score.''; + } else { + $result->toc .= ''.$statusicon.' '.format_string($sco->title).''; + } } $tocmenus[$sco->id] = scorm_repeater('−',$level) . '>' . format_string($sco->title); } else { diff --git a/mod/scorm/datamodels/scorm_13lib.php b/mod/scorm/datamodels/scorm_13lib.php index bf43267de00..cff809de841 100644 --- a/mod/scorm/datamodels/scorm_13lib.php +++ b/mod/scorm/datamodels/scorm_13lib.php @@ -1,6 +1,6 @@ id == $scoid) { $result->prerequisites = true; } + + if ($toclink == TOCFULLURL) { //display toc with urls for structure page $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr.'&scoid='.$sco->id; - $thisscoidstr = '&scoid='.$sco->id; - //$link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr; - $link = 'a='.$scorm->id.$thisscoidstr.'¤torg='.$currentorg.$modestr.'&attempt='.$attempt; - //$result->toc .= $statusicon.' '.$startbold.''.format_string($sco->title).''.$score.$endbold."\n"; - //$result->toc .= '
  • '.$statusicon.' '.format_string($sco->title).' '.$score.''."
  • \n"; + $result->toc .= $statusicon.' '.format_string($sco->title).''.$score."\n"; + } else { if ($sco->launch) { + $link = 'a='.$scorm->id.'&scoid='.$sco->id.'¤torg='.$currentorg.$modestr.'&attempt='.$attempt; $result->toc .= ''.$statusicon.' '.format_string($sco->title).' '.$score.''; - } - else { + } else { $result->toc .= ''.$statusicon.' '.format_string($sco->title).''; } - $tocmenus[$sco->id] = scorm_repeater('−',$level) . '>' . format_string($sco->title); + } + $tocmenus[$sco->id] = scorm_repeater('−',$level) . '>' . format_string($sco->title); } else { if ($sco->id == $scoid) { $result->prerequisites = false; diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index 115f466d6c3..78652e5702e 100755 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -23,6 +23,9 @@ define('AVERAGEATTEMPT', '1'); define('FIRSTATTEMPT', '2'); define('LASTATTEMPT', '3'); +define('TOCJSLINK', 1); +define('TOCFULLURL', 2); + /// Local Library of functions for module scorm /** @@ -759,7 +762,7 @@ function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') { } require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php'); - $result = scorm_get_toc($user,$scorm,'structlist',$orgidentifier); + $result = scorm_get_toc($user,$scorm,TOCFULLURL,$orgidentifier); $incomplete = $result->incomplete; // do we want the TOC to be displayed? diff --git a/mod/scorm/player.php b/mod/scorm/player.php index 3e1e02f437e..e7b97c7ce27 100755 --- a/mod/scorm/player.php +++ b/mod/scorm/player.php @@ -106,7 +106,7 @@ } $attemptstr = '&attempt=' . $attempt; - $result = scorm_get_toc($USER, $scorm, 'structurelist', $currentorg, $scoid, $mode, $attempt, true, true); + $result = scorm_get_toc($USER, $scorm, TOCJSLINK, $currentorg, $scoid, $mode, $attempt, true, true); $sco = $result->sco; if (($mode == 'browse') && ($scorm->hidebrowse == 1)) { diff --git a/mod/scorm/prereqs.php b/mod/scorm/prereqs.php index e1cddd5749a..3c84e6ef7c1 100644 --- a/mod/scorm/prereqs.php +++ b/mod/scorm/prereqs.php @@ -52,7 +52,7 @@ $result = true; $request = null; if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE,$cm->id))) { - $result = scorm_get_toc($USER,$scorm,'structurelist',$currentorg,$scoid,$mode,$attempt,true, false); + $result = scorm_get_toc($USER,$scorm,TOCJSLINK,$currentorg,$scoid,$mode,$attempt,true, false); echo $result->toc; } } -- 2.43.0