ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLPStatusEvent.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
25{
26 public static function _getNotAttempted(int $a_obj_id): array
27 {
28 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
29
30 $users = array();
31
32 $members = self::getMembers($status_info['crs_id'], true);
33 if ($members) {
34 // diff in progress and completed (use stored result in LPStatusWrapper)
35 $users = array_diff(
36 $members,
38 );
39 $users = array_diff(
40 $users,
42 );
43 }
44
45 return $users;
46 }
47
48 public static function _getInProgress(int $a_obj_id): array
49 {
50 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
51
52 // If registration is disabled in_progress is not available
53 if (!$status_info['registration']) {
54 return array();
55 }
56 // If event has occured in_progress is impossible
57 if ($status_info['starting_time'] < time()) {
58 return array();
59 }
60
61 // Otherwise all users who registered will get the status in progress
62 return $status_info['registered_users'] ?: array();
63 }
64
65 public static function _getCompleted(int $a_obj_id): array
66 {
67 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
68 return $status_info['participated_users'] ?: array();
69 }
70
71 public static function _getStatusInfo(int $a_obj_id): array
72 {
73 $tree = $GLOBALS['DIC']->repositoryTree();
74
75 $references = ilObject::_getAllReferences($a_obj_id);
76 $ref_id = end($references);
77
78 $member_ref_id = null;
79 if ($id = $tree->checkForParentType($ref_id, 'grp')) {
80 $member_ref_id = $id;
81 } elseif ($id = $tree->checkForParentType($ref_id, 'crs')) {
82 $member_ref_id = $id;
83 }
84
85 $status_info = array();
86 $status_info['crs_id'] = ilObject::_lookupObjId($member_ref_id);
87 $status_info['registration'] = ilObjSession::_lookupRegistrationEnabled(
88 $a_obj_id
89 );
90 $status_info['title'] = ilObject::_lookupTitle($a_obj_id);
91 $status_info['description'] = ilObject::_lookupDescription($a_obj_id);
92
93 $time_info = ilSessionAppointment::_lookupAppointment($a_obj_id);
94 $status_info['starting_time'] = $time_info['start'];
95 $status_info['ending_time'] = $time_info['end'];
96 $status_info['fullday'] = $time_info['fullday'];
97
98 $status_info['registered_users'] = ilEventParticipants::_getRegistered(
99 $a_obj_id
100 );
101 $status_info['participated_users'] = ilEventParticipants::_getParticipated(
102 $a_obj_id
103 );
104
105 return $status_info;
106 }
107
108 public function determineStatus(
109 int $a_obj_id,
110 int $a_usr_id,
111 ?object $a_obj = null
112 ): int {
113 global $DIC;
114
115 $ilObjDataCache = $DIC['ilObjDataCache'];
116
118 switch ($this->ilObjDataCache->lookupType($a_obj_id)) {
119 case 'sess':
120
122 $a_obj_id
123 );
125 $a_obj_id
126 );
127
128 // If registration is disabled in_progress is not available
129 // If event has occured in_progress is impossible
130 if ($registration && $time_info['start'] >= time()) {
131 // is user registered -> in progress
133 $a_usr_id,
134 $a_obj_id
135 )) {
137 }
138 }
140 $a_usr_id,
141 $a_obj_id
142 )) {
144 }
145 break;
146 }
147 return $status;
148 }
149
153 protected static function getMembers(
154 int $a_obj_id,
155 bool $a_is_crs_id = false
156 ): array {
157 if (!$a_is_crs_id) {
158 $tree = $GLOBALS['DIC']->repositoryTree();
159 $references = ilObject::_getAllReferences($a_obj_id);
160 $ref_id = end($references);
161
162 $member_ref_id = null;
163 if ($id = $tree->checkForParentType($ref_id, 'grp')) {
164 $member_ref_id = $id;
165 } elseif ($id = $tree->checkForParentType($ref_id, 'crs')) {
166 $member_ref_id = $id;
167 } else {
168 return [];
169 }
170 $member_obj_id = ilObject::_lookupObjId($member_ref_id);
171 } else {
172 $member_obj_id = $a_obj_id;
173 }
174
175 $member_obj = ilParticipants::getInstanceByObjId($member_obj_id);
176 return $member_obj->getMembers();
177 }
178
182 public static function _lookupCompletedForObject(
183 int $a_obj_id,
184 ?array $a_user_ids = null
185 ): array {
186 if (!$a_user_ids) {
187 $a_user_ids = self::getMembers($a_obj_id);
188 if (!$a_user_ids) {
189 return array();
190 }
191 }
192 return self::_lookupStatusForObject(
193 $a_obj_id,
194 self::LP_STATUS_COMPLETED_NUM,
195 $a_user_ids
196 );
197 }
198
202 public static function _lookupFailedForObject(
203 int $a_obj_id,
204 ?array $a_user_ids = null
205 ): array {
206 return array();
207 }
208
212 public static function _lookupInProgressForObject(
213 int $a_obj_id,
214 ?array $a_user_ids = null
215 ): array {
216 if (!$a_user_ids) {
217 $a_user_ids = self::getMembers($a_obj_id);
218 if (!$a_user_ids) {
219 return array();
220 }
221 }
222 return self::_lookupStatusForObject(
223 $a_obj_id,
224 self::LP_STATUS_IN_PROGRESS_NUM,
225 $a_user_ids
226 );
227 }
228}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _isRegistered(int $a_usr_id, int $a_event_id)
static _getParticipated(int $a_event_id)
static _getRegistered(int $a_event_id)
static _hasParticipated(int $a_usr_id, int $a_event_id)
static getMembers(int $a_obj_id, bool $a_is_crs_id=false)
Get members for object.
static _getStatusInfo(int $a_obj_id)
static _lookupFailedForObject(int $a_obj_id, ?array $a_user_ids=null)
Get failed users for object.
static _getCompleted(int $a_obj_id)
static _lookupInProgressForObject(int $a_obj_id, ?array $a_user_ids=null)
Get in progress users for object.
static _getInProgress(int $a_obj_id)
static _getNotAttempted(int $a_obj_id)
determineStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
static _lookupCompletedForObject(int $a_obj_id, ?array $a_user_ids=null)
Get completed users for object.
static _getInProgress(int $a_obj_id)
Static function to read users who have the status 'in_progress'.
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.
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
ilObjectDataCache $ilObjDataCache
static _lookupRegistrationEnabled(int $a_obj_id)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
static getInstanceByObjId(int $a_obj_id)
Get instance by obj type.
static _lookupAppointment(int $a_obj_id)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54