3 declare(strict_types=0);
17 if (isset($status_info[
'in_progress'])) {
18 foreach ($status_info[
'in_progress'] as $in_progress) {
19 $users = array_merge($users, $in_progress);
21 $users = array_unique($users);
38 foreach ($status_info[
'items'] as $item_id) {
39 $tmp_users = $status_info[
'completed'][$item_id];
44 $users = array_intersect($users, $tmp_users);
47 $users = array_unique($users);
57 $status_info = array();
59 $collection = $olp->getCollectionInstance();
62 $status_info[
"items"] = $collection->getItems($a_obj_id);
64 foreach ($status_info[
"items"] as $item_id) {
65 $status_info[
"in_progress"][$item_id] = array();
66 $status_info[
"completed"][$item_id] = array();
76 $possible_items = $collection->getPossibleItems(
$ref_id);
77 $chapter_ids = array_intersect(
78 array_keys($possible_items),
83 $status_info[
"items"] = $chapter_ids;
86 foreach ($chapter_ids as $item_id) {
87 $status_info[
"item_titles"][$item_id] = $possible_items[$item_id][
"title"];
91 "SELECT obj_id,usr_id,spent_seconds" .
92 " FROM lm_read_event" .
93 " WHERE " .
$ilDB->in(
"obj_id", $chapter_ids,
"",
"integer")
95 while ($row =
$ilDB->fetchAssoc($set)) {
96 if ($row[
"spent_seconds"] < $status_info[
"tlt"][$row[
"obj_id"]]) {
97 $status_info[
"in_progress"][$row[
"obj_id"]][] = $row[
"usr_id"];
99 $status_info[
"completed"][$row[
"obj_id"]][] = $row[
"usr_id"];
112 $info = self::_getStatusInfo($a_obj_id);
114 $completed_once =
false;
116 if (isset($info[
"completed"])) {
118 foreach ($info[
"completed"] as $user_ids) {
120 if (!in_array($a_usr_id, $user_ids)) {
124 $completed_once =
true;
128 return self::LP_STATUS_COMPLETED_NUM;
133 if ($completed_once) {
134 return self::LP_STATUS_IN_PROGRESS_NUM;
137 if (isset($info[
"in_progress"])) {
138 foreach ($info[
"in_progress"] as $user_ids) {
139 if (in_array($a_usr_id, $user_ids)) {
140 return self::LP_STATUS_IN_PROGRESS_NUM;
145 return self::LP_STATUS_NOT_ATTEMPTED_NUM;
static _getInProgress(int $a_obj_id)
determineStatus(int $a_obj_id, int $a_usr_id, object $a_obj=null)
static _getCompleted(int $a_obj_id)
Static function to read the users who have the status 'completed'.
static _getStatusInfo(int $a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
static _getAllReferences(int $id)
get all reference ids for object ID
static _getStatusInfo(int $a_obj_id)
static _getTypicalLearningTimeSeconds(int $a_rbac_id, int $a_obj_id=0)
static _getCompleted(int $a_obj_id)
static getInstance(int $obj_id)