Details
-
Type:
New Feature
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 1.9.7
-
Fix Version/s: DEV backlog
-
Component/s: SCORM
-
Labels:
-
Environment:LAMP, PHP 5.2.12
-
Database:MySQL
-
Difficulty:Easy
-
Affected Branches:MOODLE_19_STABLE
Description
Currently there's a really nice debug log feature for API based tracked items but nothing for HACP: while something similar could not be provided since everything is server side, it would be really useful to get some debug info during an AICC HACP session.
Patch proposal:
mod/scorm/aicc.php
@@ -14,6 +14,24 @@ $_POST[$tempkey] = $value; } + function addAICCDebugLogData($text) + { + global $CFG, $USER, $scoid; + + $debugenablelog = debugging('', DEBUG_DEVELOPER); + if (!$debugenablelog || empty($text)) { + return ; + } + + $logpath = $CFG->dataroot.'/_aiccdebug_'; + if (!file_exists($logpath)) { + @mkdir($logpath); + } + + $logfile = $logpath.'/aiccdebug_'.$USER->id.'_'.$scoid.'.log'; + @file_put_contents($logfile, date('Y/m/d H:i:s O')." DEBUG $text\r\n", FILE_APPEND); + } + $command = required_param('command', PARAM_ALPHA); $sessionid = required_param('session_id', PARAM_ALPHANUM); $aiccdata = optional_param('aicc_data', '', PARAM_RAW); @@ -50,6 +68,15 @@ error('Invalid script call'); } + addAICCDebugLogData("scoid: $scoid"); + addAICCDebugLogData("mode: $mode"); + addAICCDebugLogData("status: $status"); + addAICCDebugLogData("attempt: $attempt"); + addAICCDebugLogData("command: $command"); + addAICCDebugLogData("sessionid: $sessionid"); + addAICCDebugLogData("aiccdata:\r\n$aiccdata"); + ob_start(); + if ($scorm = get_record('scorm','id',$sco->scorm)) { switch ($command) { case 'getparam': @@ -372,4 +399,8 @@ echo "error=3\r\nerror_text=Invalid Session ID\r\n"; } } + + $aiccresponse = ob_get_contents(); + addAICCDebugLogData("response:\r\n$aiccresponse"); + ob_end_flush(); ?>@@ -14,6 +14,24 @@ $_POST[$tempkey] = $value; } + function addAICCDebugLogData($text) + { + global $CFG, $USER, $scoid; + + $debugenablelog = debugging('', DEBUG_DEVELOPER); + if (!$debugenablelog || empty($text)) { + return ; + } + + $logpath = $CFG->dataroot.'/_aiccdebug_'; + if (!file_exists($logpath)) { + @mkdir($logpath); + } + + $logfile = $logpath.'/aiccdebug_'.$USER->id.'_'.$scoid.'.log'; + @file_put_contents($logfile, date('Y/m/d H:i:s O')." DEBUG $text\r\n", FILE_APPEND); + } + $command = required_param('command', PARAM_ALPHA); $sessionid = required_param('session_id', PARAM_ALPHANUM); $aiccdata = optional_param('aicc_data', '', PARAM_RAW); @@ -50,6 +68,15 @@ error('Invalid script call'); } + addAICCDebugLogData("scoid: $scoid"); + addAICCDebugLogData("mode: $mode"); + addAICCDebugLogData("status: $status"); + addAICCDebugLogData("attempt: $attempt"); + addAICCDebugLogData("command: $command"); + addAICCDebugLogData("sessionid: $sessionid"); + addAICCDebugLogData("aiccdata:\r\n$aiccdata"); + ob_start(); + if ($scorm = get_record('scorm','id',$sco->scorm)) { switch ($command) { case 'getparam': @@ -372,4 +399,8 @@ echo "error=3\r\nerror_text=Invalid Session ID\r\n"; } } + + $aiccresponse = ob_get_contents(); + addAICCDebugLogData("response:\r\n$aiccresponse"); + ob_end_flush(); ?>