diff --git a/mod/scorm/datamodels/aicc.js.php b/mod/scorm/datamodels/aicc.js.php index 01f37e5adbf..c32789869b5 100644 --- a/mod/scorm/datamodels/aicc.js.php +++ b/mod/scorm/datamodels/aicc.js.php @@ -201,6 +201,65 @@ function AICCapi() { return "false"; } + + this.connectPrereqCallback = { + + success: function(o) { + scorm_tree_node = YAHOO.widget.TreeView.getTree('scorm_tree'); + if (o.responseText !== undefined) { + if (scorm_tree_node && o.responseText) { + var hnode = scorm_tree_node.getHighlightedNode(); + var hidx = null; + if (hnode) { + hidx = hnode.index + scorm_tree_node.getNodeCount(); + } + // all gone + var root_node = scorm_tree_node.getRoot(); + scorm_tree_node.removeNode(root_node.children[0]); + } + // make sure the temporary tree element is not there + var el_old_tree = document.getElementById('scormtree123'); + if (el_old_tree) { + el_old_tree.parentNode.removeChild(el_old_tree); + } + var el_new_tree = document.createElement('div'); + var pagecontent = document.getElementById("page-content"); + el_new_tree.setAttribute('id','scormtree123'); + el_new_tree.innerHTML = o.responseText; + // make sure it doesnt show + el_new_tree.style.display = 'none'; + pagecontent.appendChild(el_new_tree) + // ignore the first level element as this is the title + scorm_tree_node.buildTreeFromMarkup(el_new_tree.firstChild.firstChild); + var el = document.getElementById('scormtree123'); + el.parentNode.removeChild(el); + scorm_tree_node.expandAll(); + scorm_tree_node.render(); + if (hidx != null) { + hnode = scorm_tree_node.getNodeByIndex(hidx); + if (hnode) { + hnode.highlight(); + scorm_layout_widget = YAHOO.widget.Layout.getLayoutById('scorm_layout'); + var left = scorm_layout_widget.getUnitByPosition('left'); + if (left.expanded) { + hnode.focus(); + } + } + } + } + }, + + failure: function(o) { + // do some sort of error handling + var sURL = "wwwroot; ?>" + "/mod/scorm/prereqs.php?a=id ?>&scoid=&attempt=&mode=¤torg=&sesskey="; + //TODO: Enable this error handing correctly - avoiding issues when closing player MDL-23470 + //alert('Prerequisites update failed - must restart SCORM player'); + //window.location.href = sURL; + } + + }; + + function LMSFinish (param) { errorCode = "0"; if (param == "") { @@ -218,6 +277,9 @@ function AICCapi() { setTimeout('top.nextSCO();',500); } } + // trigger TOC update + var sURL = "wwwroot; ?>" + "/mod/scorm/prereqs.php?a=id ?>&scoid=&attempt=&mode=¤torg=&sesskey="; + YAHOO.util.Connect.asyncRequest('GET', sURL, this.connectPrereqCallback, null); return "true"; } else { errorCode = "301"; diff --git a/mod/scorm/datamodels/aicclib.php b/mod/scorm/datamodels/aicclib.php index 1f8e02fcae0..36eb22b185b 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) { +function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) { global $CFG, $DB, $PAGE, $OUTPUT; $strexpand = get_string('expcoll','scorm'); @@ -341,9 +341,12 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n $result = new stdClass(); //$result->toc = "\n"; + $closelist .= "\t\t\n"; $i--; } if (($i == 0) && ($sco->parent != $currentorg)) { @@ -516,13 +519,28 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n $thisscoidstr = '&scoid='.$sco->id; $link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr; //$result->toc .= $statusicon.' '.$startbold.''.format_string($sco->title).''.$score.$endbold."\n"; - $result->toc .= ''.$statusicon.' '.format_string($sco->title).' '.$score.''; + //$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).''; + } $tocmenus[$sco->id] = scorm_repeater('−',$level) . '>' . format_string($sco->title); } else { if ($sco->id == $scoid) { $result->prerequisites = false; } - $result->toc .= $statusicon.' '.format_string($sco->title)."\n"; + if ($play) { + // should be disabled + $result->toc .= ''.$statusicon.' '.format_string($sco->title).''; + } + else { + $result->toc .= $statusicon.' '.format_string($sco->title)."\n"; + } + } + if (($nextsco === false) || $nextsco->parent == $sco->parent) { + $result->toc .= ''; } } } else { @@ -548,12 +566,13 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n $result->incomplete = $incomplete; } } - //$result->toc .= "\t\n"; + $result->toc .= ''; // NEW IMS TOC - $result->toc .= ''; - $result->toc .= ''; - $result->toc .= '
'; + if ($tocheader) { + $result->toc .= ''; + $result->toc .= '
'; + } if ($scorm->hidetoc == 0) { diff --git a/mod/scorm/datamodels/scorm_12.js.php b/mod/scorm/datamodels/scorm_12.js.php index 92408c57797..153beb5929c 100644 --- a/mod/scorm/datamodels/scorm_12.js.php +++ b/mod/scorm/datamodels/scorm_12.js.php @@ -249,8 +249,6 @@ function SCORMapi1_2() { if (Initialized) { Initialized = false; result = StoreData(cmi,true); - // trigger TOC update - //alert('trigger TOC update'); if (nav.event != '') { if (nav.event == 'continue') { setTimeout('top.document.location=top.next;',500); @@ -276,6 +274,7 @@ function SCORMapi1_2() { echo 'LogAPICall("LMSFinish", param, "", 0);'; } ?> + // trigger TOC update var sURL = "wwwroot; ?>" + "/mod/scorm/prereqs.php?a=id ?>&scoid=&attempt=&mode=¤torg=&sesskey="; YAHOO.util.Connect.asyncRequest('GET', sURL, this.connectPrereqCallback, null); return result; diff --git a/mod/scorm/datamodels/scorm_12lib.php b/mod/scorm/datamodels/scorm_12lib.php index 5603c05884b..6e05b754299 100644 --- a/mod/scorm/datamodels/scorm_12lib.php +++ b/mod/scorm/datamodels/scorm_12lib.php @@ -322,7 +322,7 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n } } if (($nextsco === false) || $nextsco->parent == $sco->parent) { - $result->toc .= ''; + $result->toc .= ''; } } } else { diff --git a/mod/scorm/module.js b/mod/scorm/module.js index 1da89a45e01..8e59bebeb79 100644 --- a/mod/scorm/module.js +++ b/mod/scorm/module.js @@ -49,6 +49,7 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, windo Y.use('yui2-resize', 'yui2-dragdrop', 'yui2-container', 'yui2-button', 'yui2-layout', 'yui2-treeview', 'yui2-json', 'yui2-event', function(Y) { + var scorm_activate_item = function(node) { if (!node) { return; diff --git a/mod/scorm/player.php b/mod/scorm/player.php index 1f77ab21dbe..0ecc8eef3aa 100755 --- a/mod/scorm/player.php +++ b/mod/scorm/player.php @@ -104,7 +104,7 @@ } $attemptstr = '&attempt=' . $attempt; - $result = scorm_get_toc($USER,$scorm,'structurelist',$currentorg,$scoid,$mode,$attempt,true); + $result = scorm_get_toc($USER, $scorm, 'structurelist', $currentorg, $scoid, $mode, $attempt, true, true); $sco = $result->sco; if (($mode == 'browse') && ($scorm->hidebrowse == 1)) {