mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-22951 - convert 2004 to prereq and datamodel handling.
This commit is contained in:
parent
7d2800fb3c
commit
cac5037719
@ -106,7 +106,7 @@ function scorm_eval_prerequisites($prerequisites, $usertracks) {
|
||||
return eval('return '.implode($stack).';');
|
||||
}
|
||||
|
||||
function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=true) {
|
||||
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');
|
||||
|
@ -296,6 +296,64 @@ function SCORMapi1_3() {
|
||||
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 ?>¤torg=<?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 Terminate (param) {
|
||||
errorCode = "0";
|
||||
if (param == "") {
|
||||
@ -333,6 +391,9 @@ function SCORMapi1_3() {
|
||||
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 ?>¤torg=<?php echo $currentorg ?>&sesskey=<?php echo sesskey(); ?>";
|
||||
YAHOO.util.Connect.asyncRequest('GET', sURL, this.connectPrereqCallback, null);
|
||||
return "true";
|
||||
} else {
|
||||
if (Terminated) {
|
||||
@ -1270,4 +1331,4 @@ if (scorm_debugging($scorm)) {
|
||||
include_once($CFG->dirroot.'/mod/scorm/datamodels/debug.js.php');
|
||||
echo 'AppendToLog("Moodle SCORM 1.3 API Loaded, Activity: '.$scorm->name.', SCO: '.$sco->identifier.'", 0);';
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
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');
|
||||
@ -10,9 +10,12 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
|
||||
}
|
||||
|
||||
$result = new stdClass();
|
||||
$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;
|
||||
@ -70,14 +73,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)) {
|
||||
@ -95,6 +98,9 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
|
||||
$parents[$level]=$sco->parent;
|
||||
}
|
||||
}
|
||||
if ($isvisible) {
|
||||
$result->toc .= "<li>";
|
||||
}
|
||||
if (isset($scoes[$pos+1])) {
|
||||
$nextsco = $scoes[$pos+1];
|
||||
} else {
|
||||
@ -185,13 +191,29 @@ 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.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
|
||||
$result->toc .= '<li><a title="'.$link.'">'.$statusicon.' '.format_string($sco->title).' '.$score.'</a>'."</li>\n";
|
||||
//$result->toc .= '<li><a title="'.$link.'">'.$statusicon.' '.format_string($sco->title).' '.$score.'</a>'."</li>\n";
|
||||
if ($sco->launch) {
|
||||
$result->toc .= '<a title="'.$link.'">'.$statusicon.' '.format_string($sco->title).' '.$score.'</a>';
|
||||
}
|
||||
else {
|
||||
$result->toc .= '<span>'.$statusicon.' '.format_string($sco->title).'</span>';
|
||||
}
|
||||
$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";
|
||||
//$result->toc .= $statusicon.' '.format_string($sco->title)."\n";
|
||||
if ($play) {
|
||||
// should be disabled
|
||||
$result->toc .= '<span>'.$statusicon.' '.format_string($sco->title).'</span>';
|
||||
}
|
||||
else {
|
||||
$result->toc .= $statusicon.' '.format_string($sco->title)."\n";
|
||||
}
|
||||
}
|
||||
if (($nextsco === false) || $nextsco->parent == $sco->parent) {
|
||||
$result->toc .= '</li>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -217,14 +239,14 @@ 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) {
|
||||
|
@ -44,7 +44,7 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, windo
|
||||
var scorm_current_node;
|
||||
var scorm_buttons = [];
|
||||
var scorm_bloody_labelclick = false;
|
||||
var scorm_panel;
|
||||
var scorm_nav_panel;
|
||||
|
||||
|
||||
Y.use('yui2-resize', 'yui2-dragdrop', 'yui2-container', 'yui2-button', 'yui2-layout', 'yui2-treeview', 'yui2-json', 'yui2-event', function(Y) {
|
||||
@ -179,7 +179,9 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, windo
|
||||
scorm_layout_widget.render();
|
||||
scorm_resize_frame();
|
||||
|
||||
scorm_panel.align('bl', 'bl');
|
||||
if (scorm_nav_panel) {
|
||||
scorm_nav_panel.align('bl', 'bl');
|
||||
}
|
||||
};
|
||||
|
||||
var scorm_get_htmlelement_size = function(el, prop) {
|
||||
@ -358,15 +360,15 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, windo
|
||||
|
||||
// navigation
|
||||
if (scorm_hide_nav == false) {
|
||||
//scorm_panel = new YAHOO.widget.Panel('scorm_navpanel', { visible:true, draggable:true, close:false,
|
||||
//scorm_nav_panel = new YAHOO.widget.Panel('scorm_navpanel', { visible:true, draggable:true, close:false,
|
||||
// context: ['page', 'bl', 'bl', ["windowScroll", "textResize", "windowResize"]], constraintoviewport:true} );
|
||||
scorm_panel = new YAHOO.widget.Panel('scorm_navpanel', { visible:true, draggable:true, close:false, xy: [250, 450],
|
||||
scorm_nav_panel = new YAHOO.widget.Panel('scorm_navpanel', { visible:true, draggable:true, close:false, xy: [250, 450],
|
||||
autofillheight: "body"} );
|
||||
scorm_panel.setHeader(M.str.scorm.navigation);
|
||||
scorm_nav_panel.setHeader(M.str.scorm.navigation);
|
||||
|
||||
//TODO: make some better&accessible buttons
|
||||
scorm_panel.setBody('<span id="scorm_nav"><button id="nav_skipprev"><<</button><button id="nav_prev"><</button><button id="nav_up">^</button><button id="nav_next">></button><button id="nav_skipnext">>></button></span>');
|
||||
scorm_panel.render();
|
||||
scorm_nav_panel.setBody('<span id="scorm_nav"><button id="nav_skipprev"><<</button><button id="nav_prev"><</button><button id="nav_up">^</button><button id="nav_next">></button><button id="nav_skipnext">>></button></span>');
|
||||
scorm_nav_panel.render();
|
||||
scorm_buttons[0] = new YAHOO.widget.Button('nav_skipprev');
|
||||
scorm_buttons[1] = new YAHOO.widget.Button('nav_prev');
|
||||
scorm_buttons[2] = new YAHOO.widget.Button('nav_up');
|
||||
@ -387,7 +389,7 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, windo
|
||||
scorm_buttons[4].on('click', function(ev) {
|
||||
scorm_activate_item(scorm_skipnext(scorm_tree_node.getHighlightedNode()));
|
||||
});
|
||||
scorm_panel.render();
|
||||
scorm_nav_panel.render();
|
||||
}
|
||||
|
||||
// finally activate the chosen item
|
||||
|
Loading…
x
Reference in New Issue
Block a user