19 declare(strict_types=0);
33 if (isset($status_info[
'in_progress'])) {
34 foreach ($status_info[
'in_progress'] as $in_progress) {
35 $users = array_merge($users, $in_progress);
37 $users = array_unique($users);
54 foreach ($status_info[
'items'] as $item_id) {
55 $tmp_users = $status_info[
'completed'][$item_id];
60 $users = array_intersect($users, $tmp_users);
63 $users = array_unique($users);
73 $status_info = array();
75 $collection = $olp->getCollectionInstance();
78 $status_info[
"items"] = $collection->getItems($a_obj_id);
80 foreach ($status_info[
"items"] as $item_id) {
81 $status_info[
"in_progress"][$item_id] = array();
82 $status_info[
"completed"][$item_id] = array();
88 $status_info[
"tlt"][$item_id] = parent::_getTypicalLearningTime(
97 $possible_items = $collection->getPossibleItems(
$ref_id);
98 $chapter_ids = array_intersect(
99 array_keys($possible_items),
100 $status_info[
"items"]
104 $status_info[
"items"] = $chapter_ids;
107 foreach ($chapter_ids as $item_id) {
108 $status_info[
"item_titles"][$item_id] = $possible_items[$item_id][
"title"];
112 "SELECT obj_id,usr_id,spent_seconds" .
113 " FROM lm_read_event" .
114 " WHERE " .
$ilDB->in(
"obj_id", $chapter_ids,
"",
"integer")
116 while ($row =
$ilDB->fetchAssoc($set)) {
117 if ($row[
"spent_seconds"] < $status_info[
"tlt"][$row[
"obj_id"]]) {
118 $status_info[
"in_progress"][$row[
"obj_id"]][] = $row[
"usr_id"];
120 $status_info[
"completed"][$row[
"obj_id"]][] = $row[
"usr_id"];
131 ?
object $a_obj =
null 133 $info = self::_getStatusInfo($a_obj_id);
135 $completed_once =
false;
137 if (isset($info[
"completed"])) {
139 foreach ($info[
"completed"] as $user_ids) {
141 if (!in_array($a_usr_id, $user_ids)) {
145 $completed_once =
true;
149 return self::LP_STATUS_COMPLETED_NUM;
154 if ($completed_once) {
155 return self::LP_STATUS_IN_PROGRESS_NUM;
158 if (isset($info[
"in_progress"])) {
159 foreach ($info[
"in_progress"] as $user_ids) {
160 if (in_array($a_usr_id, $user_ids)) {
161 return self::LP_STATUS_IN_PROGRESS_NUM;
166 return self::LP_STATUS_NOT_ATTEMPTED_NUM;
determineStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
static _getInProgress(int $a_obj_id)
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)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getCompleted(int $a_obj_id)
static getInstance(int $obj_id)