forked from lushonline/moodle2-skillsoft-activity
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaicclib.php
714 lines (611 loc) · 22 KB
/
aicclib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
<?php
/*
* @package mod-skillsoft
* @author $Author$
* @version SVN: $Header$
* @copyright 2009-2014 Martin Holden
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->dirroot.'/mod/skillsoft/locallib.php');
require_once($CFG->dirroot.'/mod/skillsoft/aiccmodel.php');
require_once($CFG->dirroot.'/mod/skillsoft/olsalib.php');
defined('MOODLE_INTERNAL') || die();
/**
* This function checks if the passed $Haystack starts with $Needle
*
* @param string $Haystack the string we are checking starts with
* @param string $Needle the string it should starts with
*/
function startsWith($Haystack, $Needle){
// Recommended version, using strpos
return strpos($Haystack, $Needle) === 0;
}
/**
* Simulates Java StringTokenizer
*/
class StringTokenizer {
private $token;
private $delim;
/**
* Constructs a string tokenizer for the specified string
* @param string $str String to tokenize
* @param string $delim The set of delimiters (the characters that separate tokens)
* specified at creation time, default to ' '
*/
public function __construct($str, $delim=' ')
{
$this->token = strtok($str, $delim);
$this->delim = $delim;
}
/**
* Tests if there are more tokens available from this tokenizer's string. It
* does not move the internal pointer in any way. To move the internal pointer
* to the next element call nextToken()
* @return boolean - true if has more tokens, false otherwise
*/
public function hasMoreTokens()
{
return ($this->token !== false);
}
/**
* Returns the next token from this string tokenizer and advances the internal
* pointer by one.
* @return string - next element in the tokenized string
*/
public function nextToken()
{
$current = $this->token;
$this->token = strtok($this->delim);
return $current;
}
}
class aicchandler {
public $cmi;
public $stokenizer;
private $key;
private $block;
private $value;
private $user;
private $skillsoft;
private $attempt;
public function __construct($user, $skillsoft, $attempt=1, $enforcestrictstudentid=0)
{
$this->cmi = new cmi($enforcestrictstudentid);
$this->user = $user;
$this->skillsoft = $skillsoft;
$this->attempt = $attempt;
$this->getdata();
}
/**
* Return a UNIX time (epoch) value from the ISO8601 formatted string
*
* @param string $tstamp iso8601 formattted string
* @return number
*/
function isotoepoch($tstamp) {
//converts ISODATE to unix date
//1984-09-01T14:21:31Z
sscanf($tstamp,"%u-%u-%uT%u:%u:%uZ",$year,$month,$day,$hour,$min,$sec);
$newtstamp=mktime($hour,$min,$sec,$month,$day,$year);
return $newtstamp;
}
/**
* Convert the supplied seconds value into a CMITimeSpan representation
* hh:mm:ss
*
* @param int $time
* @return string
*/
function Sec2Time($time){
$value = array(
"hours" => 0,
"minutes" => 0, "seconds" => 0,
);
if($time >= 3600){
$value["hours"] = floor($time/3600);
$time = ($time%3600);
}
if($time >= 60){
$value["minutes"] = floor($time/60);
$time = ($time%60);
}
$value["seconds"] = floor($time);
if ($value["hours"] < 10) {
$hours = '0' . $value["hours"];
} else {
$hours = '' . $value["hours"];
}
if ($value["minutes"] < 10) {
$mins = '0' . $value["minutes"];
} else {
$mins = '' . $value["minutes"];
}
if ($value["seconds"] < 10) {
$secs = '0'. $value["seconds"];
} else {
$secs = '' . $value["seconds"];
}
return $hours . ":" . $mins . ":" . $secs;
}
/**
* Add two CMITimeSpan values
*
* Adds together two CMITimeSpan (HH:MM:SS.SS) values
*
* @param CMITimeSpan $a
* @param CMITimeSpan $b
* @return CMITimeSpan
*/
function add_time($a, $b) {
$aes = explode(':',$a);
$bes = explode(':',$b);
$aseconds = explode('.',$aes[2]);
$bseconds = explode('.',$bes[2]);
$change = 0;
$acents = 0; //Cents
if (count($aseconds) > 1) {
$acents = $aseconds[1];
}
$bcents = 0;
if (count($bseconds) > 1) {
$bcents = $bseconds[1];
}
$cents = $acents + $bcents;
$change = floor($cents / 100);
$cents = $cents - ($change * 100);
if (floor($cents) < 10) {
$cents = '0'. $cents;
}
$secs = $aseconds[0] + $bseconds[0] + $change; //Seconds
$change = floor($secs / 60);
$secs = $secs - ($change * 60);
if (floor($secs) < 10) {
$secs = '0'. $secs;
}
$mins = $aes[1] + $bes[1] + $change; //Minutes
$change = floor($mins / 60);
$mins = $mins - ($change * 60);
if ($mins < 10) {
$mins = '0' . $mins;
}
$hours = $aes[0] + $bes[0] + $change; //Hours
if ($hours < 10) {
$hours = '0' . $hours;
}
if ($cents != '0') {
return $hours . ":" . $mins . ":" . $secs . '.' . $cents;
} else {
return $hours . ":" . $mins . ":" . $secs;
}
}
/**
* This function populates the elements from the AICC Core section
* we have parsed into the appropriate datamodel elements
*
* @uses $this->key
* @uses $this->value
* @return bool if the value was succseffully copied to datamodel.
*/
private function setAICCCore()
{
switch($this->key) {
case 'student_id':
$this->cmi->core->student_id = $this->value;
return true;
break;
case 'student_name':
$this->cmi->core->student_name = $this->value;
return true;
break;
case 'lesson_location':
$this->cmi->core->lesson_location = $this->value;
return true;
break;
case 'credit':
$this->cmi->core->credit = $this->value;
return true;
break;
case 'lesson_status':
//We still need to parse it for EXIT flag
$this->cmi->core->lesson_status = $this->value;
return true;
break;
case 'time':
//We need logic on how we handle this but for now just do as session_time
$this->cmi->core->session_time = $this->value;
return true;
break;
case 'score':
//We need logic on how we handle this for min/max but for now just do as score raw
$this->cmi->core->score->raw = $this->value;
return true;
break;
}
return false;
}
/**
* This function populates the elements from the AICC CoreLesson section
* we have parsed into the appropriate datamodel elements
*
* @return bool if the value was succseffully copied to datamodel.
*/
private function setAICCCoreLesson()
{
if(($this->block != NULL) && ($this->block == "[core_lesson]"))
{
if ($this->cmi->core->core_lesson != "") {
$this->cmi->core->core_lesson = $this->cmi->core->core_lesson."\r\n".$this->value;
} else {
$this->cmi->core->core_lesson = $this->value;
}
return true;
} else {
return false;
}
}
/**
* NOT IMPLEMENTED - PlaceHolder for future implementation
* This function populates the elements from the AICC Objectives Status section
* we have parsed into the appropriate datamodel elements
*
* @return bool if the value was succseffully copied to datamodel.
*/
private function setAICCObjectivesStatus() {
return false;
}
/**
* NOT IMPLEMENTED - PlaceHolder for future implementation
* This function populates the elements from the AICC Comments section
* we have parsed into the appropriate datamodel elements
*
* @return bool if the value was succseffully copied to datamodel.
*/
private function setAICCComments() {
if(($this->block != NULL) && ($this->block == "[comments]"))
{
return true;
} else {
return false;
}
}
/**
* NOT IMPLEMENTED - PlaceHolder for future implementation
* This function populates the elements from the AICC Student_Data section
* we have parsed into the appropriate datamodel elements
*
* @return bool if the value was succseffully copied to datamodel.
*/
private function setAICCStudentData() {
if(($this->block != NULL) && ($this->block == "[student_data]"))
{
return true;
} else {
return false;
}
}
/**
* NOT IMPLEMENTED - PlaceHolder for future implementation
* This function populates the elements from the AICC Student_Data section
* we have parsed into the appropriate datamodel elements
*
* @return bool if the value was succseffully copied to datamodel.
*/
private function setAICCStudentPreferences() {
if(($this->block != NULL) && ($this->block == "[student_preferences]"))
{
return true;
} else {
return false;
}
}
/**
* Clear the CMI datamodel
*
* This function clears the CMI object
*/
public function cleardata() {
$this->cmi = new cmi();
}
/**
* Parse AICC HACP
*
* This function parses an AICC HACP putparam
* @param string $aiccdata - The contents of an AICC putparam
*/
public function parsehacp($aiccdata)
{
$AICCTokens = new StringTokenizer($aiccdata, "\r\n");
$AICCToken = "";
while ($AICCTokens->hasMoreTokens()) {
if(!startsWith($AICCToken, "[")) {
$AICCToken = trim($AICCTokens->nextToken());
}
if(!$AICCToken == "")
{
//Find block and set
if(startsWith($AICCToken, "["))
{
$this->key = strtolower($AICCToken);
$this->block = strtolower($AICCToken);
if($AICCTokens->hasMoreTokens()) {
$AICCToken = trim($AICCTokens->nextToken());
} else {
return;
}
}
if ($this->block == "[core_lesson]" || $this->block == "[comments]")
{
if(!startsWith($AICCToken,"[") && (!$AICCToken ==""))
{
$this->value = $AICCToken;
if ($this->setAICCCoreLesson() || !$this->setAICCComments())
{
};
}
} else {
$equal = strpos($AICCToken, '=');
if ($equal != 0) {
$this->key = strtolower(trim(substr($AICCToken,0,$equal)));
$this->value = trim(substr($AICCToken,$equal+1));
}
//&& !setAICCEvaluation() && !setAICCObjectivesStatus() && !setAICCStudentData() && !setAICCStudentDemographics()
if ( !$this->setAICCCore() && !$this->setAICCCoreLesson() && !$this->setAICCObjectivesStatus() && !$this->setAICCStudentData()){
if (!$this->setAICCStudentPreferences()){
}
}
}
}
}
}
/**
* Retrieve existing data
*
* This function retrieves existing data from database and populates
* the CMI model
*/
public function getdata()
{
global $CFG;
//Get data from database
$userdata=skillsoft_get_tracks($this->skillsoft->id,$this->user->id,$this->attempt);
//Populate the cmi datamodel
//Set the student ID based on
//Need to include logic for "prefix" here
$this->cmi->core->student_id = $CFG->skillsoft_accountprefix.$this->user->{$CFG->skillsoft_useridentifier};
$this->cmi->core->student_name = $this->user->lastname .', '. $this->user->firstname;
if ($this->cmi->core->lesson_mode == 'normal') {
$this->cmi->core->credit = 'credit';
} else {
$this->cmi->core->credit = 'no-credit';;
}
if (isset($userdata->{'[CORE]lesson_location'})) {
$this->cmi->core->lesson_location = $userdata->{'[CORE]lesson_location'};
} else {
$this->cmi->core->lesson_location = '';
}
if (isset($userdata->status)) {
if ($userdata->status == '') {
$this->cmi->core->lesson_status_entry = 'ab initio';
} else {
if (isset($userdata->{'[CORE]lesson_status flag'}) && ($userdata->{'[CORE]lesson_status flag'} == 'suspend')) {
$this->cmi->core->lesson_status_entry = 'resume';
} else {
$this->cmi->core->lesson_status_entry = NULL;
}
}
}
if (isset($userdata->{'[CORE]lesson_status'})) {
$this->cmi->core->lesson_status = $userdata->{'[CORE]lesson_status'};
} else {
$this->cmi->core->lesson_status = 'not attempted';
}
if (isset($userdata->{'[CORE]score'})) {
$this->cmi->core->score->raw = $userdata->{'[CORE]score'};
} else {
$this->cmi->core->score->raw = '';
}
$this->cmi->core->student_data->mastery_score = isset($this->skillsoft->mastery)?$this->skillsoft->mastery:'';
if (isset($userdata->{'[CORE]time'})) {
$this->cmi->core->time = $userdata->{'[CORE]time'};
} else {
$this->cmi->core->time = '00:00:00';
}
if (isset($userdata->{'[CORE_LESSON]'})) {
$this->cmi->core->core_lesson = stripslashes($userdata->{'[CORE_LESSON]'});
} else {
$this->cmi->core->core_lesson = '';
}
if (isset($userdata->{'[CORE]session_time'})) {
$this->cmi->core->session_time = $userdata->{'[CORE]session_time'};
} else {
$this->cmi->core->session_time = '00:00:00';
}
}
/**
* Process the AICC GetParam request
*
* @param bool $return Immediately output the value or return as a string
* @return string
*/
public function getparam($return=false)
{
//Make sure to get latest data
$this->getdata();
$response='';
$response .= 'error=0'."\r\n";
$response .= 'error_text=Successful'."\r\n";
$response .= 'aicc_data=[Core]'."\r\n";
$response .= 'student_id='.$this->cmi->core->student_id."\r\n";
$response .= 'student_name='.$this->cmi->core->student_name."\r\n";
$response .= 'lesson_location='.$this->cmi->core->lesson_location."\r\n";
$response .= 'credit='.$this->cmi->core->credit."\r\n";
$response .= 'lesson_status='.$this->cmi->core->lesson_status;
if (isset($this->cmi->core->lesson_status_entry))
{
$response .= ', '.$this->cmi->core->lesson_status_entry."\r\n";
} else {
$response .= "\r\n";
}
$response .= 'score='.$this->cmi->core->score->raw."\r\n";
$response .= 'time='.$this->cmi->core->time."\r\n";
$response .= 'lesson_mode='.$this->cmi->core->lesson_mode."\r\n";
$response .= '[Core_Lesson]'."\r\n";
$response .= $this->cmi->core->core_lesson."\r\n";
$response .= '[Student_Data]'."\r\n";
$response .= 'mastery_score='.$this->cmi->core->student_data->mastery_score."\r\n";
if ($return) {
return $response;
} else {
echo $response;
}
}
/**
* Process the AICC PutParam request
*
* @param string $aiccdata The data sent to the AICC handler by the CMI
* @param bool $return Immediately output the value or return as a string
* @return string
*/
public function putparam($aiccdata,$return=false)
{
global $CFG;
//Lets parse the response
$this->cleardata();
$this->parsehacp($aiccdata);
//If we are track to LMS perform the writes to DB
if ($CFG->skillsoft_trackingmode == TRACK_TO_LMS) {
//Persist the data
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]lesson_location', $this->cmi->core->lesson_location);
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]lesson_status', strtolower($this->cmi->core->lesson_status));
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]lesson_status flag', strtolower($this->cmi->core->lesson_status_exit));
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]score', $this->cmi->core->score->raw);
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]session_time', $this->cmi->core->session_time);
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE_LESSON]', $this->cmi->core->core_lesson);
//If the launch url contains HACP=0 we know the asset is none completable so call ExitAu here
$nonetrackable = stripos($this->skillsoft->launch, 'HACP=0');
if ($nonetrackable !== false) {
$exitaustr = $this->exitau(true);
}
}
$response = '';
$response .= 'error=0'."\r\n";
$response .= 'error_text=Successful'."\r\n";
if ($return) {
return $response;
} else {
echo $response;
}
}
/**
* Process the TDR
*
* @param string $tdr The OLSA TDR
* @return null
*/
public function processtdr($tdr,$attempt=1)
{
//Lets parse the response
$this->cleardata();
$this->attempt = $attempt;
$this->getdata();
//Convert data value into XML
$cmixml = simplexml_load_string($tdr->data);
//Populate the CMI datamodel
$this->cmi->core->lesson_location = (string)$cmixml->core->lessonLocation;
$this->cmi->core->lesson_status = (string)$cmixml->core->lessonStatus;
$this->cmi->core->session_time = (string)$cmixml->core->sessionTime;
$this->cmi->core->score->raw = (string)$cmixml->core->score->raw;
$this->cmi->core->core_lesson = (string)$cmixml->suspendData;
//Persist the data
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]lesson_location', $this->cmi->core->lesson_location);
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]lesson_status', strtolower($this->cmi->core->lesson_status));
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]score', $this->cmi->core->score->raw);
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]session_time', $this->cmi->core->session_time);
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE_LESSON]', $this->cmi->core->core_lesson);
//Now we do the EXITAU part
$value = $this->add_time($this->cmi->core->session_time, $this->cmi->core->time);
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]time', $value);
$id = skillsoft_setFirstAccessDate($this->user->id, $this->skillsoft->id, $this->attempt, $tdr->timestamp);
$id = skillsoft_setLastAccessDate($this->user->id, $this->skillsoft->id, $this->attempt, $tdr->timestamp);
if ( (substr($this->cmi->core->lesson_status,0,1) == 'c' || substr($this->cmi->core->lesson_status,0,1) == 'p'))
{
$id = skillsoft_setCompletedDate($this->user->id, $this->skillsoft->id, $this->attempt, $tdr->timestamp);
}
$id = skillsoft_setAccessCount($this->user->id, $this->skillsoft->id, $this->attempt);
$id = skillsoft_setFirstScore($this->user->id, $this->skillsoft->id, $this->attempt, $this->cmi->core->score->raw);
$id = skillsoft_setCurrentScore($this->user->id, $this->skillsoft->id, $this->attempt, $this->cmi->core->score->raw);
$id = skillsoft_setBestScore($this->user->id, $this->skillsoft->id, $this->attempt, $this->cmi->core->score->raw);
}
/**
* Process the AICC ExitAU request
*
* @param bool $return Immediately output the value or return as a string
* @return string
*/
public function exitau($return=false) {
global $CFG;
//If we are track to LMS perform the writes to DB
if ($CFG->skillsoft_trackingmode == TRACK_TO_LMS) {
$nonetrackable = stripos($this->skillsoft->launch, 'HACP=0');
$this->getdata();
//Calculate Overall Time
$value = $this->add_time($this->cmi->core->session_time, $this->cmi->core->time);
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]time', $value);
//Submit the summary data
$now = time();
$id = skillsoft_setFirstAccessDate($this->user->id, $this->skillsoft->id, $this->attempt, $now);
$id = skillsoft_setLastAccessDate($this->user->id, $this->skillsoft->id, $this->attempt, $now);
if ( (substr($this->cmi->core->lesson_status,0,1) == 'c' || substr($this->cmi->core->lesson_status,0,1) == 'p'))
{
$id = skillsoft_setCompletedDate($this->user->id, $this->skillsoft->id, $this->attempt, $now);
}
$id = skillsoft_setAccessCount($this->user->id, $this->skillsoft->id, $this->attempt);
$id = skillsoft_setFirstScore($this->user->id, $this->skillsoft->id, $this->attempt, $this->cmi->core->score->raw);
$id = skillsoft_setCurrentScore($this->user->id, $this->skillsoft->id, $this->attempt, $this->cmi->core->score->raw);
$id = skillsoft_setBestScore($this->user->id, $this->skillsoft->id, $this->attempt, $this->cmi->core->score->raw);
}
$response = '';
$response .= 'error=0'."\r\n";
$response .= 'error_text=Successful'."\r\n";
if ($return) {
return $response;
} else {
echo $response;
}
}
/**
* Process the ReportResults
*
* @param object $reportresults The ReportResults
* @return null
*/
public function processreportresults($reportresults, $attempt=1)
{
//Lets parse the response
$this->cleardata();
$this->attempt = $attempt;
$this->getdata();
$this->cmi->core->lesson_status = strtolower($reportresults->lessonstatus);
if ($reportresults->currentscore != 0) {
$this->cmi->core->score->raw = $reportresults->currentscore;
}
//Now we do the EXITAU part
//Duration
$value = $this->Sec2Time($reportresults->duration);
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]time', $value);
$id = skillsoft_setFirstAccessDate($this->user->id, $this->skillsoft->id, $this->attempt, $reportresults->firstaccessdate);
$id = skillsoft_setLastAccessDate($this->user->id, $this->skillsoft->id, $this->attempt, $reportresults->lastaccessdate);
if ( (substr($this->cmi->core->lesson_status,0,1) == 'c' || substr($this->cmi->core->lesson_status,0,1) == 'p'))
{
$id = skillsoft_setCompletedDate($this->user->id, $this->skillsoft->id, $this->attempt, $reportresults->completeddate);
}
$id = skillsoft_setAccessCount($this->user->id, $this->skillsoft->id, $this->attempt,$reportresults->accesscount);
$id = skillsoft_setFirstScore($this->user->id, $this->skillsoft->id, $this->attempt, $reportresults->firstscore);
$id = skillsoft_setCurrentScore($this->user->id, $this->skillsoft->id, $this->attempt, $reportresults->currentscore);
$id = skillsoft_setBestScore($this->user->id, $this->skillsoft->id, $this->attempt, $reportresults->bestscore);
//Need to do these last to ensure grades correctly entered
//Persist the data
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]lesson_status', $this->cmi->core->lesson_status);
$id = skillsoft_insert_track($this->user->id, $this->skillsoft->id, $this->attempt, '[CORE]score', $this->cmi->core->score->raw);
}
}