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

This commit is contained in:
Dan Marsden 2011-01-28 22:38:08 +13:00
parent 8cdc85ac62
commit 7cc7cf58f5
6 changed files with 37 additions and 32 deletions

View file

@ -330,7 +330,7 @@ function scorm_parse_aicc($scorm) {
return true; 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; global $CFG, $DB, $PAGE, $OUTPUT;
$strexpand = get_string('expcoll','scorm'); $strexpand = get_string('expcoll','scorm');
@ -515,17 +515,19 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
if ($sco->id == $scoid) { if ($sco->id == $scoid) {
$result->prerequisites = true; $result->prerequisites = true;
} }
$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr.'&scoid='.$sco->id;
$thisscoidstr = '&scoid='.$sco->id; $thisscoidstr = '&scoid='.$sco->id;
//$link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr;
$link = 'a='.$scorm->id.$thisscoidstr.'&currentorg='.$currentorg.$modestr.'&attempt='.$attempt; $link = 'a='.$scorm->id.$thisscoidstr.'&currentorg='.$currentorg.$modestr.'&attempt='.$attempt;
//$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
//$result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>'; if ($toclink == TOCFULLURL) { //display toc with urls for structure page
if ($sco->launch) { $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
$result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>'; $result->toc .= $statusicon.'&nbsp;<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score."\n";
} } else {
else { if ($sco->launch) {
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>'; $result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
} else {
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
}
} }
$tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title); $tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
} else { } else {

View file

@ -106,7 +106,7 @@ function scorm_eval_prerequisites($prerequisites, $usertracks) {
return eval('return '.implode($stack).';'); 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; global $CFG, $DB, $PAGE, $OUTPUT;
$strexpand = get_string('expcoll','scorm'); $strexpand = get_string('expcoll','scorm');
@ -293,18 +293,18 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
if ($sco->id == $scoid) { if ($sco->id == $scoid) {
$result->prerequisites = true; $result->prerequisites = true;
} }
// $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
$thisscoidstr = '&scoid='.$sco->id; $thisscoidstr = '&scoid='.$sco->id;
//$link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr;
$link = 'a='.$scorm->id.$thisscoidstr.'&currentorg='.$currentorg.$modestr.'&attempt='.$attempt; $link = 'a='.$scorm->id.$thisscoidstr.'&currentorg='.$currentorg.$modestr.'&attempt='.$attempt;
//$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."\n"; if ($toclink == TOCFULLURL) { //display toc with urls for structure page
//$result->toc .= $startbold.'<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>'.$endbold."\n"; $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
if ($sco->launch) { $result->toc .= $statusicon.'&nbsp;<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score."\n";
$result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>'; } else { //display toc for inside scorm player
} if ($sco->launch) {
else { $result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>'; } else {
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
}
} }
$tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title); $tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
} else { } else {

View file

@ -1,6 +1,6 @@
<?php <?php
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; global $CFG, $DB, $PAGE, $OUTPUT;
$strexpand = get_string('expcoll','scorm'); $strexpand = get_string('expcoll','scorm');
@ -185,19 +185,19 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
if ($sco->id == $scoid) { if ($sco->id == $scoid) {
$result->prerequisites = true; $result->prerequisites = true;
} }
if ($toclink == TOCFULLURL) { //display toc with urls for structure page
$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id; $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
$thisscoidstr = '&scoid='.$sco->id; $result->toc .= $statusicon.'&nbsp;<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score."\n";
//$link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr; } else {
$link = 'a='.$scorm->id.$thisscoidstr.'&currentorg='.$currentorg.$modestr.'&attempt='.$attempt;
//$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
//$result->toc .= '<li><a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>'."</li>\n";
if ($sco->launch) { if ($sco->launch) {
$link = 'a='.$scorm->id.'&scoid='.$sco->id.'&currentorg='.$currentorg.$modestr.'&attempt='.$attempt;
$result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>'; $result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
} } else {
else {
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>'; $result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
} }
$tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title); }
$tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
} else { } else {
if ($sco->id == $scoid) { if ($sco->id == $scoid) {
$result->prerequisites = false; $result->prerequisites = false;

View file

@ -23,6 +23,9 @@ define('AVERAGEATTEMPT', '1');
define('FIRSTATTEMPT', '2'); define('FIRSTATTEMPT', '2');
define('LASTATTEMPT', '3'); define('LASTATTEMPT', '3');
define('TOCJSLINK', 1);
define('TOCFULLURL', 2);
/// Local Library of functions for module scorm /// 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'); 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; $incomplete = $result->incomplete;
// do we want the TOC to be displayed? // do we want the TOC to be displayed?

View file

@ -106,7 +106,7 @@
} }
$attemptstr = '&amp;attempt=' . $attempt; $attemptstr = '&amp;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; $sco = $result->sco;
if (($mode == 'browse') && ($scorm->hidebrowse == 1)) { if (($mode == 'browse') && ($scorm->hidebrowse == 1)) {

View file

@ -52,7 +52,7 @@
$result = true; $result = true;
$request = null; $request = null;
if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE,$cm->id))) { 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; echo $result->toc;
} }
} }