MDL-7097 - API debug. Change the control of debugging over to SCORM admin settings.
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
$string['activation'] = 'Activation';
|
||||
$string['advanced'] = 'Parameters';
|
||||
$string['allowapidebug'] = 'Activate API debug and tracing (set the capture mask with apidebugmask)';
|
||||
$string['apidebugmask'] = 'API debug capture mask (simple regex on <username>:<activityname>)';
|
||||
$string['allowtypeexternal'] = 'Enable external package type';
|
||||
$string['allowtypeimsrepository'] = 'Enable IMS package type';
|
||||
$string['allowtypelocalsync'] = 'Enable downloaded package type';
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
}
|
||||
// // Log every datamodel update requested
|
||||
// if (substr($element,0,15) == 'adl.nav.request' || substr($element,0,3) == 'cmi') {
|
||||
// if (debugging('',DEBUG_DEVELOPER)) {
|
||||
// if (scorm_debugging($scorm)) {
|
||||
// add_to_log($course->id, 'scorm', 'trk: '.trim($scorm->name).' at: '.$attempt, 'view.php?id='.$cm->id, "$element => $value", $cm->id);
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -159,7 +159,7 @@ function SCORMapi1_2() {
|
||||
Initialized = true;
|
||||
errorCode = "0";
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
//echo 'alert("Initialized SCORM 1.2");';
|
||||
echo 'LogAPICall("LMSInitialize", param, "", errorCode);';
|
||||
}
|
||||
@@ -172,7 +172,7 @@ function SCORMapi1_2() {
|
||||
errorCode = "201";
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("LMSInitialize", param, "", errorCode);';
|
||||
}
|
||||
?>
|
||||
@@ -197,7 +197,7 @@ function SCORMapi1_2() {
|
||||
}
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
//echo 'alert("Finished SCORM 1.2");';
|
||||
echo 'LogAPICall("LMSFinish", param, "", 0);';
|
||||
}
|
||||
@@ -210,7 +210,7 @@ function SCORMapi1_2() {
|
||||
errorCode = "201";
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("LMSFinish", param, "", errorCode);';
|
||||
}
|
||||
?>
|
||||
@@ -235,7 +235,7 @@ function SCORMapi1_2() {
|
||||
if (subelement == element) {
|
||||
errorCode = "0";
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
//echo 'alert(element+": "+eval(element));';
|
||||
echo 'LogAPICall("LMSGetValue", element, eval(element), 0);';
|
||||
}
|
||||
@@ -275,7 +275,7 @@ function SCORMapi1_2() {
|
||||
errorCode = "301";
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("LMSGetValue", element, "", errorCode);';
|
||||
}
|
||||
?>
|
||||
@@ -345,7 +345,7 @@ function SCORMapi1_2() {
|
||||
eval(element+'=value;');
|
||||
errorCode = "0";
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("LMSSetValue", element, value, errorCode);';
|
||||
//echo 'alert(element+":= "+value);';
|
||||
}
|
||||
@@ -362,7 +362,7 @@ function SCORMapi1_2() {
|
||||
}
|
||||
errorCode = "0";
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("LMSSetValue", element, value, errorCode);';
|
||||
//echo 'alert(element+":= "+value);';
|
||||
}
|
||||
@@ -386,7 +386,7 @@ function SCORMapi1_2() {
|
||||
errorCode = "301";
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("LMSSetValue", element, value, errorCode);';
|
||||
}
|
||||
?>
|
||||
@@ -399,7 +399,7 @@ function SCORMapi1_2() {
|
||||
if (Initialized) {
|
||||
result = StoreData(cmi,false);
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("Commit", param, "", 0);';
|
||||
//echo 'alert("Data Commited");';
|
||||
}
|
||||
@@ -412,7 +412,7 @@ function SCORMapi1_2() {
|
||||
errorCode = "201";
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("LMSCommit", param, "", 0);';
|
||||
}
|
||||
?>
|
||||
@@ -421,7 +421,7 @@ function SCORMapi1_2() {
|
||||
|
||||
function LMSGetLastError () {
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("LMSGetLastError", "", "", errorCode);';
|
||||
}
|
||||
?>
|
||||
@@ -443,14 +443,14 @@ function SCORMapi1_2() {
|
||||
errorString["404"] = "Element is write only";
|
||||
errorString["405"] = "Incorrect data type";
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("LMSGetErrorString", param, errorString[param], 0);';
|
||||
}
|
||||
?>
|
||||
return errorString[param];
|
||||
} else {
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("LMSGetErrorString", param, "No error string found!", 0);';
|
||||
}
|
||||
?>
|
||||
@@ -463,7 +463,7 @@ function SCORMapi1_2() {
|
||||
param = errorCode;
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("LMSGetDiagnostic", param, param, 0);';
|
||||
}
|
||||
?>
|
||||
@@ -603,7 +603,7 @@ var API = new SCORMapi1_2();
|
||||
|
||||
<?php
|
||||
// pull in the debugging utilities
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
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);';
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ function SCORMapi1_3() {
|
||||
Initialized = true;
|
||||
errorCode = "0";
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
// echo 'alert("Initialized SCORM 1.3");';
|
||||
echo 'LogAPICall("Initialize", param, "", errorCode);';
|
||||
}
|
||||
@@ -247,7 +247,7 @@ function SCORMapi1_3() {
|
||||
errorCode = "201";
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
// echo 'alert("Initialize: "+GetErrorString(errorCode));';
|
||||
echo 'LogAPICall("Initialize", param, "", errorCode);';
|
||||
}
|
||||
@@ -260,7 +260,7 @@ function SCORMapi1_3() {
|
||||
if (param == "") {
|
||||
if ((Initialized) && (!Terminated)) {
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
// echo 'alert("Terminated SCORM 1.3");';
|
||||
echo 'LogAPICall("Terminate", param, "", 0);';
|
||||
}
|
||||
@@ -304,7 +304,7 @@ function SCORMapi1_3() {
|
||||
errorCode = "201";
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'alert("Terminate: "+GetErrorString(errorCode));';
|
||||
}
|
||||
?>
|
||||
@@ -336,7 +336,7 @@ function SCORMapi1_3() {
|
||||
if ((typeof eval(subelement) != "undefined") && (eval(subelement) != null)) {
|
||||
errorCode = "0";
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
// echo 'alert("GetValue("+element+") -> "+eval(element));';
|
||||
echo 'LogAPICall("GetValue", element, eval(element), 0);';
|
||||
}
|
||||
@@ -402,7 +402,7 @@ function SCORMapi1_3() {
|
||||
}
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
// echo 'alert("GetValue("+element+") -> "+GetErrorString(errorCode));';
|
||||
echo 'LogAPICall("GetValue", element, "", errorCode);';
|
||||
}
|
||||
@@ -768,7 +768,7 @@ function SCORMapi1_3() {
|
||||
eval(element+'=value;');
|
||||
errorCode = "0";
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
// echo 'alert("SetValue("+element+","+value+") -> OK");';
|
||||
echo 'LogAPICall("SetValue", element, value, errorCode);';
|
||||
}
|
||||
@@ -784,7 +784,7 @@ function SCORMapi1_3() {
|
||||
eval(element+'=value;');
|
||||
errorCode = "0";
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
// echo 'alert("SetValue("+element+","+value+") -> OK");';
|
||||
echo 'LogAPICall("SetValue", element, value, errorCode);';
|
||||
}
|
||||
@@ -812,7 +812,7 @@ function SCORMapi1_3() {
|
||||
}
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("SetValue", element, value, errorCode);';
|
||||
}
|
||||
?>
|
||||
@@ -825,7 +825,7 @@ function SCORMapi1_3() {
|
||||
if ((Initialized) && (!Terminated)) {
|
||||
result = StoreData(cmi,false);
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("Commit", param, "", 0);';
|
||||
//echo 'alert("Data Commited");';
|
||||
}
|
||||
@@ -842,7 +842,7 @@ function SCORMapi1_3() {
|
||||
errorCode = "201";
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("Commit", param, "", 0);';
|
||||
// echo 'alert("Commit: "+GetErrorString(errorCode));';
|
||||
}
|
||||
@@ -852,7 +852,7 @@ function SCORMapi1_3() {
|
||||
|
||||
function GetLastError () {
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("GetLastError", "", "", errorCode);';
|
||||
}
|
||||
?>
|
||||
@@ -943,14 +943,14 @@ function SCORMapi1_3() {
|
||||
break;
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("GetErrorString", param, errorString, 0);';
|
||||
}
|
||||
?>
|
||||
return errorString;
|
||||
} else {
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("GetErrorString", param, "No error string found!", 0);';
|
||||
}
|
||||
?>
|
||||
@@ -961,14 +961,14 @@ function SCORMapi1_3() {
|
||||
function GetDiagnostic (param) {
|
||||
if (diagnostic != "") {
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("GetDiagnostic", param, diagnostic, 0);';
|
||||
}
|
||||
?>
|
||||
return diagnostic;
|
||||
}
|
||||
<?php
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (scorm_debugging($scorm)) {
|
||||
echo 'LogAPICall("GetDiagnostic", param, param, 0);';
|
||||
}
|
||||
?>
|
||||
@@ -1012,7 +1012,7 @@ function SCORMapi1_3() {
|
||||
|
||||
function AddTime (first, second) {
|
||||
<?php
|
||||
// if (debugging('',DEBUG_DEVELOPER)) {
|
||||
// if (scorm_debugging($scorm)) {
|
||||
// echo 'alert("AddTime: "+first+" + "+second);';
|
||||
// }
|
||||
?>
|
||||
@@ -1119,14 +1119,14 @@ function SCORMapi1_3() {
|
||||
datastring += '&attempt=<?php echo $attempt ?>';
|
||||
datastring += '&scoid=<?php echo $scoid ?>';
|
||||
<?php
|
||||
// if (debugging('',DEBUG_DEVELOPER)) {
|
||||
// if (scorm_debugging($scorm)) {
|
||||
// echo 'popupwin(datastring);';
|
||||
// }
|
||||
?>
|
||||
var myRequest = NewHttpReq();
|
||||
var result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php","id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>"+datastring);
|
||||
<?php
|
||||
// if (debugging('',DEBUG_DEVELOPER)) {
|
||||
// if (scorm_debugging($scorm)) {
|
||||
// echo 'popupwin(result);';
|
||||
// }
|
||||
?>
|
||||
@@ -1153,7 +1153,7 @@ var API_1484_11 = new SCORMapi1_3();
|
||||
|
||||
<?php
|
||||
// pull in the debugging utilities
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
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);';
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
</head>
|
||||
<body onload="doredirect();">
|
||||
<p><?php echo get_string('activityloading', 'scorm');?> <span id="countdown"><?php echo $delayseconds ?></span> <?php echo get_string('numseconds');?>. <img src='<?php echo $scormpixdir;?>/wait.gif'><p>
|
||||
<?php if (debugging('',DEBUG_DEVELOPER)) {
|
||||
<?php if (scorm_debugging($scorm)) {
|
||||
add_to_log($course->id, 'scorm', 'launch', 'view.php?id='.$cm->id, $result, $cm->id);
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -896,4 +896,26 @@ function scorm_get_attempt_count($user, $scorm) {
|
||||
}
|
||||
return $attemptcount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out with this is a debug situation
|
||||
*
|
||||
* @param object $scorm a moodle scrom object - mdl_scorm
|
||||
* @return boolean - debugging true/false
|
||||
*/
|
||||
function scorm_debugging($scorm) {
|
||||
global $CFG, $USER;
|
||||
if (!$CFG->scorm_allowapidebug) {
|
||||
return false;
|
||||
}
|
||||
$identifier = $USER->username.':'.$scorm->name;
|
||||
$test = $CFG->scorm_apidebugmask;
|
||||
// check the regex is only a short list of safe characters
|
||||
if (!preg_match('/^[\w\s\*\.\?\+\:\_\\\]+$/', $test)) {
|
||||
return false;
|
||||
}
|
||||
$res = false;
|
||||
eval('$res = preg_match(\'/^'.$test.'/\', $identifier) ? true : false;');
|
||||
return $res;
|
||||
}
|
||||
?>
|
||||
@@ -21,5 +21,8 @@ $settings->add(new admin_setting_configcheckbox('scorm_allowtypelocalsync', get_
|
||||
$settings->add(new admin_setting_configcheckbox('scorm_allowtypeimsrepository', get_string('allowtypeimsrepository', 'scorm'),
|
||||
'', 0));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('scorm_allowapidebug', get_string('allowapidebug', 'scorm'),
|
||||
'', 0));
|
||||
|
||||
|
||||
$settings->add(new admin_setting_configtext('scorm_apidebugmask', get_string('apidebugmask', 'scorm'),
|
||||
'', '.*'));
|
||||
|
||||
Reference in New Issue
Block a user