MDL-22951 - implement the datamodel, and prereq handling for AICC.

This commit is contained in:
Piers Harding
2010-07-23 18:20:04 +00:00
parent 4a15bb7660
commit eea0c8eaa7
6 changed files with 97 additions and 16 deletions
+62
View File
@@ -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 = "<?php echo $CFG->wwwroot; ?>" + "/mod/scorm/prereqs.php?a=<?php echo $scorm->id ?>&scoid=<?php echo $scoid ?>&attempt=<?php echo $attempt ?>&mode=<?php echo $mode ?>&currentorg=<?php echo $currentorg ?>&sesskey=<?php echo 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 = "<?php echo $CFG->wwwroot; ?>" + "/mod/scorm/prereqs.php?a=<?php echo $scorm->id ?>&scoid=<?php echo $scoid ?>&attempt=<?php echo $attempt ?>&mode=<?php echo $mode ?>&currentorg=<?php echo $currentorg ?>&sesskey=<?php echo sesskey(); ?>";
YAHOO.util.Connect.asyncRequest('GET', sURL, this.connectPrereqCallback, null);
return "true";
} else {
errorCode = "301";
+31 -12
View File
@@ -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 = "<ul id='s0' class='$liststyle'>\n";
$result->toc = '<div id="scorm_layout">';
$result->toc .= '<div id="scorm_toc">';
$result->toc .= '<div id="scorm_tree"><ul>';
if ($tocheader) {
$result->toc = '<div id="scorm_layout">';
$result->toc .= '<div id="scorm_toc">';
$result->toc .= '<div id="scorm_tree">';
}
$result->toc .= '<ul>';
$tocmenus = array();
$result->prerequisites = true;
$incomplete = false;
@@ -404,14 +407,14 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
if ($parents[$level]!=$sco->parent) {
if ($newlevel = array_search($sco->parent,$parents)) {
for ($i=0; $i<($level-$newlevel); $i++) {
$result->toc .= "\t\t</ul></li>\n";
$result->toc .= "\t\t</li></ul></li>\n";
}
$level = $newlevel;
} else {
$i = $level;
$closelist = '';
while (($i > 0) && ($parents[$level] != $sco->parent)) {
$closelist .= "\t\t</ul></li>\n";
$closelist .= "\t\t</li></ul></li>\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.'&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>';
//$result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
if ($sco->launch) {
$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);
} else {
if ($sco->id == $scoid) {
$result->prerequisites = false;
}
$result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."</li>\n";
if ($play) {
// should be disabled
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
}
else {
$result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n";
}
}
if (($nextsco === false) || $nextsco->parent == $sco->parent) {
$result->toc .= '</li>';
}
}
} else {
@@ -548,12 +566,13 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
$result->incomplete = $incomplete;
}
}
//$result->toc .= "\t</ul>\n";
$result->toc .= '</ul>';
// NEW IMS TOC
$result->toc .= '</ul></div></div>';
$result->toc .= '</div>';
$result->toc .= '<div id="scorm_navpanel"></div>';
if ($tocheader) {
$result->toc .= '</div></div></div>';
$result->toc .= '<div id="scorm_navpanel"></div>';
}
if ($scorm->hidetoc == 0) {
+1 -2
View File
@@ -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 = "<?php echo $CFG->wwwroot; ?>" + "/mod/scorm/prereqs.php?a=<?php echo $scorm->id ?>&scoid=<?php echo $scoid ?>&attempt=<?php echo $attempt ?>&mode=<?php echo $mode ?>&currentorg=<?php echo $currentorg ?>&sesskey=<?php echo sesskey(); ?>";
YAHOO.util.Connect.asyncRequest('GET', sURL, this.connectPrereqCallback, null);
return result;
+1 -1
View File
@@ -322,7 +322,7 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
}
}
if (($nextsco === false) || $nextsco->parent == $sco->parent) {
$result->toc .= '</li>';
$result->toc .= '</li>';
}
}
} else {
+1
View File
@@ -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;
+1 -1
View File
@@ -104,7 +104,7 @@
}
$attemptstr = '&amp;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)) {