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 $ilDB->manipulate(
$query);
141 public static function activate($a_obj_id,array $a_item_ids)
146 $sql =
"SELECT item_id FROM ut_lp_collections ".
147 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
148 "AND ".$ilDB->in(
'item_id', $a_item_ids,
false,
'integer');
149 $res = $ilDB->query($sql);
151 $items_existing = array();
154 $items_existing[] =
$row->item_id;
157 $items_not_existing = array_diff($a_item_ids, $items_existing);
158 foreach($items_not_existing as $item)
160 $query =
"INSERT INTO ut_lp_collections (obj_id,item_id,grouping_id,num_obligatory,active ) ".
162 $ilDB->quote($a_obj_id,
'integer').
", ".
163 $ilDB->quote($item,
'integer').
", ".
164 $ilDB->quote(0,
'integer').
", ".
165 $ilDB->quote(0,
'integer').
", ".
166 $ilDB->quote(1,
'integer').
" ".
168 $ilDB->manipulate(
$query);
171 $query =
"SELECT grouping_id FROM ut_lp_collections ".
172 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
173 "AND ".$ilDB->in(
'item_id', $a_item_ids,
false,
'integer').
" ".
174 "AND grouping_id > ".$ilDB->quote(0,
'integer').
" ";
177 $grouping_ids = array();
180 $grouping_ids[] =
$row->grouping_id;
183 $query =
"UPDATE ut_lp_collections ".
184 "SET active = ".$ilDB->quote(1,
'integer').
" ".
185 "WHERE ".$ilDB->in(
'grouping_id', $grouping_ids,
false,
'integer');
186 $ilDB->manipulate(
$query);
202 $query =
"SELECT DISTINCT(grouping_id) grp_id FROM ut_lp_collections ".
203 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
204 "AND ".$ilDB->in(
'item_id', $a_ids,
false,
'integer').
" ".
205 "AND grouping_id != 0 ";
211 $grp_ids[] =
$row->grp_id;
214 $query =
"SELECT item_id FROM ut_lp_collections ".
215 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
216 "AND ".$ilDB->in(
'grouping_id', $grp_ids,
false,
'integer');
219 $all_item_ids = array();
222 $all_item_ids[] =
$row->item_id;
225 $all_item_ids = array_unique(array_merge($all_item_ids,$a_ids));
231 $query =
"SELECT MAX(grouping_id) grp FROM ut_lp_collections ".
232 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
243 $query =
"UPDATE ut_lp_collections SET ".
244 "grouping_id = ".$ilDB->quote($grp_id,
'integer').
", ".
245 "num_obligatory = 1, ".
246 "active = ".$ilDB->quote(1,
'integer').
" ".
247 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
248 "AND ".$ilDB->in(
'item_id',$all_item_ids,
false,
'integer');
249 $ilDB->manipulate(
$query);
264 foreach($a_obl as $grouping_id => $num)
266 $query =
"SELECT count(obj_id) num FROM ut_lp_collections ".
267 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer').
' '.
268 'AND grouping_id = '.$ilDB->quote($grouping_id,
'integer').
' '.
273 if($num <= 0 or $num >=
$row->num)
275 throw new UnexpectedValueException();
279 foreach($a_obl as $grouping_id => $num)
281 $query =
'UPDATE ut_lp_collections '.
282 'SET num_obligatory = '.$ilDB->quote($num,
'integer').
' '.
283 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer').
' '.
284 'AND grouping_id = '.$ilDB->quote($grouping_id,
'integer');
285 $ilDB->manipulate(
$query);
298 $query =
"SELECT grouping_id FROM ut_lp_collections ".
299 "WHERE obj_id = " . $ilDB->quote($a_obj_id,
'integer') .
" " .
300 "AND ".$ilDB->in(
'item_id', $a_ids,
false,
'integer').
" ".
301 "AND grouping_id > 0 ";
307 $grp_ids[] =
$row->grouping_id;
310 $query =
"UPDATE ut_lp_collections ".
311 "SET grouping_id = ".$ilDB->quote(0,
'integer').
", ".
312 "num_obligatory = 0 ".
313 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
314 "AND " . $ilDB->in(
'grouping_id', $grp_ids,
false,
'integer');
315 $ilDB->manipulate(
$query);
332 $query =
"SELECT item_id FROM ut_lp_collections ".
333 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
334 "AND grouping_id > 0 ";
336 return $res->numRows() ?
true :
false;
350 $query =
"SELECT grouping_id FROM ut_lp_collections ".
351 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
352 "AND item_id = ".$ilDB->quote($item_id,
'integer');
355 $grouping_id =
$row->grouping_id;
357 if($grouping_id == 0)
362 $query =
"SELECT item_id, num_obligatory FROM ut_lp_collections ".
363 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
364 "AND grouping_id = ".$ilDB->quote($grouping_id,
'integer');
371 $items[
'num_obligatory'] =
$row->num_obligatory;
372 $items[
'grouping_id'] = $grouping_id;
377 function delete($item_id)
381 $query =
"DELETE FROM ut_lp_collections ".
382 "WHERE item_id = ".$ilDB->quote($item_id ,
'integer').
" ".
383 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
397 if($tree->isDeleted($a_target_id))
402 $node_data = $tree->getNodeData($a_target_id);
403 foreach($tree->getSubTree($node_data) as $node)
406 if($node[
'ref_id'] == $a_target_id)
411 switch($node[
'type'])
421 $all_possible[] = $node[
'ref_id'];
426 return $all_possible ? $all_possible : array();
446 include_once
'./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
452 include_once
'./Modules/ScormAicc/classes/class.ilObjAICCLearningModule.php';
456 $items[
"$item[obj_id]"][
'title'] = $item[
'title'];
457 #$items[$item->getId()]['title'] = $item->getTitle();
462 include_once
'./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
463 include_once
'./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php';
467 $items[$item->getId()][
'title'] = $item->getTitle();
472 include_once
'./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php';
476 $items[$item[
"id"]][
'title'] = $item[
"title"];
493 $query =
"DELETE FROM ut_lp_collections ".
494 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
511 $query =
"SELECT * FROM ut_lp_collections ".
512 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
521 $grouped[
$row->grouping_id][
'items'][] =
$row->item_id;
522 $grouped[
$row->grouping_id][
'num_obligatory'] =
$row->num_obligatory;
528 function &
_getItems($a_obj_id, $a_use_subtree_by_id =
false)
530 global $ilObjDataCache;
533 include_once
'Services/Tracking/classes/class.ilLPObjSettings.php';
538 include_once
'Modules/Course/classes/class.ilCourseObjective.php';
546 if($ilObjDataCache->lookupType($a_obj_id) !=
'sahs')
549 $course_ref_id = end($course_ref_ids);
550 if (!$a_use_subtree_by_id)
556 $possible_items = $tree->getSubTreeIds($course_ref_id);
559 $query =
"SELECT * FROM ut_lp_collections utc ".
560 "JOIN object_reference obr ON item_id = ref_id ".
561 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
562 "WHERE utc.obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
563 "AND active = ".$ilDB->quote(1,
'integer').
" ".
569 $query =
"SELECT * FROM ut_lp_collections WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
570 "AND active = ".$ilDB->quote(1,
'integer');
576 if($ilObjDataCache->lookupType($a_obj_id) !=
'sahs')
578 if(!in_array(
$row->item_id,$possible_items))
585 if($ilObjDataCache->lookupType($item_obj_id = $ilObjDataCache->lookupObjId(
$row->item_id)) ==
'tst')
587 include_once
'./Modules/Test/classes/class.ilObjTest.php';
604 $query =
"DELETE FROM ut_lp_collections ".
605 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
606 "AND item_id = ".$ilDB->quote($a_item_id ,
'integer').
" ";
614 global $ilObjDataCache,
$ilDB;
616 $this->items = array();
618 if($ilObjDataCache->lookupType($this->getObjId()) !=
'sahs')
621 $course_ref_id = end($course_ref_ids);
622 $query =
"SELECT * FROM ut_lp_collections utc ".
623 "JOIN object_reference obr ON item_id = ref_id ".
624 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
625 "WHERE utc.obj_id = ".$this->db->quote($this->obj_id,
'integer').
" ".
626 "AND active = ".$ilDB->quote(1,
'integer').
" ".
631 $query =
"SELECT * FROM ut_lp_collections WHERE obj_id = ".$ilDB->quote($this->
getObjId() ,
'integer').
" ".
632 "AND active = ".$ilDB->quote(1,
'integer');
637 if($ilObjDataCache->lookupType($this->getObjId()) !=
'sahs')
646 if($ilObjDataCache->lookupType($item_obj_id = $ilObjDataCache->lookupObjId(
$row->item_id)) ==
'tst')
648 include_once
'./Modules/Test/classes/class.ilObjTest.php';
655 $this->items[] =
$row->item_id;
662 include_once
'./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
668 include_once
'./Modules/ScormAicc/classes/class.ilObjAICCLearningModule.php';
672 include_once
'./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
677 include_once
'./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php';
680 return array(
"raw" => null,
"max" => null,
"scaled" => null);