ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  public 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  // diff in progress and completed (use stored result in LPStatusWrapper)
67  $users = array_diff($members, ilLPStatusWrapper::_getInProgress($a_obj_id));
68  $users = array_diff($users, ilLPStatusWrapper::_getCompleted($a_obj_id));
69  }
70 
71  return $users;
72  }
73 
81  public static function _getInProgress($a_obj_id)
82  {
83  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
85 
86  // Exclude all users with status completed.
87  $users = array_diff((array) $users, ilLPStatusWrapper::_getCompleted($a_obj_id));
88 
89  if ($users) {
90  // Exclude all non members
91  $users = array_intersect(self::getMembers($a_obj_id), (array) $users);
92  }
93 
94  return $users;
95  }
96 
97  public static function _getCompleted($a_obj_id)
98  {
99  global $ilDB;
100 
101  $usr_ids = array();
102 
103  $query = "SELECT DISTINCT(usr_id) user_id FROM ut_lp_marks " .
104  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
105  "AND completed = '1' ";
106 
107  $res = $ilDB->query($query);
108  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
109  $usr_ids[] = $row->user_id;
110  }
111 
112  if ($usr_ids) {
113  // Exclude all non members
114  $usr_ids = array_intersect(self::getMembers($a_obj_id), (array) $usr_ids);
115  }
116 
117  return $usr_ids;
118  }
119 
128  public function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
129  {
130  global $ilObjDataCache, $ilDB;
131 
132  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
133  switch ($ilObjDataCache->lookupType($a_obj_id)) {
134  case "crs":
135  case "grp":
136  // completed?
137  $set = $ilDB->query($q = "SELECT usr_id FROM ut_lp_marks " .
138  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
139  "AND usr_id = " . $ilDB->quote($a_user_id, 'integer') . " " .
140  "AND completed = '1' ");
141  if ($rec = $ilDB->fetchAssoc($set)) {
142  $status = self::LP_STATUS_COMPLETED_NUM;
143  } else {
144  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
145  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
146  $status = self::LP_STATUS_IN_PROGRESS_NUM;
147  }
148  }
149  break;
150  }
151  return $status;
152  }
153 
159  protected static function getMembers($a_obj_id)
160  {
161  global $ilObjDataCache;
162 
163  switch ($ilObjDataCache->lookupType($a_obj_id)) {
164  case 'crs':
165  case 'grp':
166  include_once './Services/Membership/classes/class.ilParticipants.php';
167  return ilParticipants::getInstanceByObjId($a_obj_id)->getMembers();
168  }
169 
170  return array();
171  }
172 
180  public static function _lookupCompletedForObject($a_obj_id, $a_user_ids = null)
181  {
182  if (!$a_user_ids) {
183  $a_user_ids = self::getMembers($a_obj_id);
184  if (!$a_user_ids) {
185  return array();
186  }
187  }
188  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_COMPLETED_NUM, $a_user_ids);
189  }
190 
198  public static function _lookupFailedForObject($a_obj_id, $a_user_ids = null)
199  {
200  return array();
201  }
202 
210  public static function _lookupInProgressForObject($a_obj_id, $a_user_ids = null)
211  {
212  if (!$a_user_ids) {
213  $a_user_ids = self::getMembers($a_obj_id);
214  if (!$a_user_ids) {
215  return array();
216  }
217  }
218  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_IN_PROGRESS_NUM, $a_user_ids);
219  }
220 }
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.
foreach($_POST as $key=> $value) $res
static getMembers($a_obj_id)
Get members for object.
$query
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
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