ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPStatusManual.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 {
37 
38  function ilLPStatusManual($a_obj_id)
39  {
40  global $ilDB;
41 
42  parent::ilLPStatus($a_obj_id);
43  $this->db =& $ilDB;
44  }
45 
46  function _getNotAttempted($a_obj_id)
47  {
48  global $ilObjDataCache;
49 
50  global $ilBench;
51  $ilBench->start('LearningProgress','9161_LPStatusManual_notAttempted');
52 
53  switch($ilObjDataCache->lookupType($a_obj_id))
54  {
55  case 'crs':
56 
57  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
58  $members_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
59  $members = $members_obj->getParticipants();
60 
61  // diff in progress and completed (use stored result in LPStatusWrapper)
62  $users = array_diff($members,$inp = ilLPStatusWrapper::_getInProgress($a_obj_id));
63  $users = array_diff($users,$com = ilLPStatusWrapper::_getCompleted($a_obj_id));
64 
65  $ilBench->stop('LearningProgress','9161_LPStatusManual_notAttempted');
66  return $users;
67 
68  case 'grp':
69 
70  include_once './Modules/Group/classes/class.ilObjGroup.php';
71 
72  $members = ilObjGroup::_getMembers($a_obj_id);
73  // diff in progress and completed (use stored result in LPStatusWrapper)
74  $users = array_diff($members,$inp = ilLPStatusWrapper::_getInProgress($a_obj_id));
75  $users = array_diff($users,$com = ilLPStatusWrapper::_getCompleted($a_obj_id));
76 
77  $ilBench->stop('LearningProgress','9161_LPStatusManual_notAttempted');
78  return $users;
79 
80  default:
81  $ilBench->stop('LearningProgress','9161_LPStatusManual_notAttempted');
82  return array();
83  }
84  }
85 
86  function _getInProgress($a_obj_id)
87  {
88  global $ilObjDataCache;
89 
90  global $ilBench;
91  $ilBench->start('LearningProgress','9162_LPStatusManual_inProgress');
92 
93 
94  switch($ilObjDataCache->lookupType($a_obj_id))
95  {
96  case 'dbk':
97  case 'lm':
98  case 'htlm':
99  $ilBench->stop('LearningProgress','9162_LPStatusManual_inProgress');
100  return ilLPStatusManual::__getLMInProgress($a_obj_id);
101 
102  case 'crs':
103  $ilBench->stop('LearningProgress','9162_LPStatusManual_inProgress');
104  return ilLPStatusManual::__getCourseInProgress($a_obj_id);
105 
106  case 'grp':
107  $ilBench->stop('LearningProgress','9162_LPStatusManual_inProgress');
108  return ilLPStatusManual::__getGroupInProgress($a_obj_id);
109 
110  default:
111  $ilBench->stop('LearningProgress','9162_LPStatusManual_inProgress');
112  echo "ilLPStatusManual: unknown type ".$ilObjDataCache->lookupType($a_obj_id);
113 
114  }
115  return array();
116  }
117 
118  function _getCompleted($a_obj_id)
119  {
120  global $ilDB;
121 
122  global $ilBench;
123  $ilBench->start('LearningProgress','9163_LPStatusManual_completed');
124 
125  $query = "SELECT DISTINCT(usr_id) user_id FROM ut_lp_marks ".
126  "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
127  "AND completed = '1' ";
128 
129  $res = $ilDB->query($query);
130  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
131  {
132  $usr_ids[] = $row->user_id;
133  }
134  $ilBench->stop('LearningProgress','9163_LPStatusManual_completed');
135  return $usr_ids ? $usr_ids : array();
136  }
137 
138  // Private
139  function __getLMInProgress($a_obj_id)
140  {
141  global $ilDB;
142 
143  $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
144 
145  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
146  $all = ilChangeEvent::lookupUsersInProgress($a_obj_id);
147  foreach($all as $user_id)
148  {
149  if(!in_array($user_id,$completed))
150  {
151  $user_ids[] = $user_id;
152  }
153  }
154  return $user_ids ? $user_ids : array();
155  }
156 
157  function __getCourseInProgress($a_obj_id)
158  {
159  global $ilDB;
160 
161  $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
162 
163  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
164  $members_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
165  $members = $members_obj->getParticipants();
166 
167  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
168  $all = ilChangeEvent::lookupUsersInProgress($a_obj_id);
169  foreach($all as $user_id)
170  {
171  if(!in_array($user_id,$completed) and in_array($user_id,$members))
172  {
173  $user_ids[] = $user_id;
174  }
175  }
176  return $user_ids ? $user_ids : array();
177  }
178 
179  function __getGroupInProgress($a_obj_id)
180  {
181  global $ilDB;
182 
183  $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
184 
185  include_once './Modules/Group/classes/class.ilObjGroup.php';
186  $members = ilObjGroup::_getMembers($a_obj_id);
187 
188  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
189  $all = ilChangeEvent::lookupUsersInProgress($a_obj_id);
190  foreach($all as $user_id)
191  {
192  if(!in_array($user_id,$completed) and in_array($user_id,$members))
193  {
194  $user_ids[] = $user_id;
195  }
196  }
197  return $user_ids ? $user_ids : array();
198  }
199 }
200 ?>