Source for file aicc_hacp.php
Documentation is available at aicc_hacp.php
==============================================================================
* API event handler functions for AICC / CMIv4 in HACP communication mode
* @author Denes Nagy <darkden@freemail.hu>
* @author Yannick Warnier <ywarnier@beeznest.org>
* @package dokeos.learnpath
* @license GNU/GPL - See Dokeos license directory for details
==============================================================================
* This script is divided into three sections.
* The first section (below) is the initialisation part.
* The second section is the AICC object part
* The third section defines the event handlers for Dokeos' internal messaging
* This script implements the HACP messaging for AICC. The API messaging is
* made by another set of scripts.
* Rules for HACP processing of one AU
* Rule #1 The first HACP message issued must be a GetParam
* Rule #2 The last HACP message issued must be an ExitAU
* Rule #3 At least one PutParam message must be issued prior to an ExitAU message
* Rule #4 No HACP messages can be issued after a successfully issued ExitAU message
* Only suspend_data and core.lesson_location should be sent updated to a late GetParam
* request. All other params should be as when the AU was launched.
==============================================================================
==============================================================================
//flag to allow for anonymous user - needs to be set before global.inc.php
//Use session ID as provided by the request
if(!empty($_REQUEST['aicc_sid']))
if($debug> 1){error_log('New LP - '.__FILE__. ','.__LINE__. ' - reusing session ID '. $_REQUEST['aicc_sid'],0);}
//Load common libraries using a compatibility script to bridge between 1.6 and 1.8
require_once('back_compat.inc.php');
if($debug> 2){error_log('New LP - '.__FILE__. ','.__LINE__. ' - Current session ID: '. session_id(),0);}
//Load learning path libraries so we can use the objects to define the initial values
require_once('learnpath.class.php');
require_once('learnpathItem.class.php');
require_once('aicc.class.php');
// Is this needed? This is probabaly done in the header file
//$_user = $_SESSION['_user'];
$file = $_SESSION['file'];
$oItem = & $oLP->items[$oLP->current];
error_log('New LP - aicc_hacp - Could not load oItem item',0);
$autocomplete_when_80pct = 0;
$convert_enc = array('%25','%0D','%0A','%09','%20','%2D','%2F','%3B','%3F','%7B','%7D','%7C','%5C','%5E','%7E','%5B','%5D','%60','%23','%3E','%3C','%22');
$convert_dec = array('%',"\r","\n","\t",' ','-','/',';','?','{','}','|','\\','^','~','[',']','`','#','>','<','"');
$s_ec = 'error='; //string for error code
$s_et = 'error_text='; //string for error text
$s_ad = 'aicc_data='; //string for aicc_data
$errors = array(0=> 'Successful',1=> 'Invalid Command',2=> 'Invalid AU password',3=> 'Invalid Session ID');
if(!empty($_REQUEST['command']))
//error_log('In '.__FILE__.', '.__LINE__.' - request is '.$_REQUEST['command'],0);
//request for all available data to be printed out in the answer
if(!empty($_REQUEST['version'])){
if(!empty($_REQUEST['session_id'])){
$error_text = $errors[$error_code];
$result = $s_ec. $error_code. $crlf. $s_et. $error_text. $crlf. $s_ad. $crlf;
$result .= '[Core]'. $crlf;
$result .= $tab. 'Student_ID='. $_user['user_id']. $crlf;
$result .= $tab. 'Student_Name='. $_user['lastName']. ', '. $_user['firstName']. $_user['user_id']. $crlf;
$result .= $tab. 'Lesson_Location='. $oItem->get_lesson_location(). $crlf;
$result .= $tab. 'Credit='. $oItem->get_credit(). $crlf;
$result .= $tab. 'Lesson_Status='. $oItem->get_status(). $crlf;
$result .= $tab. 'Score='. $oItem->get_score(). $crlf;
$result .= $tab. 'Time='. $oItem->get_scorm_time('js'). $crlf;
$result .= $tab. 'Lesson_Mode='. $oItem->get_lesson_mode(). $crlf;
$result .= '[Core_Lesson]'. $crlf;
$result .= $oItem->get_suspend_data(). $crlf;
$result .= '[Core_Vendor]'. $crlf;
$result .= $oItem->get_launch_data. $crlf;
$result .= '[Comments]'. $crlf;
$result .= '[Evaluation]'. $crlf;
//$result .= '[Objectives_Status]'.$crlf;
$result .= '[Student_Data]'. $crlf;
$result .= $tab. 'Mastery_Score='. $oItem->masteryscore. $crlf;
//$result .= '[Student_Demographics]'.$crlf;
//$result .= '[Student_Preferences]'.$crlf;
//error_log('Returning message: '.$result,0);
$result = str_replace($convert_dec,$convert_enc,$result);
//error_log('Returning message (encoded): '.$result,0);
foreach($_REQUEST as $name => $value)
//escape the value as described in the AICC documentation p170
$hacp_session_id = $value;
//error_log('In '.__FILE__.', '.__LINE__.' - aicc data before translation is '.$value,0);
$value = str_replace($convert_enc,$convert_dec,$value);
$hacp_aicc_data = $value;
//error_log('In '.__FILE__.', '.__LINE__.' - aicc data is '.$hacp_aicc_data,0);
//treat the incoming request:
//error_log('Message is now in this form: '.print_r($msg_array,true),0);
foreach($msg_array as $key=> $dummy){
foreach($msg_array[$key] as $subkey => $value){
//error_log('Setting lesson_location to '.$value,0);
$oItem->set_lesson_location($value);
//error_log('Setting lesson_status to '.$value,0);
$oItem->set_status($value);
//error_log('Setting lesson_score to '.$value,0);
$oItem->set_score($value);
//error_log('Setting lesson_time to '.$value,0);
$oItem->set_time($value);
//error_log('Setting suspend_data to '.print_r($msg_array[$key],true),0);
$oItem->current_data = $msg_array[$key];
case 'objectives_status':
case 'student_preferences':
$error_text = $errors[$error_code];
$result = $s_ec. $error_code. $crlf. $s_et. $error_text. $crlf. $s_ad. $crlf;
$error_text = $errors[$error_code];
$result = $s_ec. $error_code. $crlf. $s_et. $error_text. $crlf. $s_ad. $crlf;
$error_text = $errors[$error_code];
$result = $s_ec. $error_code. $crlf. $s_et. $error_text. $crlf. $s_ad. $crlf;
$error_text = $errors[$error_code];
$result = $s_ec. $error_code. $crlf. $s_et. $error_text. $crlf. $s_ad. $crlf;
$error_text = $errors[$error_code];
$result = $s_ec. $error_code. $crlf. $s_et. $error_text. $crlf. $s_ad. $crlf;
$error_text = $errors[$error_code];
$result = $s_ec. $error_code. $crlf. $s_et. $error_text. $crlf. $s_ad. $crlf;
$error_text = $errors[$error_code];
$result = $s_ec. $error_code. $crlf. $s_et. $error_text. $crlf. $s_ad. $crlf;
$error_text = $errors[1];
$result = $s_ec. $error_code. $crlf. $s_et. $error_text. $crlf;
//content type must be text/plain
header('Content-type: text/plain');
|