Fixes to allow for time and status to be saved with alternative AICC/HACP communication format - refs BT#9817

1.10.x
Yannick Warnier 10 years ago
parent c44fb291e1
commit bd847b2c11
  1. 8
      main/newscorm/aicc.class.php
  2. 30
      main/newscorm/aicc_hacp.php
  3. 7
      main/newscorm/learnpathItem.class.php

@ -793,6 +793,10 @@ class aicc extends learnpath
for ($i = 0; $i < @count($f); $i++) {
$newsec = 0;
$w = @trim($f[$i]);
if (substr($w, 0, 1) == ';') {
// Ignore comment lines
continue;
}
if ($w) {
if ((!$r) or ($sec)) {
if ((@substr($w, 0, 1) == '[') and (@substr($w, -1, 1)) == ']') {
@ -840,6 +844,10 @@ class aicc extends learnpath
for ($i = 0; $i < @count($f); $i++) {
$newsec = 0;
$w = @trim($f[$i]);
if (substr($w, 0, 1) == ';') {
// Ignore comment lines
continue;
}
if ($w) {
if ((!$r) or ($sec)) {
if ((@substr($w, 0, 1) == '[') and (@substr($w, -1, 1)) == ']') {

@ -156,7 +156,7 @@ if (!empty($_REQUEST['command'])) {
foreach ($msg_array as $key => $dummy) {
switch (strtolower($key)) {
case 'core':
foreach ($msg_array[$key] as $subkey => $value){
foreach ($msg_array[$key] as $subkey => $value) {
switch (strtolower($subkey)) {
case 'lesson_location':
//error_log('Setting lesson_location to '.$value, 0);
@ -164,6 +164,27 @@ if (!empty($_REQUEST['command'])) {
break;
case 'lesson_status':
//error_log('Setting lesson_status to '.$value, 0);
// Sometimes values are sent abbreviated
switch ($value) {
case 'C':
$value = 'completed';
break;
case 'I':
$value = 'incomplete';
break;
case 'N':
case 'NA':
$value = 'not attempted';
break;
case 'P':
$value = 'passed';
break;
case 'B':
$value = 'browsed';
break;
default:
break;
}
$oItem->set_status($value);
break;
case 'score':
@ -172,7 +193,11 @@ if (!empty($_REQUEST['command'])) {
break;
case 'time':
//error_log('Setting lesson_time to '.$value, 0);
$oItem->set_time($value);
if (strpos($value, ':') !== false) {
$oItem->set_time($value, 'scorm');
} else {
$oItem->set_time($value);
}
break;
}
}
@ -234,6 +259,7 @@ if (!empty($_REQUEST['command'])) {
}
}
$_SESSION['lpobject'] = serialize($oLP);
session_write_close();
// Content type must be text/plain.
header('Content-type: text/plain');
echo $result;

@ -3418,7 +3418,7 @@ class learnpathItem
if (self::debug > 0) {
error_log('learnpathItem::set_time(' . $scorm_time . ')', 0);
}
if ($scorm_time == 0
if ($scorm_time == '0'
and ($this->type != 'sco')
and $this->current_start_time != 0)
{
@ -3990,8 +3990,9 @@ class learnpathItem
$total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
$my_status = " status = '" . $this->get_status(false) . "' ,";
} else {
// Is lp chamilo
if ($my_type_lp == 1 && $this->type != 'chapter') {
if (($my_type_lp == 3 && $this->type == 'au') ||
($my_type_lp == 1 && $this->type != 'chapter')) {
// Is AICC or Chamilo LP
$total_time = " total_time = total_time + " . $this->get_total_time() . ", ";
$my_status = " status = '" . $this->get_status(false) . "' ,";
}

Loading…
Cancel
Save