|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00017 ?> 00018 this.connectPrereqCallback = { 00019 00020 success: function(o) { 00021 scorm_tree_node = YAHOO.widget.TreeView.getTree('scorm_tree'); 00022 if (o.responseText !== undefined) { 00023 //alert('got a response: ' + o.responseText); 00024 if (scorm_tree_node && o.responseText) { 00025 var hnode = scorm_tree_node.getHighlightedNode(); 00026 var hidx = null; 00027 if (hnode) { 00028 hidx = hnode.index + scorm_tree_node.getNodeCount(); 00029 } 00030 // all gone 00031 var root_node = scorm_tree_node.getRoot(); 00032 while (root_node.children.length > 0) { 00033 scorm_tree_node.removeNode(root_node.children[0]); 00034 } 00035 } 00036 // make sure the temporary tree element is not there 00037 var el_old_tree = document.getElementById('scormtree123'); 00038 if (el_old_tree) { 00039 el_old_tree.parentNode.removeChild(el_old_tree); 00040 } 00041 var el_new_tree = document.createElement('div'); 00042 var pagecontent = document.getElementById("page-content"); 00043 el_new_tree.setAttribute('id','scormtree123'); 00044 el_new_tree.innerHTML = o.responseText; 00045 // make sure it doesnt show 00046 el_new_tree.style.display = 'none'; 00047 pagecontent.appendChild(el_new_tree) 00048 // ignore the first level element as this is the title 00049 var startNode = el_new_tree.firstChild.firstChild; 00050 if (startNode.tagName == 'LI') { 00051 // go back to the beginning 00052 startNode = el_new_tree; 00053 } 00054 //var sXML = new XMLSerializer().serializeToString(startNode); 00055 scorm_tree_node.buildTreeFromMarkup(startNode); 00056 var el = document.getElementById('scormtree123'); 00057 el.parentNode.removeChild(el); 00058 scorm_tree_node.expandAll(); 00059 scorm_tree_node.render(); 00060 if (hidx != null) { 00061 hnode = scorm_tree_node.getNodeByIndex(hidx); 00062 if (hnode) { 00063 hnode.highlight(); 00064 scorm_layout_widget = YAHOO.widget.Layout.getLayoutById('scorm_layout'); 00065 var left = scorm_layout_widget.getUnitByPosition('left'); 00066 if (left.expanded) { 00067 hnode.focus(); 00068 } 00069 } 00070 } 00071 } 00072 }, 00073 00074 failure: function(o) { 00075 // do some sort of error handling 00076 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 ?>¤torg=<?php echo $currentorg ?>&sesskey=<?php echo sesskey(); ?>"; 00077 //TODO: Enable this error handing correctly - avoiding issues when closing player MDL-23470 00078 //alert('Prerequisites update failed - must restart SCORM player'); 00079 //window.location.href = sURL; 00080 } 00081 00082 }; 00083 00084