MDL-23751: fix broken scomr API debug.

Fix continue and previous (Auto).
This commit is contained in:
Piers Harding
2010-08-17 04:03:44 +00:00
parent c994c36b83
commit 22a796743b
5 changed files with 53 additions and 26 deletions
+16
View File
@@ -721,3 +721,19 @@ function LogAPICall(func, nam, val, rc) {
s += ' => ' + String(rc);
AppendToLog(s, rc);
}
// Add in a JS controlled link for toggling the Debug logging
var logButton = document.createElement('a');
logButton.id = 'mod-scorm-log-toggle';
logButton.name = 'logToggle';
logButton.href = 'javascript:toggleLog();';
if (getLoggingActive() == "A") {
logButton.innerHTML = '<?php print_string('scormloggingon','scorm') ?>';
} else {
logButton.innerHTML = '<?php print_string('scormloggingoff','scorm') ?>';
}
var content = safeGetElement(document, 'scormpage');
content.insertBefore(logButton, content.firstChild);
AppendToLog("Moodle SCORM 1.2 API Loaded, Activity: <?php echo $scorm->name; ?>, SCO: <?php echo $sco->identifier; ?>", 0);
+4 -5
View File
@@ -197,13 +197,13 @@ function SCORMapi1_2() {
result = StoreData(cmi,true);
if (nav.event != '') {
if (nav.event == 'continue') {
setTimeout('top.document.location=top.next;',500);
setTimeout('scorm_get_next();',500);
} else {
setTimeout('top.document.location=top.prev;',500);
setTimeout('scorm_get_prev();',500);
}
} else {
if (<?php echo $scorm->auto ?> == 1) {
setTimeout('top.document.location=top.next;',500);
setTimeout('scorm_get_next();',500);
}
}
<?php
@@ -640,8 +640,7 @@ var API = new SCORMapi1_2();
<?php
// pull in the debugging utilities
if (scorm_debugging($scorm)) {
include_once($CFG->dirroot.'/mod/scorm/datamodels/debug.js.php');
echo 'AppendToLog("Moodle SCORM 1.2 API Loaded, Activity: '.$scorm->name.', SCO: '.$sco->identifier.'", 0);';
include_once($CFG->dirroot.'/mod/scorm/datamodels/debug.js.php');
}
?>
-1
View File
@@ -1278,6 +1278,5 @@ var API_1484_11 = new SCORMapi1_3();
// pull in the debugging utilities
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);';
}
?>
+32
View File
@@ -21,6 +21,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
mod_scorm_next = null;
mod_scorm_prev = null;
mod_scorm_activate_item = null;
M.mod_scorm = {};
M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launch_sco) {
@@ -134,6 +138,8 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
}
};
mod_scorm_activate_item = scorm_activate_item;
/**
* Enables/disables navigation buttons as needed.
* @return void
@@ -282,6 +288,9 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
return null;
};
mod_scorm_next = scorm_next;
mod_scorm_prev = scorm_prev;
// layout
YAHOO.widget.LayoutUnit.prototype.STR_COLLAPSE = M.str.moodle.hide;
@@ -401,3 +410,26 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
};
});
};
function scorm_get_prev() {
scorm_tree_node = YAHOO.widget.TreeView.getTree('scorm_tree');
if (scorm_tree_node) {
var hnode = scorm_tree_node.getHighlightedNode();
var prev = mod_scorm_prev(hnode);
if (prev) {
mod_scorm_activate_item(prev);
}
}
}
function scorm_get_next() {
scorm_tree_node = YAHOO.widget.TreeView.getTree('scorm_tree');
if (scorm_tree_node) {
var hnode = scorm_tree_node.getHighlightedNode();
var next = mod_scorm_next(hnode);
if (next) {
mod_scorm_activate_item(next);
}
}
}
+1 -20
View File
@@ -208,26 +208,7 @@
</noscript>
<?php
if ($result->prerequisites) {
if ($scorm->popup == 0) {
if (scorm_debugging($scorm)) {
?>
<script>
// Add in a JS controlled link for toggling the Debug logging
var logButton = document.createElement('a');
logButton.id = 'mod-scorm-log-toggle';
logButton.name = 'logToggle';
logButton.href = 'javascript:toggleLog();';
if (getLoggingActive() == "A") {
logButton.innerHTML = '<?php print_string('scormloggingon','scorm') ?>';
} else {
logButton.innerHTML = '<?php print_string('scormloggingoff','scorm') ?>';
}
var content = safeGetElement(document, 'scormpage');
content.insertBefore(logButton, content.firstChild);
</script>
<?php
}
} else {
if ($scorm->popup != 0) {
// Clean the name for the window as IE is fussy
$name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name);
if (!$name) {