Improvements to scorm logging - write file in system's temporary directory in debug mode

skala
Yannick Warnier 15 years ago
parent 75d1505375
commit ef1301cc68
  1. 35
      main/newscorm/lp_ajax_log.php
  2. 45
      main/newscorm/scorm_api.php

@ -0,0 +1,35 @@
<?php //$id$
/**
* This script contains the server part of the xajax interaction process. The client part is located
* in lp_api.php or other api's.
* This script, in particular, enables the process of SCORM messages logging.
* It stores the SCORM interaction logs right into a temporary file on disk.
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
/**
* Script
*/
//flag to allow for anonymous user - needs to be set before global.inc.php
$use_anonymous = true;
// name of the language file that needs to be included
$language_file[] = 'learnpath';
require_once('back_compat.inc.php');
/**
* Write a log with the current message
* @param string Message
* @param int Debug level (if 0, do not log)
*/
function lp_ajax_log($msg, $level) {
$debug = 0;
$return = '';
if ($debug>0) {error_log('In log('.$msg.')',0);}
if ($level == 0) {error_log('Logging level too low, not writing files in '.__FILE__); return $return;}
$msg = str_replace('<br />',"\r\n", $msg);
$file = sys_get_temp_dir().DIRECTORY_SEPARATOR.session_id().'.'.date('Ymd').'-'.api_get_user_id().'.scorm.log';
$fh = @fopen($file,'a');
@fwrite($fh,'['.date('Y-m-d H:m:s').'] '.$msg."\r\n");
@fclose($fh);
return $return;
}
echo lp_ajax_log($_POST['msg'],$_POST['debug']);

@ -7,7 +7,7 @@
* @author Yannick Warnier <ywarnier@beeznest.org>
* @version v 1.0
* @access public
* @package dokeos.learnpath.scorm
* @package chamilo.learnpath.scorm
*/
/**
* This script is divided into three sections.
@ -1054,14 +1054,24 @@ function dokeos_void_save_asset(myscore,mymax)
* @param string Message to log
* @param integer Priority (0 for top priority, 3 for lowest)
*/
function logit_scorm(message,priority){
//if(scorm_logs>=priority){
if(scorm_logs>priority){ /* fixed see http://support.chamilo.org/issues/370 */
if($("#lp_log_name") && $("#log_content")){
$("#log_content").append("SCORM: " + message + "<br/>");
}
function logit_scorm(message,priority) {
//if(scorm_logs>=priority){
if(scorm_logs>priority){ /* fixed see http://support.chamilo.org/issues/370 */
if($("#lp_log_name") && $("#log_content")){
$("#log_content").append("SCORM: " + message + "<br/>");
}
}
params = {
msg: "SCORM: " + message,
debug: scorm_logs
};
$.ajax({
type: "POST",
data: params,
url: "lp_ajax_log.php",
dataType: "script",
async: true
});
}
/**
@ -1070,11 +1080,22 @@ function logit_scorm(message,priority){
* @param integer Priority (0 for top priority, 3 for lowest)
*/
function logit_lms(message,priority){
if(lms_logs>=priority){
if ($("#lp_log_name") && $("#log_content")) {
$("#log_content").append("LMS: " + message + "<br />");
}
if(lms_logs>=priority){
if ($("#lp_log_name") && $("#log_content")) {
$("#log_content").append("LMS: " + message + "<br />");
}
}
params = {
msg: "LMS: " + message,
debug: lms_logs
};
$.ajax({
type: "POST",
data: params,
url: "lp_ajax_log.php",
dataType: "script",
async: true
});
}
/**
* Update the Table Of Contents frame, by changing CSS styles, mostly

Loading…
Cancel
Save