4include_once
'./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
20 $query =
'SELECT obj_id, title
22 WHERE slm_id = %s AND c_type = %s';
25 array(
'integer',
'text'),
29 $scoTitles[
$row[
'obj_id']] =
$row[
'title'];
38 include_once
'Services/Object/classes/class.ilObjectLP.php';
40 $collection = $olp->getCollectionInstance();
42 foreach ($a_scos as $sco_id=>$value) {
43 if ($collection && $collection->isAssignedEntry($sco_id)) {
44 $a_scos[$sco_id] =
$lng->txt(
'yes');
46 $a_scos[$sco_id]=
$lng->txt(
'no');
55 if ($b_allowExportPrivacy ==
false) {
56 $userArray[
"user"]=$user;
59 $userArray[
"login"] =
"";
60 $userArray[
"user"] =
"";
61 $userArray[
"email"] =
"";
62 $userArray[
"department"] =
"";
65 $userArray[
"login"] = $e_user->getLogin();
66 $userArray[
"user"] = $e_user->getLastname() .
', ' . $e_user->getFirstname();
67 $userArray[
"email"] =
"" . $e_user->getEmail();
68 $userArray[
"department"] =
"" . $e_user->getDepartment();
75 public function getScormTrackingValue($obj_id, $a_user = array(), $a_sco = array(), $a_empty = array(), $lvalue)
79 $query =
'SELECT user_id, sco_id, rvalue '
80 .
'FROM scorm_tracking '
81 .
'WHERE obj_id = %s '
82 .
'AND ' .
$ilDB->in(
'user_id', $a_user,
false,
'integer') .
' '
83 .
'AND ' .
$ilDB->in(
'sco_id', $a_sco,
false,
'integer') .
' '
87 array(
'integer',
'text'),
88 array($obj_id,$lvalue)
91 if (!is_null(
$data[
'rvalue'])) {
102 $query =
'SELECT user_id, sco_id, rvalue '
103 .
'FROM scorm_tracking '
104 .
'WHERE obj_id = %s '
105 .
'AND ' .
$ilDB->in(
'user_id', $a_user,
false,
'integer') .
' '
106 .
'AND ' .
$ilDB->in(
'sco_id', $a_sco,
false,
'integer') .
' '
110 array(
'integer',
'text'),
111 array($obj_id,
'cmi.' . $topic .
'.' .
$counter .
'.' . $lvalue)
114 if (!is_null(
$data[
'rvalue'])) {
124 $lng->loadLanguageModule(
"scormtrac");
130 'lm_id,lm_title,identifierref,sco_id,sco_marked_for_learning_progress,sco_title,' . $udh[
"cols"]
131 .
',c_timestamp,lvalue,rvalue'
133 $a_true=explode(
',', $udh[
"default"] .
",identifierref,c_timestamp,lvalue,rvalue");
134 for (
$i=0;
$i<count($a_cols);
$i++) {
135 $cols[$a_cols[
$i]] = array(
"txt" =>
$lng->txt($a_cols[
$i]),
"default" =>
false);
137 for (
$i=0;
$i<count($a_true);
$i++) {
138 $cols[$a_true[
$i]][
"default"] =
true;
143 public function exportSelectedRaw($a_user = array(), $a_sco = array(), $b_orderBySCO=
false, $allowExportPrivacy=
false, $obj_id)
146 $lng->loadLanguageModule(
"scormtrac");
148 $returnData = array();
154 $query =
'SELECT user_id, st.obj_id, sco_id, identifierref, c_timestamp, lvalue, rvalue '
155 .
'FROM scorm_tracking st '
156 .
'JOIN sc_item si ON st.sco_id = si.obj_id '
157 .
'WHERE ' .
$ilDB->in(
'sco_id', $a_sco,
false,
'integer') .
' '
158 .
'AND ' .
$ilDB->in(
'user_id', $a_user,
false,
'integer') .
' '
162 $query.=
'sco_id, user_id';
164 $query.=
'user_id, sco_id';
168 $data[
"lm_id"] = $obj_id;
169 $data[
"lm_title"] = $this->lmTitle;
170 $data=array_merge(
$data, self::userDataArrayForExport(
$data[
"user_id"], $allowExportPrivacy));
171 $data[
"sco_marked_for_learning_progress"] = $scoProgress[
$data[
"sco_id"]];
172 $data[
"sco_title"] = $scoTitles[
$data[
"sco_id"]];
184 $lng->loadLanguageModule(
"scormtrac");
190 'lm_id,lm_title,sco_id,sco_marked_for_learning_progress,sco_title,' . $udh[
"cols"]
191 .
',lesson_status,credit,c_entry,c_exit,c_max,c_min,c_raw,session_time,total_time,c_timestamp,suspend_data,launch_data'
193 $a_true=explode(
',', $udh[
"default"] .
",sco_title,lesson_status");
194 for (
$i=0;
$i<count($a_cols);
$i++) {
195 $cols[$a_cols[
$i]] = array(
"txt" =>
$lng->txt($a_cols[
$i]),
"default" =>
false);
197 for (
$i=0;
$i<count($a_true);
$i++) {
198 $cols[$a_true[
$i]][
"default"] =
true;
203 public function exportSelectedCore($a_user = array(), $a_sco = array(), $b_orderBySCO=
false, $allowExportPrivacy=
false, $obj_id)
206 $lng->loadLanguageModule(
"scormtrac");
208 $returnData = array();
216 for (
$i=0;
$i<count($a_user);
$i++) {
217 $a_empty[$a_user[
$i]] = array();
221 $query =
'SELECT user_id, sco_id, max(c_timestamp) as c_timestamp '
222 .
'FROM scorm_tracking '
223 .
'WHERE ' .
$ilDB->in(
'sco_id', $a_sco,
false,
'integer') .
' '
224 .
'AND ' .
$ilDB->in(
'user_id', $a_user,
false,
'integer') .
' '
225 .
'GROUP BY user_id, sco_id '
228 $query.=
'sco_id, user_id';
230 $query.=
'user_id, sco_id';
235 $a_empty[
$row[
"user_id"]][
$row[
"sco_id"]]=
"";
250 foreach ($dbdata as
$data) {
251 $data[
"lm_id"] = $obj_id;
252 $data[
"lm_title"] = $this->lmTitle;
254 $data=array_merge(
$data, self::userDataArrayForExport(
$data[
"user_id"], $allowExportPrivacy));
256 $data[
"sco_marked_for_learning_progress"] = $scoProgress[
$data[
"sco_id"]];
257 $data[
"sco_title"] = $scoTitles[
$data[
"sco_id"]];
261 $data[
"lesson_status"] = $a_lesson_status[
$data[
'user_id']][
$data[
'sco_id']];
272 $data[
"session_time"] = $a_session_time[
$data[
'user_id']][
$data[
'sco_id']];
275 $data[
"total_time"] = $a_total_time[
$data[
'user_id']][
$data[
'sco_id']];
279 $data[
"suspend_data"] = $a_suspend_data[
$data[
'user_id']][
$data[
'sco_id']];
280 $data[
"launch_data"] = $a_launch_data[
$data[
'user_id']][
$data[
'sco_id']];
290 $lng->loadLanguageModule(
"scormtrac");
295 'lm_id,lm_title,sco_id,sco_marked_for_learning_progress,sco_title,' . $udh[
"cols"]
296 .
',counter,id,weighting,type,result,student_response,latency,time,c_timestamp'
298 $a_true=explode(
',', $udh[
"default"] .
",sco_title,id,result,student_response");
299 for (
$i=0;
$i<count($a_cols);
$i++) {
300 $cols[$a_cols[
$i]] = array(
"txt" =>
$lng->txt($a_cols[
$i]),
"default" =>
false);
302 for (
$i=0;
$i<count($a_true);
$i++) {
303 $cols[$a_true[
$i]][
"default"] =
true;
312 $returnData = array();
320 $interactionsCounter = array();
323 $query =
'SELECT user_id, sco_id, lvalue, c_timestamp '
324 .
'FROM scorm_tracking '
325 .
'WHERE obj_id = %s AND ' .
$ilDB->in(
'sco_id', $a_sco,
false,
'integer') .
' '
326 .
'AND ' .
$ilDB->in(
'user_id', $a_user,
false,
'integer') .
' '
327 .
'AND left(lvalue,17) = %s '
330 $query.=
'sco_id, user_id, lvalue';
332 $query.=
'user_id, sco_id, lvalue';
336 array(
'integer',
'text'),
337 array($obj_id,
'cmi.interactions.')
341 $tmpar = explode(
'.',
$row[
"lvalue"]);
342 $tmpcounter = $tmpar[2];
343 if (in_array($tmpcounter, $interactionsCounter) ==
false) {
344 $interactionsCounter[] = $tmpcounter;
346 if ($tmpcounter != $prevcounter) {
348 $tmpar[
"user_id"] =
$row[
"user_id"];
349 $tmpar[
"sco_id"] =
$row[
"sco_id"];
350 $tmpar[
"counter"] = $tmpcounter;
352 $tmpar[
"weighting"] =
"";
354 $tmpar[
"result"] =
"";
355 $tmpar[
"student_response"] =
"";
356 $tmpar[
"latency"] =
"";
358 $tmpar[
"c_timestamp"] =
$row[
"c_timestamp"];
360 $prevcounter = $tmpcounter;
366 $a_weighting = array();
369 $a_student_response = array();
370 $a_latency = array();
372 for (
$i=0;
$i<count($interactionsCounter);
$i++) {
373 $a_id=array_merge($a_id, self::getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user, $a_sco,
'id', $interactionsCounter[
$i],
'interactions'));
374 $a_weighting=array_merge($a_weighting, self::getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user, $a_sco,
'weighting', $interactionsCounter[
$i],
'interactions'));
375 $a_type=array_merge(
$a_type, self::getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user, $a_sco,
'type', $interactionsCounter[
$i],
'interactions'));
376 $a_result=array_merge($a_result, self::getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user, $a_sco,
'result', $interactionsCounter[
$i],
'interactions'));
377 $a_student_response=array_merge($a_student_response, self::getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user, $a_sco,
'student_response', $interactionsCounter[
$i],
'interactions'));
378 $a_latency=array_merge($a_latency, self::getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user, $a_sco,
'latency', $interactionsCounter[
$i],
'interactions'));
379 $a_time=array_merge($a_time, self::getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user, $a_sco,
'time', $interactionsCounter[
$i],
'interactions'));
381 foreach ($dbdata as
$data) {
382 $data[
"lm_id"] = $obj_id;
383 $data[
"lm_title"] = $this->lmTitle;
385 $data=array_merge(
$data, self::userDataArrayForExport(
$data[
"user_id"], $allowExportPrivacy));
387 $data[
"sco_marked_for_learning_progress"] = $scoProgress[
$data[
"sco_id"]];
388 $data[
"sco_title"] = $scoTitles[
$data[
"sco_id"]];
390 $combinedId =
'' .
$data[
"user_id"] .
'-' .
$data[
"sco_id"] .
'-' .
$data[
"counter"];
391 if (array_key_exists($combinedId, $a_id)) {
392 $data[
"id"] = $a_id[$combinedId];
394 if (array_key_exists($combinedId, $a_weighting)) {
395 $data[
"weighting"] = $a_weighting[$combinedId];
397 if (array_key_exists($combinedId,
$a_type)) {
400 if (array_key_exists($combinedId, $a_result)) {
401 $data[
"result"] = $a_result[$combinedId];
403 if (array_key_exists($combinedId, $a_student_response)) {
404 $data[
"student_response"] = $a_student_response[$combinedId];
406 if (array_key_exists($combinedId, $a_latency)) {
407 $data[
"latency"] = $a_latency[$combinedId];
409 if (array_key_exists($combinedId, $a_time)) {
410 $data[
"time"] = $a_time[$combinedId];
425 $lng->loadLanguageModule(
"scormtrac");
430 'lm_id,lm_title,sco_id,sco_marked_for_learning_progress,sco_title,' . $udh[
"cols"]
431 .
',counter,id,c_max,c_min,c_raw,ostatus,c_timestamp'
433 $a_true=explode(
',', $udh[
"default"] .
",sco_title,id,c_raw,ostatus");
434 for (
$i=0;
$i<count($a_cols);
$i++) {
435 $cols[$a_cols[
$i]] = array(
"txt" =>
$lng->txt($a_cols[
$i]),
"default" =>
false);
437 for (
$i=0;
$i<count($a_true);
$i++) {
438 $cols[$a_true[
$i]][
"default"] =
true;
443 public function exportSelectedObjectives($a_user = array(), $a_sco = array(), $b_orderBySCO=
false, $allowExportPrivacy=
false, $obj_id)
447 $returnData = array();
455 $objectivesCounter = array();
458 $query =
'SELECT user_id, sco_id, lvalue, c_timestamp '
459 .
'FROM scorm_tracking '
460 .
'WHERE obj_id = %s AND ' .
$ilDB->in(
'sco_id', $a_sco,
false,
'integer') .
' '
461 .
'AND ' .
$ilDB->in(
'user_id', $a_user,
false,
'integer') .
' '
462 .
'AND left(lvalue,15) = %s '
465 $query.=
'sco_id, user_id, lvalue';
467 $query.=
'user_id, sco_id, lvalue';
471 array(
'integer',
'text'),
472 array($obj_id,
'cmi.objectives.')
476 $tmpar = explode(
'.',
$row[
"lvalue"]);
477 $tmpcounter = $tmpar[2];
478 if (in_array($tmpcounter, $objectivesCounter) ==
false) {
479 $objectivesCounter[] = $tmpcounter;
481 if ($tmpcounter != $prevcounter) {
483 $tmpar[
"user_id"] =
$row[
"user_id"];
484 $tmpar[
"sco_id"] =
$row[
"sco_id"];
485 $tmpar[
"counter"] = $tmpcounter;
487 $tmpar[
"c_max"] =
"";
488 $tmpar[
"c_min"] =
"";
489 $tmpar[
"c_raw"] =
"";
490 $tmpar[
"ostatus"] =
"";
491 $tmpar[
"c_timestamp"] =
$row[
"c_timestamp"];
493 $prevcounter = $tmpcounter;
501 for (
$i=0;
$i<count($objectivesCounter);
$i++) {
502 $a_id=array_merge($a_id, self::getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user, $a_sco,
'id', $objectivesCounter[
$i],
'objectives'));
503 $a_c_max=array_merge($a_c_max, self::getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user, $a_sco,
'score.max', $objectivesCounter[
$i],
'objectives'));
504 $a_c_min=array_merge($a_c_min, self::getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user, $a_sco,
'score.min', $objectivesCounter[
$i],
'objectives'));
505 $a_c_raw=array_merge($a_c_raw, self::getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user, $a_sco,
'score.raw', $objectivesCounter[
$i],
'objectives'));
506 $a_status=array_merge($a_status, self::getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user, $a_sco,
'status', $objectivesCounter[
$i],
'objectives'));
508 foreach ($dbdata as
$data) {
509 $data[
"lm_id"] = $obj_id;
510 $data[
"lm_title"] = $this->lmTitle;
512 $data=array_merge(
$data, self::userDataArrayForExport(
$data[
"user_id"], $allowExportPrivacy));
514 $data[
"sco_marked_for_learning_progress"] = $scoProgress[
$data[
"sco_id"]];
515 $data[
"sco_title"] = $scoTitles[
$data[
"sco_id"]];
517 $combinedId =
'' .
$data[
"user_id"] .
'-' .
$data[
"sco_id"] .
'-' .
$data[
"counter"];
518 if (array_key_exists($combinedId, $a_id)) {
519 $data[
"id"] = $a_id[$combinedId];
521 if (array_key_exists($combinedId, $a_c_max)) {
522 $data[
"c_max"] = $a_c_max[$combinedId];
524 if (array_key_exists($combinedId, $a_c_min)) {
525 $data[
"c_min"] = $a_c_min[$combinedId];
527 if (array_key_exists($combinedId, $a_c_raw)) {
528 $data[
"c_raw"] = $a_c_raw[$combinedId];
530 if (array_key_exists($combinedId, $a_status)) {
531 $data[
"ostatus"] = $a_status[$combinedId];
545 $lng->loadLanguageModule(
"scormtrac");
550 $a_cols=explode(
',',
'LearningModuleId,LearningModuleTitle,LearningModuleVersion,' . $udh[
"cols"]
551 .
',status,Percentage,Attempts,existingSCOs,startedSCOs,completedSCOs,passedSCOs,roundedTotal_timeSeconds,offline_mode,last_access');
552 $a_true=explode(
',', $udh[
"default"] .
",LearningModuleTitle,status,Percentage,Attempts");
554 for (
$i=0;
$i<count($a_cols);
$i++) {
555 $cols[$a_cols[
$i]] = array(
"txt" =>
$lng->txt($a_cols[
$i]),
"default" =>
false);
557 for (
$i=0;
$i<count($a_true);
$i++) {
558 $cols[$a_true[
$i]][
"default"] =
true;
563 public function exportSelectedSuccessRows($a_user = array(), $allowExportPrivacy=
false, $dbdata = array(), $scoCounter, $u_startedSCO, $u_completedSCO, $u_passedSCO, $obj_id)
566 foreach ($dbdata as
$data) {
568 $dat[
"LearningModuleId"] = $obj_id;
569 $dat[
"LearningModuleTitle"] =
"" . $this->lmTitle;
570 $dat[
"LearningModuleVersion"]=
"" .
$data[
"module_version"];
572 $dat=array_merge($dat, self::userDataArrayForExport(
$data[
"user_id"], $allowExportPrivacy));
574 $dat[
"status"]=
"" .
$data[
"status"];
575 $dat[
"Percentage"]=
"" .
$data[
"percentage_completed"];
576 $dat[
"Attempts"]=
"" .
$data[
"package_attempts"];
577 $dat[
"existingSCOs"]=
"" . $scoCounter;
578 $dat[
"startedSCOs"]=
"" . $u_startedSCO[
$data[
"user_id"]];
579 $dat[
"completedSCOs"]=
"" . $u_completedSCO[
$data[
"user_id"]];
580 $dat[
"passedSCOs"]=
"" . $u_passedSCO[
$data[
"user_id"]];
581 $dat[
"roundedTotal_timeSeconds"]=
"" .
$data[
"sco_total_time_sec"];
582 if (is_null(
$data[
"offline_mode"])) {
583 $dat[
"offline_mode"]=
"";
585 $dat[
"offline_mode"]=
$data[
"offline_mode"];
587 $dat[
"last_access"]=
"" .
$data[
"last_access"];
598 $query =
'SELECT count(distinct(scorm_object.obj_id)) counter '
599 .
'FROM scorm_object, sc_item, sc_resource '
600 .
'WHERE scorm_object.slm_id = %s '
601 .
'AND scorm_object.obj_id = sc_item.obj_id '
602 .
'AND sc_item.identifierref = sc_resource.import_id '
603 .
'AND (sc_resource.scormtype = %s OR sc_resource.scormtype is null)';
606 array(
'integer',
'text'),
610 $scoCounter =
$row[
'counter'];
614 $u_startedSCO = array();
615 $u_completedSCO = array();
616 $u_passedSCO = array();
617 for (
$i=0;
$i<count($a_user);
$i++) {
618 $u_startedSCO[$a_user[
$i]] = 0;
619 $u_completedSCO[$a_user[
$i]] = 0;
620 $u_passedSCO[$a_user[
$i]] = 0;
623 $query =
'SELECT user_id, count(distinct(SCO_ID)) counter '
624 .
'FROM scorm_tracking '
625 .
'WHERE obj_id = %s '
627 .
'AND ' .
$ilDB->in(
'user_id', $a_user,
false,
'integer') .
' '
628 .
'GROUP BY user_id';
635 $u_startedSCO[
$data[
'user_id']] =
$data[
'counter'];
638 $query =
'SELECT user_id, count(*) counter '
639 .
'FROM scorm_tracking '
640 .
'WHERE obj_id = %s AND lvalue = %s AND rvalue like %s '
641 .
'AND ' .
$ilDB->in(
'user_id', $a_user,
false,
'integer') .
' '
642 .
'GROUP BY user_id';
645 array(
'integer',
'text',
'text'),
646 array($obj_id,
'cmi.core.lesson_status',
'completed')
649 $u_completedSCO[
$data[
'user_id']] =
$data[
'counter'];
654 array(
'integer',
'text',
'text'),
655 array($obj_id,
'cmi.core.lesson_status',
'passed')
658 $u_passedSCO[
$data[
'user_id']] =
$data[
'counter'];
663 $query =
'SELECT * FROM sahs_user WHERE obj_id = ' .
$ilDB->quote($obj_id,
'integer')
664 .
' AND ' .
$ilDB->in(
'user_id', $a_user,
false,
'integer')
665 .
' ORDER BY user_id';
671 return $this->
exportSelectedSuccessRows($a_user, $allowExportPrivacy, $dbdata, $scoCounter, $u_startedSCO, $u_completedSCO, $u_passedSCO, $obj_id);
676 include_once(
'./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
678 $allowExportPrivacy = $privacy->enabledExportSCORM();
679 $returnData = array();
680 if ($allowExportPrivacy ==
true) {
681 $returnData[
"cols"] =
'login,user,email,department';
683 $returnData[
"cols"] =
'user';
685 $returnData[
"default"] =
'user';
695 $tarr = explode(
":", $a_time);
697 if (count($tarr) != 3 || is_nan($tarr[0]) || is_nan($tarr[1]) || is_nan($tarr[2])) {
700 $csec = (int) $tarr[0] * 360000 + (
int) $tarr[1] * 6000 + $tarr[2] * 100;
701 return round($csec/100);
An exception for terminatinating execution or to throw for unit testing.
static getInstance($a_obj_id)
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _getInstance()
Get instance of ilPrivacySettings.
Class ilSCORMTrackingItems.
static exportSelectedSuccessColumns()
scoTitlesForExportSelected($obj_id)
static exportSelectedObjectivesColumns()
getScormTrackingValueForInteractionsOrObjectives($obj_id, $a_user=array(), $a_sco=array(), $lvalue, $counter, $topic)
static exportSelectedRawColumns()
SCORMTimeToSeconds($a_time)
static userDataHeaderForExport()
exportSelectedCore($a_user=array(), $a_sco=array(), $b_orderBySCO=false, $allowExportPrivacy=false, $obj_id)
static exportSelectedCoreColumns($b_orderBySCO, $b_allowExportPrivacy)
exportSelectedSuccessRows($a_user=array(), $allowExportPrivacy=false, $dbdata=array(), $scoCounter, $u_startedSCO, $u_completedSCO, $u_passedSCO, $obj_id)
exportSelectedObjectives($a_user=array(), $a_sco=array(), $b_orderBySCO=false, $allowExportPrivacy=false, $obj_id)
static exportSelectedInteractionsColumns()
exportSelectedSuccess($a_user=array(), $allowExportPrivacy=false, $obj_id)
static userDataArrayForExport($user, $b_allowExportPrivacy=false)
exportSelectedInteractions($a_user=array(), $a_sco=array(), $b_orderBySCO=false, $allowExportPrivacy=false, $obj_id)
markedLearningStatusForExportSelected($a_scos, $obj_id)
exportSelectedRaw($a_user=array(), $a_sco=array(), $b_orderBySCO=false, $allowExportPrivacy=false, $obj_id)
getScormTrackingValue($obj_id, $a_user=array(), $a_sco=array(), $a_empty=array(), $lvalue)
foreach($_POST as $key=> $value) $res