Skip to content

Commit f414513

Browse files
committed
Fixes to allow for time and status to be saved with alternative AICC/HACP communication format - refs BT#9817
1 parent 7fece0b commit f414513

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

main/newscorm/aicc.class.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,10 @@ function parse_ini_file_quotes_safe($f) {
768768
for ($i = 0; $i < @count($f); $i++) {
769769
$newsec = 0;
770770
$w = @trim($f[$i]);
771+
if (substr($w, 0, 1) == ';') {
772+
// Ignore comment lines
773+
continue;
774+
}
771775
if ($w) {
772776
if ((!$r) or ($sec)) {
773777
if ((@substr($w, 0, 1) == '[') and (@substr($w, -1, 1)) == ']') {
@@ -815,6 +819,10 @@ function parse_ini_string_quotes_safe($s, $pure_strings = array()) {
815819
for ($i = 0; $i < @count($f); $i++) {
816820
$newsec = 0;
817821
$w = @trim($f[$i]);
822+
if (substr($w, 0, 1) == ';') {
823+
// Ignore comment lines
824+
continue;
825+
}
818826
if ($w) {
819827
if ((!$r) or ($sec)) {
820828
if ((@substr($w, 0, 1) == '[') and (@substr($w, -1, 1)) == ']') {

main/newscorm/aicc_hacp.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,35 @@
160160
foreach ($msg_array as $key => $dummy) {
161161
switch (strtolower($key)) {
162162
case 'core':
163-
foreach ($msg_array[$key] as $subkey => $value){
163+
foreach ($msg_array[$key] as $subkey => $value) {
164164
switch (strtolower($subkey)) {
165165
case 'lesson_location':
166166
//error_log('Setting lesson_location to '.$value, 0);
167167
$oItem->set_lesson_location($value);
168168
break;
169169
case 'lesson_status':
170170
//error_log('Setting lesson_status to '.$value, 0);
171+
// Sometimes values are sent abbreviated
172+
switch ($value) {
173+
case 'C':
174+
$value = 'completed';
175+
break;
176+
case 'I':
177+
$value = 'incomplete';
178+
break;
179+
case 'N':
180+
case 'NA':
181+
$value = 'not attempted';
182+
break;
183+
case 'P':
184+
$value = 'passed';
185+
break;
186+
case 'B':
187+
$value = 'browsed';
188+
break;
189+
default:
190+
break;
191+
}
171192
$oItem->set_status($value);
172193
break;
173194
case 'score':
@@ -176,7 +197,11 @@
176197
break;
177198
case 'time':
178199
//error_log('Setting lesson_time to '.$value, 0);
179-
$oItem->set_time($value);
200+
if (strpos($value, ':') !== false) {
201+
$oItem->set_time($value, 'scorm');
202+
} else {
203+
$oItem->set_time($value);
204+
}
180205
break;
181206
}
182207
}
@@ -238,6 +263,7 @@
238263
}
239264
}
240265
$_SESSION['lpobject'] = serialize($oLP);
266+
session_write_close();
241267
// Content type must be text/plain.
242268
header('Content-type: text/plain');
243269
echo $result;

main/newscorm/learnpathItem.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3397,7 +3397,7 @@ public function set_time($scorm_time, $format = 'scorm')
33973397
if (self::debug > 0) {
33983398
error_log('learnpathItem::set_time(' . $scorm_time . ')', 0);
33993399
}
3400-
if ($scorm_time == 0
3400+
if ($scorm_time == '0'
34013401
and ($this->type != 'sco')
34023402
and $this->current_start_time != 0)
34033403
{
@@ -3950,8 +3950,9 @@ public function write_to_db()
39503950
$total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
39513951
$my_status = " status = '" . $this->get_status(false) . "' ,";
39523952
} else {
3953-
// Is lp chamilo
3954-
if ($my_type_lp == 1 && $this->type != 'chapter') {
3953+
if (($my_type_lp == 3 && $this->type == 'au') ||
3954+
($my_type_lp == 1 && $this->type != 'chapter')) {
3955+
// Is AICC or Chamilo LP
39553956
$total_time = " total_time = total_time + " . $this->get_total_time() . ", ";
39563957
$my_status = " status = '" . $this->get_status(false) . "' ,";
39573958
}

0 commit comments

Comments
 (0)