ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilLPStatusObjectives.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once 'Services/Tracking/classes/class.ilLPStatus.php';
6
7
17{
18
19 function ilLPStatusObjectives($a_obj_id)
20 {
21 global $ilDB;
22
23 parent::ilLPStatus($a_obj_id);
24 $this->db =& $ilDB;
25 }
26
27 function _getNotAttempted($a_obj_id)
28 {
29 $users = array();
30
31 $members = self::getMembers($a_obj_id);
32 if($members)
33 {
34 // diff in progress, completed and failed (use stored result in LPStatusWrapper)
35 $users = array_diff((array) $members, ilLPStatusWrapper::_getInProgress($a_obj_id));
36 $users = array_diff((array) $members, ilLPStatusWrapper::_getCompleted($a_obj_id));
37 $users = array_diff((array) $members, ilLPStatusWrapper::_getFailed($a_obj_id));
38 }
39
40 return $users;
41 }
42
43 function _getInProgress($a_obj_id)
44 {
45 $objective_results = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
46 $usr_ids = (array)$objective_results['user_status'][self::LP_STATUS_IN_PROGRESS_NUM];
47
48 /* change_event is of no use when no objective has been tried yet
49 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
50 $users = ilChangeEvent::lookupUsersInProgress($a_obj_id);
51
52 // Exclude all users with status completed/failed.
53 $users = array_diff((array) $users,ilLPStatusWrapper::_getCompleted($a_obj_id));
54 $users = array_diff((array) $users,ilLPStatusWrapper::_getFailed($a_obj_id));
55 */
56
57 if($usr_ids)
58 {
59 // Exclude all non members
60 $usr_ids = array_intersect(self::getMembers($a_obj_id), (array)$usr_ids);
61 }
62
63 return $usr_ids ? $usr_ids : array();
64 }
65
66 function _getCompleted($a_obj_id)
67 {
68 $objective_results = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
69 $usr_ids = (array)$objective_results['user_status'][self::LP_STATUS_COMPLETED_NUM];
70
71 if($usr_ids)
72 {
73 // Exclude all non members
74 $usr_ids = array_intersect(self::getMembers($a_obj_id), (array)$usr_ids);
75 }
76
77 return $usr_ids ? $usr_ids : array();
78 }
79
80 function _getFailed($a_obj_id)
81 {
82 $objective_results = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
83 $usr_ids = (array)$objective_results['user_status'][self::LP_STATUS_FAILED_NUM];
84
85 if($usr_ids)
86 {
87 // Exclude all non members
88 $usr_ids = array_intersect(self::getMembers($a_obj_id), (array)$usr_ids);
89 }
90
91 return $usr_ids ? $usr_ids : array();
92 }
93
94 function _getStatusInfo($a_obj_id)
95 {
96 global $ilDB;
97
98 include_once 'Modules/Course/classes/class.ilCourseObjective.php';
99
100 $status_info = array();
101 $status_info['user_status'] = array();
102 $status_info['objectives'] = ilCourseObjective::_getObjectiveIds($a_obj_id,true);
103 $status_info['num_objectives'] = count($status_info['objectives']);
104
105 if($status_info['num_objectives'])
106 {
107 $in = $ilDB->in('objective_id',$status_info['objectives'],false,'integer');
108
109 include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
110 foreach(ilLOUserResults::getSummarizedObjectiveStatusForLP($status_info['objectives']) as $user_id => $user_status)
111 {
112 $status_info['user_status'][$user_status][] = $user_id;
113 }
114
115 // Read title/description
116 $query = "SELECT * FROM crs_objectives WHERE ".$in;
117 $res = $ilDB->query($query);
118 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
119 {
120 $status_info['objective_title'][$row->objective_id] = $row->title;
121 $status_info['objective_description'][$row->objective_id] = $row->description;
122 }
123 }
124
125 return $status_info;
126 }
127
136 function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
137 {
138 global $ilObjDataCache, $ilDB;
139
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
151 switch ($ilObjDataCache->lookupType($a_obj_id))
152 {
153 case "crs":
154 include_once("./Services/Tracking/classes/class.ilChangeEvent.php");
155 if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id))
156 {
157 // change_event is of no use when no objective has been tried
158 // $status = self::LP_STATUS_IN_PROGRESS_NUM;
159
160 include_once 'Modules/Course/classes/class.ilCourseObjective.php';
161 $objectives = ilCourseObjective::_getObjectiveIds($a_obj_id, true);
162 if ($objectives)
163 {
164 // #14051 - getSummarizedObjectiveStatusForLP() might return null
165 include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
166 $status = (int)ilLOUserResults::getSummarizedObjectiveStatusForLP($objectives, $a_user_id);
167 }
168 }
169 break;
170 }
171 return $status;
172 }
173
179 protected static function getMembers($a_obj_id)
180 {
181 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
182 $member_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
183 return $member_obj->getMembers();
184 }
185
193 public static function _lookupCompletedForObject($a_obj_id, $a_user_ids = null)
194 {
195 if(!$a_user_ids)
196 {
197 $a_user_ids = self::getMembers($a_obj_id);
198 if(!$a_user_ids)
199 {
200 return array();
201 }
202 }
203 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_COMPLETED_NUM, $a_user_ids);
204 }
205
213 public static function _lookupFailedForObject($a_obj_id, $a_user_ids = null)
214 {
215 return array();
216 }
217
225 public static function _lookupInProgressForObject($a_obj_id, $a_user_ids = null)
226 {
227 if(!$a_user_ids)
228 {
229 $a_user_ids = self::getMembers($a_obj_id);
230 if(!$a_user_ids)
231 {
232 return array();
233 }
234 }
235 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_IN_PROGRESS_NUM, $a_user_ids);
236 }
237}
238
239
240?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
static _getObjectiveIds($course_id, $a_activated_only=false)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static getSummarizedObjectiveStatusForLP(array $a_objective_ids, $a_user_id=null)
static _lookupInProgressForObject($a_obj_id, $a_user_ids=null)
Get in progress users for object.
determineStatus($a_obj_id, $a_user_id, $a_obj=null)
Determine status.
static getMembers($a_obj_id)
Get members for object.
static _lookupFailedForObject($a_obj_id, $a_user_ids=null)
Get failed users for object.
static _lookupCompletedForObject($a_obj_id, $a_user_ids=null)
Get completed users for object.
_getCompleted($a_obj_id)
Static function to read the users who have the status 'completed'.
_getFailed($a_obj_id)
Static function to read the users who have the status 'completed'.
_getStatusInfo($a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
_getInProgress($a_obj_id)
Static function to read users who have the status 'in_progress'.
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
static _lookupStatusForObject($a_obj_id, $a_status, $a_user_ids=null)
Get users with given status for object.
const LP_STATUS_NOT_ATTEMPTED_NUM
global $ilDB