ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilLPStatusManualByTutor.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
33include_once 'Services/Tracking/classes/class.ilLPStatus.php';
34
36{
44 function __construct($a_obj_id)
45 {
46 global $ilDB;
47
48 parent::ilLPStatus($a_obj_id);
49 $this->db = $ilDB;
50 }
51
60 public function _getNotAttempted($a_obj_id)
61 {
62 $users = array();
63
64 $members = self::getMembers($a_obj_id);
65 if($members)
66 {
67 // diff in progress and completed (use stored result in LPStatusWrapper)
68 $users = array_diff($members, ilLPStatusWrapper::_getInProgress($a_obj_id));
69 $users = array_diff($users, ilLPStatusWrapper::_getCompleted($a_obj_id));
70 }
71
72 return $users;
73 }
74
82 public function _getInProgress($a_obj_id)
83 {
84 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
85 $users = ilChangeEvent::lookupUsersInProgress($a_obj_id);
86
87 // Exclude all users with status completed.
88 $users = array_diff((array) $users,ilLPStatusWrapper::_getCompleted($a_obj_id));
89
90 if($users)
91 {
92 // Exclude all non members
93 $users = array_intersect(self::getMembers($a_obj_id), (array)$users);
94 }
95
96 return $users;
97 }
98
99 function _getCompleted($a_obj_id)
100 {
101 global $ilDB;
102
103 $usr_ids = array();
104
105 $query = "SELECT DISTINCT(usr_id) user_id FROM ut_lp_marks ".
106 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
107 "AND completed = '1' ";
108
109 $res = $ilDB->query($query);
110 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
111 {
112 $usr_ids[] = $row->user_id;
113 }
114
115 if($usr_ids)
116 {
117 // Exclude all non members
118 $usr_ids = array_intersect(self::getMembers($a_obj_id), (array)$usr_ids);
119 }
120
121 return $usr_ids;
122 }
123
132 function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
133 {
134 global $ilObjDataCache, $ilDB;
135
137 switch ($ilObjDataCache->lookupType($a_obj_id))
138 {
139 case "crs":
140 case "grp":
141 // completed?
142 $set = $ilDB->query($q = "SELECT usr_id FROM ut_lp_marks ".
143 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
144 "AND usr_id = ".$ilDB->quote($a_user_id ,'integer')." ".
145 "AND completed = '1' ");
146 if ($rec = $ilDB->fetchAssoc($set))
147 {
149 }
150 else
151 {
152 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
153 if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id))
154 {
156 }
157 }
158 break;
159 }
160 return $status;
161 }
162
168 protected static function getMembers($a_obj_id)
169 {
170 global $ilObjDataCache;
171
172 switch($ilObjDataCache->lookupType($a_obj_id))
173 {
174 case 'crs':
175 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
176 $member_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
177 return $member_obj->getMembers();
178
179 case 'grp':
180 include_once './Modules/Group/classes/class.ilObjGroup.php';
181 return ilObjGroup::_getMembers($a_obj_id);
182 }
183
184 return array();
185 }
186
194 public static function _lookupCompletedForObject($a_obj_id, $a_user_ids = null)
195 {
196 if(!$a_user_ids)
197 {
198 $a_user_ids = self::getMembers($a_obj_id);
199 if(!$a_user_ids)
200 {
201 return array();
202 }
203 }
204 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_COMPLETED_NUM, $a_user_ids);
205 }
206
214 public static function _lookupFailedForObject($a_obj_id, $a_user_ids = null)
215 {
216 return array();
217 }
218
226 public static function _lookupInProgressForObject($a_obj_id, $a_user_ids = null)
227 {
228 if(!$a_user_ids)
229 {
230 $a_user_ids = self::getMembers($a_obj_id);
231 if(!$a_user_ids)
232 {
233 return array();
234 }
235 }
236 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_IN_PROGRESS_NUM, $a_user_ids);
237 }
238}
239?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static lookupUsersInProgress($a_obj_id)
Lookup users in progress.
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
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.
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.
_getNotAttempted($a_obj_id)
get not attempted
_getInProgress($a_obj_id)
get in progress
_getCompleted($a_obj_id)
Static function to read the users who have the status 'completed'.
_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 ...
const LP_STATUS_COMPLETED_NUM
static _lookupStatusForObject($a_obj_id, $a_status, $a_user_ids=null)
Get users with given status for object.
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
_getMembers($a_obj_id)
global $ilDB