20 $obj_ids = array_keys($obj_refs);
22 include_once
"Services/Tracking/classes/class.ilLPObjSettings.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");
30 $set = $ilDB->query(
$query);
31 while($rec = $ilDB->fetchAssoc($set))
33 $view_modes[(int)$rec[
"obj_id"]] = (
int)$rec[
"view_mode"];
38 $query =
"SELECT object_data.obj_id, title, CASE WHEN status IS NULL THEN ".LP_STATUS_NOT_ATTEMPTED_NUM.
" ELSE status END AS status,".
39 " percentage, read_count+childs_read_count AS read_count, spent_seconds+childs_spent_seconds AS spent_seconds,".
40 " u_mode, type, visits, mark, u_comment AS comment".
42 " LEFT JOIN ut_lp_settings ON (ut_lp_settings.obj_id = object_data.obj_id)".
43 " LEFT JOIN read_event ON (read_event.obj_id = object_data.obj_id AND read_event.usr_id = ".$ilDB->quote($a_user_id,
"integer").
")".
44 " 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").
")".
46 " WHERE ".$ilDB->in(
"object_data.obj_id", $obj_ids,
false,
"integer").
48 $set = $ilDB->query(
$query);
50 while($rec = $ilDB->fetchAssoc($set))
52 $rec[
"ref_ids"] = $obj_refs[(int)$rec[
"obj_id"]];
53 $rec[
"status"] = (int)$rec[
"status"];
54 $rec[
"percentage"] = (int)$rec[
"percentage"];
55 $rec[
"read_count"] = (int)$rec[
"read_count"];
56 $rec[
"spent_seconds"] = (int)$rec[
"spent_seconds"];
57 $rec[
"u_mode"] = (int)$rec[
"u_mode"];
59 if($rec[
"type"] ==
"sess")
61 $session = $sessions[$rec[
"obj_id"]];
62 $rec[
"title"] = $session[
"title"];
71 else if(!$rec[
"u_mode"])
90 $query =
"SELECT crs_id, crs_objectives.objective_id AS obj_id, title, status, ".$ilDB->quote(
"lobj",
"text").
" AS type".
91 " FROM crs_objectives".
92 " LEFT JOIN crs_objective_status ON (crs_objectives.objective_id = crs_objective_status.objective_id AND user_id = ".$a_user_id.
")".
93 " WHERE ".$ilDB->in(
"crs_objectives.objective_id", $obj_ids,
false,
"integer").
95 $set = $ilDB->query(
$query);
97 while($rec = $ilDB->fetchAssoc($set))
111 include_once
'Services/Tracking/classes/class.ilLPStatusWrapper.php';
115 foreach($a_sco_ids as $sco_id)
117 if(in_array($a_user_id, $status_info[
"in_progress"][$sco_id]))
121 elseif(in_array($a_user_id, $status_info[
"completed"][$sco_id]))
125 elseif(in_array($a_user_id, $status_info[
"failed"][$sco_id]))
134 $items[$sco_id] = array(
135 "title" => $status_info[
"scos_title"][$sco_id],
148 if(
sizeof($obj_refs))
150 $obj_ids = array_keys($obj_refs);
152 include_once
"Services/Tracking/classes/class.ilLPObjSettings.php";
153 include_once
"Services/Tracking/classes/class.ilLPStatus.php";
156 include_once
'Modules/Course/classes/class.ilObjCourse.php';
157 $view_modes = array();
158 $query =
"SELECT obj_id, view_mode FROM crs_settings".
159 " WHERE ".$ilDB->in(
"obj_id", $obj_ids ,
false,
"integer");
160 $set = $ilDB->query(
$query);
161 while($rec = $ilDB->fetchAssoc($set))
163 $view_modes[(int)$rec[
"obj_id"]] = (
int)$rec[
"view_mode"];
166 $query =
"SELECT object_data.obj_id, title, u_mode, type".
168 " LEFT JOIN ut_lp_settings ON (ut_lp_settings.obj_id = object_data.obj_id)".
170 " AND ".$ilDB->in(
"object_data.obj_id", $obj_ids,
false,
"integer").
171 " GROUP BY object_data.obj_id, title, u_mode, type".
173 $set = $ilDB->query(
$query);
175 while($rec = $ilDB->fetchAssoc($set))
177 $rec[
"ref_ids"] = $obj_refs[(int)$rec[
"obj_id"]];
178 $rec[
"status"] = (int)$rec[
"status"];
179 $rec[
"u_mode"] = (int)$rec[
"u_mode"];
191 else if(!$rec[
"u_mode"])
197 if($rec[
"u_mode"] != LP_MODE_DEACTIVATE)
199 $result[$rec[
"obj_id"]] = $rec;
221 $a_offset = 0, $a_limit = 9999, array $a_filters = NULL, array $a_additional_fields = NULL,
222 $check_agreement =
false, $privacy_fields = NULL)
226 $fields = array(
"usr_data.usr_id",
"login");
230 $where[] =
"usr_data.usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
239 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
242 if (is_array($a_users))
245 $where[] = $ilDB->in(
"usr_data.usr_id", $a_users,
false,
"integer");
248 $query =
" FROM usr_data ".$left.
" JOIN read_event ON (read_event.usr_id = usr_data.usr_id".
249 " AND read_event.obj_id = ".$ilDB->quote($obj_id,
"integer").
")".
250 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id ".
251 " AND ut_lp_marks.obj_id = ".$ilDB->quote($obj_id,
"integer").
")".
252 " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = ".$ilDB->quote(
"language",
"text").
")".
255 $queries = array(array(
"fields"=>$fields,
"query"=>
$query));
260 $a_order_field =
"login";
262 else if(substr($a_order_field, 0, 4) ==
"udf_")
264 $udf_order = $a_order_field;
265 $a_order_field = null;
273 $query =
"SELECT usr_id, field_id, value FROM udf_text WHERE ".$ilDB->in(
"field_id", $udf,
false,
"integer");
274 $set = $ilDB->query(
$query);
276 while(
$row = $ilDB->fetchAssoc($set))
278 $udf[
$row[
"usr_id"]][
"udf_".$row[
"field_id"]] =
$row[
"value"];
286 include_once
"Services/Membership/classes/class.ilMemberAgreement.php";
292 $query =
"SELECT usr_id FROM usr_pref WHERE keyword = ".$ilDB->quote(
"public_profile",
"text").
293 " AND value = ".$ilDB->quote(
"y",
"text").
" OR value = ".$ilDB->quote(
"g",
"text");
294 $set = $ilDB->query(
$query);
295 $all_public = array();
296 while(
$row = $ilDB->fetchAssoc($set))
298 $all_public[] =
$row[
"usr_id"];
300 $query =
"SELECT usr_id,keyword FROM usr_pref WHERE ".$ilDB->like(
"keyword",
"text",
"public_%",
false).
301 " AND value = ".$ilDB->quote(
"y",
"text").
" AND ".$ilDB->in(
"usr_id", $all_public,
"",
"integer");
302 $set = $ilDB->query(
$query);
304 while(
$row = $ilDB->fetchAssoc($set))
306 $public[
$row[
"usr_id"]][] = substr($row[
"keyword"], 7);
311 foreach($result[
"set"] as $idx =>
$row)
314 if(isset($udf[
$row[
"usr_id"]]))
316 $result[
"set"][$idx] = $row = array_merge($row, $udf[$row[
"usr_id"]]);
320 if(
sizeof($privacy_fields) && $check_agreement && !in_array($row[
"usr_id"], $agreements))
322 foreach($privacy_fields as $field)
325 if(isset($row[$field]) && (!isset($public[$row[
"usr_id"]]) ||
326 !in_array($field, $public[$row[
"usr_id"]])))
329 if(isset($a_filters[$field]))
331 unset($result[
"set"][$idx]);
337 $result[
"set"][$idx][$field] =
false;
347 include_once
"Services/Utilities/classes/class.ilStr.php";
349 $udf_order, $a_order_dir);
370 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,
371 array $a_filter = NULL, array $a_additional_fields = NULL, $use_collection =
true)
375 $fields = array(
"object_data.obj_id",
"title",
"type");
380 $query =
" FROM object_data LEFT JOIN read_event ON (object_data.obj_id = read_event.obj_id AND".
381 " read_event.usr_id = ".$ilDB->quote($a_user_id,
"integer").
")".
382 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = ".$ilDB->quote($a_user_id,
"integer").
" AND".
383 " ut_lp_marks.obj_id = object_data.obj_id)".
384 " WHERE ".$ilDB->in(
"object_data.obj_id", $objects[
"object_ids"],
false,
"integer").
388 $queries[] = array(
"fields"=>$fields,
"query"=>
$query);
391 if($objects[
"objectives_parent_id"])
393 $objective_fields = array(
"crs_objectives.objective_id AS obj_id",
"title",
394 $ilDB->quote(
"lobj",
"text").
" as type");
396 if (is_array($a_additional_fields))
398 foreach($a_additional_fields as $field)
400 if($field !=
"status")
402 $objective_fields[] =
"NULL AS ".$field;
406 include_once(
"Services/Tracking/classes/class.ilLPStatus.php");
407 $objective_fields[] =
"(CASE WHEN status IS NOT NULL THEN ".LP_STATUS_COMPLETED_NUM.
" ELSE NULL END) AS status";
413 $where[] =
"crs_objectives.crs_id = ".$ilDB->quote($objects[
"objectives_parent_id"],
"integer");
415 $objectives_query =
" FROM crs_objectives".
416 " LEFT JOIN crs_objective_status ON (crs_objectives.objective_id = crs_objective_status.objective_id".
417 " AND crs_objective_status.user_id = ".$ilDB->quote($a_user_id,
"integer").
")".
420 $queries[] = array(
"fields"=>$objective_fields,
"query"=>$objectives_query,
"count"=>
"crs_objectives.objective_id");
423 if(!in_array($a_order_field, $fields))
425 $a_order_field =
"title";
434 foreach($result[
"set"] as $idx => $item)
436 if($item[
"type"] ==
"sess")
438 $session = $sessions[$item[
"obj_id"]];
439 $result[
"set"][$idx][
"title"] = $session[
"title"];
440 $result[
"set"][$idx][
"sort_title"] = $session[
"e_start"];
444 $result[
"set"][$idx][
"ref_id"] = $objects[
"ref_ids"][$item[
"obj_id"]];
448 if($objects[
"scorm"])
450 include_once(
"./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
452 if($subtype ==
"scorm2004")
454 include_once(
"./Modules/Scorm2004/classes/class.ilObjScorm2004LearningModule.php");
456 $scos_tracking = $sobj->getTrackingDataAgg($a_user_id,
true);
460 include_once(
"./Modules/ScormAicc/classes/class.ilObjScormLearningModule.php");
462 $scos_tracking = array();
463 foreach($sobj->getTrackingDataAgg($a_user_id) as $item)
468 $time = explode(
":", $item[
"time"]);
469 $item[
"time"] = $time[0]*60*60+$time[1]*60+$time[2];
471 $scos_tracking[$item[
"sco_id"]] = array(
"session_time"=>$item[
"time"]);
475 foreach($objects[
"scorm"][
"scos"] as $sco)
477 $row = array(
"title" => $objects[
"scorm"][
"scos_title"][$sco],
481 if(in_array($a_user_id, $objects[
"scorm"][
"completed"][$sco]))
485 else if(in_array($a_user_id, $objects[
"scorm"][
"failed"][$sco]))
489 else if(in_array($a_user_id, $objects[
"scorm"][
"in_progress"][$sco]))
493 $row[
"status"] = $status;
496 if(isset($scos_tracking[$sco]))
498 if(isset($scos_tracking[$sco][
"last_access"]))
503 $row[
"spent_seconds"] = $scos_tracking[$sco][
"session_time"];
506 $result[
"set"][] =
$row;
525 $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,".
526 " mark, e_comment AS comment".
528 " JOIN event_appointment ON (event.obj_id = event_appointment.event_id)".
529 " LEFT JOIN event_participants ON (event_participants.event_id = event.obj_id AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
")".
530 " WHERE ".$ilDB->in(
"obj_id", $obj_ids ,
false,
"integer");
531 $set = $ilDB->query(
$query);
533 while($rec = $ilDB->fetchAssoc($set))
541 $rec[
"title"] = $date.
': '.$rec[
"title"];
545 $rec[
"title"] = $date;
547 $sessions[$rec[
"obj_id"]] = $rec;
568 static function getObjectsSummaryForObject($a_parent_obj_id, $a_parent_ref_id, $a_order_field =
"", $a_order_dir =
"", $a_offset = 0, $a_limit = 9999,
569 array $a_filters = NULL, array $a_additional_fields = NULL, $use_collection =
true)
579 $set = $ilDB->query(
"SELECT obj_id,title,type FROM object_data".
580 " WHERE ".$ilDB->in(
"obj_id", $objects[
"object_ids"],
false,
"integer"));
581 while($rec = $ilDB->fetchAssoc($set))
583 $object_data[$rec[
"obj_id"]] = $rec;
587 foreach($objects[
"ref_ids"] as $object_id =>
$ref_id)
590 if(
sizeof($object_result))
592 $result[] = array_merge($object_data[$object_id], $object_result);
597 if($objects[
"objectives_parent_id"])
602 return array(
"cnt"=>
sizeof($result),
"set"=>$result);
618 $where[] =
"usr_data.usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
623 if (is_array($a_users) &&
sizeof($a_users))
626 $where[] = $ilDB->in(
"usr_data.usr_id", $a_users,
false,
"integer");
630 $query =
" FROM usr_data ".$left.
" JOIN read_event ON (read_event.usr_id = usr_data.usr_id".
631 " AND obj_id = ".$ilDB->quote($obj_id,
"integer").
")".
632 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id ".
633 " AND ut_lp_marks.obj_id = ".$ilDB->quote($obj_id,
"integer").
")".
634 " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = ".$ilDB->quote(
"language",
"text").
")".
637 $fields[] =
'COUNT(usr_data.usr_id) AS user_count';
640 $queries[] = array(
"fields"=>$fields,
"query"=>
$query,
"count"=>
"*");
643 $result = $result[
"set"][0];
644 $users_no = $result[
"user_count"];
651 else if(isset($a_filters[
"user_total"]))
653 if($a_filters[
"user_total"][
"from"] && $users_no < $a_filters[
"user_total"][
"from"])
657 else if($a_filters[
"user_total"][
"to"] && $users_no > $a_filters[
"user_total"][
"to"])
680 $result[
"user_total"] = $users_no;
700 $field_alias = $field;
704 $field_alias = $alias;
705 $alias =
" AS ".$alias;
710 if(preg_match(
"/".preg_quote(
" [[--HAVING").
"(.+)".preg_quote(
"HAVING--]]").
"/", $base_query, $hits))
712 $having =
" HAVING ".$hits[1];
713 $base_query = str_replace($hits[0],
"", $base_query);
716 $query =
"SELECT COUNT(*) AS counter, ".$field.$alias.
" ".$base_query.
" GROUP BY ".$field.$having.
" ORDER BY counter DESC";
717 $set = $ilDB->query(
$query);
719 while($rec = $ilDB->fetchAssoc($set))
721 $result[$rec[$field_alias]] = (int)$rec[
"counter"];
743 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
745 $a_users = $member_obj->getMembers();
749 include_once
"Modules/Group/classes/class.ilGroupParticipants.php";
751 $a_users = $member_obj->getMembers();
755 include_once(
"./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
766 include_once(
"./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
768 $all = $mod->getTrackedUsers(
"");
772 foreach($all as $item)
774 $a_users[] = $item[
"user_id"];
780 include_once(
"./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php");
787 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
788 include_once(
"./Modules/Exercise/classes/class.ilObjExercise.php");
791 $a_users = $members->getMembers();
795 include_once(
"./Services/Tracking/classes/class.ilLPStatusTestFinished.php");
805 $path = $tree->getPathId($a_ref_id);
807 foreach(array_reverse(
$path) as $path_ref_id)
829 static protected function buildFilters(array $where, array $a_filters = NULL, $a_aggregate =
false)
835 if(
sizeof($a_filters))
837 foreach($a_filters as $id => $value)
848 case "matriculation":
852 $where[] = $ilDB->like(
"usr_data.".$id,
"text",
"%".$value.
"%");
858 $where[] =
"usr_data.".$id.
" = ".$ilDB->quote($value ,
"text");
862 $where[] = $ilDB->like(
"ut_lp_marks.".$id,
"text",
"%".$value.
"%");
867 $where[] =
"ut_lp_marks.".$id.
" = ".$ilDB->quote($value ,
"text");
876 $where[] =
"ut_lp_marks.".$id.
" >= ".$ilDB->quote($value[
"from"] ,
"integer");
880 $where[] =
"ut_lp_marks.".$id.
" <= ".$ilDB->quote($value[
"to"] ,
"integer");
887 $having[] =
"ROUND(AVG(ut_lp_marks.".$id.
")) >= ".$ilDB->quote($value[
"from"] ,
"integer");
891 $having[] =
"ROUND(AVG(ut_lp_marks.".$id.
")) <= ".$ilDB->quote($value[
"to"] ,
"integer");
897 $where[] =
"usr_pref.value = ".$ilDB->quote($value ,
"text");
915 if($id ==
"registration")
926 $where[] = $id.
" >= ".$ilDB->quote($value[
"from"] ,
"date");
930 $where[] = $id.
" <= ".$ilDB->quote($value[
"to"] ,
"date");
939 $where[] =
"(read_event.".$id.
"+read_event.childs_".$id.
") >= ".$ilDB->quote($value[
"from"] ,
"integer");
943 $where[] =
"(read_event.".$id.
"+read_event.childs_".$id.
") <= ".$ilDB->quote($value[
"to"] ,
"integer");
950 $having[] =
"SUM(read_event.".$id.
"+read_event.childs_".$id.
") >= ".$ilDB->quote($value[
"from"] ,
"integer");
954 $having[] =
"SUM(read_event.".$id.
"+read_event.childs_".$id.
") <= ".$ilDB->quote($value[
"to"] ,
"integer");
959 case "spent_seconds":
964 $where[] =
"(read_event.".$id.
"+read_event.childs_".$id.
") >= ".$ilDB->quote($value[
"from"] ,
"integer");
968 $where[] =
"(read_event.".$id.
"+read_event.childs_".$id.
") <= ".$ilDB->quote($value[
"to"] ,
"integer");
975 $having[] =
"ROUND(AVG(read_event.".$id.
"+read_event.childs_".$id.
")) >= ".$ilDB->quote($value[
"from"] ,
"integer");
979 $having[] =
"ROUND(AVG(read_event.".$id.
"+read_event.childs_".$id.
")) <= ".$ilDB->quote($value[
"to"] ,
"integer");
994 $sql .=
" WHERE ".implode(
" AND ", $where);
999 $sql .=
" [[--HAVING ".implode(
" AND ", $having).
"HAVING--]]";
1013 static protected function buildColumns(array &$a_fields, array $a_additional_fields = NULL, $a_aggregate =
false)
1015 if(
sizeof($a_additional_fields))
1018 foreach($a_additional_fields as $field)
1020 if(substr($field, 0, 4) !=
"udf_")
1025 $pos = strrpos($field,
"_");
1030 $function = strtoupper(substr($field,
$pos+1));
1031 $field = substr($field, 0,
$pos);
1032 if(!in_array($function, array(
"MIN",
"MAX",
"SUM",
"AVG",
"COUNT")))
1043 $a_fields[] = $function.
"(value) AS ".$field.
"_".strtolower($function);
1047 $a_fields[] =
"value AS ".$field;
1052 case "spent_seconds":
1055 $a_fields[] =
"(".$field.
"+childs_".$field.
") AS ".$field;
1059 if($function ==
"AVG")
1061 $a_fields[] =
"ROUND(AVG(".$field.
"+childs_".$field.
"), 2) AS ".$field.
"_".strtolower($function);
1065 $a_fields[] = $function.
"(".$field.
"+childs_".$field.
") AS ".$field.
"_".strtolower($function);
1073 if($function ==
"AVG")
1075 $a_fields[] =
"ROUND(AVG(".$field.
"), 2) AS ".$field.
"_".strtolower($function);
1079 $a_fields[] = $function.
"(".$field.
") AS ".$field.
"_".strtolower($function);
1084 $a_fields[] = $field;
1091 $udf[] = substr($field, 4);
1106 static public function getObjectIds($a_parent_obj_id, $a_parent_ref_id =
false, $use_collection =
true)
1110 include_once
"Services/Tracking/classes/class.ilLPObjSettings.php";
1112 $object_ids = array($a_parent_obj_id);
1113 $ref_ids = array($a_parent_obj_id=>$a_parent_ref_id);
1114 $objectives_parent_id = $scorm =
false;
1121 include_once
"Services/Tracking/classes/class.ilLPStatusSCORM.php";
1123 $scorm = $status_scorm->_getStatusInfo($a_parent_obj_id);
1129 $objectives_parent_id = $a_parent_obj_id;
1137 include_once
'Services/Tracking/classes/class.ilLPCollectionCache.php';
1141 $object_ids[] = $child_id;
1142 $ref_ids[$child_id] = $child_ref_id;
1149 $object_ids = array_unique($object_ids);
1152 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
1153 foreach($object_ids as $idx => $object_id)
1161 unset($object_ids[$idx]);
1167 return array(
"object_ids" => $object_ids,
1168 "ref_ids" => $ref_ids,
1169 "objectives_parent_id" => $objectives_parent_id,
1180 static protected function getSubTree($a_parent_ref_id, array &$a_object_ids, array &$a_ref_ids)
1184 $children = $tree->getChilds($a_parent_ref_id);
1187 foreach($children as $child)
1194 $a_object_ids[] = $child[
"obj_id"];
1195 $a_ref_ids[$child[
"obj_id"]] = $child[
"ref_id"];
1213 static function executeQueries(array $queries, $a_order_field =
"", $a_order_dir =
"", $a_offset = 0, $a_limit = 9999)
1218 $subqueries = array();
1219 foreach($queries as $item)
1222 $item = str_replace(
"[[--HAVING",
"HAVING", $item);
1223 $item = str_replace(
"HAVING--]]",
"", $item);
1225 if(!isset($item[
"count"]))
1227 $count_field = $item[
"fields"];
1228 $count_field = array_shift($count_field);
1232 $count_field = $item[
"count"];
1234 $count_query =
"SELECT COUNT(".$count_field.
") AS cnt".$item[
"query"];
1235 $set = $ilDB->query($count_query);
1236 if ($rec = $ilDB->fetchAssoc($set))
1238 $cnt += $rec[
"cnt"];
1241 $subqueries[] =
"SELECT ".implode(
",", $item[
"fields"]).$item[
"query"];
1248 if(
sizeof($subqueries) > 1)
1250 $base = array_shift($subqueries);
1251 $query = $base.
" UNION (".implode(
") UNION (", $subqueries).
")";
1258 if ($a_order_dir !=
"asc" && $a_order_dir !=
"desc")
1260 $a_order_dir =
"asc";
1264 $query.=
" ORDER BY ".$a_order_field.
" ".strtoupper($a_order_dir);
1267 $offset = (int) $a_offset;
1268 $limit = (int) $a_limit;
1269 $ilDB->setLimit($limit, $offset);
1271 $set = $ilDB->query(
$query);
1272 while($rec = $ilDB->fetchAssoc($set))
1278 return array(
"cnt" => $cnt,
"set" => $result);
1293 $result = array(
"cnt"=>0,
"set"=>NULL);
1294 if(
sizeof($a_obj_ids))
1297 $where[] =
"usr_data.usr_id <> ".$ilDB->quote(ANONYMOUS_USER_ID,
"integer");
1300 $where[] = $ilDB->like(
"usr_data.login",
"text",
"%".$a_user_filter.
"%");
1306 if (is_array($a_users))
1309 $where[] = $ilDB->in(
"usr_data.usr_id", $a_users,
false,
"integer");
1312 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
1314 $fields = array(
"usr_data.usr_id",
"login",
"status",
"percentage",
1315 "last_access",
"spent_seconds+childs_spent_seconds as spent_seconds");
1319 $a_order_field =
"login";
1324 foreach($a_obj_ids as $obj_id)
1330 $query =
" FROM usr_data ".$left.
" JOIN read_event ON (read_event.usr_id = usr_data.usr_id".
1331 " AND read_event.obj_id = ".$ilDB->quote($obj_id,
"integer").
")".
1332 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id ".
1333 " AND ut_lp_marks.obj_id = ".$ilDB->quote($obj_id,
"integer").
")".
1340 foreach($raw[
"set"] as $idx =>
$row)
1342 $result[
"set"][
$row[
"usr_id"]][
"login"] = $row[
"login"];
1343 $result[
"set"][$row[
"usr_id"]][
"usr_id"] = $row[
"usr_id"];
1344 $result[
"set"][$row[
"usr_id"]][
"objects"][$obj_id] = array(
"status"=>$row[
"status"],
1345 "percentage"=>$row[
"percentage"]);
1346 if($obj_id == $parent_obj_id)
1348 $result[
"set"][$row[
"usr_id"]][
"last_access"] = $row[
"last_access"];
1349 $result[
"set"][$row[
"usr_id"]][
"spent_seconds"] = $row[
"spent_seconds"];
1355 $result[
"cnt"] =
sizeof($result[
"set"]);
1356 $result[
"users"] = $a_users;
1365 if($a_parent_obj_id && $a_users)
1367 include_once(
"Services/Tracking/classes/class.ilLPStatus.php");
1369 $fields = array(
"crs_objectives.objective_id AS obj_id",
"crs_objective_status.user_id AS usr_id",
"title");
1370 $fields[] =
"(CASE WHEN status IS NOT NULL THEN ".LP_STATUS_COMPLETED_NUM.
" ELSE NULL END) AS status";
1373 $where[] =
"crs_objectives.crs_id = ".$ilDB->quote($a_parent_obj_id,
"integer");
1375 $query =
" FROM crs_objectives".
1376 " LEFT JOIN crs_objective_status ON (crs_objectives.objective_id = crs_objective_status.objective_id".
1377 " AND ".$ilDB->in(
"crs_objective_status.user_id", $a_users,
"",
"integer").
")".