ILIAS  release_7 Revision v7.30-3-g800a261c036
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 public function __construct($a_obj_id)
45 {
46 global $DIC;
47
48 $ilDB = $DIC['ilDB'];
49
50 parent::__construct($a_obj_id);
51 $this->db = $ilDB;
52 }
53
62 public static function _getNotAttempted($a_obj_id)
63 {
64 $users = array();
65
66 $members = self::getMembers($a_obj_id);
67 if ($members) {
68 // diff in progress and completed (use stored result in LPStatusWrapper)
69 $users = array_diff($members, ilLPStatusWrapper::_getInProgress($a_obj_id));
70 $users = array_diff($users, ilLPStatusWrapper::_getCompleted($a_obj_id));
71 }
72
73 return $users;
74 }
75
83 public static function _getInProgress($a_obj_id)
84 {
85 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
86 $users = ilChangeEvent::lookupUsersInProgress($a_obj_id);
87
88 // Exclude all users with status completed.
89 $users = array_diff((array) $users, ilLPStatusWrapper::_getCompleted($a_obj_id));
90
91 if ($users) {
92 // Exclude all non members
93 $users = array_intersect(self::getMembers($a_obj_id), (array) $users);
94 }
95
96 return $users;
97 }
98
99 public static function _getCompleted($a_obj_id)
100 {
101 global $DIC;
102
103 $ilDB = $DIC['ilDB'];
104
105 $usr_ids = array();
106
107 $query = "SELECT DISTINCT(usr_id) user_id FROM ut_lp_marks " .
108 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
109 "AND completed = '1' ";
110
111 $res = $ilDB->query($query);
112 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
113 $usr_ids[] = $row->user_id;
114 }
115
116 if ($usr_ids) {
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 public function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
133 {
134 global $DIC;
135
136 $ilObjDataCache = $DIC['ilObjDataCache'];
137 $ilDB = $DIC['ilDB'];
138
140 switch ($ilObjDataCache->lookupType($a_obj_id)) {
141 case "crs":
142 case "grp":
143 // completed?
144 $set = $ilDB->query($q = "SELECT usr_id FROM ut_lp_marks " .
145 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
146 "AND usr_id = " . $ilDB->quote($a_user_id, 'integer') . " " .
147 "AND completed = '1' ");
148 if ($rec = $ilDB->fetchAssoc($set)) {
150 } else {
151 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
152 if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
154 }
155 }
156 break;
157 }
158 return $status;
159 }
160
166 protected static function getMembers($a_obj_id)
167 {
168 global $DIC;
169
170 $ilObjDataCache = $DIC['ilObjDataCache'];
171
172 switch ($ilObjDataCache->lookupType($a_obj_id)) {
173 case 'crs':
174 case 'grp':
175 include_once './Services/Membership/classes/class.ilParticipants.php';
176 return ilParticipants::getInstanceByObjId($a_obj_id)->getMembers();
177 }
178
179 return array();
180 }
181
189 public static function _lookupCompletedForObject($a_obj_id, $a_user_ids = null)
190 {
191 if (!$a_user_ids) {
192 $a_user_ids = self::getMembers($a_obj_id);
193 if (!$a_user_ids) {
194 return array();
195 }
196 }
197 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_COMPLETED_NUM, $a_user_ids);
198 }
199
207 public static function _lookupFailedForObject($a_obj_id, $a_user_ids = null)
208 {
209 return array();
210 }
211
219 public static function _lookupInProgressForObject($a_obj_id, $a_user_ids = null)
220 {
221 if (!$a_user_ids) {
222 $a_user_ids = self::getMembers($a_obj_id);
223 if (!$a_user_ids) {
224 return array();
225 }
226 }
227 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_IN_PROGRESS_NUM, $a_user_ids);
228 }
229}
An exception for terminatinating execution or to throw for unit testing.
static lookupUsersInProgress($a_obj_id)
Lookup users in progress.
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
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.
static _getInProgress($a_obj_id)
get in progress
static _getNotAttempted($a_obj_id)
get not attempted
static _getCompleted($a_obj_id)
Static function to read the users who have the status 'completed'.
static _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
static getInstanceByObjId($a_obj_id)
Get instance by obj type.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$query
foreach($_POST as $key=> $value) $res
global $ilDB