Task #1765 - LP tool, cleaning files (1).

skala
Ivan Tcholakov 15 years ago
parent f4adb7c366
commit 643a575db9
  1. 1247
      main/newscorm/aicc.class.php
  2. 83
      main/newscorm/aiccBlock.class.php
  3. 215
      main/newscorm/aiccItem.class.php
  4. 82
      main/newscorm/aiccObjective.class.php
  5. 75
      main/newscorm/aiccResource.class.php
  6. 324
      main/newscorm/aicc_api.php
  7. 107
      main/newscorm/aicc_hacp.php
  8. 6
      main/newscorm/js/api_wrapper.js

File diff suppressed because it is too large Load Diff

@ -1,60 +1,55 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Container for the aiccResource class that deals with elemens from AICC Course Structure file
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
*/
/**
* Class defining the Block elements in an AICC Course Structure file
*
* Class defining the Block elements in an AICC Course Structure file.
*/
require_once 'learnpathItem.class.php';
class aiccBlock extends learnpathItem{
class aiccBlock extends learnpathItem {
public $identifier = '';
public $members = array();
/**
* Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
* object from database records or from the array given as second param
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
*/
function aiccBlock($type='config',$params) {
if(isset($params))
{
switch($type){
case 'db':
//TODO implement this way of object creation
return false;
case 'config': //do the same as the default
default:
foreach($params as $a => $value)
{
switch($a)
{
case 'system_id':
$this->identifier = strtolower($value);
break;
case 'member':
if(strstr($value,',')!==false){
$temp = split(',',$value);
foreach($temp as $val){
if(!empty($val)){
$this->members[] = $val;
}
}
}
break;
}
}
/**
* Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
* object from database records or from the array given as second param
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
*/
function aiccBlock($type = 'config', $params) {
if (isset($params)) {
switch ($type) {
case 'db':
//TODO: Implement this way of object creation.
return false;
case 'config': // Do the same as the default.
default:
foreach ($params as $a => $value) {
switch ($a) {
case 'system_id':
$this->identifier = strtolower($value);
break;
case 'member':
if (strstr($value, ',') !== false) {
$temp = split(',', $value);
foreach ($temp as $val) {
if (!empty($val)) {
$this->members[] = $val;
}
}
}
break;
}
}
return true;
}
}
return false;
}
}
}
return false;
}
}
?>

@ -1,138 +1,135 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Container for the aiccItem class that deals with AICC Assignable Units (AUs)
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
*/
/**
* This class handles the elements from an AICC Descriptor file.
*/
require_once 'learnpathItem.class.php';
class aiccItem extends learnpathItem{
public $identifier = '';//AICC AU's system_id
class aiccItem extends learnpathItem {
public $identifier = ''; // AICC AU's system_id
public $identifierref = '';
public $parameters = ''; //AICC AU's web_launch
public $title = ''; //no AICC equivalent
public $sub_items = array(); //AICC elements (des)
//public $prerequisites = ''; - defined in learnpathItem.class.php
//public $max_score = ''; //defined in learnpathItem
//public $path = ''; //defined in learnpathItem
public $maxtimeallowed = '00:00:00'; //AICC AU's max_time_allowed
public $timelimitaction = ''; //AICC AU's time_limit_action
public $masteryscore = ''; //AICC AU's mastery_score
public $core_vendor = ''; //AICC AU's core_vendor
public $system_vendor = ''; //AICC AU's system_vendor
public $au_type = ''; //AICC AU's type
public $command_line = ''; //AICC AU's command_line
public $debug=0;
public $parameters = ''; // AICC AU's web_launch
public $title = ''; // no AICC equivalent
public $sub_items = array(); // AICC elements (des)
//public $prerequisites = ''; // defined in learnpathItem.class.php
//public $max_score = ''; // defined in learnpathItem
//public $path = ''; // defined in learnpathItem
public $maxtimeallowed = '00:00:00'; // AICC AU's max_time_allowed
public $timelimitaction = ''; // AICC AU's time_limit_action
public $masteryscore = ''; // AICC AU's mastery_score
public $core_vendor = ''; // AICC AU's core_vendor
public $system_vendor = ''; // AICC AU's system_vendor
public $au_type = ''; // AICC AU's type
public $command_line = ''; // AICC AU's command_line
public $debug = 0;
/**
* Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormItem
* object from database records or from the array given as second parameter
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
*/
public function aiccItem($type='config',$params) {
if(isset($params))
{
switch($type){
case 'db':
parent::__construct($params,api_get_user_id());
$this->aicc_contact = false;
//TODO implement this way of metadata object creation
return false;
case 'config': //do the same as the default
default:
//if($first_item->type == XML_ELEMENT_NODE) this is already check prior to the call to this function
foreach($params as $a => $value)
{
switch($a)
{
case 'system_id':
$this->identifier = Database::escape_string(strtolower($value));
break;
case 'type':
$this->au_type = Database::escape_string($value);
break;
case 'command_line':
$this->command_line = Database::escape_string($value);
break;
case 'max_time_allowed':
$this->maxtimeallowed = Database::escape_string($value);
break;
case 'time_limit_action':
$this->timelimitaction = Database::escape_string($value);
break;
case 'max_score':
$this->max_score = Database::escape_string($value);
break;
case 'core_vendor':
$this->core_vendor = Database::escape_string($value);
break;
case 'system_vendor':
$this->system_vendor = Database::escape_string($value);
break;
case 'file_name':
$this->path = Database::escape_string($value);
break;
case 'mastery_score':
$this->masteryscore = Database::escape_string($value);
break;
case 'web_launch':
$this->parameters = Database::escape_string($value);
break;
}
}
/**
* Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormItem
* object from database records or from the array given as second parameter
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
*/
public function aiccItem($type = 'config', $params) {
if (isset($params)) {
switch ($type) {
case 'db':
parent::__construct($params,api_get_user_id());
$this->aicc_contact = false;
//TODO: Implement this way of metadata object creation.
return false;
case 'config': // Do the same as the default.
default:
//if($first_item->type == XML_ELEMENT_NODE) this is already check prior to the call to this function
foreach ($params as $a => $value) {
switch ($a) {
case 'system_id':
$this->identifier = Database::escape_string(strtolower($value));
break;
case 'type':
$this->au_type = Database::escape_string($value);
break;
case 'command_line':
$this->command_line = Database::escape_string($value);
break;
case 'max_time_allowed':
$this->maxtimeallowed = Database::escape_string($value);
break;
case 'time_limit_action':
$this->timelimitaction = Database::escape_string($value);
break;
case 'max_score':
$this->max_score = Database::escape_string($value);
break;
case 'core_vendor':
$this->core_vendor = Database::escape_string($value);
break;
case 'system_vendor':
$this->system_vendor = Database::escape_string($value);
break;
case 'file_name':
$this->path = Database::escape_string($value);
break;
case 'mastery_score':
$this->masteryscore = Database::escape_string($value);
break;
case 'web_launch':
$this->parameters = Database::escape_string($value);
break;
}
}
return true;
}
}
return false;
}
/**
* Builds a flat list with the current item and calls itself recursively on all children
* @param array Reference to the array to complete with the current item
* @param integer Optional absolute order (pointer) of the item in this learning path
* @param integer Optional relative order of the item at this level
* @param integer Optional level. If not given, assumes it's level 0
*/
function get_flat_list(&$list,&$abs_order,$rel_order=1,$level=0)
{
$list[] = array(
'au_type' => $this->au_type,
}
}
return false;
}
/**
* Builds a flat list with the current item and calls itself recursively on all children
* @param array Reference to the array to complete with the current item
* @param integer Optional absolute order (pointer) of the item in this learning path
* @param integer Optional relative order of the item at this level
* @param integer Optional level. If not given, assumes it's level 0
*/
function get_flat_list(&$list, &$abs_order, $rel_order = 1, $level = 0) {
$list[] = array(
'au_type' => $this->au_type,
'command_line' => $this->command_line,
'core_vendor' => $this->core_vendor,
'core_vendor' => $this->core_vendor,
'identifier' => $this->identifier,
'identifierref' => $this->identifierref,
'masteryscore' => $this->masteryscore,
'maxtimeallowed' => $this->maxtimeallowed,
'level' => $level,
'parameters' => $this->parameters,
'prerequisites' => (!empty($this->prereq_string)?$this->prereq_string:''),
'prerequisites' => (!empty($this->prereq_string) ? $this->prereq_string : ''),
'timelimitaction' => $this->timelimitaction,
);
);
$abs_order++;
$i = 1;
foreach($this->sub_items as $id => $dummy)
{
foreach ($this->sub_items as $id => $dummy) {
$oSubitem =& $this->sub_items[$id];
$oSubitem->get_flat_list($list,$abs_order,$i,$level+1);
$oSubitem->get_flat_list($list, $abs_order, $i, $level + 1);
$i++;
}
}
/**
* Save function. Uses the parent save function and adds a layer for AICC.
* @param boolean Save from URL params (1) or from object attributes (0)
*/
function save($from_outside=true, $prereqs_complete=false)
{
parent::save($from_outside, $prereqs_complete=false);
//under certain conditions, the scorm_contact should not be set, because no scorm signal was sent
$this->aicc_contact = true;
if(!$this->aicc_contact){
//error_log('New LP - was expecting SCORM message but none received',0);
}
}
}
/**
* Save function. Uses the parent save function and adds a layer for AICC.
* @param boolean Save from URL params (1) or from object attributes (0)
*/
function save($from_outside = true, $prereqs_complete = false) {
parent::save($from_outside, $prereqs_complete = false);
// Under certain conditions, the scorm_contact should not be set, because no scorm signal was sent.
$this->aicc_contact = true;
if (!$this->aicc_contact) {
//error_log('New LP - was expecting SCORM message but none received', 0);
}
}
}
?>

@ -1,60 +1,56 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Container for the aiccResource class that deals with elemens from AICC Objectives file
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
*/
/**
* Class defining the Block elements in an AICC Course Structure file
*
* Class defining the Block elements in an AICC Course Structure file.
*/
require_once 'learnpathItem.class.php';
class aiccObjective extends learnpathItem{
class aiccObjective extends learnpathItem {
public $identifier = '';
public $members = array();
/**
* Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
* object from database records or from the array given as second param
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
*/
function aiccObjective($type='config',$params) {
/**
* Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
* object from database records or from the array given as second param
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
*/
function aiccObjective($type = 'config', $params) {
if(isset($params))
{
switch($type){
case 'db':
//TODO implement this way of object creation
return false;
case 'config': //do the same as the default
default:
foreach($params as $a => $value)
{
switch($a)
{
case 'system_id':
$this->identifier = strtolower($value);
break;
case 'member':
if(strstr($value,',')!==false){
$temp = split(',',$value);
foreach($temp as $val){
if(!empty($val)){
$this->members[] = $val;
}
}
}
break;
}
}
if (isset($params)) {
switch ($type) {
case 'db':
// TODO: Implement this way of object creation.
return false;
case 'config': // Do the same as the default.
default:
foreach ($params as $a => $value) {
switch ($a) {
case 'system_id':
$this->identifier = strtolower($value);
break;
case 'member':
if (strstr($value, ',') !== false) {
$temp = split(',', $value);
foreach ($temp as $val) {
if (!empty($val)) {
$this->members[] = $val;
}
}
}
break;
}
}
return true;
}
}
return false;
}
}
}
return false;
}
}
?>

@ -1,13 +1,15 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Container for the aiccResource class that deals with elemens from AICC Descriptor file
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
*/
/**
* Class defining the elements from an AICC Descriptor file
* Class defining the elements from an AICC Descriptor file.
*/
class aiccResource {
public $identifier = '';
@ -15,44 +17,39 @@ class aiccResource {
public $description = '';
public $developer_id = '';
/**
* Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
* object from database records or from the array given as second param
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
*/
public function aiccResource($type='config',$params) {
/**
* Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
* object from database records or from the array given as second param
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
*/
public function aiccResource($type = 'config', $params) {
if(isset($params))
{
switch($type){
case 'db':
//TODO implement this way of object creation
return false;
case 'config': //do the same as the default
default:
foreach($params as $a => $value)
{
switch($a)
{
case 'system_id':
$this->identifier = strtolower($value);
break;
case 'title':
$this->title = $value;
case 'description':
$this->description = $value;
break;
case 'developer_id':
$this->developer_id = $value;
break;
}
}
if (isset($params)) {
switch ($type) {
case 'db':
// TODO: Implement this way of object creation.
return false;
case 'config': // Do the same as the default.
default:
foreach ($params as $a => $value) {
switch ($a) {
case 'system_id':
$this->identifier = strtolower($value);
break;
case 'title':
$this->title = $value;
case 'description':
$this->description = $value;
break;
case 'developer_id':
$this->developer_id = $value;
break;
}
}
return true;
}
}
return false;
}
}
}
return false;
}
}
?>

@ -1,57 +1,54 @@
<?php
/* For licensing terms, see /license.txt */
/**
* API event handler functions for AICC / CMIv4 in API communication mode
*
* @author Denes Nagy <darkden@freemail.hu>
* @author Yannick Warnier <ywarnier@beeznest.org>
* @version v 1.0
* @access public
* @package chamilo.learnpath
* @license GNU/GPL
*/
* API event handler functions for AICC / CMIv4 in API communication mode
*
* @author Denes Nagy <darkden@freemail.hu>
* @author Yannick Warnier <ywarnier@beeznest.org>
* @version v 1.0
* @access public
* @package chamilo.learnpath
* @license GNU/GPL
*/
/**
* 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
* The third section defines the event handlers for Chamilo's internal messaging
* and frames refresh
*
* This script implements the API messaging for AICC. The HACP messaging is
* made by another set of scripts.
*/
/*
* INIT SECTION
*/
//flag to allow for anonymous user - needs to be set before global.inc.php
/* INIT SECTION */
// Flag to allow for anonymous user - needs to be set before global.inc.php.
$use_anonymous = true;
//Load common libraries using a compatibility script to bridge between 1.6 and 1.8
// Load common libraries using a compatibility script to bridge between 1.6 and 1.8.
require_once 'back_compat.inc.php';
//Load learning path libraries so we can use the objects to define the initial values
//of the API
// Load learning path libraries so we can use the objects to define the initial values of the API.
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
// Is this needed? This is probabaly done in the header file.
// $_user = $_SESSION['_user'];
$file = $_SESSION['file'];
$oLP = unserialize($_SESSION['lpobject']);
$oItem = $oLP->items[$oLP->current];
if(!is_object($oItem)){
error_log('New LP - scorm_api - Could not load oItem item',0);
if (!is_object($oItem)) {
error_log('New LP - scorm_api - Could not load oItem item', 0);
exit;
}
$autocomplete_when_80pct = 0;
/*
==============================================================================
JavaScript Functions
==============================================================================
*/
?>var scorm_logs=<?php echo (empty($oLP->scorm_debug)?'0':'3');?>; //debug log level for SCORM. 0 = none, 1=light, 2=a lot, 3=all - displays logs in log frame
/* JavaScript Functions */
?>var scorm_logs=<?php echo (empty($oLP->scorm_debug) ? '0' : '3'); ?>; //debug log level for SCORM. 0 = none, 1=light, 2=a lot, 3=all - displays logs in log frame
var lms_logs=0; //debug log level for LMS actions. 0=none, 1=light, 2=a lot, 3=all
//logit_lms('scormfunctions.php included',0);
@ -66,7 +63,7 @@ function APIobject() {
this.LMSGetDiagnostic=LMSGetDiagnostic;
}
//it is not sure that the scos use the above declarations
// It is not sure that the scos use the above declarations.
API = new APIobject(); //for scorm 1.2
@ -87,7 +84,7 @@ var G_LastError = G_NoError ;
var commit = false ;
//Strictly scorm variables
// Strictly SCORM variables.
var score=<?php echo $oItem->get_score();?>;
var max=<?php echo $oItem->get_max();?>;
var min=<?php echo $oItem->get_min();?>;
@ -97,7 +94,7 @@ var suspend_data = '<?php echo $oItem->get_suspend_data();?>';
var lesson_location = '<?php echo $oItem->get_lesson_location();?>';
var total_time = '<?php echo $oItem->get_scorm_time('js');?>';
//Dokeos internal variables
// Chamilo internal variables.
var saved_lesson_status = 'not attempted';
var lms_lp_id = <?php echo $oLP->get_id();?>;
var lms_item_id = <?php echo $oItem->get_id();?>;
@ -116,7 +113,7 @@ var lms_previous_item = '<?php echo $oLP->get_previous_item_id();?>';
var lms_lp_type = '<?php echo $oLP->get_type();?>';
var lms_item_type = '<?php echo $oItem->get_type();?>';
//Backup for old values
// Backup for old values.
var old_score = 0;
var old_max = 0;
var old_min = 0;
@ -140,18 +137,18 @@ function LMSGetValue(param) {
}else if(param == 'cmi.core.exit'){
result='';
}else if(param == 'cmi.core.lesson_status'){
if(lesson_status != '') {
result=lesson_status;
}
else{
result='not attempted';
}
if(lesson_status != '') {
result=lesson_status;
}
else{
result='not attempted';
}
}else if(param == 'cmi.core.student_id'){
result='<?php echo $_user['user_id']; ?>';
}else if(param == 'cmi.core.student_name'){
<?php
$who=addslashes(api_get_person_name($_user['firstName'], $_user['lastName']));
echo "result='$who';";
$who = addslashes(api_get_person_name($_user['firstName'], $_user['lastName']));
echo "result='$who';";
?>
}else if(param == 'cmi.core.lesson_location'){
result=lesson_location;
@ -179,7 +176,7 @@ function LMSGetValue(param) {
result='<?php echo $oItem->get_view_count();?>';
}
/*
//Switch not working??? WTF???
// Switch not working??? WTF???
switch(param) {
case 'cmi.core._children' :
result='entry, exit, lesson_status, student_id, student_name, lesson_location, total_time, credit, lesson_mode, score, session_time';
@ -194,20 +191,20 @@ function LMSGetValue(param) {
result='';
break;
case 'cmi.core.lesson_status' :
if(lesson_status != '') {
result=lesson_status;
}
else{
result='not attempted';
}
break;
if(lesson_status != '') {
result=lesson_status;
}
else{
result='not attempted';
}
break;
case 'cmi.core.student_id' :
result='<?php echo $_user['user_id']; ?>';
break;
case 'cmi.core.student_name' :
<?php
$who=addslashes(api_get_person_name($_user['firstName'], $_user['lastName']));
echo "result='$who';";
$who = addslashes(api_get_person_name($_user['firstName'], $_user['lastName']));
echo "result='$who';";
?> break;
case 'cmi.core.lesson_location' :
result='';
@ -263,9 +260,9 @@ function LMSSetValue(param, val) {
case 'cmi.core.lesson_status' :
saved_lesson_status = lesson_status;
lesson_status = val;
<?php if($oLP->mode != 'fullscreen'){ ?>
//var update = update_toc(lesson_status,lms_item_id);
<?php } ?>
<?php if ($oLP->mode != 'fullscreen') { ?>
//var update = update_toc(lesson_status,lms_item_id);
<?php } ?>
break;
case 'cmi.completion_status' : lesson_status = val; break; //1.3
case 'cmi.core.session_time' : session_time = val; break;
@ -273,29 +270,29 @@ function LMSSetValue(param, val) {
case 'cmi.success_status' : success_status = val; break; //1.3
case 'cmi.suspend_data' : suspend_data = val; break;
}
//var update = update_toc();
//var update = update_toc();
//var update_progress = update_progress_bar();
<?php
if ($oLP->force_commit == 1){
echo " var mycommit = LMSCommit('force');";
if ($oLP->force_commit == 1) {
echo " var mycommit = LMSCommit('force');";
}
?>
return(true);
}
function savedata(origin) { //origin can be 'commit', 'finish' or 'terminate'
<?php if ($autocomplete_when_80pct){ ?>
if( ( lesson_status == 'incomplete') && (score >= (0.8*max) ) ){
lesson_status = 'completed';
}
<?php }?>
param = 'id='+lms_item_id+'&origin='+origin+'&score='+score+'&max='+max+'&min='+min+'&lesson_status='+lesson_status+'&time='+session_time+'&suspend_data='+suspend_data;
<?php if ($autocomplete_when_80pct) { ?>
if( ( lesson_status == 'incomplete') && (score >= (0.8*max) ) ){
lesson_status = 'completed';
}
<?php }?>
param = 'id='+lms_item_id+'&origin='+origin+'&score='+score+'&max='+max+'&min='+min+'&lesson_status='+lesson_status+'&time='+session_time+'&suspend_data='+suspend_data;
url="http://<?php
$self=api_get_self();
$url=$_SERVER['HTTP_HOST'].$self;
$url=substr($url,0,-14);//14 is the length of this file's name (/scorm_api.php)
echo $url;
?>/lp_controller.php?cidReq=<?php echo api_get_course_id();?>&action=save&lp_id=<?php echo $oLP->get_id();?>&" + param + "";
url="http://<?php
$self = api_get_self();
$url = $_SERVER['HTTP_HOST'].$self;
$url = substr($url, 0, -14); // 14 is the length of this file's name (/scorm_api.php).
echo $url;
?>/lp_controller.php?cidReq=<?php echo api_get_course_id();?>&action=save&lp_id=<?php echo $oLP->get_id();?>&" + param + "";
logit_lms('saving data (status='+lesson_status+')',1);
xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, session_time, suspend_data, lesson_location);
//xajax_update_pgs();
@ -304,7 +301,7 @@ function savedata(origin) { //origin can be 'commit', 'finish' or 'terminate'
function LMSCommit(val) {
logit_scorm('LMSCommit()',0);
commit = true ;
commit = true ;
savedata('commit');
return('true');
}
@ -331,17 +328,16 @@ function LMSGetDiagnostic(errCode){
return(API.LMSGetLastError());
}
<?php
//--------------------------------------------------------------------//
/**
* Dokeos-specific code that deals with event handling and inter-frames
* Chamilo-specific code that deals with event handling and inter-frames
* messaging/refreshing.
* Note that from now on, the Dokeos JS code in this library will act as
* Note that from now on, the Chamilo JS code in this library will act as
* a controller, of the MVC pattern, and receive all requests for frame
* updates, then redispatch to any frame concerned.
*/
?>
/**
* Defining the AJAX-object class to be made available from other frames
* Defining the AJAX-object class to be made available from other frames.
*/
function XAJAXobject() {
this.xajax_switch_item_details=xajax_switch_item_details;
@ -389,8 +385,8 @@ function addListeners(){
//assign event handlers to objects
if(lms_lp_type==1 || lms_item_type=='asset'){
logit_lms('Dokeos LP or asset',2);
//if this path is a Dokeos learnpath, then start manual save
//when something is loaded in there
// If this path is a Chamilo learnpath, then start manual save
// when something is loaded in there.
var myelem = document.getElementById('content_id');
if(!myelem){logit_lms("Impossible to find content_id element in document",2);}
addEvent(myelem,'unload',dokeos_save_asset,false);
@ -433,15 +429,15 @@ function load_item(item_id,url){
return false;
}
/**
* Save a Dokeos learnpath item's time and mark as completed upon
* Save a Chamilo learnpath item's time and mark as completed upon
* leaving it
*/
function dokeos_save_asset(){
//var linkparams = 'id='+lms_item_id+'&score='+score+'&max='+max+'&min='+min+'&lesson_status='+lesson_status+'&time='+session_time+'&suspend_data='+suspend_data;
//var url = "<?php echo api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php' ?>?action=save&" + linkparams + "";
//var linkparams = 'id='+lms_item_id+'&score='+score+'&max='+max+'&min='+min+'&lesson_status='+lesson_status+'&time='+session_time+'&suspend_data='+suspend_data;
//var url = "<?php echo api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php'; ?>?action=save&" + linkparams + "";
logit_lms('dokeos_save_asset: '+url,0);
//frames["message_name"].src = url;
xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, session_time, suspend_data, lesson_location);
//frames["message_name"].src = url;
xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, session_time, suspend_data, lesson_location);
}
/**
* Logs information about SCORM messages into the log frame
@ -471,7 +467,7 @@ function logit_lms(message,priority){
*/
function update_toc(update_action,update_id)
{
<?php if($oLP->mode != 'fullscreen'){ ?>
<?php if ($oLP->mode != 'fullscreen') { ?>
var myframe = frames["toc_name"];
var myelem = myframe.document.getElementById("toc_"+update_id);
var myelemimg = myframe.document.getElementById("toc_img_"+update_id);
@ -526,7 +522,7 @@ function update_toc(update_action,update_id)
}
}
return true;
<?php } ?>
<?php } ?>
return true;
}
/**
@ -598,7 +594,7 @@ function update_message_frame(msg_msg)
* current item, (2) refresh all the values inside the SCORM API object, (3) open the
* new item into the content_id frame, (4) refresh the table of contents, (5) refresh
* the progress bar (completion), (6) refresh the message frame
* @param integer Dokeos ID for the current item
* @param integer Chamilo ID for the current item
* @param string This parameter can be a string specifying the next
* item (like 'next', 'previous', 'first' or 'last') or the id to the next item
*/
@ -662,106 +658,106 @@ function switch_item(current_item, next_item){
* manually into GET[]
*/
function xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, session_time, suspend_data, lesson_location, interactions, lms_item_core_exit) {
params='';
params += 'lid='+lms_lp_id+'&uid='+lms_user_id+'&vid='+lms_view_id;
params += '&iid='+lms_item_id+'&s='+score+'&max='+max+'&min='+min;
params += '&status='+lesson_status+'&t='+session_time;
params += '&suspend='+suspend_data+'&loc='+lesson_location;
params += '&core_exit='+lms_item_core_exit;
interact_string = '';
for (i in interactions){
interact_string += '&interact['+i+']=';
interact_temp = '[';
for (j in interactions[i]) {
interact_temp += interactions[i][j]+',';
}
interact_temp = interact_temp.substr(0,(interact_temp.length-2)) + ']';
interact_string += encodeURIComponent(interact_temp);
}
//interact_string = encodeURIComponent(interact_string.substr(0,(interact_string.length-1)));
params += interact_string;
/*params = {
'lid': lms_lp_id,
'uid': lms_user_id,
'vid': lms_view_id,
'iid': lms_item_id,
's': score,
'max': max,
'min': min,
'status': lesson_status,
't': session_time,
'suspend': suspend_data,
'loc': lesson_location,
'interact': interac_string,
'core_exit': lms_item_core_exit
}
*/
$.ajax({
type:"POST",
data: params,
url: "lp_ajax_save_item.php",
dataType: "script",
async: false
}
);
params='';
params += 'lid='+lms_lp_id+'&uid='+lms_user_id+'&vid='+lms_view_id;
params += '&iid='+lms_item_id+'&s='+score+'&max='+max+'&min='+min;
params += '&status='+lesson_status+'&t='+session_time;
params += '&suspend='+suspend_data+'&loc='+lesson_location;
params += '&core_exit='+lms_item_core_exit;
interact_string = '';
for (i in interactions){
interact_string += '&interact['+i+']=';
interact_temp = '[';
for (j in interactions[i]) {
interact_temp += interactions[i][j]+',';
}
interact_temp = interact_temp.substr(0,(interact_temp.length-2)) + ']';
interact_string += encodeURIComponent(interact_temp);
}
//interact_string = encodeURIComponent(interact_string.substr(0,(interact_string.length-1)));
params += interact_string;
/*params = {
'lid': lms_lp_id,
'uid': lms_user_id,
'vid': lms_view_id,
'iid': lms_item_id,
's': score,
'max': max,
'min': min,
'status': lesson_status,
't': session_time,
'suspend': suspend_data,
'loc': lesson_location,
'interact': interac_string,
'core_exit': lms_item_core_exit
}
*/
$.ajax({
type:"POST",
data: params,
url: "lp_ajax_save_item.php",
dataType: "script",
async: false
}
);
}
/**
* Starts the timer with the server clock time.
* Originally, we used the xajax library. Now we use jQuery
*/
function xajax_start_timer() {
$.ajax({
type: "GET",
url: "lp_ajax_start_timer.php",
dataType: "script",
async: false
});
$.ajax({
type: "GET",
url: "lp_ajax_start_timer.php",
dataType: "script",
async: false
});
}
/**
* Save a specific item's objectives into the LMS through
* an AJAX call. Originally, we used the xajax library. Now we use jQuery
*/
function xajax_save_objectives(lms_lp_id,lms_user_id,lms_view_id,lms_item_id,item_objectives) {
params='';
params += 'lid='+lms_lp_id+'&uid='+lms_user_id+'&vid='+lms_view_id;
params += '&iid='+lms_item_id;
obj_string = '';
for (i in item_objectives){
obj_string += '&objectives['+i+']=';
obj_temp = '[';
for (j in item_objectives[i]) {
obj_temp += item_objectives[i][j]+',';
}
obj_temp = obj_temp.substr(0,(obj_temp.length-2)) + ']';
obj_string += encodeURIComponent(obj_temp);
}
params += obj_string;
$.ajax({
type: "POST",
data: params,
url: "lp_ajax_save_objectives.php",
dataType: "script",
async: false
});
params='';
params += 'lid='+lms_lp_id+'&uid='+lms_user_id+'&vid='+lms_view_id;
params += '&iid='+lms_item_id;
obj_string = '';
for (i in item_objectives){
obj_string += '&objectives['+i+']=';
obj_temp = '[';
for (j in item_objectives[i]) {
obj_temp += item_objectives[i][j]+',';
}
obj_temp = obj_temp.substr(0,(obj_temp.length-2)) + ']';
obj_string += encodeURIComponent(obj_temp);
}
params += obj_string;
$.ajax({
type: "POST",
data: params,
url: "lp_ajax_save_objectives.php",
dataType: "script",
async: false
});
}
/**
* Switch between two items through
* an AJAX call. Originally, we used the xajax library. Now we use jQuery
*/
function xajax_switch_item_details(lms_lp_id,lms_user_id,lms_view_id,lms_item_id,next_item) {
params = {
'lid': lms_lp_id,
'uid': lms_user_id,
'vid': lms_view_id,
'iid': lms_item_id,
'next': next_item
}
$.ajax({
type: "POST",
data: params,
url: "lp_ajax_switch_item.php",
dataType: "script",
async: false
});
params = {
'lid': lms_lp_id,
'uid': lms_user_id,
'vid': lms_view_id,
'iid': lms_item_id,
'next': next_item
}
$.ajax({
type: "POST",
data: params,
url: "lp_ajax_switch_item.php",
dataType: "script",
async: false
});
}
addEvent(window,'load',addListeners,false);

@ -1,15 +1,17 @@
<?php // $Id: $
<?php
/* For licensing terms, see /license.txt */
/**
* API event handler functions for AICC / CMIv4 in HACP communication mode
*
* @author Denes Nagy <darkden@freemail.hu>
* @author Yannick Warnier <ywarnier@beeznest.org>
* @author Yannick Warnier <ywarnier@beeznest.org>
* @version v 1.0
* @access public
* @package chamilo.learnpath
* @license GNU/GPL
*/
/**
* This script is divided into three sections.
* The first section (below) is the initialisation part.
@ -29,48 +31,44 @@
* 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.
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
/* INIT SECTION */
$debug = 0;
//flag to allow for anonymous user - needs to be set before global.inc.php
// Flag to allow for anonymous user - needs to be set before global.inc.php.
$use_anonymous = true;
//Use session ID as provided by the request
if(!empty($_REQUEST['aicc_sid']))
{
// Use session ID as provided by the request.
if (!empty($_REQUEST['aicc_sid'])) {
session_id($_REQUEST['aicc_sid']);
if($debug>1){error_log('New LP - '.__FILE__.','.__LINE__.' - reusing session ID '.$_REQUEST['aicc_sid'],0);}
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
//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
//of the API
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 of the API.
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
// Is this needed? This is probabaly done in the header file.
//$_user = $_SESSION['_user'];
$file = $_SESSION['file'];
$oLP = unserialize($_SESSION['lpobject']);
$oItem =& $oLP->items[$oLP->current];
if(!is_object($oItem)){
error_log('New LP - aicc_hacp - Could not load oItem item',0);
if (!is_object($oItem)) {
error_log('New LP - aicc_hacp - Could not load oItem item', 0);
exit;
}
$autocomplete_when_80pct = 0;
$result = array(
'core'=>array(),
'core_lesson'=>array(),
'core_vendor'=>array(),
'evaluation'=>array(),
'student_data'=>array(),
'core' => array(),
'core_lesson' => array(),
'core_vendor' => array(),
'evaluation' => array(),
'student_data' => array(),
);
$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",' ','-','/',';','?','{','}','|','\\','^','~','[',']','`','#','>','<','"');
@ -80,24 +78,22 @@ $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');
$errors = array(0 => 'Successful', 1 => 'Invalid Command', 2 => 'Invalid AU password', 3 => 'Invalid Session ID');
$error_code = 0;
$error_text = '';
$aicc_data = '';
$result = '';
//GET REQUEST
if(!empty($_REQUEST['command']))
{
//error_log('In '.__FILE__.', '.__LINE__.' - request is '.$_REQUEST['command'],0);
switch(strtolower($_REQUEST['command']))
{
// Get REQUEST
if (!empty($_REQUEST['command'])) {
//error_log('In '.__FILE__.', '.__LINE__.' - request is '.$_REQUEST['command'], 0);
switch (strtolower($_REQUEST['command'])) {
case 'getparam':
//request for all available data to be printed out in the answer
if(!empty($_REQUEST['version'])){
// Request for all available data to be printed out in the answer.
if (!empty($_REQUEST['version'])) {
$hacp_version = learnpath::escape_string($_REQUEST['version']);
}
if(!empty($_REQUEST['session_id'])){
if (!empty($_REQUEST['session_id'])) {
$hacp_session_id = learnpath::escape_string($_REQUEST['session_id']);
}
$error_code = 0;
@ -127,18 +123,16 @@ if(!empty($_REQUEST['command']))
//$result .= '[Student_Preferences]'.$crlf;
//error_log('Returning message: '.$result,0);
$result = str_replace($convert_dec,$convert_enc,$result);
$result = str_replace($convert_dec, $convert_enc, $result);
//error_log('Returning message (encoded): '.$result,0);
break;
case 'putparam':
$hacp_version = '';
$hacp_session_id = '';
$hacp_aicc_data = '';
foreach($_REQUEST as $name => $value)
{
foreach ($_REQUEST as $name => $value) {
//escape the value as described in the AICC documentation p170
switch(strtolower($name))
{
switch (strtolower($name)) {
case 'version':
$hacp_version = $value;
break;
@ -146,43 +140,43 @@ if(!empty($_REQUEST['command']))
$hacp_session_id = $value;
break;
case 'aicc_data':
//error_log('In '.__FILE__.', '.__LINE__.' - aicc data before translation is '.$value,0);
$value = str_replace('+',' ',$value);
$value = str_replace($convert_enc,$convert_dec,$value);
//error_log('In '.__FILE__.', '.__LINE__.' - aicc data before translation is '.$value, 0);
$value = str_replace('+', ' ', $value);
$value = str_replace($convert_enc, $convert_dec, $value);
$hacp_aicc_data = $value;
break;
}
}
//error_log('In '.__FILE__.', '.__LINE__.' - aicc data is '.$hacp_aicc_data,0);
//treat the incoming request:
$msg_array = aicc::parse_ini_string_quotes_safe($hacp_aicc_data,array('core_lesson','core_vendor'));
//error_log('Message is now in this form: '.print_r($msg_array,true),0);
foreach($msg_array as $key=>$dummy){
switch (strtolower($key)){
//error_log('In '.__FILE__.', '.__LINE__.' - aicc data is '.$hacp_aicc_data, 0);
// Treat the incoming request:
$msg_array = aicc::parse_ini_string_quotes_safe($hacp_aicc_data, array('core_lesson', 'core_vendor'));
//error_log('Message is now in this form: '.print_r($msg_array, true), 0);
foreach ($msg_array as $key => $dummy) {
switch (strtolower($key)) {
case 'core':
foreach($msg_array[$key] as $subkey => $value){
switch(strtolower($subkey)){
foreach ($msg_array[$key] as $subkey => $value){
switch (strtolower($subkey)) {
case 'lesson_location':
//error_log('Setting lesson_location to '.$value,0);
//error_log('Setting lesson_location to '.$value, 0);
$oItem->set_lesson_location($value);
break;
case 'lesson_status':
//error_log('Setting lesson_status to '.$value,0);
//error_log('Setting lesson_status to '.$value, 0);
$oItem->set_status($value);
break;
case 'score':
//error_log('Setting lesson_score to '.$value,0);
//error_log('Setting lesson_score to '.$value, 0);
$oItem->set_score($value);
break;
case 'time':
//error_log('Setting lesson_time to '.$value,0);
//error_log('Setting lesson_time to '.$value, 0);
$oItem->set_time($value);
break;
}
}
break;
case 'core_lesson':
//error_log('Setting suspend_data to '.print_r($msg_array[$key],true),0);
//error_log('Setting suspend_data to '.print_r($msg_array[$key], true), 0);
$oItem->current_data = $msg_array[$key];
break;
case 'comments':
@ -238,7 +232,6 @@ if(!empty($_REQUEST['command']))
}
}
$_SESSION['lpobject'] = serialize($oLP);
//content type must be text/plain
// Content type must be text/plain.
header('Content-type: text/plain');
echo $result;
?>

@ -1,5 +1,5 @@
/**
* Wrapper to the SCORM API provided by Dokeos
* Wrapper to the SCORM API provided by Chamilo
* The complete set of functions and variables are in this file to avoid unnecessary file
* accesses.
* Only event triggers and answer data are inserted into the final document.
@ -9,7 +9,7 @@
/**
* Initialisation of the SCORM API section.
* Find the SCO functions (startTimer, computeTime, etc in the second section)
* Find the Dokeos-proper functions (checkAnswers, etc in the third section)
* Find the Chamilo-proper functions (checkAnswers, etc in the third section)
*/
var _debug = false;
var findAPITries = 0;
@ -413,7 +413,7 @@ function unloadPage(status)
}
}
/**
* Third section - depending on Dokeos - check answers and set score
* Third section - depending on Chamilo - check answers and set score
*/
var questions = new Array();
var questions_answers = new Array();

Loading…
Cancel
Save