ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
33 include_once 'Services/Tracking/classes/class.ilLPStatus.php';
34 
36 {
44  function __construct($a_obj_id)
45  {
46  global $ilDB;
47 
48  parent::__construct($a_obj_id);
49  $this->db = $ilDB;
50  }
51 
60  public static 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 static 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  static 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(ilDBConstants::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 
136  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
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  {
148  $status = self::LP_STATUS_COMPLETED_NUM;
149  }
150  else
151  {
152  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
153  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id))
154  {
155  $status = self::LP_STATUS_IN_PROGRESS_NUM;
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  case 'grp':
176  include_once './Services/Membership/classes/class.ilParticipants.php';
177  return ilParticipants::getInstanceByObjId($a_obj_id)->getMembers();
178  }
179 
180  return array();
181  }
182 
190  public static function _lookupCompletedForObject($a_obj_id, $a_user_ids = null)
191  {
192  if(!$a_user_ids)
193  {
194  $a_user_ids = self::getMembers($a_obj_id);
195  if(!$a_user_ids)
196  {
197  return array();
198  }
199  }
200  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_COMPLETED_NUM, $a_user_ids);
201  }
202 
210  public static function _lookupFailedForObject($a_obj_id, $a_user_ids = null)
211  {
212  return array();
213  }
214 
222  public static function _lookupInProgressForObject($a_obj_id, $a_user_ids = null)
223  {
224  if(!$a_user_ids)
225  {
226  $a_user_ids = self::getMembers($a_obj_id);
227  if(!$a_user_ids)
228  {
229  return array();
230  }
231  }
232  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_IN_PROGRESS_NUM, $a_user_ids);
233  }
234 }
235 ?>
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
static _getInProgress($a_obj_id)
Static function to read users who have the status &#39;in_progress&#39;.
static _getCompleted($a_obj_id)
Static function to read the users who have the status &#39;completed&#39;.
static _getNotAttempted($a_obj_id)
get not attempted
static _lookupFailedForObject($a_obj_id, $a_user_ids=null)
Get failed users for object.
static getMembers($a_obj_id)
Get members for object.
Create styles array
The data for the language used.
determineStatus($a_obj_id, $a_user_id, $a_obj=null)
Determine status.
global $ilDB
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
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.
static getInstanceByObjId($a_obj_id)
Get instance by obj type.
static lookupUsersInProgress($a_obj_id)
Lookup users in progress.
static _getInProgress($a_obj_id)
get in progress