ILIAS  release_8 Revision v8.24
class.ilLPStatusObjectives.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
4
5/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
6
13{
14 public static function _getNotAttempted(int $a_obj_id): array
15 {
16 $users = array();
17
18 $members = self::getMembers($a_obj_id);
19 if ($members) {
20 // diff in progress, completed and failed (use stored result in LPStatusWrapper)
21 $users = array_diff(
22 (array) $members,
24 );
25 $users = array_diff(
26 (array) $members,
28 );
29 $users = array_diff(
30 (array) $members,
32 );
33 }
34 return $users;
35 }
36
37 public static function _getInProgress(int $a_obj_id): array
38 {
39 $objective_results = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
40 $usr_ids = (array) ($objective_results['user_status'][self::LP_STATUS_IN_PROGRESS_NUM] ?? []);
41
42 if ($usr_ids) {
43 // Exclude all non members
44 $usr_ids = array_intersect(self::getMembers($a_obj_id), $usr_ids);
45 }
46
47 if ($usr_ids) {
48 return $usr_ids;
49 } else {
50 return array();
51 }
52 }
53
54 public static function _getCompleted(int $a_obj_id): array
55 {
56 $objective_results = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
57 $usr_ids = (array) ($objective_results['user_status'][self::LP_STATUS_COMPLETED_NUM] ?? []);
58
59 if ($usr_ids) {
60 // Exclude all non members
61 $usr_ids = array_intersect(self::getMembers($a_obj_id), $usr_ids);
62 }
63
64 return $usr_ids ?: array();
65 }
66
67 public static function _getFailed(int $a_obj_id): array
68 {
69 $objective_results = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
70 $usr_ids = (array) ($objective_results['user_status'][self::LP_STATUS_FAILED_NUM] ?? []);
71
72 if ($usr_ids) {
73 // Exclude all non members
74 $usr_ids = array_intersect(self::getMembers($a_obj_id), $usr_ids);
75 }
76
77 return $usr_ids;
78 }
79
80 public static function _getStatusInfo(int $a_obj_id): array
81 {
82 global $DIC;
83
84 $ilDB = $DIC['ilDB'];
85
86 $status_info = array();
87 $status_info['user_status'] = array();
88 $status_info['objectives'] = ilCourseObjective::_getObjectiveIds(
89 $a_obj_id,
90 true
91 );
92 $status_info['num_objectives'] = count($status_info['objectives']);
93
94 if ($status_info['num_objectives']) {
95 $in = $ilDB->in(
96 'objective_id',
97 $status_info['objectives'],
98 false,
99 'integer'
100 );
101
103 $a_obj_id,
104 $status_info['objectives']
105 ) as $user_id => $user_status) {
106 $status_info['user_status'][$user_status][] = $user_id;
107 }
108
109 // change event should lead to "in progress" - see determineStatus()
111 $a_obj_id
112 ) as $user_id) {
113 if (!isset(
114 $status_info['user_status'][ilLPStatus::LP_STATUS_IN_PROGRESS_NUM]
115 ) ||
116 !in_array(
117 $user_id,
118 $status_info['user_status'][ilLPStatus::LP_STATUS_IN_PROGRESS_NUM]
119 )) {
120 $status_info['user_status'][ilLPStatus::LP_STATUS_IN_PROGRESS_NUM][] = $user_id;
121 }
122 }
123
124 // Read title/description
125 $query = "SELECT * FROM crs_objectives WHERE " . $in;
126 $res = $ilDB->query($query);
127 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
128 $status_info['objective_title'][$row->objective_id] = $row->title;
129 $status_info['objective_description'][$row->objective_id] = $row->description;
130 }
131 }
132 return $status_info;
133 }
134
135 public function determineStatus(
136 int $a_obj_id,
137 int $a_usr_id,
138 object $a_obj = null
139 ): int {
140 // the status completed depends on:
141 // $status_info['num_objectives'] (ilLPStatusWrapper::_getStatusInfo($a_obj_id);)
142 // - ilCourseObjective::_getObjectiveIds($a_obj_id);
143 // - table crs_objectives manipulated in
144 // - ilCourseObjective
145
146 // $status_info['objective_result'] (ilLPStatusWrapper::_getStatusInfo($a_obj_id);)
147 // table crs_objective_status (must not contain a dataset)
148 // ilCourseObjectiveResult -> added ilLPStatusWrapper::_updateStatus()
149
150 $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
151 switch ($this->ilObjDataCache->lookupType($a_obj_id)) {
152 case "crs":
153 if (ilChangeEvent::hasAccessed($a_obj_id, $a_usr_id)) {
154 // an initial test (only) should also lead to "in progress"
156
158 $a_obj_id,
159 true
160 );
161 if ($objectives) {
162 // #14051 - getSummarizedObjectiveStatusForLP() might return null
164 $a_obj_id,
166 $a_usr_id
167 );
168 if ($objtv_status !== null) {
169 $status = $objtv_status;
170 }
171 }
172 }
173 break;
174 }
175 return $status;
176 }
177
182 protected static function getMembers(int $a_obj_id): array
183 {
184 $member_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
185 return $member_obj->getMembers();
186 }
187
191 public static function _lookupCompletedForObject(
192 int $a_obj_id,
193 ?array $a_user_ids = null
194 ): array {
195 if (!$a_user_ids) {
196 $a_user_ids = self::getMembers($a_obj_id);
197 if (!$a_user_ids) {
198 return array();
199 }
200 }
201 return self::_lookupStatusForObject(
202 $a_obj_id,
203 self::LP_STATUS_COMPLETED_NUM,
204 $a_user_ids
205 );
206 }
207
211 public static function _lookupFailedForObject(
212 int $a_obj_id,
213 ?array $a_user_ids = null
214 ): array {
215 return array();
216 }
217
221 public static function _lookupInProgressForObject(
222 int $a_obj_id,
223 ?array $a_user_ids = null
224 ): array {
225 if (!$a_user_ids) {
226 $a_user_ids = self::getMembers($a_obj_id);
227 if (!$a_user_ids) {
228 return array();
229 }
230 }
231 return self::_lookupStatusForObject(
232 $a_obj_id,
233 self::LP_STATUS_IN_PROGRESS_NUM,
234 $a_user_ids
235 );
236 }
237}
static hasAccessed(int $a_obj_id, int $a_usr_id)
Has accessed.
static lookupUsersInProgress(int $a_obj_id)
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
static _getInstanceByObjId(int $a_obj_id)
static getSummarizedObjectiveStatusForLP(int $a_obj_id, array $a_objective_ids, int $a_user_id=0)
static _getFailed(int $a_obj_id)
static _lookupFailedForObject(int $a_obj_id, ?array $a_user_ids=null)
Get failed users for object.
static _lookupCompletedForObject(int $a_obj_id, ?array $a_user_ids=null)
Get completed users for object.
static _getStatusInfo(int $a_obj_id)
static _getCompleted(int $a_obj_id)
static _getInProgress(int $a_obj_id)
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)
static getMembers(int $a_obj_id)
static _getNotAttempted(int $a_obj_id)
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 _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_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69
$query
$objectives