ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPStatusSCORM.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 ilLPStatusSCORM($a_obj_id)
39  {
40  global $ilDB;
41 
42  parent::ilLPStatus($a_obj_id);
43  $this->db =& $ilDB;
44  }
45 
46 
47  function _getInProgress($a_obj_id)
48  {
49  include_once './Services/Tracking/classes/class.ilLPCollectionCache.php';
50  include_once './Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php';
51 
52  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
53  $users = array();
54 
55  foreach($status_info['in_progress'] as $in_progress)
56  {
57  $users = array_merge($users,$in_progress);
58  }
59  $users = array_unique($users);
60  $users = array_diff($users,ilLPStatusWrapper::_getCompleted($a_obj_id));
61  $users = array_diff($users,ilLPStatusWrapper::_getFailed($a_obj_id));
62 
63  return $users;
64  }
65 
66  function _getCompleted($a_obj_id)
67  {
68  global $ilDB;
69 
70  include_once './Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php';
71 
72  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
73 
74  $items = $status_info['scos'];
75 
76  $counter = 0;
77  $users = array();
78  foreach($items as $sco_id)
79  {
80  $tmp_users = $status_info['completed'][$sco_id];
81 
82  if(!$counter++)
83  {
84  $users = $tmp_users;
85  }
86  else
87  {
88  $users = array_intersect($users,$tmp_users);
89  }
90  }
91 
92  $users = array_diff($users,ilLPStatusWrapper::_getFailed($a_obj_id));
93  return $users;
94  }
95 
96  function _getFailed($a_obj_id)
97  {
98  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
99 
100  if(!count($status_info['scos']))
101  {
102  return array();
103  }
104  $users = array();
105  foreach($status_info['scos'] as $sco_id)
106  {
107  $users = array_merge($users,(array) $status_info['failed'][$sco_id]);
108  }
109  return array_unique($users);
110  }
111 
112 
113  function _getStatusInfo($a_obj_id)
114  {
115  // Which sco's determine the status
116  include_once './Services/Tracking/classes/class.ilLPCollectionCache.php';
117  $status_info['scos'] = ilLPCollectionCache::_getItems($a_obj_id);
118 
119  $status_info['num_scos'] = count($status_info['scos']);
120 
121  // Get subtype
122  include_once './Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
123  $status_info['subtype'] = ilObjSAHSLearningModule::_lookupSubType($a_obj_id);
124 
125  switch($status_info['subtype'])
126  {
127  case 'hacp':
128  case 'aicc':
129  include_once './Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php';
130  $status_info['num_completed'] = ilObjSCORMTracking::_getCountCompletedPerUser($status_info['scos'],$a_obj_id);
131 
132  include_once './Modules/ScormAicc/classes/class.ilObjAICCLearningModule.php';
133  foreach(ilObjAICCLearningModule::_getTrackingItems($a_obj_id) as $item)
134  {
135  if(in_array($item['obj_id'],$status_info['scos']))
136  {
137  $status_info['scos_title']["$item[obj_id]"] = $item['title'];
138  }
139  }
140  $info = ilObjSCORMTracking::_getProgressInfo($status_info['scos'],$a_obj_id);
141  break;
142 
143  case 'scorm':
144  include_once './Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php';
145  $status_info['num_completed'] = ilObjSCORMTracking::_getCountCompletedPerUser($status_info['scos'],$a_obj_id);
146 
147  include_once './Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php';
148  foreach($status_info['scos'] as $sco_id)
149  {
150  $status_info['scos_title'][$sco_id] = ilSCORMItem::_lookupTitle($sco_id);
151  }
152  $info = ilObjSCORMTracking::_getProgressInfo($status_info['scos'],$a_obj_id);
153  break;
154 
155  case "scorm2004":
156  include_once './Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php';
157  $status_info['num_completed'] = ilSCORM2004Tracking::_getCountCompletedPerUser($status_info['scos'],$a_obj_id,true);
158  include_once './Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php';
159  foreach($status_info['scos'] as $sco_id)
160  {
161  $status_info['scos_title'][$sco_id] = ilObjSCORM2004LearningModule::_lookupItemTitle($sco_id);
162  }
163 
164  $info = ilSCORM2004Tracking::_getItemProgressInfo($status_info['scos'],$a_obj_id,true);
165  break;
166  }
167 
168  $status_info['completed'] = array();
169  $status_info['failed'] = array();
170  $status_info['in_progress'] = array();
171  foreach($status_info['scos'] as $sco_id)
172  {
173  $status_info['completed'][$sco_id] = $info['completed'][$sco_id] ? $info['completed'][$sco_id] : array();
174  $status_info['failed'][$sco_id] = $info['failed'][$sco_id] ? $info['failed'][$sco_id] : array();
175  $status_info['in_progress'][$sco_id] = $info['in_progress'][$sco_id] ? $info['in_progress'][$sco_id] : array();
176  }
177 //var_dump($status_info["completed"]);
178  return $status_info;
179  }
180 
189  function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
190  {
191  global $ilObjDataCache, $ilDB, $ilLog;
192 
193  $status = LP_STATUS_NOT_ATTEMPTED_NUM;
194 
195  // if the user has accessed the scorm object
196  // the status is at least "in progress"
197  include_once("./Services/Tracking/classes/class.ilChangeEvent.php");
198  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id))
199  {
200  $status = LP_STATUS_IN_PROGRESS_NUM;
201  }
202 //$ilLog->write("-".$status."-");
203  // Which sco's determine the status
204  include_once './Services/Tracking/classes/class.ilLPCollectionCache.php';
205  include_once './Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
206  $scos = ilLPCollectionCache::_getItems($a_obj_id);
207  $completed = true;
208  $failed = false;
209  $subtype = ilObjSAHSLearningModule::_lookupSubType($a_obj_id);
210  switch($subtype)
211  {
212  case 'hacp':
213  case 'aicc':
214  case 'scorm':
215  include_once("./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php");
216  $scorm_status = ilObjSCORMTracking::_getCollectionStatus($scos, $a_obj_id, $a_user_id);
217  break;
218 
219  case 'scorm2004':
220  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php");
221  $scorm_status = ilSCORM2004Tracking::_getCollectionStatus($scos, $a_obj_id, $a_user_id);
222  break;
223  }
224 
225  switch ($scorm_status)
226  {
227  case "in_progress":
228  $status = LP_STATUS_IN_PROGRESS_NUM;
229  break;
230  case "completed":
231  $status = LP_STATUS_COMPLETED_NUM;
232  break;
233  case "failed":
234  $status = LP_STATUS_FAILED_NUM;
235  break;
236  }
237 //$ilLog->write("-".$status."-");
238  return $status;
239  }
240 
249  function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
250  {
251  // Which sco's determine the status
252  include_once './Services/Tracking/classes/class.ilLPCollectionCache.php';
253  $scos = ilLPCollectionCache::_getItems($a_obj_id);
254  $reqscos = count($scos);
255 
256  include_once './Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
257  $subtype = ilObjSAHSLearningModule::_lookupSubType($a_obj_id);
258 
259  if ($subtype != "scorm2004")
260  {
261  include_once("./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php");
262  $compl = ilObjSCORMTracking::_countCompleted($scos, $a_obj_id, $a_user_id);
263  }
264  else
265  {
266  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php");
267  $compl = ilSCORM2004Tracking::_countCompleted($scos, $a_obj_id, $a_user_id, true);
268  }
269 
270  if ($reqscos > 0)
271  {
272  $per = min(100, 100 / $reqscos * $compl);
273  }
274  else
275  {
276  $per = 100;
277  }
278 
279  return $per;
280  }
281 
282 }
283 ?>