ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLPCollectionOfSCOs.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "Services/Tracking/classes/collection/class.ilLPCollection.php";
6 
17 {
18  protected static $possible_items = array();
19 
20  // see ilSCORMCertificateAdapter
21  public function getPossibleItems()
22  {
23  if (!isset(self::$possible_items[$this->obj_id])) {
24  include_once './Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
25 
26  $items = array();
27 
28  switch (ilObjSAHSLearningModule::_lookupSubType($this->obj_id)) {
29  case 'hacp':
30  case 'aicc':
31  include_once './Modules/ScormAicc/classes/class.ilObjAICCLearningModule.php';
32  foreach (ilObjAICCLearningModule::_getTrackingItems($this->obj_id) as $item) {
33  $items[$item['obj_id']]['title'] = $item['title'];
34  }
35  break;
36 
37  case 'scorm':
38  include_once './Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
39  include_once './Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php';
40  foreach (ilObjSCORMLearningModule::_getTrackingItems($this->obj_id) as $item) {
41  $items[$item->getId()]['title'] = $item->getTitle();
42  }
43  break;
44 
45  case 'scorm2004':
46  include_once './Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php';
47  foreach (ilObjSCORM2004LearningModule::_getTrackingItems($this->obj_id) as $item) {
48  $items[$item['id']]['title'] = $item['title'];
49  }
50  break;
51  }
52 
53  self::$possible_items[$this->obj_id] = $items;
54  }
55 
56  return self::$possible_items[$this->obj_id];
57  }
58 
59 
60  //
61  // TABLE GUI
62  //
63 
64  public function getTableGUIData($a_parent_ref_id)
65  {
66  $data = array();
67 
68  foreach ($this->getPossibleItems() as $sco_id => $item) {
69  $tmp = array();
70  $tmp['id'] = $sco_id;
71  $tmp['ref_id'] = 0;
72  $tmp['type'] = 'sco';
73  $tmp['title'] = $item['title'];
74  $tmp["status"] = $this->isAssignedEntry($sco_id);
75 
76  $data[] = $tmp;
77  }
78 
79  return $data;
80  }
81 
82 
83  //
84  // HELPER
85  //
86 
87  // see ilSCORMCertificateAdapter
88  public function getScoresForUserAndCP_Node_Id($item_id, $user_id)
89  {
90  include_once './Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
91  switch (ilObjSAHSLearningModule::_lookupSubType($this->obj_id)) {
92  case 'hacp':
93  case 'aicc':
94  include_once './Modules/ScormAicc/classes/class.ilObjAICCLearningModule.php';
95  return ilObjAICCLearningModule::_getScoresForUser($item_id, $user_id);
96 
97  case 'scorm':
98  include_once './Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
99  //include_once './Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php';
100  return ilObjSCORMLearningModule::_getScoresForUser($item_id, $user_id);
101 
102  case 'scorm2004':
103  include_once './Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php';
104  return ilObjSCORM2004LearningModule::_getScores2004ForUser($item_id, $user_id);
105  }
106 
107  return array("raw" => null, "max" => null, "scaled" => null);
108  }
109 
117  public function cloneCollection($a_target_id, $a_copy_id)
118  {
119  global $DIC;
120 
121  $target_obj_id = ilObject::_lookupObjId($a_target_id);
122  $new_collection = new static($target_obj_id, $this->mode);
123  $possible_items = $new_collection->getPossibleItems();
124  foreach ($this->items as $item_id) {
125  foreach ($possible_items as $pos_item_id => $pos_item) {
126  if ($this->itemsAreEqual($item_id, $pos_item_id)) {
127  $new_collection->addEntry($pos_item_id);
128  }
129  }
130  }
131 
132  $DIC->logger()->root()->write(__METHOD__ . ': cloned learning progress collection.');
133  }
134 
135 
142  protected function itemsAreEqual($item_a_id, $item_b_id)
143  {
144  global $DIC;
145  switch (ilObjSAHSLearningModule::_lookupSubType($this->obj_id)) {
146  case 'scorm':
147  $res_a = $DIC->database()->query('SELECT import_id, identifierref FROM sc_item WHERE obj_id = ' . $DIC->database()->quote($item_a_id, 'integer'))->fetchAssoc();
148  $res_b = $DIC->database()->query('SELECT import_id, identifierref FROM sc_item WHERE obj_id = ' . $DIC->database()->quote($item_b_id, 'integer'))->fetchAssoc();
149  return (
150  $res_a
151  && $res_b
152  && ($res_a['import_id'] == $res_b['import_id'])
153  && ($res_a['identifierref'] == $res_b['identifierref'])
154  );
155  case 'scorm2004':
156  $res_a = $DIC->database()->query('SELECT id, resourceid FROM cp_item WHERE cp_node_id = ' . $DIC->database()->quote($item_a_id, 'integer'))->fetchAssoc();
157  $res_b = $DIC->database()->query('SELECT id, resourceid FROM cp_item WHERE cp_node_id = ' . $DIC->database()->quote($item_b_id, 'integer'))->fetchAssoc();
158  return (
159  $res_a
160  && $res_b
161  && ($res_a['import_id'] == $res_b['import_id'])
162  && ($res_a['identifierref'] == $res_b['identifierref'])
163  );
164  default:
165  return false;
166  }
167  }
168 }
static _getTrackingItems($a_obj_id)
get all tracking items of scorm object
global $DIC
Definition: saml.php:7
itemsAreEqual($item_a_id, $item_b_id)
static _lookupSubType($a_obj_id)
lookup subtype id (scorm, )
static _getScores2004ForUser($a_cp_node_id, $a_user)
cloneCollection($a_target_id, $a_copy_id)
Scorm items are not copied, they are newly created by reading the manifest.
static _lookupObjId($a_id)
Create styles array
The data for the language used.
static _getTrackingItems($a_obj_id)
get all tracking items of scorm object static
LP collection base class.
isAssignedEntry($a_item_id)
getScoresForUserAndCP_Node_Id($item_id, $user_id)
static _getScoresForUser($a_item_id, $a_user_id)