SCORM MDL-24731 - close table correctly
[moodle.git] / mod / scorm / datamodels / callback.js.php
CommitLineData
e62c1d22
PH
1
2 this.connectPrereqCallback = {
3
4 success: function(o) {
5 scorm_tree_node = YAHOO.widget.TreeView.getTree('scorm_tree');
6 if (o.responseText !== undefined) {
07b5ee31
PH
7 if (scorm_tree_node && o.responseText) {
8 var hnode = scorm_tree_node.getHighlightedNode();
9 var hidx = null;
10 if (hnode) {
11 hidx = hnode.index + scorm_tree_node.getNodeCount();
12 }
13 // all gone
14 var root_node = scorm_tree_node.getRoot();
15 while (root_node.children.length > 0) {
16 scorm_tree_node.removeNode(root_node.children[0]);
17 }
e62c1d22
PH
18 }
19 // make sure the temporary tree element is not there
20 var el_old_tree = document.getElementById('scormtree123');
21 if (el_old_tree) {
22 el_old_tree.parentNode.removeChild(el_old_tree);
23 }
24 var el_new_tree = document.createElement('div');
25 var pagecontent = document.getElementById("page-content");
26 el_new_tree.setAttribute('id','scormtree123');
27 el_new_tree.innerHTML = o.responseText;
28 // make sure it doesnt show
29 el_new_tree.style.display = 'none';
30 pagecontent.appendChild(el_new_tree)
31 // ignore the first level element as this is the title
32 scorm_tree_node.buildTreeFromMarkup(el_new_tree.firstChild.firstChild);
33 var el = document.getElementById('scormtree123');
34 el.parentNode.removeChild(el);
35 scorm_tree_node.expandAll();
36 scorm_tree_node.render();
37 if (hidx != null) {
38 hnode = scorm_tree_node.getNodeByIndex(hidx);
39 if (hnode) {
40 hnode.highlight();
41 scorm_layout_widget = YAHOO.widget.Layout.getLayoutById('scorm_layout');
42 var left = scorm_layout_widget.getUnitByPosition('left');
43 if (left.expanded) {
44 hnode.focus();
45 }
46 }
47 }
48 }
49 },
50
51 failure: function(o) {
52 // do some sort of error handling
53 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(); ?>";
54 //TODO: Enable this error handing correctly - avoiding issues when closing player MDL-23470
55 //alert('Prerequisites update failed - must restart SCORM player');
56 //window.location.href = sURL;
57 }
58
59 };
60
61