ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPStatusEvent.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
35 
37 {
38 
39  function ilLPStatusEvent($a_obj_id)
40  {
41  global $ilDB;
42 
43  parent::ilLPStatus($a_obj_id);
44  $this->db =& $ilDB;
45  }
46 
47  function _getNotAttempted($a_obj_id)
48  {
49  global $ilObjDataCache;
50 
51  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
52 
53  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
54  $member_obj = ilCourseParticipants::_getInstanceByObjId($status_info['crs_id']);
55  $members = $member_obj->getParticipants();
56 
57  // diff in progress and completed (use stored result in LPStatusWrapper)
58  $users = array_diff((array) $members,$inp = ilLPStatusWrapper::_getInProgress($a_obj_id));
59  $users = array_diff((array) $users,$com = ilLPStatusWrapper::_getCompleted($a_obj_id));
60  return $users;
61  }
62 
63  function _getInProgress($a_obj_id)
64  {
65  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
66 
67  // If registration is disabled in_progress is not available
68  if(!$status_info['registration'])
69  {
70  return array();
71  }
72  // If event has occured in_progress is impossible
73  if($status_info['starting_time'] < time())
74  {
75  return array();
76  }
77 
78  // Otherwise all users who registered will get the status in progress
79  return $status_info['registered_users'] ? $status_info['registered_users'] : array();
80  }
81 
82  function _getCompleted($a_obj_id)
83  {
84  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
85  return $status_info['participated_users'] ? $status_info['participated_users'] : array();
86  }
87 
88  function _getStatusInfo($a_obj_id)
89  {
90  global $tree;
91 
92  include_once './Modules/Session/classes/class.ilEventParticipants.php';
93  include_once('./Modules/Session/classes/class.ilObjSession.php');
94  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
95 
96  $references = ilObject::_getAllReferences($a_obj_id);
97  $ref_id = end($references);
98 
99  $course_ref_id = $tree->checkForParentType($ref_id,'crs');
100  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
101 
102  $status_info['crs_id'] = $course_obj_id;
103  $status_info['registration'] = ilObjSession::_lookupRegistrationEnabled($a_obj_id);
104  $status_info['title'] = ilObject::_lookupTitle($a_obj_id);
105  $status_info['description'] = ilObject::_lookupDescription($a_obj_id);
106 
107  // TODO: needs static method
108  #$appointment =& $event->getFirstAppointment();
109  $time_info = ilSessionAppointment::_lookupAppointment($a_obj_id);
110  $status_info['starting_time'] = $time_info['start'];
111  $status_info['ending_time'] = $time_info['end'];
112  $status_info['fullday'] = $time_info['fullday'];
113 
114  $status_info['registered_users'] = ilEventParticipants::_getRegistered($a_obj_id);
115  $status_info['participated_users'] = ilEventParticipants::_getParticipated($a_obj_id);
116  #var_dump("<pre>",$a_obj_id,$time_info,$status_info,"</pre>");
117  return $status_info;
118  }
119 
128  function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
129  {
130  global $ilObjDataCache, $ilDB;
131 
132  $status = LP_STATUS_NOT_ATTEMPTED_NUM;
133  switch ($ilObjDataCache->lookupType($a_obj_id))
134  {
135  case 'sess':
136  include_once './Modules/Session/classes/class.ilEventParticipants.php';
137  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
138  include_once('./Modules/Session/classes/class.ilObjSession.php');
139 
140  $time_info = ilSessionAppointment::_lookupAppointment($a_obj_id);
141  $registration = ilObjSession::_lookupRegistrationEnabled($a_obj_id);
142 
143  // If registration is disabled in_progress is not available
144  // If event has occured in_progress is impossible
145  if ($registration && $time_info['start'] >= time())
146  {
147  // is user registered -> in progress
148  if (ilEventParticipants::_isRegistered($a_user_id, $a_obj_id))
149  {
150  $status = LP_STATUS_IN_PROGRESS_NUM;
151  }
152  }
153  if (ilEventParticipants::_hasParticipated($a_user_id, $a_obj_id))
154  {
155  $status = LP_STATUS_COMPLETED_NUM;
156  }
157  break;
158  }
159  return $status;
160  }
161 
162 }
163 ?>