24 global $ilObjDataCache,$ilDB;
28 $this->obj_id = $a_obj_id;
42 global $ilObjDataCache,
$ilLog;
44 $target_obj_id = $ilObjDataCache->lookupObjId($a_target_id);
46 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
48 $mappings = $cwo->getMappings();
51 foreach($this->items as $item)
53 if(!isset($mappings[$item]) or !$mappings[$item])
58 $new_collections->add($mappings[$item]);
59 $ilLog->write(__METHOD__.
': Added learning progress collection.');
75 return (
bool) in_array($a_ref_id,$this->items);
78 function add($item_id)
82 $query =
"SELECT * FROM ut_lp_collections ".
83 "WHERE obj_id = ".$ilDB->quote($this->
getObjId(),
'integer').
" ".
84 "AND item_id = ".$ilDB->quote($item_id,
'integer');
91 $query =
"INSERT INTO ut_lp_collections (obj_id, item_id) ".
93 $ilDB->quote($this->obj_id ,
'integer').
", ".
94 $ilDB->quote($item_id ,
'integer').
106 public static function deactivate($a_obj_id,array $a_item_ids)
111 $query =
"DELETE FROM ut_lp_collections ".
112 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
113 "AND ".$ilDB->in(
'item_id', $a_item_ids,
false,
'integer').
" ".
114 "AND grouping_id = ".$ilDB->quote(0,
'integer');
115 $ilDB->manipulate(
$query);
118 $query =
"SELECT grouping_id FROM ut_lp_collections ".
119 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
120 "AND ".$ilDB->in(
'item_id', $a_item_ids,
false,
'integer');
123 $grouping_ids = array();
126 $grouping_ids[] =
$row->grouping_id;
129 $query =
"UPDATE ut_lp_collections ".
130 "SET active = ".$ilDB->quote(0,
'integer').
" ".
131 "WHERE ".$ilDB->in(
'grouping_id', $grouping_ids,
false,
'integer').
" ".
132 "AND obj_id = ".$ilDB->quote($a_obj_id,
'integer');
133 $ilDB->manipulate(
$query);
142 public static function activate($a_obj_id,array $a_item_ids)
147 $sql =
"SELECT item_id,active FROM ut_lp_collections ".
148 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
149 "AND ".$ilDB->in(
'item_id', $a_item_ids,
false,
'integer');
150 $res = $ilDB->query($sql);
152 $items_existing = $remove_existing = array();
157 $items_existing[] =
$row->item_id;
161 $remove_existing[] =
$row->item_id;
166 if(
sizeof($remove_existing))
168 $ilDB->manipulate(
"DELETE FROM ut_lp_collections".
169 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
170 " AND ".$ilDB->in(
"item_id", $remove_existing,
"",
"integer"));
173 $items_not_existing = array_diff($a_item_ids, $items_existing);
174 foreach($items_not_existing as $item)
176 $query =
"INSERT INTO ut_lp_collections (obj_id,item_id,grouping_id,num_obligatory,active ) ".
178 $ilDB->quote($a_obj_id,
'integer').
", ".
179 $ilDB->quote($item,
'integer').
", ".
180 $ilDB->quote(0,
'integer').
", ".
181 $ilDB->quote(0,
'integer').
", ".
182 $ilDB->quote(1,
'integer').
" ".
184 $ilDB->manipulate(
$query);
187 $query =
"SELECT grouping_id FROM ut_lp_collections ".
188 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
189 "AND ".$ilDB->in(
'item_id', $a_item_ids,
false,
'integer').
" ".
190 "AND grouping_id > ".$ilDB->quote(0,
'integer').
" ";
193 $grouping_ids = array();
196 $grouping_ids[] =
$row->grouping_id;
199 $query =
"UPDATE ut_lp_collections ".
200 "SET active = ".$ilDB->quote(1,
'integer').
" ".
201 "WHERE ".$ilDB->in(
'grouping_id', $grouping_ids,
false,
'integer').
" ".
202 "AND obj_id = ".$ilDB->quote($a_obj_id,
'integer');
203 $ilDB->manipulate(
$query);
219 $query =
"SELECT DISTINCT(grouping_id) grp_id FROM ut_lp_collections ".
220 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
221 "AND ".$ilDB->in(
'item_id', $a_ids,
false,
'integer').
" ".
222 "AND grouping_id != 0 ";
228 $grp_ids[] =
$row->grp_id;
231 $query =
"SELECT item_id FROM ut_lp_collections ".
232 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
233 "AND ".$ilDB->in(
'grouping_id', $grp_ids,
false,
'integer');
236 $all_item_ids = array();
239 $all_item_ids[] =
$row->item_id;
242 $all_item_ids = array_unique(array_merge($all_item_ids,$a_ids));
248 $query =
"SELECT MAX(grouping_id) grp FROM ut_lp_collections ".
249 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
260 $query =
"UPDATE ut_lp_collections SET ".
261 "grouping_id = ".$ilDB->quote($grp_id,
'integer').
", ".
262 "num_obligatory = 1, ".
263 "active = ".$ilDB->quote(1,
'integer').
" ".
264 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
265 "AND ".$ilDB->in(
'item_id',$all_item_ids,
false,
'integer');
266 $ilDB->manipulate(
$query);
281 foreach($a_obl as $grouping_id => $num)
283 $query =
"SELECT count(obj_id) num FROM ut_lp_collections ".
284 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer').
' '.
285 'AND grouping_id = '.$ilDB->quote($grouping_id,
'integer').
' '.
290 if($num <= 0 or $num >=
$row->num)
292 throw new UnexpectedValueException();
296 foreach($a_obl as $grouping_id => $num)
298 $query =
'UPDATE ut_lp_collections '.
299 'SET num_obligatory = '.$ilDB->quote($num,
'integer').
' '.
300 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer').
' '.
301 'AND grouping_id = '.$ilDB->quote($grouping_id,
'integer');
302 $ilDB->manipulate(
$query);
315 $query =
"SELECT grouping_id FROM ut_lp_collections ".
316 "WHERE obj_id = " . $ilDB->quote($a_obj_id,
'integer') .
" " .
317 "AND ".$ilDB->in(
'item_id', $a_ids,
false,
'integer').
" ".
318 "AND grouping_id > 0 ";
324 $grp_ids[] =
$row->grouping_id;
327 $query =
"UPDATE ut_lp_collections ".
328 "SET grouping_id = ".$ilDB->quote(0,
'integer').
", ".
329 "num_obligatory = 0 ".
330 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
331 "AND " . $ilDB->in(
'grouping_id', $grp_ids,
false,
'integer');
332 $ilDB->manipulate(
$query);
349 $query =
"SELECT item_id FROM ut_lp_collections ".
350 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
351 "AND grouping_id > 0 ";
353 return $res->numRows() ?
true :
false;
367 $query =
"SELECT grouping_id FROM ut_lp_collections ".
368 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
369 "AND item_id = ".$ilDB->quote($item_id,
'integer');
372 $grouping_id =
$row->grouping_id;
374 if($grouping_id == 0)
379 $query =
"SELECT item_id, num_obligatory FROM ut_lp_collections ".
380 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
381 "AND grouping_id = ".$ilDB->quote($grouping_id,
'integer');
388 $items[
'num_obligatory'] =
$row->num_obligatory;
389 $items[
'grouping_id'] = $grouping_id;
394 function delete($item_id)
398 $query =
"DELETE FROM ut_lp_collections ".
399 "WHERE item_id = ".$ilDB->quote($item_id ,
'integer').
" ".
400 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
414 if($tree->isDeleted($a_target_id))
419 include_once
'Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php';
420 $plugin_types = array();
422 $node_data = $tree->getNodeData($a_target_id);
423 foreach($tree->getSubTree($node_data) as $node)
426 if($node[
'ref_id'] == $a_target_id)
431 switch($node[
'type'])
441 $all_possible[] = $node[
'ref_id'];
446 $only_active =
false;
447 if($a_collection && !$a_collection->isAssigned($node[
'ref_id']))
453 $all_possible[] = $node[
'ref_id'];
459 return $all_possible ? $all_possible : array();
479 include_once
'./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
485 include_once
'./Modules/ScormAicc/classes/class.ilObjAICCLearningModule.php';
489 $items[
"$item[obj_id]"][
'title'] = $item[
'title'];
490 #$items[$item->getId()]['title'] = $item->getTitle();
495 include_once
'./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
496 include_once
'./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php';
500 $items[$item->getId()][
'title'] = $item->getTitle();
505 include_once
'./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php';
509 $items[$item[
"id"]][
'title'] = $item[
"title"];
526 $query =
"DELETE FROM ut_lp_collections ".
527 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
544 $query =
"SELECT * FROM ut_lp_collections ".
545 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
554 $grouped[
$row->grouping_id][
'items'][] =
$row->item_id;
555 $grouped[
$row->grouping_id][
'num_obligatory'] =
$row->num_obligatory;
561 function &
_getItems($a_obj_id, $a_use_subtree_by_id =
false)
563 global $ilObjDataCache;
566 include_once
'Services/Tracking/classes/class.ilLPObjSettings.php';
571 include_once
'Modules/Course/classes/class.ilCourseObjective.php';
579 if($ilObjDataCache->lookupType($a_obj_id) !=
'sahs')
582 $course_ref_id = end($course_ref_ids);
583 if (!$a_use_subtree_by_id)
589 $possible_items = $tree->getSubTreeIds($course_ref_id);
592 $query =
"SELECT * FROM ut_lp_collections utc ".
593 "JOIN object_reference obr ON item_id = ref_id ".
594 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
595 "WHERE utc.obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
596 "AND active = ".$ilDB->quote(1,
'integer').
" ".
602 $query =
"SELECT * FROM ut_lp_collections WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
603 "AND active = ".$ilDB->quote(1,
'integer');
609 if($ilObjDataCache->lookupType($a_obj_id) !=
'sahs')
611 if(!in_array(
$row->item_id,$possible_items))
618 if($ilObjDataCache->lookupType($item_obj_id = $ilObjDataCache->lookupObjId(
$row->item_id)) ==
'tst')
620 include_once
'./Modules/Test/classes/class.ilObjTest.php';
637 $query =
"DELETE FROM ut_lp_collections ".
638 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
639 "AND item_id = ".$ilDB->quote($a_item_id ,
'integer').
" ";
647 global $ilObjDataCache, $ilDB;
649 $this->items = array();
651 if($ilObjDataCache->lookupType($this->getObjId()) !=
'sahs')
654 $course_ref_id = end($course_ref_ids);
655 $query =
"SELECT * FROM ut_lp_collections utc ".
656 "JOIN object_reference obr ON item_id = ref_id ".
657 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
658 "WHERE utc.obj_id = ".$this->db->quote($this->obj_id,
'integer').
" ".
659 "AND active = ".$ilDB->quote(1,
'integer').
" ".
664 $query =
"SELECT * FROM ut_lp_collections WHERE obj_id = ".$ilDB->quote($this->
getObjId() ,
'integer').
" ".
665 "AND active = ".$ilDB->quote(1,
'integer');
670 if($ilObjDataCache->lookupType($this->getObjId()) !=
'sahs')
679 if($ilObjDataCache->lookupType($item_obj_id = $ilObjDataCache->lookupObjId(
$row->item_id)) ==
'tst')
681 include_once
'./Modules/Test/classes/class.ilObjTest.php';
688 $this->items[] =
$row->item_id;
695 include_once
'./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
701 include_once
'./Modules/ScormAicc/classes/class.ilObjAICCLearningModule.php';
705 include_once
'./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
710 include_once
'./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php';
713 return array(
"raw" => null,
"max" => null,
"scaled" => null);