ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLPCollectionOfSCOs.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
27{
28 protected static array $possible_items = array();
29
30 public function getPossibleItems(): array
31 {
32 if (!isset(self::$possible_items[$this->obj_id])) {
33 $items = array();
34
35 switch (ilObjSAHSLearningModule::_lookupSubType($this->obj_id)) {
36 case 'hacp':
37 case 'aicc':
38 foreach (ilObjAICCLearningModule::_getTrackingItems(
39 $this->obj_id
40 ) as $item) {
41 $items[$item['obj_id']]['title'] = $item['title'];
42 }
43 break;
44
45 case 'scorm':
47 $this->obj_id
48 ) as $item) {
49 $items[$item->getId()]['title'] = $item->getTitle();
50 }
51 break;
52
53 case 'scorm2004':
55 $this->obj_id
56 ) as $item) {
57 $items[$item['id']]['title'] = $item['title'];
58 }
59 break;
60 }
61
62 self::$possible_items[$this->obj_id] = $items;
63 }
64
65 return self::$possible_items[$this->obj_id];
66 }
67
68 public function getTableGUIData(int $a_parent_ref_id): array
69 {
70 $data = array();
71
72 foreach ($this->getPossibleItems() as $sco_id => $item) {
73 $tmp = array();
74 $tmp['id'] = $sco_id;
75 $tmp['ref_id'] = 0;
76 $tmp['type'] = 'sco';
77 $tmp['title'] = $item['title'];
78 $tmp["status"] = $this->isAssignedEntry($sco_id);
79
80 $data[] = $tmp;
81 }
82
83 return $data;
84 }
85
86
87 //
88 // HELPER
89 //
90
91 // see ilSCORMCertificateAdapter
93 int $item_id,
94 int $user_id
95 ): array {
96 switch (ilObjSAHSLearningModule::_lookupSubType($this->obj_id)) {
97 case 'hacp':
98 case 'aicc':
99 return ilObjAICCLearningModule::_getScoresForUser(
100 $item_id,
102 );
103
104 case 'scorm':
106 $item_id,
108 );
109
110 case 'scorm2004':
112 $item_id,
114 );
115 }
116
117 return array("raw" => null, "max" => null, "scaled" => null);
118 }
119
126 public function cloneCollection(int $a_target_id, int $a_copy_id): void
127 {
128 $target_obj_id = ilObject::_lookupObjId($a_target_id);
129 $new_collection = new static($target_obj_id, $this->mode);
130 $possible_items = $new_collection->getPossibleItems();
131 foreach ($this->items as $item_id) {
132 foreach ($possible_items as $pos_item_id => $pos_item) {
133 if ($this->itemsAreEqual($item_id, $pos_item_id)) {
134 $new_collection->addEntry($pos_item_id);
135 }
136 }
137 }
138 }
139
140 protected function itemsAreEqual(int $item_a_id, int $item_b_id): bool
141 {
142 global $DIC;
143 switch (ilObjSAHSLearningModule::_lookupSubType($this->obj_id)) {
144 case 'scorm':
145 $res_a = $DIC->database()->query(
146 'SELECT import_id, identifierref FROM sc_item WHERE obj_id = ' . $DIC->database(
147 )->quote(
148 $item_a_id,
149 'integer'
150 )
151 )->fetchAssoc();
152 $res_b = $DIC->database()->query(
153 'SELECT import_id, identifierref FROM sc_item WHERE obj_id = ' . $DIC->database(
154 )->quote(
155 $item_b_id,
156 'integer'
157 )
158 )->fetchAssoc();
159 return (
160 $res_a
161 && $res_b
162 && ($res_a['import_id'] == $res_b['import_id'])
163 && ($res_a['identifierref'] == $res_b['identifierref'])
164 );
165 case 'scorm2004':
166 $res_a = $DIC->database()->query(
167 'SELECT id, resourceid FROM cp_item WHERE cp_node_id = ' . $DIC->database(
168 )->quote(
169 $item_a_id,
170 'integer'
171 )
172 )->fetchAssoc();
173 $res_b = $DIC->database()->query(
174 'SELECT id, resourceid FROM cp_item WHERE cp_node_id = ' . $DIC->database(
175 )->quote(
176 $item_b_id,
177 'integer'
178 )
179 )->fetchAssoc();
180 return (
181 $res_a
182 && $res_b
183 && ($res_a['id'] == $res_b['id'])
184 && ($res_a['resourceid'] == $res_b['resourceid'])
185 );
186 default:
187 return false;
188 }
189 }
190}
getScoresForUserAndCP_Node_Id(int $item_id, int $user_id)
cloneCollection(int $a_target_id, int $a_copy_id)
Scorm items are not copied, they are newly created by reading the manifest.
itemsAreEqual(int $item_a_id, int $item_b_id)
getTableGUIData(int $a_parent_ref_id)
LP collection base class.
isAssignedEntry(int $a_item_id)
Class ilObjSCORMLearningModule.
static _lookupSubType(int $a_obj_id)
lookup subtype id (scorm, )
static _getTrackingItems(int $a_obj_id)
get all tracking items of scorm object currently a for learning progress only
static _getScores2004ForUser(int $a_cp_node_id, int $a_user)
static _getTrackingItems(int $a_obj_id)
get all tracking items of scorm object
static _getScoresForUser(int $a_item_id, int $a_user_id)
static _lookupObjId(int $ref_id)
global $DIC
Definition: shib_login.php:26