ILIAS  Release_3_10_x_branch Revision 61812
 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  $query = "SELECT DISTINCT(usr_id) FROM read_event ".
76  "WHERE obj_id = '".$a_obj_id."'";
77 
78  $res = $ilDB->query($query);
79  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
80  {
81  if(!in_array($row->usr_id,$completed) and in_array($row->usr_id,$members))
82  {
83  $user_ids[] = $row->usr_id;
84  }
85  }
86  return $user_ids ? $user_ids : array();
87  }
88 
89  function _getCompleted($a_obj_id)
90  {
91  global $ilDB;
92 
93  global $ilBench;
94  $ilBench->start('LearningProgress','9173_LPStatusObjectives_completed');
95 
96  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
97  foreach($status_info['objective_result'] as $user_id => $completed)
98  {
99  if(count($completed) == $status_info['num_objectives'])
100  {
101  $usr_ids[] = $user_id;
102  }
103  }
104  $ilBench->stop('LearningProgress','9173_LPStatusObjectives_completed');
105  return $usr_ids ? $usr_ids : array();
106  }
107 
108 
109  function _getStatusInfo($a_obj_id)
110  {
111  include_once 'Modules/Course/classes/class.ilCourseObjective.php';
112 
113  global $ilDB;
114 
115  $status_info['objective_result'] = array();
116  $status_info['objectives'] = ilCourseObjective::_getObjectiveIds($a_obj_id);
117  $status_info['num_objectives'] = count($status_info['objectives']);
118 
119  if(!$status_info['num_objectives'])
120  {
121  return $status_info;
122  }
123  else
124  {
125  $in = "objective_id IN('".implode("','",$status_info['objectives'])."') ";
126  }
127 
128  $query = "SELECT * FROM crs_objective_status ".
129  "WHERE ".$in;
130 
131  $res = $ilDB->query($query);
132  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
133  {
134  $status_info['completed'][$row->objective_id][] = $row->user_id;
135  $status_info['objective_result'][$row->user_id][$row->objective_id] = $row->objective_id;
136  }
137 
138  // Read title/description
139  $query = "SELECT * FROM crs_objectives ".
140  "WHERE ".$in;
141  $res = $ilDB->query($query);
142  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
143  {
144  $status_info['objective_title'][$row->objective_id] = $row->title;
145  $status_info['objective_description'][$row->objective_id] = $row->description;
146  }
147  return $status_info;
148  }
149 }
150 
151 
152 ?>