20 $obj_ids = array_keys($obj_refs);
23 include_once
"Services/Tracking/classes/class.ilLPObjSettings.php";
24 include_once
"Services/Tracking/classes/class.ilLPStatus.php";
27 include_once
'Modules/Course/classes/class.ilObjCourse.php';
28 $view_modes = array();
29 $query =
"SELECT obj_id, view_mode FROM crs_settings".
30 " WHERE ".$ilDB->in(
"obj_id", $obj_ids ,
false,
"integer");
31 $set = $ilDB->query(
$query);
32 while($rec = $ilDB->fetchAssoc($set))
34 $view_modes[(int)$rec[
"obj_id"]] = (
int)$rec[
"view_mode"];
39 $query =
"SELECT object_data.obj_id, title, CASE WHEN status IS NULL THEN ".LP_STATUS_NOT_ATTEMPTED_NUM.
" ELSE status END AS status,".
40 " status_changed, percentage, read_count+childs_read_count AS read_count, spent_seconds+childs_spent_seconds AS spent_seconds,".
41 " u_mode, type, visits, mark, u_comment".
43 " LEFT JOIN ut_lp_settings ON (ut_lp_settings.obj_id = object_data.obj_id)".
44 " LEFT JOIN read_event ON (read_event.obj_id = object_data.obj_id AND read_event.usr_id = ".$ilDB->quote($a_user_id,
"integer").
")".
45 " 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").
")".
47 " WHERE ".$ilDB->in(
"object_data.obj_id", $obj_ids,
false,
"integer").
49 $set = $ilDB->query(
$query);
51 while($rec = $ilDB->fetchAssoc($set))
53 $rec[
"comment"] = $rec[
"u_comment"];
54 unset($rec[
"u_comment"]);
56 $rec[
"ref_ids"] = $obj_refs[(int)$rec[
"obj_id"]];
57 $rec[
"status"] = (int)$rec[
"status"];
58 $rec[
"percentage"] = (int)$rec[
"percentage"];
59 $rec[
"read_count"] = (int)$rec[
"read_count"];
60 $rec[
"spent_seconds"] = (int)$rec[
"spent_seconds"];
61 $rec[
"u_mode"] = (int)$rec[
"u_mode"];
63 if($rec[
"type"] ==
"sess")
65 $session = $sessions[$rec[
"obj_id"]];
66 $rec[
"title"] = $session[
"title"];
75 else if(!$rec[
"u_mode"])
94 $query =
"SELECT crs_id, crs_objectives.objective_id AS obj_id, title, status, ".$ilDB->quote(
"lobj",
"text").
" AS type".
95 " FROM crs_objectives".
96 " LEFT JOIN crs_objective_status ON (crs_objectives.objective_id = crs_objective_status.objective_id AND user_id = ".$a_user_id.
")".
97 " WHERE ".$ilDB->in(
"crs_objectives.objective_id", $a_objective_ids,
false,
"integer").
99 $set = $ilDB->query(
$query);
101 while($rec = $ilDB->fetchAssoc($set))
117 include_once
'Services/Tracking/classes/class.ilLPStatusWrapper.php';
121 foreach($a_sco_ids as $sco_id)
124 if(in_array($a_user_id, $status_info[
"failed"][$sco_id]))
128 elseif(in_array($a_user_id, $status_info[
"completed"][$sco_id]))
132 elseif(in_array($a_user_id, $status_info[
"in_progress"][$sco_id]))
141 $items[$sco_id] = array(
142 "title" => $status_info[
"scos_title"][$sco_id],
155 if(
sizeof($obj_refs))
157 $obj_ids = array_keys($obj_refs);
160 include_once
"Services/Tracking/classes/class.ilLPObjSettings.php";
161 include_once
"Services/Tracking/classes/class.ilLPStatus.php";
164 include_once
'Modules/Course/classes/class.ilObjCourse.php';
165 $view_modes = array();
166 $query =
"SELECT obj_id, view_mode FROM crs_settings".
167 " WHERE ".$ilDB->in(
"obj_id", $obj_ids ,
false,
"integer");
168 $set = $ilDB->query(
$query);
169 while($rec = $ilDB->fetchAssoc($set))
171 $view_modes[(int)$rec[
"obj_id"]] = (
int)$rec[
"view_mode"];
174 $query =
"SELECT object_data.obj_id, title, u_mode, type".
176 " LEFT JOIN ut_lp_settings ON (ut_lp_settings.obj_id = object_data.obj_id)".
178 " AND ".$ilDB->in(
"object_data.obj_id", $obj_ids,
false,
"integer").
179 " GROUP BY object_data.obj_id, title, u_mode, type".
181 $set = $ilDB->query(
$query);
183 while($rec = $ilDB->fetchAssoc($set))
185 $rec[
"ref_ids"] = $obj_refs[(int)$rec[
"obj_id"]];
186 $rec[
"status"] = (int)$rec[
"status"];
187 $rec[
"u_mode"] = (int)$rec[
"u_mode"];
199 else if(!$rec[
"u_mode"])
205 if($rec[
"u_mode"] != LP_MODE_DEACTIVATE)
207 $result[$rec[
"obj_id"]] = $rec;
229 $a_offset = 0, $a_limit = 9999, array $a_filters = NULL, array $a_additional_fields = NULL,
230 $check_agreement =
false, $privacy_fields = NULL)
234 $fields = array(
"usr_data.usr_id",
"login",
"active");
238 $where[] =
"usr_data.usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
247 if (is_array($a_users))
250 $where[] = $ilDB->in(
"usr_data.usr_id", $a_users,
false,
"integer");
253 $query =
" FROM usr_data ".$left.
" JOIN read_event ON (read_event.usr_id = usr_data.usr_id".
254 " AND read_event.obj_id = ".$ilDB->quote($obj_id,
"integer").
")".
255 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id ".
256 " AND ut_lp_marks.obj_id = ".$ilDB->quote($obj_id,
"integer").
")".
257 " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = ".$ilDB->quote(
"language",
"text").
")".
260 $queries = array(array(
"fields"=>$fields,
"query"=>
$query));
266 $a_order_field =
"login";
268 else if(substr($a_order_field, 0, 4) ==
"udf_")
270 $udf_order = $a_order_field;
271 $a_order_field = null;
279 $query =
"SELECT usr_id, field_id, value FROM udf_text WHERE ".$ilDB->in(
"field_id", $udf,
false,
"integer");
280 $set = $ilDB->query(
$query);
282 while(
$row = $ilDB->fetchAssoc($set))
284 $udf[
$row[
"usr_id"]][
"udf_".$row[
"field_id"]] =
$row[
"value"];
292 include_once
"Services/Membership/classes/class.ilMemberAgreement.php";
296 $query =
"SELECT usr_id FROM usr_pref WHERE keyword = ".$ilDB->quote(
"public_profile",
"text").
297 " AND value = ".$ilDB->quote(
"y",
"text").
" OR value = ".$ilDB->quote(
"g",
"text");
298 $set = $ilDB->query(
$query);
299 $all_public = array();
300 while(
$row = $ilDB->fetchAssoc($set))
302 $all_public[] =
$row[
"usr_id"];
304 $query =
"SELECT usr_id,keyword FROM usr_pref WHERE ".$ilDB->like(
"keyword",
"text",
"public_%",
false).
305 " AND value = ".$ilDB->quote(
"y",
"text").
" AND ".$ilDB->in(
"usr_id", $all_public,
"",
"integer");
306 $set = $ilDB->query(
$query);
308 while(
$row = $ilDB->fetchAssoc($set))
310 $public[
$row[
"usr_id"]][] = substr($row[
"keyword"], 7);
318 if(isset($udf[
$row[
"usr_id"]]))
320 $result[
"set"][$idx] = $row = array_merge($row, $udf[$row[
"usr_id"]]);
324 if(
sizeof($privacy_fields) && $check_agreement && !in_array($row[
"usr_id"], $agreements))
326 foreach($privacy_fields as $field)
329 if(isset($row[$field]) && (!isset($public[$row[
"usr_id"]]) ||
330 !in_array($field, $public[$row[
"usr_id"]])))
333 if(isset($a_filters[$field]))
341 $result[
"set"][$idx][$field] =
false;
351 include_once
"Services/Utilities/classes/class.ilStr.php";
353 $udf_order, $a_order_dir);
374 static function getObjectsDataForUser($a_user_id, $a_parent_obj_id, $a_parent_ref_id, $a_order_field =
"", $a_order_dir =
"", $a_offset = 0, $a_limit = 9999,
375 array $a_filters = NULL, array $a_additional_fields = NULL, $use_collection =
true)
379 $fields = array(
"object_data.obj_id",
"title",
"type");
382 $objects =
self::getObjectIds($a_parent_obj_id, $a_parent_ref_id, $use_collection,
true, array($a_user_id));
384 $query =
" FROM object_data LEFT JOIN read_event ON (object_data.obj_id = read_event.obj_id AND".
385 " read_event.usr_id = ".$ilDB->quote($a_user_id,
"integer").
")".
386 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = ".$ilDB->quote($a_user_id,
"integer").
" AND".
387 " ut_lp_marks.obj_id = object_data.obj_id)".
388 " WHERE ".$ilDB->in(
"object_data.obj_id", $objects[
"object_ids"],
false,
"integer").
392 $queries[] = array(
"fields"=>$fields,
"query"=>
$query);
395 if($objects[
"objectives_parent_id"])
397 $objective_fields = array(
"crs_objectives.objective_id AS obj_id",
"title",
398 $ilDB->quote(
"lobj",
"text").
" as type");
400 if (is_array($a_additional_fields))
402 foreach($a_additional_fields as $field)
404 if($field !=
"status")
406 $objective_fields[] =
"NULL AS ".$field;
410 include_once(
"Services/Tracking/classes/class.ilLPStatus.php");
411 $objective_fields[] =
"CASE WHEN status IS NOT NULL THEN ".LP_STATUS_COMPLETED_NUM.
" ELSE NULL END AS status";
417 $where[] =
"crs_objectives.crs_id = ".$ilDB->quote($objects[
"objectives_parent_id"],
"integer");
419 $objectives_query =
" FROM crs_objectives".
420 " LEFT JOIN crs_objective_status ON (crs_objectives.objective_id = crs_objective_status.objective_id".
421 " AND crs_objective_status.user_id = ".$ilDB->quote($a_user_id,
"integer").
")".
424 $queries[] = array(
"fields"=>$objective_fields,
"query"=>$objectives_query,
"count"=>
"crs_objectives.objective_id");
427 if(!in_array($a_order_field, $fields))
429 $a_order_field =
"title";
438 foreach(
$result[
"set"] as $idx => $item)
440 if($item[
"type"] ==
"sess")
442 $session = $sessions[$item[
"obj_id"]];
443 $result[
"set"][$idx][
"title"] = $session[
"title"];
444 $result[
"set"][$idx][
"sort_title"] = $session[
"e_start"];
448 $result[
"set"][$idx][
"ref_id"] = $objects[
"ref_ids"][$item[
"obj_id"]];
452 if($objects[
"scorm"])
454 include_once(
"./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
456 if($subtype ==
"scorm2004")
458 include_once(
"./Modules/Scorm2004/classes/class.ilObjScorm2004LearningModule.php");
460 $scos_tracking = $sobj->getTrackingDataAgg($a_user_id,
true);
464 include_once(
"./Modules/ScormAicc/classes/class.ilObjScormLearningModule.php");
466 $scos_tracking = array();
467 foreach($sobj->getTrackingDataAgg($a_user_id) as $item)
472 $time = explode(
":", $item[
"time"]);
473 $item[
"time"] = $time[0]*60*60+$time[1]*60+$time[2];
475 $scos_tracking[$item[
"sco_id"]] = array(
"session_time"=>$item[
"time"]);
479 foreach($objects[
"scorm"][
"scos"] as $sco)
481 $row = array(
"title" => $objects[
"scorm"][
"scos_title"][$sco],
485 if(in_array($a_user_id, $objects[
"scorm"][
"completed"][$sco]))
489 else if(in_array($a_user_id, $objects[
"scorm"][
"failed"][$sco]))
493 else if(in_array($a_user_id, $objects[
"scorm"][
"in_progress"][$sco]))
497 $row[
"status"] = $status;
500 if(isset($scos_tracking[$sco]))
502 if(isset($scos_tracking[$sco][
"last_access"]))
507 $row[
"spent_seconds"] = $scos_tracking[$sco][
"session_time"];
529 $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,".
532 " JOIN event_appointment ON (event.obj_id = event_appointment.event_id)".
533 " LEFT JOIN event_participants ON (event_participants.event_id = event.obj_id AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
")".
534 " WHERE ".$ilDB->in(
"obj_id", $obj_ids ,
false,
"integer");
535 $set = $ilDB->query(
$query);
537 while($rec = $ilDB->fetchAssoc($set))
539 $rec[
"comment"] = $rec[
"e_comment"];
540 unset($rec[
"e_comment"]);
548 $rec[
"title"] = $date.
': '.$rec[
"title"];
552 $rec[
"title"] = $date;
554 $sessions[$rec[
"obj_id"]] = $rec;
575 static function getObjectsSummaryForObject($a_parent_obj_id, $a_parent_ref_id, $a_order_field =
"", $a_order_dir =
"", $a_offset = 0, $a_limit = 9999,
576 array $a_filters = NULL, array $a_additional_fields = NULL, $a_preselected_obj_ids = NULL)
584 if($a_preselected_obj_ids === NULL)
590 foreach($a_preselected_obj_ids as $obj_id => $ref_ids)
592 $objects[
"object_ids"][] = $obj_id;
593 $objects[
"ref_ids"][$obj_id] = array_pop($ref_ids);
601 $set = $ilDB->query(
"SELECT obj_id,title,type FROM object_data".
602 " WHERE ".$ilDB->in(
"obj_id", $objects[
"object_ids"],
false,
"integer"));
603 while($rec = $ilDB->fetchAssoc($set))
605 $object_data[$rec[
"obj_id"]] = $rec;
606 if($a_preselected_obj_ids)
608 $object_data[$rec[
"obj_id"]][
"ref_ids"] = $a_preselected_obj_ids[$rec[
"obj_id"]];
612 foreach($objects[
"ref_ids"] as $object_id =>
$ref_id)
615 if(
sizeof($object_result))
617 if($object_data[$object_id])
619 $result[] = array_merge($object_data[$object_id], $object_result);
625 if($objects[
"objectives_parent_id"])
647 $where[] =
"usr_data.usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
652 if (is_array($a_users) &&
sizeof($a_users))
655 $where[] = $ilDB->in(
"usr_data.usr_id", $a_users,
false,
"integer");
661 $query =
" FROM usr_data ".$left.
" JOIN read_event ON (read_event.usr_id = usr_data.usr_id".
662 " AND obj_id = ".$ilDB->quote($obj_id,
"integer").
")".
663 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id ".
664 " AND ut_lp_marks.obj_id = ".$ilDB->quote($obj_id,
"integer").
")".
665 " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = ".$ilDB->quote(
"language",
"text").
")".
668 $fields[] =
'COUNT(usr_data.usr_id) AS user_count';
671 $queries[] = array(
"fields"=>$fields,
"query"=>
$query,
"count"=>
"*");
675 $users_no =
$result[
"user_count"];
682 else if(isset($a_filters[
"user_total"]))
684 if($a_filters[
"user_total"][
"from"] && $users_no < $a_filters[
"user_total"][
"from"])
688 else if($a_filters[
"user_total"][
"to"] && $users_no > $a_filters[
"user_total"][
"to"])
711 $result[
"user_total"] = $users_no;
731 $field_alias = $field;
735 $field_alias = $alias;
736 $alias =
" AS ".$alias;
741 if(preg_match(
"/".preg_quote(
" [[--HAVING").
"(.+)".preg_quote(
"HAVING--]]").
"/", $base_query, $hits))
743 $having =
" HAVING ".$hits[1];
744 $base_query = str_replace($hits[0],
"", $base_query);
747 $query =
"SELECT COUNT(*) AS counter, ".$field.$alias.
" ".$base_query.
" GROUP BY ".$field.$having.
" ORDER BY counter DESC";
748 $set = $ilDB->query(
$query);
750 while($rec = $ilDB->fetchAssoc($set))
752 $result[$rec[$field_alias]] = (int)$rec[
"counter"];
774 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
776 return $member_obj->getMembers();
779 include_once
"Modules/Group/classes/class.ilGroupParticipants.php";
781 return $member_obj->getMembers();
785 $path = $tree->getPathId($a_ref_id);
787 foreach(array_reverse(
$path) as $path_ref_id)
790 if($type ==
"crs" || $type ==
"grp")
804 include_once(
"./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
806 if ($subtype ==
"scorm2004")
809 include_once(
"./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
811 $all = $mod->getTrackedUsers(
"");
815 foreach($all as $item)
817 $a_users[] = $item[
"user_id"];
823 include_once(
"./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php");
829 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
830 include_once(
"./Modules/Exercise/classes/class.ilObjExercise.php");
833 $a_users = $members->getMembers();
837 include_once(
"./Services/Tracking/classes/class.ilLPStatusTestFinished.php");
857 static protected function buildFilters(array $where, array $a_filters = NULL, $a_aggregate =
false)
863 if(
sizeof($a_filters))
865 foreach($a_filters as $id => $value)
876 case "matriculation":
880 $where[] = $ilDB->like(
"usr_data.".$id,
"text",
"%".$value.
"%");
886 $where[] =
"usr_data.".$id.
" = ".$ilDB->quote($value ,
"text");
890 $where[] = $ilDB->like(
"ut_lp_marks.".$id,
"text",
"%".$value.
"%");
898 " OR ut_lp_marks.status IS NULL)";
904 $where[] =
"ut_lp_marks.".$id.
" = ".$ilDB->quote($value ,
"text");
912 $where[] =
"ut_lp_marks.".$id.
" >= ".$ilDB->quote($value[
"from"] ,
"integer");
916 $where[] =
"ut_lp_marks.".$id.
" <= ".$ilDB->quote($value[
"to"] ,
"integer");
923 $having[] =
"ROUND(AVG(ut_lp_marks.".$id.
")) >= ".$ilDB->quote($value[
"from"] ,
"integer");
927 $having[] =
"ROUND(AVG(ut_lp_marks.".$id.
")) <= ".$ilDB->quote($value[
"to"] ,
"integer");
933 $where[] =
"usr_pref.value = ".$ilDB->quote($value ,
"text");
950 case 'status_changed':
954 if($id ==
"registration")
965 $where[] = $id.
" >= ".$ilDB->quote($value[
"from"] ,
"date");
969 $where[] = $id.
" <= ".$ilDB->quote($value[
"to"] ,
"date");
978 $where[] =
"(read_event.".$id.
"+read_event.childs_".$id.
") >= ".$ilDB->quote($value[
"from"] ,
"integer");
982 $where[] =
"(read_event.".$id.
"+read_event.childs_".$id.
") <= ".$ilDB->quote($value[
"to"] ,
"integer");
989 $having[] =
"SUM(read_event.".$id.
"+read_event.childs_".$id.
") >= ".$ilDB->quote($value[
"from"] ,
"integer");
993 $having[] =
"SUM(read_event.".$id.
"+read_event.childs_".$id.
") <= ".$ilDB->quote($value[
"to"] ,
"integer");
998 case "spent_seconds":
1003 $where[] =
"(read_event.".$id.
"+read_event.childs_".$id.
") >= ".$ilDB->quote($value[
"from"] ,
"integer");
1007 $where[] =
"(read_event.".$id.
"+read_event.childs_".$id.
") <= ".$ilDB->quote($value[
"to"] ,
"integer");
1014 $having[] =
"ROUND(AVG(read_event.".$id.
"+read_event.childs_".$id.
")) >= ".$ilDB->quote($value[
"from"] ,
"integer");
1018 $having[] =
"ROUND(AVG(read_event.".$id.
"+read_event.childs_".$id.
")) <= ".$ilDB->quote($value[
"to"] ,
"integer");
1033 $sql .=
" WHERE ".implode(
" AND ", $where);
1038 $sql .=
" [[--HAVING ".implode(
" AND ", $having).
"HAVING--]]";
1052 static protected function buildColumns(array &$a_fields, array $a_additional_fields = NULL, $a_aggregate =
false)
1054 if(
sizeof($a_additional_fields))
1057 foreach($a_additional_fields as $field)
1059 if(substr($field, 0, 4) !=
"udf_")
1064 $pos = strrpos($field,
"_");
1069 $function = strtoupper(substr($field, $pos+1));
1070 $field = substr($field, 0, $pos);
1071 if(!in_array($function, array(
"MIN",
"MAX",
"SUM",
"AVG",
"COUNT")))
1082 $a_fields[] = $function.
"(value) AS ".$field.
"_".strtolower($function);
1086 $a_fields[] =
"value AS ".$field;
1091 case "spent_seconds":
1094 $a_fields[] =
"(".$field.
"+childs_".$field.
") AS ".$field;
1098 if($function ==
"AVG")
1100 $a_fields[] =
"ROUND(AVG(".$field.
"+childs_".$field.
"), 2) AS ".$field.
"_".strtolower($function);
1104 $a_fields[] = $function.
"(".$field.
"+childs_".$field.
") AS ".$field.
"_".strtolower($function);
1109 case "read_count_spent_seconds":
1110 if($function ==
"AVG")
1112 $a_fields[] =
"ROUND(AVG((spent_seconds+childs_spent_seconds)/(read_count+childs_read_count)), 2) AS ".$field.
"_".strtolower($function);
1119 if($function ==
"AVG")
1121 $a_fields[] =
"ROUND(AVG(".$field.
"), 2) AS ".$field.
"_".strtolower($function);
1125 $a_fields[] = $function.
"(".$field.
") AS ".$field.
"_".strtolower($function);
1130 $a_fields[] = $field;
1137 $udf[] = substr($field, 4);
1142 $a_fields = array_unique($a_fields);
1145 $udf = array_unique($udf);
1162 static public function getObjectIds($a_parent_obj_id, $a_parent_ref_id =
false, $use_collection =
true, $a_refresh_status =
true, $a_user_ids = null)
1164 include_once
"Services/Tracking/classes/class.ilLPObjSettings.php";
1166 $object_ids = array($a_parent_obj_id);
1167 $ref_ids = array($a_parent_obj_id => $a_parent_ref_id);
1168 $objectives_parent_id = $scorm =
false;
1175 include_once
"Services/Tracking/classes/class.ilLPStatusSCORM.php";
1177 $scorm = $status_scorm->_getStatusInfo($a_parent_obj_id);
1183 $objectives_parent_id = $a_parent_obj_id;
1191 include_once
'Services/Tracking/classes/class.ilLPCollectionCache.php';
1195 $object_ids[] = $child_id;
1196 $ref_ids[$child_id] = $child_ref_id;
1203 $object_ids = array_unique($object_ids);
1206 foreach($object_ids as $idx => $object_id)
1210 unset($object_ids[$idx]);
1216 if($a_refresh_status)
1221 return array(
"object_ids" => $object_ids,
1222 "ref_ids" => $ref_ids,
1223 "objectives_parent_id" => $objectives_parent_id,
1234 static protected function getSubTree($a_parent_ref_id, array &$a_object_ids, array &$a_ref_ids)
1238 $children = $tree->getChilds($a_parent_ref_id);
1241 foreach($children as $child)
1243 if($child[
"type"] ==
"adm" || $child[
"type"] ==
"rolf")
1253 $a_object_ids[] = $child[
"obj_id"];
1254 $a_ref_ids[$child[
"obj_id"]] = $child[
"ref_id"];
1272 static function executeQueries(array $queries, $a_order_field =
"", $a_order_dir =
"", $a_offset = 0, $a_limit = 9999)
1277 $subqueries = array();
1278 foreach($queries as $item)
1281 $item = str_replace(
"[[--HAVING",
"HAVING", $item);
1282 $item = str_replace(
"HAVING--]]",
"", $item);
1284 if(!isset($item[
"count"]))
1286 $count_field = $item[
"fields"];
1287 $count_field = array_shift($count_field);
1291 $count_field = $item[
"count"];
1293 $count_query =
"SELECT COUNT(".$count_field.
") AS cnt".$item[
"query"];
1294 $set = $ilDB->query($count_query);
1295 if ($rec = $ilDB->fetchAssoc($set))
1297 $cnt += $rec[
"cnt"];
1300 $subqueries[] =
"SELECT ".implode(
",", $item[
"fields"]).$item[
"query"];
1307 if(
sizeof($subqueries) > 1)
1309 $base = array_shift($subqueries);
1310 $query = $base.
" UNION (".implode(
") UNION (", $subqueries).
")";
1317 if ($a_order_dir !=
"asc" && $a_order_dir !=
"desc")
1319 $a_order_dir =
"asc";
1323 $query.=
" ORDER BY ".$a_order_field.
" ".strtoupper($a_order_dir);
1326 $offset = (int) $a_offset;
1327 $limit = (int) $a_limit;
1328 $ilDB->setLimit($limit, $offset);
1330 $set = $ilDB->query(
$query);
1331 while($rec = $ilDB->fetchAssoc($set))
1337 return array(
"cnt" => $cnt,
"set" =>
$result);
1352 $result = array(
"cnt"=>0,
"set"=>NULL);
1353 if(
sizeof($a_obj_ids))
1356 $where[] =
"usr_data.usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
1359 $where[] = $ilDB->like(
"usr_data.login",
"text",
"%".$a_user_filter.
"%");
1365 if (is_array($a_users))
1368 $where[] = $ilDB->in(
"usr_data.usr_id", $a_users,
false,
"integer");
1371 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
1373 $fields = array(
"usr_data.usr_id",
"login",
"active",
"status",
1374 "status_changed",
"percentage",
"last_access",
1375 "spent_seconds+childs_spent_seconds as spent_seconds");
1383 foreach($a_obj_ids as $obj_id)
1386 $query =
" FROM usr_data ".$left.
" JOIN read_event ON (read_event.usr_id = usr_data.usr_id".
1387 " AND read_event.obj_id = ".$ilDB->quote($obj_id,
"integer").
")".
1388 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id ".
1389 " AND ut_lp_marks.obj_id = ".$ilDB->quote($obj_id,
"integer").
")".
1396 foreach($raw[
"set"] as
$row)
1398 $result[
"set"][$row[
"usr_id"]][
"login"] = $row[
"login"];
1399 $result[
"set"][$row[
"usr_id"]][
"usr_id"] = $row[
"usr_id"];
1400 $result[
"set"][$row[
"usr_id"]][
"objects"][$obj_id] = array(
"status"=>$row[
"status"],
1401 "percentage"=>$row[
"percentage"]);
1402 if($obj_id == $parent_obj_id)
1404 $result[
"set"][$row[
"usr_id"]][
"status_changed"] = $row[
"status_changed"];
1405 $result[
"set"][$row[
"usr_id"]][
"last_access"] = $row[
"last_access"];
1406 $result[
"set"][$row[
"usr_id"]][
"spent_seconds"] = $row[
"spent_seconds"];
1421 if($a_parent_obj_id && $a_users)
1423 include_once(
"Services/Tracking/classes/class.ilLPStatus.php");
1425 $fields = array(
"crs_objectives.objective_id AS obj_id",
"crs_objective_status.user_id AS usr_id",
"title");
1426 $fields[] =
"CASE WHEN status IS NOT NULL THEN ".LP_STATUS_COMPLETED_NUM.
" ELSE NULL END AS status";
1429 $where[] =
"crs_objectives.crs_id = ".$ilDB->quote($a_parent_obj_id,
"integer");
1431 $query =
" FROM crs_objectives".
1432 " LEFT JOIN crs_objective_status ON (crs_objectives.objective_id = crs_objective_status.objective_id".
1433 " AND ".$ilDB->in(
"crs_objective_status.user_id", $a_users,
"",
"integer").
")".
1444 $obj_ids = array_keys($a_ref_ids);
1456 $sql =
"SELECT obj_id,".$column.
",SUM(read_count) read_count,SUM(childs_read_count) childs_read_count,".
1457 "SUM(spent_seconds) spent_seconds,SUM(childs_spent_seconds) childs_spent_seconds".
1459 " WHERE ".$ilDB->in(
"obj_id", $obj_ids,
"",
"integer").
1460 " AND yyyy = ".$ilDB->quote($a_year,
"integer");
1463 $sql .=
" AND mm = ".$ilDB->quote($a_month,
"integer");
1465 $sql .=
" GROUP BY obj_id,".$column;
1466 $set = $ilDB->query($sql);
1467 while(
$row = $ilDB->fetchAssoc($set))
1469 $row[
"read_count"] +=
$row[
"childs_read_count"];
1470 $row[
"spent_seconds"] +=
$row[
"childs_spent_seconds"];
1471 $res[
$row[
"obj_id"]][
$row[$column]][
"read_count"] += $row[
"read_count"];
1472 $res[$row[
"obj_id"]][$row[$column]][
"spent_seconds"] += $row[
"spent_seconds"];
1479 global
$ilDB, $objDefinition;
1484 include_once
"Services/Tree/classes/class.ilTree.php";
1486 $sql =
"SELECT ".$tree->table_obj_data.
".obj_id,".$tree->table_obj_data.
".type,".
1487 $tree->table_tree.
".".$tree->tree_pk.
",".$tree->table_obj_reference.
".ref_id".
1488 " FROM ".$tree->table_tree.
1489 " ".$tree->buildJoin().
1490 " WHERE ".$ilDB->in($tree->table_obj_data.
".type", $types,
"",
"text");
1491 $set = $ilDB->query($sql);
1493 while(
$row = $ilDB->fetchAssoc($set))
1495 $res[
$row[
"type"]][
"type"] = $row[
"type"];
1496 $res[$row[
"type"]][
"references"]++;
1497 $res[$row[
"type"]][
"objects"][] = $row[
"obj_id"];
1498 if($row[$tree->tree_pk] < 0)
1500 $res[$row[
"type"]][
"deleted"]++;
1504 foreach(
$res as $type => $values)
1506 $res[$type][
"objects"] =
sizeof(array_unique($values[
"objects"]));
1516 $obj_ids = array_keys($a_ref_ids);
1519 $sql =
"SELECT obj_id,hh,SUM(read_count) read_count,SUM(childs_read_count) childs_read_count,".
1520 "SUM(spent_seconds) spent_seconds,SUM(childs_spent_seconds) childs_spent_seconds".
1522 " WHERE ".$ilDB->in(
"obj_id", $obj_ids,
"",
"integer").
1523 " AND yyyy = ".$ilDB->quote($a_year,
"integer");
1526 $sql .=
" AND mm = ".$ilDB->quote($a_month,
"integer");
1528 $sql .=
" GROUP BY obj_id,hh";
1529 $set = $ilDB->query($sql);
1530 while(
$row = $ilDB->fetchAssoc($set))
1532 $row[
"read_count"] +=
$row[
"childs_read_count"];
1533 $row[
"spent_seconds"] +=
$row[
"childs_spent_seconds"];
1535 $res[
$row[
"obj_id"]][(int)
$row[
"hh"]][
"spent_seconds"] +=
$row[
"spent_seconds"];
1544 $set = $ilDB->query(
"SELECT COUNT(*) AS COUNTER,yyyy,mm".
1546 " GROUP BY yyyy, mm".
1547 " ORDER BY yyyy DESC, mm DESC");
1549 while(
$row = $ilDB->fetchAssoc($set))
1552 "count"=>$row[
"counter"]);
1561 $sql =
"DELETE FROM obj_stat".
1562 " WHERE ".$ilDB->in($ilDB->concat(array(array(
"yyyy",
""), array($ilDB->quote(
"-",
"text"),
""),
1563 array(
"mm",
""))), $a_months,
"",
"text");
1564 return $ilDB->manipulate($sql);
1569 global
$ilDB, $tree;
1571 if($a_type ==
"lres")
1573 $a_type = array(
'lm',
'sahs',
'htlm',
'dbk');
1576 $sql =
"SELECT r.ref_id,r.obj_id".
1577 " FROM object_data o".
1578 " JOIN object_reference r ON (o.obj_id = r.obj_id)".
1579 " JOIN tree t ON (t.child = r.ref_id)".
1580 " WHERE t.tree = ".$ilDB->quote(1,
"integer");
1582 if(!is_array($a_type))
1584 $sql .=
" AND o.type = ".$ilDB->quote($a_type,
"text");
1588 $sql .=
" AND ".$ilDB->in(
"o.type", $a_type,
"",
"text");
1593 $sql .=
" AND (".$ilDB->like(
"o.title",
"text",
"%".$a_title.
"%").
1594 " OR ".$ilDB->like(
"o.description",
"text",
"%".$a_title.
"%").
")";
1597 $set = $ilDB->query($sql);
1599 while(
$row = $ilDB->fetchAssoc($set))
1601 if($a_root && $a_root != ROOT_FOLDER_ID)
1605 if($tree->isGrandChild($a_root,
$ref_id))
1607 $res[
$row[
"obj_id"]][] = $row[
"ref_id"];
1614 $res[
$row[
"obj_id"]][] = $row[
"ref_id"];
1628 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
1629 foreach($a_obj_ids as $obj_id)
1644 $set = $ilDB->query(
"SELECT COUNT(*) counter, MIN(tstamp) tstamp".
1645 " FROM obj_stat_log");
1646 return $ilDB->fetchAssoc($set);