26 $this->insert = array();
27 if (is_array(
$_GET[
"iL"]))
29 foreach(
$_GET[
"iL"] as $key => $value)
31 $this->insert[] = array(
"left" => $value,
"right" =>
$_GET[
"iR"][$key]);
34 if (is_array(
$_POST[
"iL"]))
36 foreach(
$_POST[
"iL"] as $key => $value)
38 $this->insert[] = array(
"left" => $value,
"right" =>
$_POST[
"iR"][$key]);
42 $this->update = array();
43 if (is_array(
$_GET[
"uL"]))
45 foreach(
$_GET[
"uL"] as $key => $value)
47 $this->update[] = array(
"left" => $value,
"right" =>
$_GET[
"uR"][$key]);
50 if (is_array(
$_POST[
"uL"]))
52 foreach(
$_POST[
"uL"] as $key => $value)
54 $this->update[] = array(
"left" => $value,
"right" =>
$_POST[
"uR"][$key]);
59 function store($obj_id=0, $sahs_id=0, $extractData=1)
61 global
$ilDB, $ilUser;
70 $f = fopen(
"./Modules/ScormAicc/log/scorm.log",
"a");
71 fwrite(
$f,
"\nCALLING SCORM store()\n");
72 fwrite(
$f,
'POST: '.print_r(
$_POST,
true));
81 if (is_object($ilUser))
83 $user_id = $ilUser->getId();
90 fwrite(
$f,
"Error: No obj_id given.\n");
94 foreach($this->insert as $insert)
96 $set = $ilDB->queryF(
'
97 SELECT * FROM scorm_tracking
102 array(
'integer',
'integer',
'text',
'integer'),
103 array($user_id,$sahs_id,$insert[
"left"],$obj_id));
104 if ($rec = $ilDB->fetchAssoc($set))
106 fwrite(
$f,
"Error Insert, left value already exists. L:".$insert[
"left"].
",R:".
107 $insert[
"right"].
",sahs_id:".$sahs_id.
",user_id:".$user_id.
"\n");
111 $ilDB->insert(
'scorm_tracking', array(
112 'obj_id' => array(
'integer', $obj_id),
113 'user_id' => array(
'integer', $user_id),
114 'sco_id' => array(
'integer', $sahs_id),
115 'lvalue' => array(
'text', $insert[
"left"]),
116 'rvalue' => array(
'clob', $insert[
"right"]),
120 fwrite(
$f,
"Insert - L:".$insert[
"left"].
",R:".
121 $insert[
"right"].
",sahs_id:".$sahs_id.
",user_id:".$user_id.
"\n");
124 foreach($this->update as $update)
126 $set = $ilDB->queryF(
'
127 SELECT * FROM scorm_tracking
132 array(
'integer',
'integer',
'text',
'integer'),
133 array($user_id,$sahs_id,$update[
"left"],$obj_id));
135 if ($rec = $ilDB->fetchAssoc($set))
137 $ilDB->update(
'scorm_tracking',
139 'rvalue' => array(
'clob', $update[
"right"]),
143 'user_id' => array(
'integer', $user_id),
144 'sco_id' => array(
'integer', $sahs_id),
145 'lvalue' => array(
'text', $update[
"left"]),
146 'obj_id' => array(
'integer', $obj_id)
152 fwrite(
$f,
"ERROR Update, left value does not exist. L:".$update[
"left"].
",R:".
153 $update[
"right"].
",sahs_id:".$sahs_id.
",user_id:".$user_id.
"\n");
161 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
171 $b_updateStatus=
false;
174 if ($ilLog->current_log_level == 30)
183 $ilLog->write(
"ScormAicc: CALLING SCORM storeJsApi() ".
$_POST);
185 if (is_object($ilUser))
186 $user_id = $ilUser->getId();
189 if (is_array(
$_POST[
"S"])) {
190 foreach(
$_POST[
"S"] as $key => $value) {
191 $aa_data[] = array(
"sco_id" => $value,
"left" =>
$_POST[
"L"][$key],
"right" => rawurldecode(
$_POST[
"R"][$key]));
196 $ilLog->write(
"ScormAicc: storeJsApi: Error: No valid obj_id given.");
199 foreach($aa_data as $a_data) {
200 $set = $ilDB->queryF(
'
201 SELECT rvalue FROM scorm_tracking
206 array(
'integer',
'integer',
'text',
'integer'),
207 array($user_id,$a_data[
"sco_id"],$a_data[
"left"],$obj_id));
208 if ($rec = $ilDB->fetchAssoc($set)) {
209 if ($a_data[
"left"] ==
'cmi.core.lesson_status' && $a_data[
"right"] != $rec[
"rvalue"]) {
210 $b_updateStatus =
true;
212 $ilDB->update(
'scorm_tracking',
214 'rvalue' => array(
'clob', $a_data[
"right"]),
218 'user_id' => array(
'integer', $user_id),
219 'sco_id' => array(
'integer', $a_data[
"sco_id"]),
220 'lvalue' => array(
'text', $a_data[
"left"]),
221 'obj_id' => array(
'integer', $obj_id)
225 $ilLog->write(
"ScormAicc: storeJsApi Updated - L:".$a_data[
"left"].
",R:".
226 $a_data[
"right"].
" for obj_id:".$obj_id.
",sco_id:".$a_data[
"sco_id"].
",user_id:".$user_id);
230 if ($a_data[
"left"] ==
'cmi.core.lesson_status') {
231 $b_updateStatus =
true;
233 $ilDB->insert(
'scorm_tracking', array(
234 'obj_id' => array(
'integer', $obj_id),
235 'user_id' => array(
'integer', $user_id),
236 'sco_id' => array(
'integer', $a_data[
"sco_id"]),
237 'lvalue' => array(
'text', $a_data[
"left"]),
238 'rvalue' => array(
'clob', $a_data[
"right"]),
242 $ilLog->write(
"ScormAicc: storeJsApi Inserted - L:".$a_data[
"left"].
",R:".
243 $a_data[
"right"].
" for obj_id:".$obj_id.
",sco_id:".$$a_data[
"sco_id"].
",user_id:".$user_id);
250 if ($b_updateStatus ==
true) {
251 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
270 $val_set = $ilDB->queryF(
'
271 SELECT * FROM scorm_tracking
276 array(
'integer',
'integer',
'text',
'integer'),
277 array($a_user_id,0,
'package_attempts',$a_obj_id));
279 $val_rec = $ilDB->fetchAssoc($val_set);
281 $val_rec[
"rvalue"] = str_replace(
"\r\n",
"\n", $val_rec[
"rvalue"]);
282 if ($val_rec[
"rvalue"] == null) {
283 $val_rec[
"rvalue"]=
"";
285 $attempts = $val_rec[
"rvalue"];
288 $sco_set = $ilDB->queryF(
'
289 SELECT sco_id, rvalue FROM scorm_tracking
294 array(
'integer',
'integer',
'text',
'integer'),
295 array($a_obj_id,$a_user_id,
'cmi.core.total_time',0));
298 while($sco_rec = $ilDB->fetchAssoc($sco_set))
300 $tarr = explode(
":", $sco_rec[
"rvalue"]);
301 $sec = (int) $tarr[2] + (
int) $tarr[1] * 60 +
302 (int) substr($tarr[0], strlen($tarr[0]) - 3) * 60 * 60;
306 include_once(
"./Services/Tracking/classes/class.ilChangeEvent.php");
312 global
$ilDB, $ilUser;
314 $ilDB->insert(
'scorm_tracking', array(
315 'obj_id' => array(
'integer', $a_obj_id),
316 'user_id' => array(
'integer', $ilUser->getId()),
317 'sco_id' => array(
'integer', $a_sahs_id),
318 'lvalue' => array(
'text', $a_lval),
319 'rvalue' => array(
'clob', $a_rval),
323 if ($a_lval ==
"cmi.core.lesson_status")
325 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
343 if(is_array($scorm_item_id))
345 $in = $ilDB->in(
'sco_id', $scorm_item_id,
false,
'integer');
347 $res = $ilDB->queryF(
'SELECT user_id,sco_id FROM scorm_tracking
350 GROUP BY user_id, sco_id',
351 array(
'integer'),array($a_obj_id));
356 $res = $ilDB->queryF(
'SELECT user_id,sco_id FROM scorm_tracking
359 array(
'integer',
'integer'),array($scorm_item_id,$a_obj_id)
363 while(
$row = $ilDB->fetchObject(
$res))
365 $in_progress[
$row->sco_id][] =
$row->user_id;
367 return is_array($in_progress) ? $in_progress : array();
382 if(is_array($scorm_item_id))
384 $in = $ilDB->in(
'sco_id', $scorm_item_id,
false,
'integer');
386 $res = $ilDB->queryF(
'SELECT DISTINCT(user_id) FROM scorm_tracking
390 AND ('.$ilDB->like(
'rvalue',
'clob',
'completed').
' OR '.$ilDB->like(
'rvalue',
'clob',
'passed').
')',
391 array(
'integer',
'text'),
392 array($a_obj_id,
'cmi.core.lesson_status'));
396 $res = $ilDB->queryF(
'SELECT DISTINCT(user_id) FROM scorm_tracking
400 AND ('.$ilDB->like(
'rvalue',
'clob',
'completed').
' OR '.$ilDB->like(
'rvalue',
'clob',
'passed').
')',
401 array(
'integer',
'integer',
'text'),
402 array($scorm_item_id,$a_obj_id,
'cmi.core.lesson_status'));
405 while(
$row = $ilDB->fetchObject(
$res))
407 $user_ids[] =
$row->user_id;
409 return $user_ids ? $user_ids : array();
417 $status =
"not_attempted";
419 if (is_array($a_scos))
421 $in = $ilDB->in(
'sco_id', $a_scos,
false,
'integer');
423 $res = $ilDB->queryF(
'SELECT sco_id, rvalue FROM scorm_tracking
428 array(
'integer',
'text',
'integer'),
429 array($a_obj_id,
'cmi.core.lesson_status', $a_user_id));
434 while ($rec = $ilDB->fetchAssoc(
$res))
436 if ($rec[
"rvalue"] ==
"failed")
440 if ($rec[
"rvalue"] !=
"completed" && $rec[
"rvalue"] !=
"passed")
448 $status =
"in_progress";
450 if ($completed && $cnt == count($a_scos))
452 $status =
"completed";
467 if (is_array($a_scos))
469 $in = $ilDB->in(
'sco_id', $a_scos,
false,
'integer');
471 $res = $ilDB->queryF(
'SELECT sco_id, rvalue FROM scorm_tracking
476 array(
'integer',
'text',
'integer'),
477 array($a_obj_id,
'cmi.core.lesson_status', $a_user_id));
480 while ($rec = $ilDB->fetchAssoc(
$res))
482 if ($rec[
"rvalue"] ==
"completed" || $rec[
"rvalue"] ==
"passed")
500 $res = $ilDB->queryF(
'SELECT DISTINCT user_id FROM scorm_tracking
503 array(
'integer',
'text'),
504 array($a_obj_id,
'cmi.core.lesson_status'));
507 while (
$row = $ilDB->fetchAssoc(
$res))
509 $users[] =
$row[
"user_id"];
526 if(is_array($scorm_item_id))
528 $in = $ilDB->in(
'sco_id', $scorm_item_id,
false,
'integer');
530 $res = $ilDB->queryF(
'
531 SELECT DISTINCT(user_id) FROM scorm_tracking
535 AND '.$ilDB->like(
'rvalue',
'clob',
'failed').
' ',
536 array(
'integer',
'text'),
537 array($a_obj_id,
'cmi.core.lesson_status'));
542 $res = $ilDB->queryF(
'
543 SELECT DISTINCT(user_id) FROM scorm_tracking
547 AND '.$ilDB->like(
'rvalue',
'clob',
'failed').
' ',
548 array(
'integer',
'integer',
'text'),
549 array($scorm_item_id,$a_obj_id,
'cmi.core.lesson_status'));
552 while(
$row = $ilDB->fetchObject(
$res))
554 $user_ids[] =
$row->user_id;
556 return $user_ids ? $user_ids : array();
569 $in = $ilDB->in(
'sco_id', $a_scorm_item_ids,
false,
'integer');
587 $query =
"SELECT user_id,rvalue FROM scorm_tracking ".
589 "AND obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
590 "AND lvalue = ".$ilDB->quote(
'cmi.core.lesson_status',
'text');
593 while(
$row = $ilDB->fetchObject(
$res))
595 if(
$row->rvalue ==
'passed' or
$row->rvalue ==
'completed')
597 ++$users[
$row->user_id];
600 return $users ? $users : array();
613 $in = $ilDB->in(
'sco_id', $sco_item_ids,
false,
'integer');
615 $res = $ilDB->queryF(
'
616 SELECT * FROM scorm_tracking
620 array(
'integer',
'text'),
621 array($a_obj_id,
'cmi.core.lesson_status'));
623 $info[
'completed'] = array();
624 $info[
'failed'] = array();
626 while(
$row = $ilDB->fetchObject(
$res))
632 $info[
'completed'][
$row->sco_id][] =
$row->user_id;
636 $info[
'failed'][
$row->sco_id][] =
$row->user_id;