18 if (
sizeof($obj_refs)) {
19 $obj_ids = array_keys($obj_refs);
22 include_once
"Services/Object/classes/class.ilObjectLP.php";
23 include_once
"Services/Tracking/classes/class.ilLPStatus.php";
26 include_once
'Modules/Course/classes/class.ilObjCourse.php';
27 $view_modes = array();
28 $query =
"SELECT obj_id, view_mode FROM crs_settings" .
29 " WHERE " .
$ilDB->in(
"obj_id", $obj_ids,
false,
"integer");
31 while ($rec =
$ilDB->fetchAssoc($set)) {
32 $view_modes[(int) $rec[
"obj_id"]] = (
int) $rec[
"view_mode"];
38 " status_changed, percentage, read_count+childs_read_count AS read_count, spent_seconds+childs_spent_seconds AS spent_seconds," .
39 " u_mode, type, visits, mark, u_comment" .
41 " LEFT JOIN ut_lp_settings ON (ut_lp_settings.obj_id = object_data.obj_id)" .
42 " LEFT JOIN read_event ON (read_event.obj_id = object_data.obj_id AND read_event.usr_id = " .
$ilDB->quote($a_user_id,
"integer") .
")" .
43 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.obj_id = object_data.obj_id AND ut_lp_marks.usr_id = " .
$ilDB->quote($a_user_id,
"integer") .
")" .
45 " WHERE " .
$ilDB->in(
"object_data.obj_id", $obj_ids,
false,
"integer") .
49 while ($rec =
$ilDB->fetchAssoc($set)) {
50 $rec[
"comment"] = $rec[
"u_comment"];
51 unset($rec[
"u_comment"]);
53 $rec[
"ref_ids"] = $obj_refs[(int) $rec[
"obj_id"]];
54 $rec[
"status"] = (int) $rec[
"status"];
55 $rec[
"percentage"] = (int) $rec[
"percentage"];
56 $rec[
"read_count"] = (int) $rec[
"read_count"];
57 $rec[
"spent_seconds"] = (int) $rec[
"spent_seconds"];
58 $rec[
"u_mode"] = (int) $rec[
"u_mode"];
60 if ($rec[
"type"] ==
"sess") {
61 $session = $sessions[$rec[
"obj_id"]];
69 } elseif (!$rec[
"u_mode"]) {
71 $rec[
"u_mode"] = $olp->getCurrentMode();
87 include_once
"Modules/Course/classes/Objectives/class.ilLOUserResults.php";
90 $query =
"SELECT crs_id, crs_objectives.objective_id AS obj_id, title," .
$ilDB->quote(
"lobj",
"text") .
" AS type" .
91 " FROM crs_objectives" .
92 " WHERE " .
$ilDB->in(
"crs_objectives.objective_id", $a_objective_ids,
false,
"integer") .
93 " AND active = " .
$ilDB->quote(1,
"integer") .
97 while ($rec =
$ilDB->fetchAssoc($set)) {
98 if (array_key_exists($rec[
"obj_id"], $lo_lp_status)) {
99 $rec[
"status"] = $lo_lp_status[$rec[
"obj_id"]];
114 $scores_raw = $scores = array();
115 include_once
'./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
121 include_once
'./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
123 $scores_raw =
$module->getTrackingDataAgg($a_user_id);
127 include_once
'./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php';
129 $scores_raw =
$module->getTrackingDataAgg($a_user_id);
133 foreach ($scores_raw as $item) {
134 $scores[$item[
"sco_id"]] = $item[
"score"];
140 include_once
'Services/Tracking/classes/class.ilLPStatusWrapper.php';
144 foreach ($a_sco_ids as $sco_id) {
146 if (in_array($a_user_id, $status_info[
"failed"][$sco_id])) {
148 } elseif (in_array($a_user_id, $status_info[
"completed"][$sco_id])) {
150 } elseif (in_array($a_user_id, $status_info[
"in_progress"][$sco_id])) {
156 $items[$sco_id] = array(
157 "title" => $status_info[
"scos_title"][$sco_id],
160 "score" => (
int) $scores[$sco_id]
181 include_once
'./Services/Object/classes/class.ilObjectLP.php';
183 $collection = $olp->getCollectionInstance();
186 $ref_id = end($ref_ids);
187 $item_data = $collection->getPossibleItems($ref_id);
195 include_once
'Services/Tracking/classes/class.ilLPStatusWrapper.php';
199 foreach ($a_item_ids as $item_id) {
200 if (!isset($item_data[$item_id])) {
204 if (in_array($a_user_id, $status_info[
"completed"][$item_id])) {
206 } elseif (in_array($a_user_id, $status_info[
"in_progress"][$item_id])) {
212 $items[$item_id] = array(
213 "title" => $item_data[$item_id][
"title"],
215 "type" => self::getSubItemType($a_parent_obj_id)
242 array $a_filters =
null,
243 array $a_additional_fields =
null,
244 $check_agreement =
false,
245 $privacy_fields =
null
249 $fields = array(
"usr_data.usr_id",
"login",
"active");
253 $where[] =
"usr_data.usr_id <> " .
$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
262 if (is_array($a_users)) {
264 $where[] =
$ilDB->in(
"usr_data.usr_id", $a_users,
false,
"integer");
267 $query =
" FROM usr_data " . $left .
" JOIN read_event ON (read_event.usr_id = usr_data.usr_id" .
268 " AND read_event.obj_id = " .
$ilDB->quote($obj_id,
"integer") .
")" .
269 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id " .
270 " AND ut_lp_marks.obj_id = " .
$ilDB->quote($obj_id,
"integer") .
")" .
271 " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = " .
$ilDB->quote(
"language",
"text") .
")" .
274 $queries = array(array(
"fields"=>$fields,
"query"=>
$query));
277 if ($a_order_field ==
"language") {
278 $a_order_field =
"usr_pref.value";
283 if (!$a_order_field) {
284 $a_order_field =
"login";
285 } elseif (substr($a_order_field, 0, 4) ==
"udf_") {
286 $udf_order = $a_order_field;
287 $a_order_field =
null;
297 include_once
"Services/Utilities/classes/class.ilStr.php";
320 $a_check_agreement =
null,
321 array $a_privacy_fields =
null,
322 array $a_filters =
null
326 if (!$a_result[
"cnt"]) {
330 if (is_array($a_udf) && count($a_udf) > 0) {
331 $query =
"SELECT usr_id, field_id, value FROM udf_text WHERE " .
$ilDB->in(
"field_id", $a_udf,
false,
"integer");
335 $udf[
$row[
"usr_id"]][
"udf_" .
$row[
"field_id"]] =
$row[
"value"];
340 if ($a_check_agreement) {
342 include_once
"Services/Membership/classes/class.ilMemberAgreement.php";
346 $query =
"SELECT usr_id FROM usr_pref WHERE keyword = " .
$ilDB->quote(
"public_profile",
"text") .
347 " AND value = " .
$ilDB->quote(
"y",
"text") .
" OR value = " .
$ilDB->quote(
"g",
"text");
349 $all_public = array();
351 $all_public[] =
$row[
"usr_id"];
353 $query =
"SELECT usr_id,keyword FROM usr_pref WHERE " .
$ilDB->like(
"keyword",
"text",
"public_%",
false) .
354 " AND value = " .
$ilDB->quote(
"y",
"text") .
" AND " .
$ilDB->in(
"usr_id", $all_public,
"",
"integer");
358 $public[
$row[
"usr_id"]][] = substr(
$row[
"keyword"], 7);
363 foreach ($a_result[
"set"] as $idx =>
$row) {
365 if (isset($udf[
$row[
"usr_id"]])) {
366 $a_result[
"set"][$idx] =
$row = array_merge(
$row, $udf[
$row[
"usr_id"]]);
370 if (
sizeof($a_privacy_fields) && $a_check_agreement && !in_array(
$row[
"usr_id"], $agreements)) {
371 foreach ($a_privacy_fields as $field) {
373 if (isset(
$row[$field]) && (!isset($public[
$row[
"usr_id"]]) ||
374 !in_array($field, $public[
$row[
"usr_id"]]))) {
376 if (isset($a_filters[$field])) {
378 foreach (array_keys(
$row) as $col_id) {
379 $a_result[
"set"][$idx][$col_id] =
null;
381 $a_result[
"set"][$idx][
"privacy_conflict"] =
true;
387 $a_result[
"set"][$idx][$field] =
false;
420 array $a_filters =
null,
421 array $a_additional_fields =
null,
422 $use_collection =
true
426 $fields = array(
"object_data.obj_id",
"title",
"type");
429 $objects =
self::getObjectIds($a_parent_obj_id, $a_parent_ref_id, $use_collection,
true, array($a_user_id));
431 $query =
" FROM object_data LEFT JOIN read_event ON (object_data.obj_id = read_event.obj_id AND" .
432 " read_event.usr_id = " .
$ilDB->quote($a_user_id,
"integer") .
")" .
433 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = " .
$ilDB->quote($a_user_id,
"integer") .
" AND" .
434 " ut_lp_marks.obj_id = object_data.obj_id)" .
435 " WHERE " .
$ilDB->in(
"object_data.obj_id", $objects[
"object_ids"],
false,
"integer") .
439 $queries[] = array(
"fields"=>$fields,
"query"=>
$query);
441 if (!in_array($a_order_field, $fields)) {
442 $a_order_field =
"title";
450 foreach (
$result[
"set"] as $idx => $item) {
451 if ($item[
"type"] ==
"sess") {
452 $session = $sessions[$item[
"obj_id"]];
458 $result[
"set"][$idx][
"ref_id"] = $objects[
"ref_ids"][$item[
"obj_id"]];
462 if ($objects[
"scorm"]) {
463 include_once(
"./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
465 if ($subtype ==
"scorm2004") {
466 include_once(
"./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
468 $scos_tracking = $sobj->getTrackingDataAgg($a_user_id,
true);
470 include_once(
"./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php");
472 $scos_tracking = array();
473 foreach ($sobj->getTrackingDataAgg($a_user_id) as $item) {
476 $time = explode(
":", $item[
"time"]);
479 $scos_tracking[$item[
"sco_id"]] = array(
"session_time"=>$item[
"time"]);
483 foreach ($objects[
"scorm"][
"scos"] as $sco) {
484 $row = array(
"title" => $objects[
"scorm"][
"scos_title"][$sco],
488 if (in_array($a_user_id, $objects[
"scorm"][
"completed"][$sco])) {
490 } elseif (in_array($a_user_id, $objects[
"scorm"][
"failed"][$sco])) {
492 } elseif (in_array($a_user_id, $objects[
"scorm"][
"in_progress"][$sco])) {
495 $row[
"status"] = $status;
498 if (isset($scos_tracking[$sco])) {
499 if (isset($scos_tracking[$sco][
"last_access"])) {
503 $row[
"spent_seconds"] = $scos_tracking[$sco][
"session_time"];
512 if ($objects[
"objectives_parent_id"]) {
513 include_once
"Modules/Course/classes/class.ilCourseObjective.php";
514 include_once
"Modules/Course/classes/Objectives/class.ilLOUserResults.php";
516 foreach (self::getObjectivesStatusForUser($a_user_id, $objects[
"objectives_parent_id"], $objtv_ids) as $item) {
523 if ($objects[
"subitems"]) {
525 foreach ($objects[
"subitems"][
"items"] as $item_id) {
526 $row = array(
"title" => $objects[
"subitems"][
"item_titles"][$item_id],
527 "type" => $sub_type);
530 if (in_array($a_user_id, $objects[
"subitems"][
"completed"][$item_id])) {
533 $row[
"status"] = $status;
570 $query =
"SELECT obj_id, title, e_start, e_end, CASE WHEN participated = 1 THEN 2 WHEN registered = 1 THEN 1 ELSE NULL END AS status," .
573 " JOIN event_appointment ON (event.obj_id = event_appointment.event_id)" .
574 " LEFT JOIN event_participants ON (event_participants.event_id = event.obj_id AND usr_id = " .
$ilDB->quote($a_user_id,
"integer") .
")" .
575 " WHERE " .
$ilDB->in(
"obj_id", $obj_ids,
false,
"integer");
578 while ($rec =
$ilDB->fetchAssoc($set)) {
579 $rec[
"comment"] = $rec[
"e_comment"];
580 unset($rec[
"e_comment"]);
588 $rec[
"title"] = $date .
': ' . $rec[
"title"];
590 $rec[
"title"] = $date;
592 $sessions[$rec[
"obj_id"]] = $rec;
620 array $a_filters =
null,
621 array $a_additional_fields =
null,
622 $a_preselected_obj_ids =
null
630 if ($a_preselected_obj_ids ===
null) {
633 foreach ($a_preselected_obj_ids as $obj_id => $ref_ids) {
634 $objects[
"object_ids"][] = $obj_id;
635 $objects[
"ref_ids"][$obj_id] = array_pop($ref_ids);
642 $set =
$ilDB->query(
"SELECT obj_id,title,type FROM object_data" .
643 " WHERE " .
$ilDB->in(
"obj_id", $objects[
"object_ids"],
false,
"integer"));
644 while ($rec =
$ilDB->fetchAssoc($set)) {
645 $object_data[$rec[
"obj_id"]] = $rec;
646 if ($a_preselected_obj_ids) {
647 $object_data[$rec[
"obj_id"]][
"ref_ids"] = $a_preselected_obj_ids[$rec[
"obj_id"]];
649 $object_data[$rec[
"obj_id"]][
"ref_ids"] = array($objects[
"ref_ids"][$rec[
"obj_id"]]);
653 foreach ($objects[
"ref_ids"] as $object_id => $ref_id) {
655 if (
sizeof($object_result)) {
656 if ($object_data[$object_id]) {
657 $result[] = array_merge($object_data[$object_id], $object_result);
663 if ($objects[
"objectives_parent_id"]) {
683 $where[] =
"usr_data.usr_id <> " .
$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
689 if (is_array($a_users)) {
691 $where[] =
$ilDB->in(
"usr_data.usr_id", $a_users,
false,
"integer");
697 $query =
" FROM usr_data " . $left .
" JOIN read_event ON (read_event.usr_id = usr_data.usr_id" .
698 " AND obj_id = " .
$ilDB->quote($obj_id,
"integer") .
")" .
699 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id " .
700 " AND ut_lp_marks.obj_id = " .
$ilDB->quote($obj_id,
"integer") .
")" .
701 " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = " .
$ilDB->quote(
"language",
"text") .
")" .
704 $fields[] =
'COUNT(usr_data.usr_id) AS user_count';
707 $queries[] = array(
"fields"=>$fields,
"query"=>
$query,
"count"=>
"*");
711 $users_no =
$result[
"user_count"];
716 } elseif (isset($a_filters[
"user_total"])) {
717 if ($a_filters[
"user_total"][
"from"] && $users_no < $a_filters[
"user_total"][
"from"]) {
719 } elseif ($a_filters[
"user_total"][
"to"] && $users_no > $a_filters[
"user_total"][
"to"]) {
737 $result[
"user_total"] = $users_no;
756 $field_alias = $field;
758 $field_alias = $alias;
759 $alias =
" AS " . $alias;
764 if (preg_match(
"/" . preg_quote(
" [[--HAVING") .
"(.+)" . preg_quote(
"HAVING--]]") .
"/", $base_query, $hits)) {
765 $having =
" HAVING " . $hits[1];
766 $base_query = str_replace($hits[0],
"", $base_query);
769 $query =
"SELECT COUNT(*) AS counter, " . $field . $alias .
" " . $base_query .
" GROUP BY " . $field . $having .
" ORDER BY counter DESC";
772 while ($rec =
$ilDB->fetchAssoc($set)) {
773 $result[$rec[$field_alias]] = (int) $rec[
"counter"];
794 $members_read =
false;
798 $members_read =
true;
800 $members = $member_obj->getMembers();
808 $members_read =
true;
809 include_once(
"Modules/IndividualAssessment/classes/class.ilObjIndividualAssessment.php");
811 $members = $iass->loadMembers()->membersIds();
816 $path = $tree->getPathId($a_ref_id);
818 foreach (array_reverse(
$path) as $path_ref_id) {
821 $members_read =
true;
830 return $GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
831 'read_learning_progress',
832 'read_learning_progress',
843 include_once(
"./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
845 if ($subtype ==
"scorm2004") {
847 include_once(
"./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
849 $all = $mod->getTrackedUsers(
"");
852 foreach ($all as $item) {
853 $a_users[] = $item[
"user_id"];
857 include_once(
"./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php");
863 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
864 include_once(
"./Modules/Exercise/classes/class.ilObjExercise.php");
867 $a_users = $members->getMembers();
871 include_once
"Services/Tracking/classes/class.ilLPStatusFactory.php";
873 $a_users = $class::getParticipants($obj_id);
877 include_once
"Services/Tracking/classes/class.ilLPStatusFactory.php";
879 $a_users = $class::getParticipants($obj_id);
883 include_once(
"Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
885 $a_users = $prg->getIdsOfUsersWithRelevantProgress();
892 if (is_null($a_users)) {
897 return $GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
898 'read_learning_progress',
899 'read_learning_progress',
913 protected static function buildFilters(array $where, array $a_filters =
null, $a_aggregate =
false)
919 if (is_array($a_filters) &&
sizeof($a_filters) > 0) {
920 foreach ($a_filters as
$id => $value) {
929 case "matriculation":
933 $where[] =
$ilDB->like(
"usr_data." .
$id,
"text",
"%" . $value .
"%");
939 $where[] =
"usr_data." .
$id .
" = " .
$ilDB->quote($value,
"text");
943 $where[] =
$ilDB->like(
"ut_lp_marks." .
$id,
"text",
"%" . $value .
"%");
950 " OR ut_lp_marks.status IS NULL)";
957 $where[] =
"ut_lp_marks." .
$id .
" = " .
$ilDB->quote($value,
"text");
962 if ($value[
"from"]) {
963 $where[] =
"ut_lp_marks." .
$id .
" >= " .
$ilDB->quote($value[
"from"],
"integer");
966 $where[] =
"(ut_lp_marks." .
$id .
" <= " .
$ilDB->quote($value[
"to"],
"integer") .
967 " OR ut_lp_marks." .
$id .
" IS NULL)";
970 if ($value[
"from"]) {
971 $having[] =
"ROUND(AVG(ut_lp_marks." .
$id .
")) >= " .
$ilDB->quote($value[
"from"],
"integer");
974 $having[] =
"ROUND(AVG(ut_lp_marks." .
$id .
")) <= " .
$ilDB->quote($value[
"to"],
"integer");
980 $where[] =
"usr_pref.value = " .
$ilDB->quote($value,
"text");
985 if ($value[
"from"]) {
986 $value[
"from"] = substr($value[
"from"], 0, -2) .
"00";
991 if (strlen($value[
"to"]) == 19) {
992 $value[
"to"] = substr($value[
"to"], 0, -2) .
"59";
1000 case 'status_changed':
1003 case "registration":
1004 if (
$id ==
"registration") {
1005 $id =
"create_date";
1011 case "first_access":
1013 if ($value[
"from"]) {
1014 $where[] =
$id .
" >= " .
$ilDB->quote($value[
"from"],
"date");
1017 if (strlen($value[
"to"]) == 19) {
1018 $value[
"to"] = substr($value[
"to"], 0, -2) .
"59";
1020 $where[] =
$id .
" <= " .
$ilDB->quote($value[
"to"],
"date");
1025 if (!$a_aggregate) {
1026 if ($value[
"from"]) {
1027 $where[] =
"(read_event." .
$id .
"+read_event.childs_" .
$id .
") >= " .
$ilDB->quote($value[
"from"],
"integer");
1030 $where[] =
"((read_event." .
$id .
"+read_event.childs_" .
$id .
") <= " .
$ilDB->quote($value[
"to"],
"integer") .
1031 " OR (read_event." .
$id .
"+read_event.childs_" .
$id .
") IS NULL)";
1034 if ($value[
"from"]) {
1035 $having[] =
"SUM(read_event." .
$id .
"+read_event.childs_" .
$id .
") >= " .
$ilDB->quote($value[
"from"],
"integer");
1038 $having[] =
"SUM(read_event." .
$id .
"+read_event.childs_" .
$id .
") <= " .
$ilDB->quote($value[
"to"],
"integer");
1043 case "spent_seconds":
1044 if (!$a_aggregate) {
1045 if ($value[
"from"]) {
1046 $where[] =
"(read_event." .
$id .
"+read_event.childs_" .
$id .
") >= " .
$ilDB->quote($value[
"from"],
"integer");
1049 $where[] =
"((read_event." .
$id .
"+read_event.childs_" .
$id .
") <= " .
$ilDB->quote($value[
"to"],
"integer") .
1050 " OR (read_event." .
$id .
"+read_event.childs_" .
$id .
") IS NULL)";
1053 if ($value[
"from"]) {
1054 $having[] =
"ROUND(AVG(read_event." .
$id .
"+read_event.childs_" .
$id .
")) >= " .
$ilDB->quote($value[
"from"],
"integer");
1057 $having[] =
"ROUND(AVG(read_event." .
$id .
"+read_event.childs_" .
$id .
")) <= " .
$ilDB->quote($value[
"to"],
"integer");
1070 if (
sizeof($where)) {
1071 $sql .=
" WHERE " . implode(
" AND ", $where);
1073 if (
sizeof($having)) {
1075 $sql .=
" [[--HAVING " . implode(
" AND ", $having) .
"HAVING--]]";
1089 protected static function buildColumns(array &$a_fields, array $a_additional_fields =
null, $a_aggregate =
false)
1091 if (
sizeof($a_additional_fields)) {
1093 foreach ($a_additional_fields as $field) {
1094 if (substr($field, 0, 4) !=
"udf_") {
1097 $pos = strrpos($field,
"_");
1098 if ($pos ===
false) {
1101 $function = strtoupper(substr($field, $pos+1));
1102 $field = substr($field, 0, $pos);
1103 if (!in_array(
$function, array(
"MIN",
"MAX",
"SUM",
"AVG",
"COUNT"))) {
1116 $a_fields[] =
"value as " . $field;
1121 case "spent_seconds":
1123 $a_fields[] =
"(" . $field .
"+childs_" . $field .
") " . $field;
1126 $a_fields[] =
"ROUND(AVG(" . $field .
"+childs_" . $field .
"), 2) " . $field .
"_" . strtolower(
$function);
1128 $a_fields[] =
$function .
"(COALESCE(" . $field .
", 0) + COALESCE(childs_" . $field .
", 0)) " . $field .
"_" . strtolower(
$function);
1133 case "read_count_spent_seconds":
1135 $a_fields[] =
"ROUND(AVG((spent_seconds+childs_spent_seconds)/(read_count+childs_read_count)), 2) " . $field .
"_" . strtolower(
$function);
1142 $a_fields[] =
"ROUND(AVG(" . $field .
"), 2) " . $field .
"_" . strtolower(
$function);
1144 $a_fields[] =
$function .
"(" . $field .
") " . $field .
"_" . strtolower(
$function);
1147 $a_fields[] = $field;
1152 $udf[] = substr($field, 4);
1157 $a_fields = array_unique($a_fields);
1158 if (is_array($udf)) {
1159 $udf = array_unique($udf);
1176 public static function getObjectIds($a_parent_obj_id, $a_parent_ref_id =
false, $use_collection =
true, $a_refresh_status =
true, $a_user_ids =
null)
1178 include_once
"Services/Object/classes/class.ilObjectLP.php";
1180 $object_ids = array($a_parent_obj_id);
1181 $ref_ids = array($a_parent_obj_id => $a_parent_ref_id);
1182 $objectives_parent_id = $scorm = $subitems =
false;
1185 $mode = $olp->getCurrentMode();
1189 include_once
"Services/Tracking/classes/class.ilLPStatusFactory.php";
1191 $scorm = $status_scorm::_getStatusInfo($a_parent_obj_id);
1196 $objectives_parent_id = $a_parent_obj_id;
1203 include_once
"Services/Tracking/classes/class.ilLPStatusFactory.php";
1205 $subitems = $status_coll_tlt::_getStatusInfo($a_parent_obj_id);
1210 if ($use_collection) {
1211 $collection = $olp->getCollectionInstance();
1213 foreach ($collection->getItems() as $child_ref_id) {
1215 $object_ids[] = $child_id;
1216 $ref_ids[$child_id] = $child_ref_id;
1223 $object_ids = array_unique($object_ids);
1226 foreach ($object_ids as $idx => $object_id) {
1228 unset($object_ids[$idx]);
1234 if ($a_refresh_status) {
1238 return array(
"object_ids" => $object_ids,
1239 "ref_ids" => $ref_ids,
1240 "objectives_parent_id" => $objectives_parent_id,
1242 "subitems" => $subitems);
1252 protected static function getSubTree($a_parent_ref_id, array &$a_object_ids, array &$a_ref_ids)
1256 $children = $tree->getChilds($a_parent_ref_id);
1258 foreach ($children as $child) {
1259 if ($child[
"type"] ==
"adm" || $child[
"type"] ==
"rolf") {
1267 $cmode = $olp->getCurrentMode();
1283 $a_object_ids[] = $child[
"obj_id"];
1284 $a_ref_ids[$child[
"obj_id"]] = $child[
"ref_id"];
1302 public static function executeQueries(array $queries, $a_order_field =
"", $a_order_dir =
"", $a_offset = 0, $a_limit = 9999)
1307 $subqueries = array();
1308 foreach ($queries as $item) {
1310 $item = str_replace(
"[[--HAVING",
"HAVING", $item);
1311 $item = str_replace(
"HAVING--]]",
"", $item);
1313 if (!isset($item[
"count"])) {
1314 $count_field = $item[
"fields"];
1315 $count_field = array_shift($count_field);
1317 $count_field = $item[
"count"];
1319 $count_query =
"SELECT COUNT(" . $count_field .
") AS cnt" . $item[
"query"];
1320 $set =
$ilDB->query($count_query);
1321 if ($rec =
$ilDB->fetchAssoc($set)) {
1322 $cnt += $rec[
"cnt"];
1325 $subqueries[] =
"SELECT " . implode(
",", $item[
"fields"]) . $item[
"query"];
1331 if (
sizeof($subqueries) > 1) {
1332 $base = array_shift($subqueries);
1333 $query =
$base .
" UNION (" . implode(
") UNION (", $subqueries) .
")";
1338 if ($a_order_dir !=
"asc" && $a_order_dir !=
"desc") {
1339 $a_order_dir =
"asc";
1341 if ($a_order_field) {
1342 $query.=
" ORDER BY " . $a_order_field .
" " . strtoupper($a_order_dir);
1345 $offset = (int) $a_offset;
1346 $limit = (int) $a_limit;
1347 $ilDB->setLimit($limit, $offset);
1350 while ($rec =
$ilDB->fetchAssoc($set)) {
1355 return array(
"cnt" => $cnt,
"set" =>
$result);
1372 $a_user_filter =
null,
1373 array $a_additional_fields =
null,
1374 array $a_privacy_fields =
null,
1375 $a_check_agreement =
null
1379 $result = array(
"cnt"=>0,
"set"=>
null);
1380 if (
sizeof($a_obj_ids)) {
1382 $where[] =
"usr_data.usr_id <> " .
$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
1383 if ($a_user_filter) {
1384 $where[] =
$ilDB->like(
"usr_data.login",
"text",
"%" . $a_user_filter .
"%");
1390 if (is_array($a_users)) {
1392 $where[] =
$ilDB->in(
"usr_data.usr_id", $a_users,
false,
"integer");
1398 $fields = array(
"usr_data.usr_id",
"login",
"active");
1401 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
1404 $fields[] =
"percentage";
1407 foreach ($a_obj_ids as $obj_id) {
1409 $query =
" FROM usr_data " . $left .
" JOIN read_event ON (read_event.usr_id = usr_data.usr_id" .
1410 " AND read_event.obj_id = " .
$ilDB->quote($obj_id,
"integer") .
")" .
1411 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id " .
1412 " AND ut_lp_marks.obj_id = " .
$ilDB->quote($obj_id,
"integer") .
")" .
1413 " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = " .
$ilDB->quote(
"language",
"text") .
")" .
1419 foreach ($raw[
"set"] as
$row) {
1425 $result[
"set"][
$row[
"usr_id"]][
"obj_" . $obj_id .
"_perc"] =
$row[
"percentage"];
1427 if ($obj_id == $parent_obj_id) {
1428 $result[
"set"][
$row[
"usr_id"]][
"status_changed"] =
$row[
"status_changed"];
1430 $result[
"set"][
$row[
"usr_id"]][
"spent_seconds"] =
$row[
"spent_seconds"];
1434 foreach ($fields as $field) {
1436 if (stristr($field,
"language")) {
1437 $field =
"language";
1440 if (isset(
$row[$field])) {
1442 if ($obj_id == $parent_obj_id ||
1443 !in_array($field, array(
"mark",
"u_comment"))) {
1453 if (is_array(
$result[
"set"])) {
1467 if ($a_parent_obj_id && $a_users) {
1470 include_once
"Services/Tracking/classes/class.ilLPStatus.php";
1471 include_once
"Modules/Course/classes/Objectives/class.ilLOUserResults.php";
1472 include_once
"Modules/Course/classes/class.ilCourseObjective.php";
1476 include_once
"Modules/Course/classes/Objectives/class.ilLOSettings.php";
1478 $initial_qualifying = $lo_set->isInitialTestQualifying();
1481 foreach ($objective_ids as $objective_id) {
1482 foreach ($a_users as $user_id) {
1487 $query =
"SELECT * FROM loc_user_results" .
1488 " WHERE " .
$ilDB->in(
"objective_id", $objective_ids,
"",
"integer") .
1489 " AND " .
$ilDB->in(
"user_id", $a_users,
"",
"integer");
1490 if (!(
bool) $initial_qualifying) {
1493 $query .=
" ORDER BY type";
1495 while (
$row =
$ilDB->fetchAssoc($set)) {
1496 $objective_id =
$row[
"objective_id"];
1497 $user_id =
$row[
"user_id"];
1505 $res[$user_id][$objective_id] =
$row[
"is_final"]
1519 $obj_ids = array_keys($a_ref_ids);
1528 $sql =
"SELECT obj_id," .
$column .
",SUM(read_count) read_count,SUM(childs_read_count) childs_read_count," .
1529 "SUM(spent_seconds) spent_seconds,SUM(childs_spent_seconds) childs_spent_seconds" .
1531 " WHERE " .
$ilDB->in(
"obj_id", $obj_ids,
"",
"integer") .
1532 " AND yyyy = " .
$ilDB->quote($a_year,
"integer");
1534 $sql .=
" AND mm = " .
$ilDB->quote($a_month,
"integer");
1536 $sql .=
" GROUP BY obj_id," .
$column;
1537 $set =
$ilDB->query($sql);
1538 while (
$row =
$ilDB->fetchAssoc($set)) {
1539 $row[
"read_count"] +=
$row[
"childs_read_count"];
1540 $row[
"spent_seconds"] +=
$row[
"childs_spent_seconds"];
1548 $sql =
"SELECT obj_id," .
$column .
",SUM(counter) counter" .
1549 " FROM obj_user_stat" .
1550 " WHERE " .
$ilDB->in(
"obj_id", $obj_ids,
"",
"integer") .
1551 " AND yyyy = " .
$ilDB->quote($a_year,
"integer");
1553 $sql .=
" AND mm = " .
$ilDB->quote($a_month,
"integer");
1555 $sql .=
" GROUP BY obj_id," .
$column;
1556 $set =
$ilDB->query($sql);
1557 while (
$row =
$ilDB->fetchAssoc($set)) {
1566 global
$ilDB, $objDefinition;
1572 include_once
"Services/Tree/classes/class.ilTree.php";
1574 $sql =
"SELECT " . $tree->table_obj_data .
".obj_id," . $tree->table_obj_data .
".type," .
1575 $tree->table_tree .
"." . $tree->tree_pk .
"," . $tree->table_obj_reference .
".ref_id" .
1576 " FROM " . $tree->table_tree .
1577 " " . $tree->buildJoin() .
1578 " WHERE " .
$ilDB->in($tree->table_obj_data .
".type", $types,
"",
"text");
1579 $set =
$ilDB->query($sql);
1581 while (
$row =
$ilDB->fetchAssoc($set)) {
1583 $res[
$row[
"type"]][
"references"]++;
1585 if (
$row[$tree->tree_pk] < 0) {
1591 $res[
$type][
"objects"] =
sizeof(array_unique($values[
"objects"]));
1595 foreach (self::getPortfolios() as $obj_id) {
1596 $res[
"prtf"][
"type"] =
"prtf";
1597 $res[
"prtf"][
"references"]++;
1598 $res[
"prtf"][
"objects"]++;
1601 foreach (self::getWorkspaceBlogs() as $obj_id) {
1602 $res[
"blog"][
"type"] =
"blog";
1603 $res[
"blog"][
"references"]++;
1604 $res[
"blog"][
"objects"]++;
1617 $sql =
"SELECT od.obj_id,oref.wsp_id,od.type" .
1618 " FROM tree_workspace wst" .
1619 " JOIN object_reference_ws oref ON (oref.wsp_id = wst.child)" .
1620 " JOIN object_data od ON (oref.obj_id = od.obj_id)" .
1621 " WHERE od.type = " .
$ilDB->quote(
"blog",
"text");
1624 $sql .=
" AND " .
$ilDB->like(
"od.title",
"text",
"%" . $a_title .
"%");
1627 $set =
$ilDB->query($sql);
1628 while (
$row =
$ilDB->fetchAssoc($set)) {
1641 $sql =
"SELECT od.obj_id" .
1642 " FROM usr_portfolio prtf" .
1643 " JOIN object_data od ON (od.obj_id = prtf.id)";
1646 $sql .=
" WHERE " .
$ilDB->like(
"od.title",
"text",
"%" . $a_title .
"%");
1649 $set =
$ilDB->query($sql);
1650 while (
$row =
$ilDB->fetchAssoc($set)) {
1661 $obj_ids = array_keys($a_ref_ids);
1664 $sql =
"SELECT obj_id,hh,SUM(read_count) read_count,SUM(childs_read_count) childs_read_count," .
1665 "SUM(spent_seconds) spent_seconds,SUM(childs_spent_seconds) childs_spent_seconds" .
1667 " WHERE " .
$ilDB->in(
"obj_id", $obj_ids,
"",
"integer") .
1668 " AND yyyy = " .
$ilDB->quote($a_year,
"integer");
1670 $sql .=
" AND mm = " .
$ilDB->quote($a_month,
"integer");
1672 $sql .=
" GROUP BY obj_id,hh";
1673 $set =
$ilDB->query($sql);
1674 while (
$row =
$ilDB->fetchAssoc($set)) {
1675 $row[
"read_count"] +=
$row[
"childs_read_count"];
1676 $row[
"spent_seconds"] +=
$row[
"childs_spent_seconds"];
1677 $res[
$row[
"obj_id"]][(int)
$row[
"hh"]][
"read_count"] +=
$row[
"read_count"];
1678 $res[
$row[
"obj_id"]][(int)
$row[
"hh"]][
"spent_seconds"] +=
$row[
"spent_seconds"];
1687 $set =
$ilDB->query(
"SELECT COUNT(*) AS COUNTER,yyyy,mm" .
1689 " GROUP BY yyyy, mm" .
1690 " ORDER BY yyyy DESC, mm DESC");
1692 while (
$row =
$ilDB->fetchAssoc($set)) {
1693 $res[] = array(
"month"=>
$row[
"yyyy"] .
"-" .
$row[
"mm"],
1694 "count"=>
$row[
"counter"]);
1704 $date_compare =
$ilDB->in(
$ilDB->concat(array(array(
"yyyy",
""),
1705 array(
$ilDB->quote(
"-",
"text"),
""),
1706 array(
"mm",
""))), $a_months,
"",
"text");
1707 $sql =
"DELETE FROM obj_stat" .
1708 " WHERE " . $date_compare;
1709 $ilDB->manipulate($sql);
1712 $tables = array(
"obj_lp_stat",
"obj_type_stat",
"obj_user_stat");
1713 foreach ($a_months as $month) {
1714 $year = substr($month, 0, 4);
1715 $month = substr($month, 5);
1716 $from = $year . str_pad($month, 2,
"0", STR_PAD_LEFT) .
"01";
1717 $to = $year . str_pad($month, 2,
"0", STR_PAD_LEFT) .
"31";
1719 foreach ($tables as
$table) {
1720 $sql =
"DELETE FROM " .
$table .
1721 " WHERE fulldate >= " .
$ilDB->quote(
$from,
"integer") .
1722 " AND fulldate <= " .
$ilDB->quote($to,
"integer");
1723 $ilDB->manipulate($sql);
1728 public static function searchObjects(
$a_type, $a_title =
null, $a_root =
null, $a_hidden =
null, $a_preset_obj_ids =
null)
1730 global
$ilDB, $tree;
1733 $a_type = array(
'lm',
'sahs',
'htlm');
1736 $sql =
"SELECT r.ref_id,r.obj_id" .
1737 " FROM object_data o" .
1738 " JOIN object_reference r ON (o.obj_id = r.obj_id)" .
1739 " JOIN tree t ON (t.child = r.ref_id)" .
1740 " WHERE t.tree = " .
$ilDB->quote(1,
"integer");
1743 $sql .=
" AND o.type = " .
$ilDB->quote(
$a_type,
"text");
1745 $sql .=
" AND " .
$ilDB->in(
"o.type",
$a_type,
"",
"text");
1749 $sql .=
" AND (" .
$ilDB->like(
"o.title",
"text",
"%" . $a_title .
"%") .
1750 " OR " .
$ilDB->like(
"o.description",
"text",
"%" . $a_title .
"%") .
")";
1753 if (is_array($a_hidden)) {
1754 $sql .=
" AND " .
$ilDB->in(
"o.obj_id", $a_hidden,
true,
"integer");
1757 if (is_array($a_preset_obj_ids)) {
1758 $sql .=
" AND " .
$ilDB->in(
"o.obj_id", $a_preset_obj_ids,
false,
"integer");
1761 $set =
$ilDB->query($sql);
1763 while (
$row =
$ilDB->fetchAssoc($set)) {
1764 if ($a_root && $a_root != ROOT_FOLDER_ID) {
1766 if ($tree->isGrandChild($a_root, $ref_id)) {
1786 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
1787 foreach ($a_obj_ids as $obj_id) {
1801 $set =
$ilDB->query(
"SELECT COUNT(*) counter, MIN(tstamp) tstamp" .
1802 " FROM obj_stat_log");
1803 return $ilDB->fetchAssoc($set);
1810 if ($a_group_by_day) {
1817 $sql =
"SELECT obj_id," .
$column .
"," .
1818 "MIN(mem_cnt) mem_cnt_min,AVG(mem_cnt) mem_cnt_avg, MAX(mem_cnt) mem_cnt_max," .
1819 "MIN(in_progress) in_progress_min,AVG(in_progress) in_progress_avg,MAX(in_progress) in_progress_max," .
1820 "MIN(completed) completed_min,AVG(completed) completed_avg,MAX(completed) completed_max," .
1821 "MIN(failed) failed_min,AVG(failed) failed_avg,MAX(failed) failed_max," .
1822 "MIN(not_attempted) not_attempted_min,AVG(not_attempted) not_attempted_avg,MAX(not_attempted) not_attempted_max" .
1823 " FROM obj_lp_stat" .
1824 " WHERE " .
$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer") .
1825 " AND yyyy = " .
$ilDB->quote($a_year,
"integer");
1827 $sql .=
" AND mm = " .
$ilDB->quote($a_month,
"integer");
1829 $sql .=
" GROUP BY obj_id," .
$column;
1830 $set =
$ilDB->query($sql);
1831 while (
$row =
$ilDB->fetchAssoc($set)) {
1843 $a_year =
date(
"Y");
1846 $agg = strtoupper($a_aggregation);
1849 $sql =
"SELECT type,yyyy,mm," . $agg .
"(cnt_objects) cnt_objects," . $agg .
"(cnt_references) cnt_references," .
1850 "" . $agg .
"(cnt_deleted) cnt_deleted FROM obj_type_stat" .
1851 " WHERE yyyy = " .
$ilDB->quote($a_year,
"integer") .
1852 " GROUP BY type,yyyy,mm";
1853 $set =
$ilDB->query($sql);
1854 while (
$row =
$ilDB->fetchAssoc($set)) {
1855 $row[
"mm"] = str_pad(
$row[
"mm"], 2,
"0", STR_PAD_LEFT);
1857 "objects" => (
int)
$row[
"cnt_objects"],
1858 "references" => (
int)
$row[
"cnt_references"],
1859 "deleted" => (
int)
$row[
"cnt_deleted"]
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
const IL_CRS_VIEW_OBJECTIVE
static _getObjectiveIds($course_id, $a_activated_only=false)
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
@classDescription Date and time handling
static getInstanceByObjId($a_obj_id)
get singleton instance
static getObjectiveStatusForLP($a_user_id, $a_obj_id, array $a_objective_ids)
const LP_MODE_COLLECTION_TLT
const LP_MODE_SURVEY_FINISHED
const LP_MODE_TEST_FINISHED
const LP_MODE_COLLECTION_MANUAL
const LP_MODE_COLLECTION_MOBS
static _getClassById($a_obj_id, $a_mode=null)
static _getInstance($a_obj_id, $a_mode=null)
static _getStatusInfo($a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_COMPLETED
const LP_STATUS_IN_PROGRESS_NUM
static checkStatusForObject($a_obj_id, $a_users=false)
This function checks whether the status for a given number of users is dirty and must be recalculated...
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_FAILED_NUM
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
static lookupAcceptedAgreements($a_obj_id)
Lookup users who have accepted the agreement.
For the purpose of streamlining the grading and learning-process status definition outside of tests,...
static _lookupSubType($a_obj_id)
lookup subtype id (scorm, )
Class ilObjSCORM2004LearningModule.
Class ilObjSCORMLearningModule.
static _getTrackedUsers($a_obj_id)
Get all tracked users.
Class ilObjStudyProgramme.
static getInstance($a_obj_id)
static _lookupObjId($a_id)
static _lookupObjectId($a_ref_id)
lookup object id
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstance($a_ref_id)
Get instance by ref_id.
static getObjectTypeStatisticsPerMonth($a_aggregation, $a_year=null)
static getObjectDailyStatistics(array $a_ref_ids, $a_year, $a_month=null)
static getObjectsDataForUser( $a_user_id, $a_parent_obj_id, $a_parent_ref_id, $a_order_field="", $a_order_dir="", $a_offset=0, $a_limit=9999, array $a_filters=null, array $a_additional_fields=null, $use_collection=true)
Get all object-based tracking data for user and parent object.
static getObjectivesStatusForUser($a_user_id, $a_obj_id, array $a_objective_ids)
static getUDFAndHandlePrivacy(array &$a_result, array $a_udf=null, $a_check_agreement=null, array $a_privacy_fields=null, array $a_filters=null)
Handle privacy and add udf data to (user) result data.
static getUserObjectMatrix( $a_parent_ref_id, $a_obj_ids, $a_user_filter=null, array $a_additional_fields=null, array $a_privacy_fields=null, $a_check_agreement=null)
Get status matrix for users on objects.
static getUserDataForObject( $a_ref_id, $a_order_field="", $a_order_dir="", $a_offset=0, $a_limit=9999, array $a_filters=null, array $a_additional_fields=null, $check_agreement=false, $privacy_fields=null)
Get all user-based tracking data for object.
static getUserObjectiveMatrix($a_parent_obj_id, $a_users)
static getObjectTypeStatistics()
static getObjectIds($a_parent_obj_id, $a_parent_ref_id=false, $use_collection=true, $a_refresh_status=true, $a_user_ids=null)
Get (sub)objects for given object, also handles learning objectives (course only)
static getSubItemsStatusForUser($a_user_id, $a_parent_obj_id, array $a_item_ids)
Get subitems status.
static getObjectsStatusForUser($a_user_id, array $obj_refs)
static getObjectsSummaryForObject( $a_parent_obj_id, $a_parent_ref_id, $a_order_field="", $a_order_dir="", $a_offset=0, $a_limit=9999, array $a_filters=null, array $a_additional_fields=null, $a_preselected_obj_ids=null)
Get all aggregated tracking data for parent object.
static getObjectStatisticsMonthlySummary()
static refreshObjectsStatus(array $a_obj_ids, $a_users=null)
check whether status (for all relevant users) exists
static getObjectAccessStatistics(array $a_ref_ids, $a_year, $a_month=null)
static getSessionData($a_user_id, array $obj_ids)
Get session data for given objects and user.
static getObjectLPStatistics(array $a_obj_ids, $a_year, $a_month=null, $a_group_by_day=false)
static buildFilters(array $where, array $a_filters=null, $a_aggregate=false)
Build sql from filter definition.
static buildColumns(array &$a_fields, array $a_additional_fields=null, $a_aggregate=false)
Build sql from field definition.
static searchObjects($a_type, $a_title=null, $a_root=null, $a_hidden=null, $a_preset_obj_ids=null)
static getParticipantsForObject($a_ref_id)
Get participant ids for given object.
static getSummaryDataForObject($a_ref_id, array $fields, array $a_filters=null)
Get all aggregated tracking data for object.
static getObjectStatisticsLogInfo()
Get last update info for object statistics.
static getSubItemType($a_parent_obj_id)
Get sub-item object type for parent.
static getWorkspaceBlogs($a_title=null)
static getSummaryPercentages($field, $base_query, $alias=null)
Get aggregated data for field.
static getSCOsStatusForUser($a_user_id, $a_parent_obj_id, array $a_sco_ids)
static getPortfolios($a_title=null)
static getSubTree($a_parent_ref_id, array &$a_object_ids, array &$a_ref_ids)
Get complete branch of tree (recursively)
static executeQueries(array $queries, $a_order_field="", $a_order_dir="", $a_offset=0, $a_limit=9999)
Execute given queries, including count query.
static deleteObjectStatistics(array $a_months)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static stableSortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false)
Sort an aray using a stable sort algorithm, which preveserves the sequence of array elements which ha...
if(!array_key_exists('StateId', $_REQUEST)) $id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
if($modEnd===false) $module
if(empty($password)) $table
foreach($_POST as $key=> $value) $res