ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLPStatusManualByTutor.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
27{
31 public static function _getNotAttempted(int $a_obj_id): array
32 {
33 $users = array();
34
35 $members = self::getMembers($a_obj_id);
36 if ($members) {
37 // diff in progress and completed (use stored result in LPStatusWrapper)
38 $users = array_diff(
39 $members,
41 );
42 $users = array_diff(
43 $users,
45 );
46 }
47
48 return $users;
49 }
50
57 public static function _getInProgress(int $a_obj_id): array
58 {
59 $users = ilChangeEvent::lookupUsersInProgress($a_obj_id);
60
61 // Exclude all users with status completed.
62 $users = array_diff(
63 $users,
65 );
66
67 if ($users) {
68 // Exclude all non members
69 $users = array_intersect(self::getMembers($a_obj_id), $users);
70 }
71
72 return $users;
73 }
74
75 public static function _getCompleted(int $a_obj_id): array
76 {
77 global $DIC;
78
79 $ilDB = $DIC['ilDB'];
80
81 $usr_ids = array();
82
83 $query = "SELECT DISTINCT(usr_id) user_id FROM ut_lp_marks " .
84 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
85 "AND completed = '1' ";
86
87 $res = $ilDB->query($query);
88 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
89 $usr_ids[] = (int) $row->user_id;
90 }
91
92 if ($usr_ids) {
93 // Exclude all non members
94 $usr_ids = array_intersect(self::getMembers($a_obj_id), $usr_ids);
95 }
96 return $usr_ids;
97 }
98
102 public function determineStatus(
103 int $a_obj_id,
104 int $a_usr_id,
105 ?object $a_obj = null
106 ): int {
107 global $DIC;
108
109 $ilObjDataCache = $DIC['ilObjDataCache'];
110
112 switch ($this->ilObjDataCache->lookupType($a_obj_id)) {
113 case "crs":
114 case "grp":
115 // completed?
116 $set = $this->db->query(
117 $q = "SELECT usr_id FROM ut_lp_marks " .
118 "WHERE obj_id = " . $this->db->quote(
119 $a_obj_id,
120 'integer'
121 ) . " " .
122 "AND usr_id = " . $this->db->quote(
123 $a_usr_id,
124 'integer'
125 ) . " " .
126 "AND completed = '1' "
127 );
128 if ($rec = $this->db->fetchAssoc($set)) {
130 } else {
131 if (ilChangeEvent::hasAccessed($a_obj_id, $a_usr_id)) {
133 }
134 }
135 break;
136 }
137 return $status;
138 }
139
140 public function refreshStatus(int $a_obj_id, ?array $a_users = null): void
141 {
142 parent::refreshStatus($a_obj_id, $a_users);
143
144 if (ilObject::_lookupType($a_obj_id) !== 'crs') {
145 return;
146 }
147
148 $course_gui = new ilObjCourseGUI('', $a_obj_id, false);
149
150 $in_progress = ilLPStatusWrapper::_getInProgress($a_obj_id);
151 $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
152 $failed = ilLPStatusWrapper::_getFailed($a_obj_id);
153 $not_attempted = ilLPStatusWrapper::_getNotAttempted($a_obj_id);
154 $all_active_users = array_unique(
155 array_merge($in_progress, $completed, $failed, $not_attempted)
156 );
157
158 foreach ($all_active_users as $usr_id) {
159 $course_gui->updateLPFromStatus(
160 $usr_id,
161 ilParticipants::_hasPassed($a_obj_id, $usr_id)
162 );
163 }
164 }
165
169 protected static function getMembers(int $a_obj_id): array
170 {
171 global $DIC;
172
173 $ilObjDataCache = $DIC['ilObjDataCache'];
174
175 switch ($ilObjDataCache->lookupType($a_obj_id)) {
176 case 'crs':
177 case 'grp':
179 $a_obj_id
180 )->getMembers();
181 }
182
183 return array();
184 }
185
189 public static function _lookupCompletedForObject(
190 int $a_obj_id,
191 ?array $a_user_ids = null
192 ): array {
193 if (!$a_user_ids) {
194 $a_user_ids = self::getMembers($a_obj_id);
195 if (!$a_user_ids) {
196 return array();
197 }
198 }
199 return self::_lookupStatusForObject(
200 $a_obj_id,
201 self::LP_STATUS_COMPLETED_NUM,
202 $a_user_ids
203 );
204 }
205
209 public static function _lookupFailedForObject(
210 int $a_obj_id,
211 ?array $a_user_ids = null
212 ): array {
213 return array();
214 }
215
219 public static function _lookupInProgressForObject(
220 int $a_obj_id,
221 ?array $a_user_ids = null
222 ): array {
223 if (!$a_user_ids) {
224 $a_user_ids = self::getMembers($a_obj_id);
225 if (!$a_user_ids) {
226 return array();
227 }
228 }
229 return self::_lookupStatusForObject(
230 $a_obj_id,
231 self::LP_STATUS_IN_PROGRESS_NUM,
232 $a_user_ids
233 );
234 }
235}
static hasAccessed(int $a_obj_id, int $a_usr_id)
Has accessed.
static lookupUsersInProgress(int $a_obj_id)
static _lookupFailedForObject(int $a_obj_id, ?array $a_user_ids=null)
Get failed users for object.
static getMembers(int $a_obj_id)
Get members for object.
static _lookupCompletedForObject(int $a_obj_id, ?array $a_user_ids=null)
Get completed users for object.
static _lookupInProgressForObject(int $a_obj_id, ?array $a_user_ids=null)
Get in progress users for object.
determineStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
Determine status.
refreshStatus(int $a_obj_id, ?array $a_users=null)
Refresh status.
static _getInProgress(int $a_obj_id)
get in progress @access public
static _getNotAttempted(int $a_obj_id)
get not attempted
static _getInProgress(int $a_obj_id)
Static function to read users who have the status 'in_progress'.
static _getFailed(int $a_obj_id)
Static function to read the users who have the status 'completed'.
static _getNotAttempted(int $a_obj_id)
Static function to read the number of user who have the status 'not_attempted'.
static _getCompleted(int $a_obj_id)
Static function to read the users who have the status 'completed'.
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
Class ilObjCourseGUI.
static _lookupType(int $id, bool $reference=false)
static _hasPassed(int $a_obj_id, int $a_usr_id)
Check if user has passed course.
static getInstanceByObjId(int $a_obj_id)
Get instance by obj type.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23