ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPStatusObjectives.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 
36 {
37 
38  function ilLPStatusObjectives($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','9171_LPStatusObjectives_notAttempted');
52 
53  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
54  $members_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
55  $members = $members_obj->getParticipants();
56 
57  // diff in progress and completed (use stored result in LPStatusWrapper)
58  $users = array_diff($members,$inp = ilLPStatusWrapper::_getInProgress($a_obj_id));
59  $users = array_diff($users,$com = ilLPStatusWrapper::_getCompleted($a_obj_id));
60 
61  $ilBench->stop('LearningProgress','9171_LPStatusObjectives_notAttempted');
62  return $users ? $users : array();
63  }
64 
65  function _getInProgress($a_obj_id)
66  {
67  global $ilDB;
68 
69  $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
70 
71  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
72  $members_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
73  $members = $members_obj->getParticipants();
74 
75  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
76  $all = ilChangeEvent::lookupUsersInProgress($a_obj_id);
77  foreach($all as $user_id)
78  {
79  if(!in_array($user_id,$completed) and in_array($user_id,$members))
80  {
81  $user_ids[] = $user_id;
82  }
83  }
84  return $user_ids ? $user_ids : array();
85  }
86 
87  function _getCompleted($a_obj_id)
88  {
89  global $ilDB;
90 
91  global $ilBench;
92  $ilBench->start('LearningProgress','9173_LPStatusObjectives_completed');
93 
94  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
95  foreach($status_info['objective_result'] as $user_id => $completed)
96  {
97  if(count($completed) == $status_info['num_objectives'])
98  {
99  $usr_ids[] = $user_id;
100  }
101  }
102  $ilBench->stop('LearningProgress','9173_LPStatusObjectives_completed');
103  return $usr_ids ? $usr_ids : array();
104  }
105 
106 
107  function _getStatusInfo($a_obj_id)
108  {
109  include_once 'Modules/Course/classes/class.ilCourseObjective.php';
110 
111  global $ilDB;
112 
113  $status_info['objective_result'] = array();
114  $status_info['objectives'] = ilCourseObjective::_getObjectiveIds($a_obj_id);
115  $status_info['num_objectives'] = count($status_info['objectives']);
116 
117  if(!$status_info['num_objectives'])
118  {
119  return $status_info;
120  }
121  else
122  {
123  $in = $ilDB->in('objective_id',$status_info['objectives'], false,'integer');
124  }
125 
126  $query = "SELECT * FROM crs_objective_status ".
127  "WHERE ".$in;
128 
129  $res = $ilDB->query($query);
130  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
131  {
132  $status_info['completed'][$row->objective_id][] = $row->user_id;
133  $status_info['objective_result'][$row->user_id][$row->objective_id] = $row->objective_id;
134  }
135 
136  // Read title/description
137  $query = "SELECT * FROM crs_objectives ".
138  "WHERE ".$in;
139  $res = $ilDB->query($query);
140  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
141  {
142  $status_info['objective_title'][$row->objective_id] = $row->title;
143  $status_info['objective_description'][$row->objective_id] = $row->description;
144  }
145  return $status_info;
146  }
147 }
148 
149 
150 ?>