19 declare(strict_types=0);
    29         $ilDB = $DIC->database();
    31         if (
sizeof($obj_refs)) {
    32             $obj_ids = array_keys($obj_refs);
    33             self::refreshObjectsStatus($obj_ids, array($a_user_id));
    36             $view_modes = array();
    37             $query = 
"SELECT obj_id, view_mode FROM crs_settings" .
    38                 " WHERE " . 
$ilDB->in(
"obj_id", $obj_ids, 
false, 
"integer");
    39             $set = 
$ilDB->query($query);
    40             while ($rec = 
$ilDB->fetchAssoc($set)) {
    41                 $view_modes[(
int) $rec[
"obj_id"]] = (
int) $rec[
"view_mode"];
    44             $sessions = self::getSessionData($a_user_id, $obj_ids);
    47                 " status_changed, percentage, read_count+childs_read_count AS read_count, spent_seconds+childs_spent_seconds AS spent_seconds," .
    48                 " u_mode, type, visits, mark, u_comment" .
    50                 " LEFT JOIN ut_lp_settings ON (ut_lp_settings.obj_id = object_data.obj_id)" .
    51                 " LEFT JOIN read_event ON (read_event.obj_id = object_data.obj_id AND read_event.usr_id = " . 
$ilDB->quote(
    55                 " LEFT JOIN ut_lp_marks ON (ut_lp_marks.obj_id = object_data.obj_id AND ut_lp_marks.usr_id = " . 
$ilDB->quote(
    60                 " WHERE " . 
$ilDB->in(
    67             $set = 
$ilDB->query($query);
    69             while ($rec = 
$ilDB->fetchAssoc($set)) {
    70                 $rec[
"comment"] = $rec[
"u_comment"];
    71                 unset($rec[
"u_comment"]);
    73                 $rec[
"ref_ids"] = $obj_refs[(
int) $rec[
"obj_id"]];
    74                 $rec[
"status"] = (
int) $rec[
"status"];
    75                 $rec[
"percentage"] = (
int) $rec[
"percentage"];
    76                 $rec[
"read_count"] = (
int) $rec[
"read_count"];
    77                 $rec[
"spent_seconds"] = (
int) $rec[
"spent_seconds"];
    78                 $rec[
"u_mode"] = (
int) $rec[
"u_mode"];
    80                 if ($rec[
"type"] == 
"sess") {
    81                     $session = $sessions[(
int) $rec[
"obj_id"]];
    82                     $rec[
"title"] = $session[
"title"];
    89                 } elseif (!$rec[
"u_mode"]) {
    91                     $rec[
"u_mode"] = $olp->getCurrentMode();
   107         array $a_objective_ids
   111         $ilDB = $DIC->database();
   119         $query = 
"SELECT crs_id, crs_objectives.objective_id AS obj_id, title," . 
$ilDB->quote(
   123             " FROM crs_objectives" .
   124             " WHERE " . 
$ilDB->in(
   125                 "crs_objectives.objective_id",
   130             " AND active = " . 
$ilDB->quote(1, 
"integer") .
   131             " ORDER BY position";
   132         $set = 
$ilDB->query($query);
   134         while ($rec = 
$ilDB->fetchAssoc($set)) {
   135             $rec[
'crs_id'] = (
int) $rec[
'crs_id'];
   136             $rec[
'obj_id'] = (
int) $rec[
'obj_id'];
   137             if (array_key_exists($rec[
"obj_id"], $lo_lp_status)) {
   138                 $rec[
"status"] = $lo_lp_status[$rec[
"obj_id"]];
   150         int $a_parent_obj_id,
   153         self::refreshObjectsStatus(array($a_parent_obj_id), array($a_user_id));
   156         $scores_raw = $scores = array();
   163                 $scores_raw = $module->getTrackingDataAgg($a_user_id);
   171                 $scores_raw = $module->getTrackingDataAgg($a_user_id);
   175             foreach ($scores_raw as $item) {
   176                 $scores[$item[
"sco_id"]] = $item[
"score"];
   185         foreach ($a_sco_ids as $sco_id) {
   187             if (in_array($a_user_id, $status_info[
"failed"][$sco_id])) {
   191                 $status_info[
"completed"][$sco_id]
   196                 $status_info[
"in_progress"][$sco_id]
   203             $items[$sco_id] = array(
   204                 "title" => $status_info[
"scos_title"][$sco_id],
   205                 "status" => (
int) $status,
   207                 "score" => (
int) ($scores[$sco_id] ?? 0)
   218         int $a_parent_obj_id,
   221         self::refreshObjectsStatus(array($a_parent_obj_id), array($a_user_id));
   227                 $collection = $olp->getCollectionInstance();
   231                     $item_data = $collection->getPossibleItems(
$ref_id);
   242         foreach ($a_item_ids as $item_id) {
   243             if (!isset($item_data[$item_id])) {
   247             if (in_array($a_user_id, ($status_info[
"completed"][$item_id] ?? []))) {
   249             } elseif (in_array($a_user_id, ($status_info[
"in_progress"][$item_id] ?? []))) {
   255             $items[$item_id] = array(
   256                 "title" => ($item_data[$item_id][
"title"] ?? 
''),
   257                 "status" => (
int) $status,
   258                 "type" => self::getSubItemType($a_parent_obj_id)
   267         string $a_order_field = 
"",
   268         string $a_order_dir = 
"",
   271         ?array $a_filters = null,
   272         ?array $a_additional_fields = null,
   273         ?
int $check_agreement = null,
   274         ?array $privacy_fields = null
   278         $ilDB = $DIC->database();
   280         $fields = array(
"usr_data.usr_id", 
"login", 
"active");
   281         $udf = self::buildColumns($fields, $a_additional_fields);
   284         $where[] = 
"usr_data.usr_id <> " . 
$ilDB->quote(
   291         $a_users = self::getParticipantsForObject($a_ref_id);
   294         self::refreshObjectsStatus(array($obj_id), $a_users);
   296         if (is_array($a_users)) {
   298             $where[] = 
$ilDB->in(
"usr_data.usr_id", $a_users, 
false, 
"integer");
   301         $query = 
" FROM usr_data " . $left . 
" JOIN read_event ON (read_event.usr_id = usr_data.usr_id" .
   302             " AND read_event.obj_id = " . 
$ilDB->quote(
   306             " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id " .
   307             " AND ut_lp_marks.obj_id = " . 
$ilDB->quote(
   311             " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = " . 
$ilDB->quote(
   315             self::buildFilters($where, $a_filters);
   317         $queries = array(array(
"fields" => $fields, 
"query" => $query));
   320         if ($a_order_field == 
"language") {
   321             $a_order_field = 
"usr_pref.value";
   326         if (!$a_order_field) {
   327             $a_order_field = 
"login";
   328         } elseif (substr($a_order_field, 0, 4) == 
"udf_") {
   329             $udf_order = $a_order_field;
   332         $result = self::executeQueries(
   340         self::getUDFAndHandlePrivacy(
   366         ?array $a_udf = null,
   367         ?
int $a_check_agreement = null,
   368         ?array $a_privacy_fields = null,
   369         ?array $a_filters = null
   373         $ilDB = $DIC->database();
   375         if (!$a_result[
"cnt"]) {
   379         if (is_array($a_udf) && count($a_udf) > 0) {
   380             $query = 
"SELECT usr_id, field_id, value FROM udf_text WHERE " . 
$ilDB->in(
   386             $set = 
$ilDB->query($query);
   388             while ($row = 
$ilDB->fetchAssoc($set)) {
   389                 $udf[(
int) $row[
"usr_id"]][
"udf_" . $row[
"field_id"]] = $row[
"value"];
   394         if ($a_check_agreement) {
   401             $query = 
"SELECT usr_id FROM usr_pref WHERE keyword = " . 
$ilDB->quote(
   405                 " AND value = " . 
$ilDB->quote(
   408                 ) . 
" OR value = " . 
$ilDB->quote(
"g", 
"text");
   409             $set = 
$ilDB->query($query);
   410             $all_public = array();
   411             while ($row = 
$ilDB->fetchAssoc($set)) {
   412                 $all_public[] = $row[
"usr_id"];
   414             $query = 
"SELECT usr_id,keyword FROM usr_pref WHERE " . 
$ilDB->like(
   420                 " AND value = " . 
$ilDB->quote(
   423                 ) . 
" AND " . 
$ilDB->in(
   429             $set = 
$ilDB->query($query);
   431             while ($row = 
$ilDB->fetchAssoc($set)) {
   432                 $public[$row[
"usr_id"]][] = substr($row[
"keyword"], 7);
   437         foreach ($a_result[
"set"] as $idx => $row) {
   439             if (isset($udf[$row[
"usr_id"]])) {
   440                 $a_result[
"set"][$idx] = $row = array_merge(
   447             if (
sizeof($a_privacy_fields) && $a_check_agreement && !in_array(
   451                 foreach ($a_privacy_fields as $field) {
   453                     if (isset($row[$field]) && (!isset($public[$row[
"usr_id"]]) ||
   454                             !in_array($field, $public[$row[
"usr_id"]]))) {
   456                         if (isset($a_filters[$field])) {
   458                             foreach (array_keys($row) as $col_id) {
   459                                 $a_result[
"set"][$idx][$col_id] = null;
   461                             $a_result[
"set"][$idx][
"privacy_conflict"] = 
true;
   466                             $a_result[
"set"][$idx][$field] = 
false;
   480         int $a_parent_obj_id,
   481         int $a_parent_ref_id,
   482         string $a_order_field = 
"",
   483         string $a_order_dir = 
"",
   486         ?array $a_filters = null,
   487         ?array $a_additional_fields = null,
   488         bool $use_collection = 
true   492         $ilDB = $DIC->database();
   494         $fields = array(
"object_data.obj_id", 
"title", 
"type");
   495         self::buildColumns($fields, $a_additional_fields);
   497         $objects = self::getObjectIds(
   505         $query = 
" FROM object_data LEFT JOIN read_event ON (object_data.obj_id = read_event.obj_id AND" .
   506             " read_event.usr_id = " . 
$ilDB->quote(
   510             " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = " . 
$ilDB->quote(
   514             " ut_lp_marks.obj_id = object_data.obj_id)" .
   515             " WHERE " . 
$ilDB->in(
   516                 "object_data.obj_id",
   517                 $objects[
"object_ids"],
   521             self::buildFilters(array(), $a_filters);
   524         $queries[] = array(
"fields" => $fields, 
"query" => $query);
   526         if (!in_array($a_order_field, $fields)) {
   527             $a_order_field = 
"title";
   530         $result = self::executeQueries(
   537         if ($result[
"cnt"]) {
   539             $sessions = self::getSessionData(
   541                 $objects[
"object_ids"]
   544             foreach ($result[
"set"] as $idx => $item) {
   545                 if ($item[
"type"] == 
"sess") {
   546                     $session = $sessions[(
int) $item[
"obj_id"]];
   547                     $result[
"set"][$idx][
"title"] = $session[
"title"];
   548                     $result[
"set"][$idx][
"sort_title"] = $session[
"e_start"];
   552                 $result[
"set"][$idx][
"ref_id"] = $objects[
"ref_ids"][(
int) $item[
"obj_id"]];
   556                     $item[
'title'] == 
'' &&
   557                     ($item[
'type'] == 
'catr' ||
   558                     $item[
'type'] == 
'crsr' ||
   559                     $item[
'type'] == 
'grpr')
   561                     $result[
'set'][$idx][
'title'] =
   563                             (
int) $item[
"obj_id"]
   569             if ($objects[
"scorm"]) {
   573                 if ($subtype == 
"scorm2004") {
   578                     $scos_tracking = $sobj->getTrackingDataAgg(
   587                     $scos_tracking = array();
   588                     foreach ($sobj->getTrackingDataAgg($a_user_id) as $item) {
   591                             $time = explode(
":", $item[
"time"]);
   592                             $item[
"time"] = $time[0] * 60 * 60 + $time[1] * 60 + $time[2];
   594                         $scos_tracking[(
int) $item[
"sco_id"]] = array(
"session_time" => $item[
"time"]);
   598                 foreach ($objects[
"scorm"][
"scos"] as $sco) {
   599                     $row = array(
"title" => $objects[
"scorm"][
"scos_title"][$sco],
   606                         $objects[
"scorm"][
"completed"][$sco]
   611                         $objects[
"scorm"][
"failed"][$sco]
   616                         $objects[
"scorm"][
"in_progress"][$sco]
   620                     $row[
"status"] = $status;
   623                     if (isset($scos_tracking[$sco])) {
   624                         if (isset($scos_tracking[$sco][
"last_access"])) {
   626                                 $scos_tracking[$sco][
"last_access"],
   631                         $row[
"spent_seconds"] = $scos_tracking[$sco][
"session_time"];
   634                     $result[
"set"][] = $row;
   635                     $result[
"cnt"] = ($result[
"cnt"] ?? 0) + 1;
   640             if ($objects[
"objectives_parent_id"]) {
   642                     $objects[
"objectives_parent_id"],
   645                 foreach (self::getObjectivesStatusForUser(
   647                     $objects[
"objectives_parent_id"],
   650                     $result[
"set"][] = $item;
   651                     $result[
"cnt"] = ($result[
"cnt"] ?? 0) + 1;
   656             if ($objects[
"subitems"]) {
   657                 $sub_type = self::getSubItemType($a_parent_obj_id);
   658                 foreach ($objects[
"subitems"][
"items"] as $item_id) {
   659                     $row = array(
"title" => $objects[
"subitems"][
"item_titles"][$item_id],
   666                         $objects[
"subitems"][
"completed"][(
int) $item_id]
   670                     $row[
"status"] = $status;
   672                     $result[
"set"][] = $row;
   673                     $result[
"cnt"] = ($result[
"cnt"] ?? 0) + 1;
   704         $ilDB = $DIC->database();
   705         $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," .
   708             " JOIN event_appointment ON (event.obj_id = event_appointment.event_id)" .
   709             " LEFT JOIN event_participants ON (event_participants.event_id = event.obj_id AND usr_id = " . 
$ilDB->quote(
   713             " WHERE " . 
$ilDB->in(
"obj_id", $obj_ids, 
false, 
"integer");
   714         $set = 
$ilDB->query($query);
   716         while ($rec = 
$ilDB->fetchAssoc($set)) {
   717             $rec[
"comment"] = $rec[
"e_comment"];
   718             unset($rec[
"e_comment"]);
   730                 $rec[
"title"] = $date . 
': ' . $rec[
"title"];
   732                 $rec[
"title"] = $date;
   734             $sessions[(
int) $rec[
"obj_id"]] = $rec;
   744         int $a_parent_obj_id,
   745         int $a_parent_ref_id,
   746         string $a_order_field = 
"",
   747         string $a_order_dir = 
"",
   750         ?array $a_filters = null,
   751         ?array $a_additional_fields = null,
   752         ?array $a_preselected_obj_ids = null
   756         $ilDB = $DIC->database();
   759         self::buildColumns($fields, $a_additional_fields, 
true);
   762         if ($a_preselected_obj_ids === null) {
   763             $objects = self::getObjectIds(
   770             foreach ($a_preselected_obj_ids as $obj_id => $ref_ids) {
   771                 $objects[
"object_ids"][] = $obj_id;
   772                 $objects[
"ref_ids"][$obj_id] = array_pop($ref_ids);
   781                 "SELECT obj_id,title,type FROM object_data" .
   782                 " WHERE " . 
$ilDB->in(
   784                     $objects[
"object_ids"],
   789             while ($rec = 
$ilDB->fetchAssoc($set)) {
   790                 $object_data[(
int) $rec[
"obj_id"]] = $rec;
   791                 if ($a_preselected_obj_ids) {
   792                     $object_data[(
int) $rec[
"obj_id"]][
"ref_ids"] = $a_preselected_obj_ids[(
int) $rec[
"obj_id"]];
   794                     $object_data[(
int) $rec[
"obj_id"]][
"ref_ids"] = array($objects[
"ref_ids"][(
int) $rec[
"obj_id"]]);
   798             foreach ($objects[
"ref_ids"] as $object_id => 
$ref_id) {
   799                 $object_result = self::getSummaryDataForObject(
   804                 if (
sizeof($object_result)) {
   805                     if ($object_data[$object_id]) {
   806                         $result[] = array_merge(
   807                             $object_data[$object_id],
   816         return array(
"cnt" => 
sizeof($result), 
"set" => $result);
   822         ?array $a_filters = null
   826         $ilDB = $DIC[
'ilDB'];
   829         $where[] = 
"usr_data.usr_id <> " . 
$ilDB->quote(
   835         $a_users = self::getParticipantsForObject($a_ref_id);
   838         if (is_array($a_users)) { 
   840             $where[] = 
$ilDB->in(
"usr_data.usr_id", $a_users, 
false, 
"integer");
   844         self::refreshObjectsStatus(array($obj_id), $a_users);
   846         $query = 
" FROM usr_data " . $left . 
" JOIN read_event ON (read_event.usr_id = usr_data.usr_id" .
   847             " AND obj_id = " . 
$ilDB->quote($obj_id, 
"integer") . 
")" .
   848             " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id " .
   849             " AND ut_lp_marks.obj_id = " . 
$ilDB->quote(
   853             " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = " . 
$ilDB->quote(
   857             self::buildFilters($where, $a_filters, 
true);
   859         $fields[] = 
'COUNT(usr_data.usr_id) AS user_count';
   862         $queries[] = array(
"fields" => $fields,
   867         $result = self::executeQueries($queries);
   868         $result = (array) ($result[
'set'][0] ?? []);
   869         $users_no = $result[
"user_count"] ?? 0;
   874         } elseif (isset($a_filters[
"user_total"])) {
   875             if ($a_filters[
"user_total"][
"from"] && $users_no < $a_filters[
"user_total"][
"from"]) {
   877             } elseif ($a_filters[
"user_total"][
"to"] && $users_no > $a_filters[
"user_total"][
"to"]) {
   883             $result[
"country"] = self::getSummaryPercentages(
"country", $query);
   884             $result[
"sel_country"] = self::getSummaryPercentages(
   888             $result[
"city"] = self::getSummaryPercentages(
"city", $query);
   889             $result[
"gender"] = self::getSummaryPercentages(
"gender", $query);
   890             $result[
"language"] = self::getSummaryPercentages(
   895             $result[
"status"] = self::getSummaryPercentages(
"status", $query);
   896             $result[
"mark"] = self::getSummaryPercentages(
"mark", $query);
   902             $result[
"user_total"] = $users_no;
   914         ?
string $alias = null
   918         $ilDB = $DIC[
'ilDB'];
   921             $field_alias = $field;
   923             $field_alias = $alias;
   924             $alias = 
" AS " . $alias;
   930             "/" . preg_quote(
" [[--HAVING") . 
"(.+)" . preg_quote(
   936             $having = 
" HAVING " . $hits[1];
   937             $base_query = str_replace($hits[0], 
"", $base_query);
   940         $query = 
"SELECT COUNT(*) AS counter, " . $field . $alias . 
" " . $base_query . 
" GROUP BY " . $field . $having . 
" ORDER BY counter DESC";
   941         $set = 
$ilDB->query($query);
   943         while ($rec = 
$ilDB->fetchAssoc($set)) {
   944             $result[$rec[$field_alias]] = (
int) $rec[
"counter"];
   958         $tree = $DIC[
'tree'];
   966         $members_read = 
false;
   969                 $members_read = 
true;
   971                 $members = $olp->getMembers();
   976                 $members_read = 
true;
   978                 $members = $member_obj->getMembers();
   985                 $members_read = 
true;
   987                 $members = $iass->loadMembers()->membersIds();
   992                 $path = $tree->getPathId($a_ref_id);
   994                 foreach (array_reverse(
$path) as $path_ref_id) {
   996                     if ($type == 
"crs" || $type == 
"grp") {
   997                         $members_read = 
true;
   998                         $members = self::getParticipantsForObject($path_ref_id);
  1005         if ($members_read) {
  1007             $members = self::filterOutUsersWithoutData($members);
  1010             )->filterUserIdsByRbacOrPositionOfCurrentUser(
  1011                 'read_learning_progress',
  1012                 'read_learning_progress',
  1021         switch ($obj_type) {
  1024                 if ($subtype == 
"scorm2004") {
  1027                     $all = $mod->getTrackedUsers(
"");
  1030                         foreach ($all as $item) {
  1031                             $a_users[] = $item[
"user_id"];
  1042                 $a_users = $members->getMembers();
  1050                 $a_users = $class::getParticipants($obj_id);
  1058                 $a_users = $class::getParticipants($obj_id);
  1063                 $a_users = $prg->getIdsOfUsersWithRelevantProgress();
  1070         if (is_null($a_users)) {
  1075         $a_users = self::filterOutUsersWithoutData($a_users);
  1079         )->filterUserIdsByRbacOrPositionOfCurrentUser(
  1080             'read_learning_progress',
  1081             'read_learning_progress',
  1104             $DIC->logger()->trac()->info(
  1105                 'Excluded user with id ' . $user_id .
  1106                 ' from participants, because they do not have an entry in usr_data.'  1114         array $a_filters = null,
  1115         bool $a_aggregate = 
false  1119         $ilDB = $DIC->database();
  1123         if (is_array($a_filters) && 
sizeof($a_filters) > 0) {
  1124             foreach ($a_filters as 
$id => $value) {
  1133                     case "matriculation":
  1137                         $where[] = 
$ilDB->like(
  1147                         $where[] = 
"usr_data." . 
$id . 
" = " . 
$ilDB->quote(
  1154                         $where[] = 
$ilDB->like(
  1155                             "ut_lp_marks." . 
$id,
  1164                             $where[] = 
"(ut_lp_marks.status = " . 
$ilDB->quote(
  1168                                 " OR ut_lp_marks.status IS NULL)";
  1175                         $where[] = 
"ut_lp_marks." . 
$id . 
" = " . 
$ilDB->quote(
  1182                         if (!$a_aggregate) {
  1183                             if (isset($value[
"from"])) {
  1184                                 $where[] = 
"ut_lp_marks." . 
$id . 
" >= " . 
$ilDB->quote(
  1189                             if (isset($value[
"to"])) {
  1190                                 $where[] = 
"(ut_lp_marks." . 
$id . 
" <= " . 
$ilDB->quote(
  1194                                     " OR ut_lp_marks." . 
$id . 
" IS NULL)";
  1197                             if (isset($value[
"from"])) {
  1198                                 $having[] = 
"ROUND(AVG(ut_lp_marks." . 
$id . 
")) >= " . 
$ilDB->quote(
  1203                             if (isset($value[
"to"])) {
  1204                                 $having[] = 
"ROUND(AVG(ut_lp_marks." . 
$id . 
")) <= " . 
$ilDB->quote(
  1213                         $where[] = 
"usr_pref.value = " . 
$ilDB->quote(
  1221                         if (isset($value[
"from"])) {
  1222                             $value[
"from"] = substr(
  1231                             $value[
"from"] = $value[
"from"]->get(
IL_CAL_UNIX);
  1233                         if (isset($value[
"to"])) {
  1234                             if (strlen($value[
"to"]) == 19) {
  1235                                 $value[
"to"] = substr(
  1250                     case 'status_changed':
  1253                     case "registration":
  1254                         if (
$id == 
"registration") {
  1255                             $id = 
"create_date";
  1261                     case "first_access":
  1263                         if (isset($value[
"from"])) {
  1264                             $where[] = 
$id . 
" >= " . 
$ilDB->quote(
  1269                         if (isset($value[
"to"])) {
  1270                             if (strlen($value[
"to"]) == 19) {
  1271                                 $value[
"to"] = substr(
  1277                             $where[] = 
$id . 
" <= " . 
$ilDB->quote(
  1285                         if (!$a_aggregate) {
  1286                             if (isset($value[
"from"]) && $value[
"from"] > 0) {
  1287                                 $where[] = 
"(read_event." . 
$id . 
"+read_event.childs_" . 
$id . 
") >= " . 
$ilDB->quote(
  1292                             if (isset($value[
"to"])) {
  1293                                 $where[] = 
"((read_event." . 
$id . 
"+read_event.childs_" . 
$id . 
") <= " . 
$ilDB->quote(
  1297                                     " OR (read_event." . 
$id . 
"+read_event.childs_" . 
$id . 
") IS NULL)";
  1300                             if (isset($value[
"from"]) && $value[
"from"] > 0) {
  1301                                 $having[] = 
"IFNULL(SUM(read_event." . 
$id . 
"+read_event.childs_" . 
$id . 
"),0) >= " . 
$ilDB->quote(
  1306                             if (isset($value[
"to"])) {
  1307                                 $having[] = 
"IFNULL(SUM(read_event." . 
$id . 
"+read_event.childs_" . 
$id . 
"),0) <= " . 
$ilDB->quote(
  1315                     case "spent_seconds":
  1316                         if (!$a_aggregate) {
  1317                             if (isset($value[
"from"]) && $value[
"from"] > 0) {
  1318                                 $where[] = 
"(read_event." . 
$id . 
"+read_event.childs_" . 
$id . 
") >= " . 
$ilDB->quote(
  1323                             if (isset($value[
"to"]) && $value[
"to"] > 0) {
  1324                                 $where[] = 
"((read_event." . 
$id . 
"+read_event.childs_" . 
$id . 
") <= " . 
$ilDB->quote(
  1328                                     " OR (read_event." . 
$id . 
"+read_event.childs_" . 
$id . 
") IS NULL)";
  1331                             if (isset($value[
"from"]) && $value[
"from"] > 0) {
  1332                                 $having[] = 
"ROUND(AVG(read_event." . 
$id . 
"+read_event.childs_" . 
$id . 
")) >= " . 
$ilDB->quote(
  1337                             if (isset($value[
"to"]) && $value[
"to"] > 0) {
  1338                                 $having[] = 
"ROUND(AVG(read_event." . 
$id . 
"+read_event.childs_" . 
$id . 
")) <= " . 
$ilDB->quote(
  1354         if (
sizeof($where)) {
  1355             $sql .= 
" WHERE " . implode(
" AND ", $where);
  1357         if (
sizeof($having)) {
  1359             $sql .= 
" [[--HAVING " . implode(
" AND ", $having) . 
" HAVING--]]";
  1367         array $a_additional_fields = null,
  1368         bool $a_aggregate = 
false  1370         if ($a_additional_fields === null || !count($a_additional_fields)) {
  1374         foreach ($a_additional_fields as $field) {
  1375             if (substr($field, 0, 4) != 
"udf_") {
  1378                     $pos = strrpos($field, 
"_");
  1379                     if ($pos === 
false) {
  1382                     $function = strtoupper(substr($field, $pos + 1));
  1383                     $field = substr($field, 0, $pos);
  1386                         array(
"MIN", 
"MAX", 
"SUM", 
"AVG", 
"COUNT")
  1398                             $a_fields[] = $function . 
"(value) " . $field . 
"_" . strtolower(
  1402                             $a_fields[] = 
"value as " . $field;
  1407                     case "spent_seconds":
  1409                             $a_fields[] = 
"(" . $field . 
"+childs_" . $field . 
") " . $field;
  1411                             if ($function == 
"AVG") {
  1412                                 $a_fields[] = 
"ROUND(AVG(" . $field . 
"+childs_" . $field . 
"), 2) " . $field . 
"_" . strtolower(
  1416                                 $a_fields[] = $function . 
"(COALESCE(" . $field . 
", 0) + COALESCE(childs_" . $field . 
", 0)) " . $field . 
"_" . strtolower(
  1423                     case "read_count_spent_seconds":
  1424                         if ($function == 
"AVG") {
  1425                             $a_fields[] = 
"ROUND(AVG((spent_seconds+childs_spent_seconds)/(read_count+childs_read_count)), 2) " . $field . 
"_" . strtolower(
  1433                             if ($function == 
"AVG") {
  1434                                 $a_fields[] = 
"ROUND(AVG(" . $field . 
"), 2) " . $field . 
"_" . strtolower(
  1438                                 $a_fields[] = $function . 
"(" . $field . 
") " . $field . 
"_" . strtolower(
  1443                             $a_fields[] = $field;
  1448                 $udf[] = substr($field, 4);
  1453         $a_fields = array_unique($a_fields);
  1455             $udf = array_unique($udf);
  1470         int $a_parent_obj_id,
  1471         int $a_parent_ref_id,
  1472         bool $use_collection = 
true,
  1473         bool $a_refresh_status = 
true,
  1474         ?array $a_user_ids = null
  1476         $object_ids = array($a_parent_obj_id);
  1477         $ref_ids = array($a_parent_obj_id => $a_parent_ref_id);
  1478         $objectives_parent_id = $scorm = $subitems = 
false;
  1481         $mode = $olp->getCurrentMode();
  1485                 $status_scorm = get_class(
  1491                 $scorm = $status_scorm::_getStatusInfo($a_parent_obj_id);
  1496                     $objectives_parent_id = $a_parent_obj_id;
  1503                 $status_coll_tlt = get_class(
  1506                 $subitems = $status_coll_tlt::_getStatusInfo($a_parent_obj_id);
  1511                 if ($use_collection) {
  1512                     $collection = $olp->getCollectionInstance();
  1514                         foreach ($collection->getItems() as $child_ref_id) {
  1516                             $object_ids[] = $child_id;
  1517                             $ref_ids[$child_id] = $child_ref_id;
  1522                     self::getSubTree($a_parent_ref_id, $object_ids, $ref_ids);
  1523                     $object_ids = array_unique($object_ids);
  1526                 foreach ($object_ids as $idx => $object_id) {
  1528                         unset($object_ids[$idx]);
  1534         if ($a_refresh_status) {
  1535             self::refreshObjectsStatus($object_ids, $a_user_ids);
  1538         return array(
"object_ids" => $object_ids,
  1539                      "ref_ids" => $ref_ids,
  1540                      "objectives_parent_id" => $objectives_parent_id,
  1542                      "subitems" => $subitems
  1550         int $a_parent_ref_id,
  1551         array &$a_object_ids,
  1556         $tree = $DIC[
'tree'];
  1558         $children = $tree->getChilds($a_parent_ref_id);
  1560             foreach ($children as $child) {
  1561                 if ($child[
"type"] == 
"adm" || $child[
"type"] == 
"rolf") {
  1569                 $cmode = $olp->getCurrentMode();
  1572                     $a_object_ids[] = $child[
"obj_id"];
  1573                     $a_ref_ids[$child[
"obj_id"]] = $child[
"ref_id"];
  1576                 self::getSubTree($child[
"ref_id"], $a_object_ids, $a_ref_ids);
  1592         string $a_order_field = 
"",
  1593         string $a_order_dir = 
"",
  1599         $ilDB = $DIC->database();
  1601         $subqueries = array();
  1602         foreach ($queries as $item) {
  1604             $item[
'query'] = str_replace(
"[[--HAVING", 
"HAVING", $item[
'query']);
  1605             $item[
'query'] = str_replace(
"HAVING--]]", 
"", $item[
'query']);
  1607             if (!isset($item[
"count"])) {
  1608                 $count_field = $item[
"fields"];
  1609                 $count_field = array_shift($count_field);
  1611                 $count_field = $item[
"count"];
  1613             $count_query = 
"SELECT COUNT(" . $count_field . 
") AS cnt" . $item[
"query"];
  1614             $set = 
$ilDB->query($count_query);
  1615             if ($rec = 
$ilDB->fetchAssoc($set)) {
  1616                 $cnt += $rec[
"cnt"];
  1619             $subqueries[] = 
"SELECT " . implode(
  1628             if (
sizeof($subqueries) > 1) {
  1629                 $base = array_shift($subqueries);
  1630                 $query = $base . 
" UNION (" . implode(
  1635                 $query = $subqueries[0];
  1638             if ($a_order_dir != 
"asc" && $a_order_dir != 
"desc") {
  1639                 $a_order_dir = 
"asc";
  1641             if ($a_order_field) {
  1642                 $query .= 
" ORDER BY " . $a_order_field . 
" " . strtoupper(
  1647             $offset = $a_offset;
  1649             $ilDB->setLimit($limit, $offset);
  1650             $set = 
$ilDB->query($query);
  1651             while ($rec = 
$ilDB->fetchAssoc($set)) {
  1656         return array(
"cnt" => $cnt, 
"set" => $result);
  1670         int $a_parent_ref_id,
  1672         string $a_user_filter = null,
  1673         ?array $a_additional_fields = null,
  1674         ?array $a_privacy_fields = null,
  1675         ?
int $a_check_agreement = null
  1678         $ilDB = $DIC->database();
  1680         $result = array(
"cnt" => 0, 
"set" => null);
  1681         if (
sizeof($a_obj_ids)) {
  1683             $where[] = 
"usr_data.usr_id <> " . 
$ilDB->quote(
  1687             if ($a_user_filter) {
  1688                 $where[] = 
$ilDB->like(
  1691                     "%" . $a_user_filter . 
"%"  1697             $a_users = self::getParticipantsForObject($a_parent_ref_id);
  1698             if (is_array($a_users)) {
  1700                 $where[] = 
$ilDB->in(
  1709             self::refreshObjectsStatus($a_obj_ids, $a_users);
  1711             $fields = array(
"usr_data.usr_id", 
"login", 
"active");
  1712             $udf = self::buildColumns($fields, $a_additional_fields);
  1715             $fields[] = 
"percentage";
  1718             foreach ($a_obj_ids as $obj_id) {
  1720                 $query = 
" FROM usr_data " . $left . 
" JOIN read_event ON (read_event.usr_id = usr_data.usr_id" .
  1721                     " AND read_event.obj_id = " . 
$ilDB->quote(
  1725                     " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id " .
  1726                     " AND ut_lp_marks.obj_id = " . 
$ilDB->quote(
  1730                     " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = " . 
$ilDB->quote(
  1734                     self::buildFilters($where);
  1736                 $raw = self::executeQueries(
  1737                     array(array(
"fields" => $fields, 
"query" => $query)),
  1742                     foreach ($raw[
"set"] as $row) {
  1743                         $result[
"set"][(
int) $row[
"usr_id"]][
"login"] = ($row[
"login"] ?? 
'');
  1744                         $result[
"set"][(
int) $row[
"usr_id"]][
"usr_id"] = (
int) ($row[
"usr_id"] ?? 0);
  1747                         $result[
"set"][(
int) $row[
"usr_id"]][
"obj_" . $obj_id] = (
int) ($row[
"status"] ?? 0);
  1748                         $result[
"set"][(
int) $row[
"usr_id"]][
"obj_" . $obj_id . 
"_perc"] = (
int) ($row[
"percentage"] ?? 0);
  1749                         if ($obj_id == $parent_obj_id) {
  1750                             $result[
"set"][(
int) $row[
"usr_id"]][
"status_changed"] = (
int) ($row[
"status_changed"] ?? 0);
  1751                             $result[
"set"][(
int) $row[
"usr_id"]][
"last_access"] = (
int) ($row[
"last_access"] ?? 0);
  1752                             $result[
"set"][(
int) $row[
"usr_id"]][
"spent_seconds"] = (
int) ($row[
"spent_seconds"] ?? 0);
  1753                             $result[
"set"][(
int) $row[
"usr_id"]][
"read_count"] = (
int) ($row[
"read_count"] ?? 0);
  1757                         foreach ($fields as $field) {
  1759                             if (stristr($field, 
"language")) {
  1760                                 $field = 
"language";
  1763                             if (isset($row[$field])) {
  1765                                 if ($obj_id == $parent_obj_id ||
  1768                                         array(
"mark", 
"u_comment")
  1770                                     $result[
"set"][(
int) $row[
"usr_id"]][$field] = $row[$field];
  1779             if (is_array($result[
"set"])) {
  1780                 $result[
"cnt"] = count($result[
"set"]);
  1782             $result[
"users"] = $a_users;
  1784             self::getUDFAndHandlePrivacy(
  1789                 $a_additional_fields
  1796         int $a_parent_obj_id,
  1801         $ilDB = $DIC->database();
  1803         if ($a_parent_obj_id && $a_users) {
  1813             $initial_qualifying = $lo_set->isInitialTestQualifying();
  1816             foreach ($objective_ids as $objective_id) {
  1822             $query = 
"SELECT * FROM loc_user_results" .
  1823                 " WHERE " . 
$ilDB->in(
  1829                 " AND " . 
$ilDB->in(
"user_id", $a_users, 
false, 
"integer");
  1830             if (!$initial_qualifying) {
  1831                 $query .= 
" AND type = " . 
$ilDB->quote(
  1836             $query .= 
" ORDER BY type"; 
  1837             $set = 
$ilDB->query($query);
  1838             while ($row = 
$ilDB->fetchAssoc($set)) {
  1839                 $objective_id = (
int) $row[
"objective_id"];
  1862         ?
string $a_month = null
  1866         $ilDB = $DIC[
'ilDB'];
  1868         $obj_ids = array_keys($a_ref_ids);
  1877         $sql = 
"SELECT obj_id," . $column . 
",SUM(read_count) read_count,SUM(childs_read_count) childs_read_count," .
  1878             "SUM(spent_seconds) spent_seconds,SUM(childs_spent_seconds) childs_spent_seconds" .
  1880             " WHERE " . 
$ilDB->in(
"obj_id", $obj_ids, 
"", 
"integer") .
  1881             " AND yyyy = " . 
$ilDB->quote($a_year, 
"integer");
  1883             $sql .= 
" AND mm = " . 
$ilDB->quote($a_month, 
"integer");
  1885         $sql .= 
" GROUP BY obj_id," . $column;
  1886         $set = 
$ilDB->query($sql);
  1887         while ($row = 
$ilDB->fetchAssoc($set)) {
  1888             $row[
"read_count"] += (
int) $row[
"childs_read_count"];
  1889             $row[
"spent_seconds"] += (
int) $row[
"childs_spent_seconds"];
  1890             $res[$row[
"obj_id"]][$row[$column]][
"read_count"] =
  1891                 (
$res[$row[
"obj_id"]][$row[$column]][
"read_count"] ?? 0) + $row[
"read_count"];
  1892             $res[$row[
"obj_id"]][$row[$column]][
"spent_seconds"] =
  1893                 (
$res[$row[
"obj_id"]][$row[$column]][
"spent_seconds"] ?? 0) + $row[
"spent_seconds"];
  1898         $sql = 
"SELECT obj_id," . $column . 
",SUM(counter) counter" .
  1899             " FROM obj_user_stat" .
  1900             " WHERE " . 
$ilDB->in(
"obj_id", $obj_ids, 
"", 
"integer") .
  1901             " AND yyyy = " . 
$ilDB->quote($a_year, 
"integer");
  1903             $sql .= 
" AND mm = " . 
$ilDB->quote($a_month, 
"integer");
  1905         $sql .= 
" GROUP BY obj_id," . $column;
  1906         $set = 
$ilDB->query($sql);
  1907         while ($row = 
$ilDB->fetchAssoc($set)) {
  1908             if (!isset(
$res[(
int) $row[
"obj_id"]][$row[$column]][
"users"])) {
  1909                 $res[(
int) $row[
"obj_id"]][$row[$column]][
"users"] = 0;
  1911             $res[(
int) $row[
"obj_id"]][$row[$column]][
"users"] += (
int) $row[
"counter"];
  1921         $ilDB = $DIC[
'ilDB'];
  1922         $objDefinition = $DIC[
'objDefinition'];
  1925         $types = array_keys(
  1926             $objDefinition->getCreatableSubObjects(
  1934         $sql = 
"SELECT " . $tree->getObjectDataTable(
  1935         ) . 
".obj_id," . $tree->getObjectDataTable() . 
".type," .
  1936             $tree->getTreeTable() . 
"." . $tree->getTreePk(
  1937             ) . 
"," . $tree->getTableReference() . 
".ref_id" .
  1938             " FROM " . $tree->getTreeTable() .
  1939             " " . $tree->buildJoin() .
  1940             " WHERE " . 
$ilDB->in(
  1941                 $tree->getObjectDataTable() . 
".type",
  1946         $set = 
$ilDB->query($sql);
  1948         while ($row = 
$ilDB->fetchAssoc($set)) {
  1949             $res[$row[
"type"]][
"type"] = (string) $row[
"type"];
  1950             $res[$row[
"type"]][
"references"] = (
$res[$row[
"type"]][
"references"] ?? 0) + 1;
  1951             $res[$row[
"type"]][
"objects"][] = (
int) $row[
"obj_id"];
  1952             if ($row[$tree->getTreePk()] < 0) {
  1953                 $res[$row[
"type"]][
"deleted"] = (
$res[$row[
"type"]][
"deleted"] ?? 0) + 1;
  1955                 $res[$row[
"type"]][
"deleted"] = (
$res[$row[
"type"]][
"deleted"] ?? 0);
  1959         foreach (
$res as $type => $values) {
  1960             $res[$type][
"objects"] = count((array_unique($values[
"objects"] ?? [])));
  1964         foreach (self::getPortfolios() as $obj_id) {
  1965             $res[
"prtf"][
"type"] = 
"prtf";
  1966             $res[
"prtf"][
"references"] = (
$res[
"prtf"][
"references"] ?? 0) + 1;
  1967             $res[
"prtf"][
"objects"] = (
$res[
"prtf"][
"objects"] ?? 0) + 1;
  1970         foreach (self::getWorkspaceBlogs() as $obj_id) {
  1971             $res[
"blog"][
"type"] = 
"blog";
  1972             $res[
"blog"][
"references"] = (
$res[
"blog"][
"references"] ?? 0) + 1;
  1973             $res[
"blog"][
"objects"] = (
$res[
"blog"][
"objects"] ?? 0) + 1;
  1982         $ilDB = $DIC->database();
  1987         $sql = 
"SELECT od.obj_id,oref.wsp_id,od.type" .
  1988             " FROM tree_workspace wst" .
  1989             " JOIN object_reference_ws oref ON (oref.wsp_id = wst.child)" .
  1990             " JOIN object_data od ON (oref.obj_id = od.obj_id)" .
  1991             " WHERE od.type = " . 
$ilDB->quote(
"blog", 
"text");
  1994             $sql .= 
" AND " . 
$ilDB->like(
  1997                 "%" . $a_title . 
"%"  2001         $set = 
$ilDB->query($sql);
  2002         while ($row = 
$ilDB->fetchAssoc($set)) {
  2003             $res[] = (
int) $row[
"obj_id"];
  2012         $ilDB = $DIC[
'ilDB'];
  2016         $sql = 
"SELECT od.obj_id" .
  2017             " FROM usr_portfolio prtf" .
  2018             " JOIN object_data od ON (od.obj_id = prtf.id)";
  2021             $sql .= 
" WHERE " . 
$ilDB->like(
  2024                 "%" . $a_title . 
"%"  2028         $set = 
$ilDB->query($sql);
  2029         while ($row = 
$ilDB->fetchAssoc($set)) {
  2030             $res[] = (
int) $row[
"obj_id"];
  2039         ?
string $a_month = null
  2043         $ilDB = $DIC->database();
  2044         $obj_ids = array_keys($a_ref_ids);
  2047         $sql = 
"SELECT obj_id,hh,SUM(read_count) read_count,SUM(childs_read_count) childs_read_count," .
  2048             "SUM(spent_seconds) spent_seconds,SUM(childs_spent_seconds) childs_spent_seconds" .
  2050             " WHERE " . 
$ilDB->in(
"obj_id", $obj_ids, 
false, 
"integer") .
  2051             " AND yyyy = " . 
$ilDB->quote($a_year, 
"integer");
  2053             $sql .= 
" AND mm = " . 
$ilDB->quote($a_month, 
"integer");
  2055         $sql .= 
" GROUP BY obj_id,hh";
  2056         $set = 
$ilDB->query($sql);
  2057         while ($row = 
$ilDB->fetchAssoc($set)) {
  2058             $row[
"read_count"] += (
int) $row[
"childs_read_count"];
  2059             $row[
"spent_seconds"] += (
int) $row[
"childs_spent_seconds"];
  2060             $res[$row[
"obj_id"]][(
int) $row[
"hh"]][
"read_count"] =
  2061                 (
$res[$row[
"obj_id"]][(
int) $row[
"hh"]][
"read_count"] ?? 0) + $row[
"read_count"];
  2062             $res[$row[
"obj_id"]][(
int) $row[
"hh"]][
"spent_seconds"] =
  2063                 (
$res[$row[
"obj_id"]][(
int) $row[
"hh"]][
"spent_seconds"] ?? 0) + $row[
"spent_seconds"];
  2072         $ilDB = $DIC[
'ilDB'];
  2074         $set = 
$ilDB->query(
  2075             "SELECT COUNT(*) AS COUNTER,yyyy,mm" .
  2077             " GROUP BY yyyy, mm" .
  2078             " ORDER BY yyyy DESC, mm DESC"  2081         while ($row = 
$ilDB->fetchAssoc($set)) {
  2082             $res[] = array(
"month" => $row[
"yyyy"] . 
"-" . $row[
"mm"],
  2083                            "count" => (
int) ($row[
"COUNTER"] ?? 0)
  2093         $ilDB = $DIC->database();
  2096         $date_compare = 
$ilDB->in(
  2098                 array(array(
"yyyy", 
""),
  2099                       array(
$ilDB->quote(
"-", 
"text"), 
""),
  2107         $sql = 
"DELETE FROM obj_stat" .
  2108             " WHERE " . $date_compare;
  2109         $ilDB->manipulate($sql);
  2112         $tables = array(
"obj_lp_stat", 
"obj_type_stat", 
"obj_user_stat");
  2113         foreach ($a_months as $month) {
  2114             $year = substr($month, 0, 4);
  2115             $month = substr($month, 5);
  2116             $from = $year . str_pad($month, 2, 
"0", STR_PAD_LEFT) . 
"01";
  2117             $to = $year . str_pad($month, 2, 
"0", STR_PAD_LEFT) . 
"31";
  2119             foreach ($tables as $table) {
  2120                 $sql = 
"DELETE FROM " . $table .
  2121                     " WHERE fulldate >= " . 
$ilDB->quote($from, 
"integer") .
  2122                     " AND fulldate <= " . 
$ilDB->quote($to, 
"integer");
  2123                 $ilDB->manipulate($sql);
  2130         ?
string $a_title = null,
  2131         ?
int $a_root = null,
  2132         ?array $a_hidden = null,
  2133         ?array $a_preset_obj_ids = null
  2137         $ilDB = $DIC->database();
  2138         $tree = $DIC->repositoryTree();
  2140         if ($a_type == 
"lres") {
  2141             $a_type = array(
'lm', 
'sahs', 
'htlm');
  2144         $sql = 
"SELECT r.ref_id,r.obj_id" .
  2145             " FROM object_data o" .
  2146             " JOIN object_reference r ON (o.obj_id = r.obj_id)" .
  2147             " JOIN tree t ON (t.child = r.ref_id)" .
  2148             " WHERE t.tree = " . 
$ilDB->quote(1, 
"integer");
  2150         if (!is_array($a_type)) {
  2151             $sql .= 
" AND o.type = " . 
$ilDB->quote($a_type, 
"text");
  2153             $sql .= 
" AND " . 
$ilDB->in(
"o.type", $a_type, 
false, 
"text");
  2157             $sql .= 
" AND (" . 
$ilDB->like(
  2160                 "%" . $a_title . 
"%"  2162                 " OR " . 
$ilDB->like(
  2165                     "%" . $a_title . 
"%"  2169         if (is_array($a_hidden)) {
  2170             $sql .= 
" AND " . 
$ilDB->in(
"o.obj_id", $a_hidden, 
true, 
"integer");
  2173         if (is_array($a_preset_obj_ids)) {
  2174             $sql .= 
" AND " . 
$ilDB->in(
  2182         $set = 
$ilDB->query($sql);
  2184         while ($row = 
$ilDB->fetchAssoc($set)) {
  2189                     if ($tree->isGrandChild($a_root, 
$ref_id)) {
  2190                         $res[$row[
"obj_id"]][] = (
int) $row[
"ref_id"];
  2194                 $res[$row[
"obj_id"]][] = (
int) $row[
"ref_id"];
  2205         ?array $a_users = null
  2207         foreach ($a_obj_ids as $obj_id) {
  2219         $ilDB = $DIC->database();
  2220         $set = 
$ilDB->query(
  2221             "SELECT COUNT(*) counter, MIN(tstamp) tstamp" .
  2222             " FROM obj_stat_log"  2224         return $ilDB->fetchAssoc($set);
  2230         int $a_month = null,
  2231         bool $a_group_by_day = 
false  2235         $ilDB = $DIC->database();
  2236         if ($a_group_by_day) {
  2239             $column = 
"mm,yyyy";
  2243         $sql = 
"SELECT obj_id," . $column . 
"," .
  2244             "MIN(mem_cnt) mem_cnt_min,AVG(mem_cnt) mem_cnt_avg, MAX(mem_cnt) mem_cnt_max," .
  2245             "MIN(in_progress) in_progress_min,AVG(in_progress) in_progress_avg,MAX(in_progress) in_progress_max," .
  2246             "MIN(completed) completed_min,AVG(completed) completed_avg,MAX(completed) completed_max," .
  2247             "MIN(failed) failed_min,AVG(failed) failed_avg,MAX(failed) failed_max," .
  2248             "MIN(not_attempted) not_attempted_min,AVG(not_attempted) not_attempted_avg,MAX(not_attempted) not_attempted_max" .
  2249             " FROM obj_lp_stat" .
  2250             " WHERE " . 
$ilDB->in(
"obj_id", $a_obj_ids, 
false, 
"integer") .
  2251             " AND yyyy = " . 
$ilDB->quote($a_year, 
"integer");
  2253             $sql .= 
" AND mm = " . 
$ilDB->quote($a_month, 
"integer");
  2255         $sql .= 
" GROUP BY obj_id," . $column;
  2256         $set = 
$ilDB->query($sql);
  2257         while ($row = 
$ilDB->fetchAssoc($set)) {
  2258             $row[
'obj_id'] = (
int) $row[
'obj_id'];
  2266         string $a_aggregation,
  2267         ?
string $a_year = null
  2271         $ilDB = $DIC[
'ilDB'];
  2274             $a_year = date(
"Y");
  2277         $agg = strtoupper($a_aggregation);
  2280         $sql = 
"SELECT type,yyyy,mm," . $agg . 
"(cnt_objects) cnt_objects," . $agg . 
"(cnt_references) cnt_references," .
  2281             "" . $agg . 
"(cnt_deleted) cnt_deleted FROM obj_type_stat" .
  2282             " WHERE yyyy = " . 
$ilDB->quote($a_year, 
"integer") .
  2283             " GROUP BY type,yyyy,mm";
  2284         $set = 
$ilDB->query($sql);
  2285         while ($row = 
$ilDB->fetchAssoc($set)) {
  2286             $row[
"mm"] = str_pad($row[
"mm"], 2, 
"0", STR_PAD_LEFT);
  2287             $res[$row[
"type"]][$row[
"yyyy"] . 
"-" . $row[
"mm"]] = array(
  2288                 "objects" => (
int) $row[
"cnt_objects"],
  2289                 "references" => (
int) $row[
"cnt_references"],
  2290                 "deleted" => (
int) $row[
"cnt_deleted"]
  2301         $db = $DIC->database();
  2302         $query = 
'select min(yyyy) min from obj_type_stat';
  2303         $res = $db->query($query);
 const LP_STATUS_COMPLETED_NUM
 
static _lookupTargetTitle(int $a_obj_id)
 
static refreshObjectsStatus(array $a_obj_ids, ?array $a_users=null)
check whether status (for all relevant users) exists 
 
static searchObjects(string $a_type, ?string $a_title=null, ?int $a_root=null, ?array $a_hidden=null, ?array $a_preset_obj_ids=null)
 
For the purpose of streamlining the grading and learning-process status definition outside of tests...
 
static getSubItemsStatusForUser(int $a_user_id, int $a_parent_obj_id, array $a_item_ids)
Get subitems status. 
 
static getObjectivesStatusForUser(int $a_user_id, int $a_obj_id, array $a_objective_ids)
 
static getUserObjectiveMatrix(int $a_parent_obj_id, array $a_users)
 
static getObjectStatisticsMonthlySummary()
 
const LP_STATUS_NOT_ATTEMPTED
 
static _getStatusInfo(int $a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits. 
 
static getInstance(int $a_ref_id)
 
static _getAllReferences(int $id)
get all reference ids for object ID 
 
static getUserDataForObject(int $a_ref_id, string $a_order_field="", string $a_order_dir="", int $a_offset=0, int $a_limit=9999, ?array $a_filters=null, ?array $a_additional_fields=null, ?int $check_agreement=null, ?array $privacy_fields=null)
 
static deleteObjectStatistics(array $a_months)
 
const LP_STATUS_IN_PROGRESS_NUM
 
static getSCOsStatusForUser(int $a_user_id, int $a_parent_obj_id, array $a_sco_ids)
 
const LP_MODE_COLLECTION_MANUAL
 
static getObjectIds(int $a_parent_obj_id, int $a_parent_ref_id, bool $use_collection=true, bool $a_refresh_status=true, ?array $a_user_ids=null)
Get (sub)objects for given object, also handles learning objectives (course only) ...
 
static getSummaryDataForObject(int $a_ref_id, array $fields, ?array $a_filters=null)
 
const LP_MODE_COLLECTION_TLT
 
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
 
static getObjectiveStatusForLP(int $a_user_id, int $a_obj_id, array $a_objective_ids)
 
static getSubItemType(int $a_parent_obj_id)
Get sub-item object type for parent. 
 
const LP_MODE_TEST_FINISHED
 
static getObjectDailyStatistics(array $a_ref_ids, string $a_year, ?string $a_month=null)
 
static _lookupSubType(int $a_obj_id)
lookup subtype id (scorm, ) 
 
static getSummaryPercentages(string $field, string $base_query, ?string $alias=null)
Get aggregated data for field. 
 
const LP_STATUS_IN_PROGRESS
 
static _lookupObjId(int $ref_id)
 
static getObjectsSummaryForObject(int $a_parent_obj_id, int $a_parent_ref_id, string $a_order_field="", string $a_order_dir="", int $a_offset=0, int $a_limit=9999, ?array $a_filters=null, ?array $a_additional_fields=null, ?array $a_preselected_obj_ids=null)
Get all aggregated tracking data for parent object :TODO: sorting, offset, limit, objectives...
 
static getUserObjectMatrix(int $a_parent_ref_id, array $a_obj_ids, string $a_user_filter=null, ?array $a_additional_fields=null, ?array $a_privacy_fields=null, ?int $a_check_agreement=null)
Get status matrix for users on objects. 
 
static getSessionData(int $a_user_id, array $obj_ids)
Get session data for given objects and user. 
 
static userExists(array $a_usr_ids=[])
 
static getWorkspaceBlogs(?string $a_title=null)
 
static getUDFAndHandlePrivacy(array &$a_result, ?array $a_udf=null, ?int $a_check_agreement=null, ?array $a_privacy_fields=null, ?array $a_filters=null)
Handle privacy and add udf data to (user) result data. 
 
static _getClassById(int $a_obj_id, ?int $a_mode=null)
 
static _lookupObjectId(int $ref_id)
 
const LP_MODE_SURVEY_FINISHED
 
static _getTrackedUsers(int $a_obj_id)
Get all tracked users. 
 
static getObjectTypeStatisticsPerMonth(string $a_aggregation, ?string $a_year=null)
 
static stableSortArray(array $array, string $a_array_sortby, string $a_array_sortorder="asc", bool $a_numeric=false)
Sort an aray using a stable sort algorithm, which preveserves the sequence of array elements which ha...
 
static buildColumns(array &$a_fields, array $a_additional_fields=null, bool $a_aggregate=false)
 
static getInstanceByObjId(int $a_obj_id)
 
const IL_CRS_VIEW_OBJECTIVE
 
static filterOutUsersWithoutData(array $user_ids)
 
static executeQueries(array $queries, string $a_order_field="", string $a_order_dir="", int $a_offset=0, int $a_limit=9999)
Execute given queries, including count query. 
 
static getObjectTypeStatisticsMinYear()
 
const LP_STATUS_NOT_ATTEMPTED_NUM
 
static getObjectsStatusForUser(int $a_user_id, array $obj_refs)
 
static getSubTree(int $a_parent_ref_id, array &$a_object_ids, array &$a_ref_ids)
Get complete branch of tree (recursively) 
 
static _getInstance(int $a_obj_id, ?int $a_mode=null)
 
const LP_MODE_COLLECTION_MOBS
 
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ilObjUser $user=null)
Format a period of two dates Shows: 14. 
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static getParticipantsForObject(int $a_ref_id)
Get participant ids for given object. 
 
static getPortfolios(?string $a_title=null)
 
static buildFilters(array $where, array $a_filters=null, bool $a_aggregate=false)
 
static lookupAcceptedAgreements(int $a_obj_id)
Lookup users who have accepted the agreement. 
 
static getObjectTypeStatistics()
 
static _lookupType(int $id, bool $reference=false)
 
static checkStatusForObject(int $a_obj_id, ?array $a_users=null)
This function checks whether the status for a given number of users is dirty and must be recalculated...
 
const LP_STATUS_COMPLETED
 
static getObjectAccessStatistics(array $a_ref_ids, string $a_year, ?string $a_month=null)
 
static getInstance(int $obj_id)
 
static getObjectsDataForUser(int $a_user_id, int $a_parent_obj_id, int $a_parent_ref_id, string $a_order_field="", string $a_order_dir="", int $a_offset=0, int $a_limit=9999, ?array $a_filters=null, ?array $a_additional_fields=null, bool $use_collection=true)
Get all object-based tracking data for user and parent object. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static getObjectStatisticsLogInfo()
Get last update info for object statistics. 
 
const LP_STATUS_FAILED_NUM
 
static getObjectLPStatistics(array $a_obj_ids, int $a_year, int $a_month=null, bool $a_group_by_day=false)