5 require_once
"Services/Tracking/classes/collection/class.ilLPCollection.php";
22 global $tree, $objDefinition;
24 $cache_idx = $a_ref_id.
"__".$a_full_data;
26 if(!isset(self::$possible_items[$cache_idx]))
28 $all_possible =
array();
30 if(!$tree->isDeleted($a_ref_id))
32 include_once
'Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php';
36 $data = $tree->getRbacSubTreeInfo($a_ref_id);
40 $node = $tree->getNodeData($a_ref_id);
41 $data = $tree->getSubTree($node);
43 foreach(
$data as $node)
47 $item_ref_id = $node[
'child'];
51 $item_ref_id = $node[
'ref_id'];
55 if($item_ref_id == $a_ref_id ||
78 $all_possible[] = $item_ref_id;
82 $all_possible[$item_ref_id] =
array(
83 'ref_id' => $item_ref_id,
84 'obj_id' => $node[
'obj_id'],
85 'title' => $node[
'title'],
86 'description' => $node[
'description'],
87 'type' => $node[
'type']
93 case $objDefinition->isPluginTypeName($node[
'type']):
103 $all_possible[] = $item_ref_id;
107 $all_possible[$item_ref_id] =
array(
108 'ref_id' => $item_ref_id,
109 'obj_id' => $node[
'obj_id'],
110 'title' => $node[
'title'],
111 'description' => $node[
'description'],
112 'type' => $node[
'type']
121 self::$possible_items[$cache_idx] = $all_possible;
124 return self::$possible_items[$cache_idx];
135 if($a_item_type ==
'tst')
140 if($olp->isAnonymized())
150 parent::cloneCollection($a_target_id, $a_copy_id);
152 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
154 $mappings = $cwo->getMappings();
157 $target_collection =
new static($target_obj_id,
$this->mode);
162 $target_item_ids =
array();
163 foreach($group[
"items"] as $item)
165 if(!isset($mappings[$item])
or !$mappings[$item])
170 $target_item_ids[] = $mappings[$item];
174 if($grouping_id &&
sizeof($target_item_ids) > 1)
177 $num_obligatory = min(
sizeof($target_item_ids), $group[
"num_obligatory"]);
179 $target_collection->createNewGrouping($target_item_ids, $num_obligatory);
184 foreach($target_item_ids as $item_id)
197 protected function read($a_obj_id)
207 $res = $ilDB->query(
"SELECT utc.item_id, obd.type".
208 " FROM ut_lp_collections utc".
209 " JOIN object_reference obr ON item_id = ref_id".
210 " JOIN object_data obd ON obr.obj_id = obd.obj_id".
211 " WHERE utc.obj_id = ".$ilDB->quote($a_obj_id,
"integer").
212 " AND active = ".$ilDB->quote(1,
"integer").
216 if(in_array(
$row->item_id, $possible) &&
240 $query =
"INSERT INTO ut_lp_collections".
241 " (obj_id, lpmode, item_id, grouping_id, num_obligatory, active)".
242 " VALUES (".$ilDB->quote($this->obj_id ,
"integer").
243 ", ".$ilDB->quote($this->mode,
"integer").
244 ", ".$ilDB->quote($a_item_id ,
"integer").
245 ", ".$ilDB->quote(0,
"integer").
246 ", ".$ilDB->quote(0,
"integer").
247 ", ".$ilDB->quote(1,
"integer").
249 $ilDB->manipulate(
$query);
250 $this->items[] = $a_item_id;
259 $query =
"DELETE FROM ut_lp_collections ".
260 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
261 " AND item_id = ".$ilDB->quote($a_item_id,
"integer").
262 " AND grouping_id = ".$ilDB->quote(0,
"integer");
263 $ilDB->manipulate(
$query);
276 $query =
"SELECT item_id FROM ut_lp_collections".
277 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer").
278 " AND grouping_id > ".$ilDB->quote(0,
"integer");
280 return $res->numRows() ? true :
false;
287 $grouping_ids =
array();
289 $query =
"SELECT grouping_id FROM ut_lp_collections".
290 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
291 " AND ".$ilDB->in(
"item_id", $a_item_ids,
false,
"integer").
292 " AND grouping_id > ".$ilDB->quote(0,
"integer");
296 $grouping_ids[] =
$row->grouping_id;
299 return $grouping_ids;
306 parent::deactivateEntries($a_item_ids);
311 $query =
"UPDATE ut_lp_collections".
312 " SET active = ".$ilDB->quote(0,
"integer").
313 " WHERE ".$ilDB->in(
"grouping_id", $grouping_ids,
false,
"integer").
314 " AND obj_id = ".$ilDB->quote($this->obj_id,
"integer");
315 $ilDB->manipulate(
$query);
323 parent::activateEntries($a_item_ids);
328 $query =
"UPDATE ut_lp_collections".
329 " SET active = ".$ilDB->quote(1,
"integer").
330 " WHERE ".$ilDB->in(
"grouping_id", $grouping_ids,
false,
"integer").
331 " AND obj_id = ".$ilDB->quote($this->obj_id,
"integer");
332 $ilDB->manipulate(
$query);
342 $all_item_ids =
array();
346 $query =
"SELECT item_id FROM ut_lp_collections".
347 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
348 " AND ".$ilDB->in(
"grouping_id", $grouping_ids,
false,
"integer");
352 $all_item_ids[] =
$row->item_id;
355 $all_item_ids = array_unique(array_merge($all_item_ids, $a_item_ids));
360 $query =
"SELECT MAX(grouping_id) grp FROM ut_lp_collections".
361 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
368 $query =
"UPDATE ut_lp_collections SET".
369 " grouping_id = ".$ilDB->quote($grp_id,
"integer").
370 ", num_obligatory = ".$ilDB->quote($a_num_obligatory,
"integer").
371 ", active = ".$ilDB->quote(1,
"integer").
372 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
373 " AND ".$ilDB->in(
"item_id", $all_item_ids,
false,
"integer");
374 $ilDB->manipulate(
$query);
385 $query =
"UPDATE ut_lp_collections".
386 " SET grouping_id = ".$ilDB->quote(0,
"integer").
387 ", num_obligatory = ".$ilDB->quote(0,
"integer").
388 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
389 " AND " . $ilDB->in(
"grouping_id", $grouping_ids,
false,
"integer");
390 $ilDB->manipulate(
$query);
397 foreach($a_obl as $grouping_id => $num)
399 $query =
"SELECT count(obj_id) num FROM ut_lp_collections".
400 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
401 " AND grouping_id = ".$ilDB->quote($grouping_id,
'integer').
406 if($num <= 0 || $num >=
$row->num)
412 foreach($a_obl as $grouping_id => $num)
414 $query =
"UPDATE ut_lp_collections".
415 " SET num_obligatory = ".$ilDB->quote($num,
"integer").
416 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
417 " AND grouping_id = ".$ilDB->quote($grouping_id,
"integer");
418 $ilDB->manipulate(
$query);
433 foreach(
$items as $item_id => $item)
435 if(in_array($item_id, $done))
443 $table_item[
'grouped'] =
array();
445 if(count((
array)$grouped_items[
'items']) > 1)
447 foreach($grouped_items[
'items'] as $grouped_item_id)
449 if($grouped_item_id == $item_id ||
450 !is_array(
$items[$grouped_item_id]))
456 $table_item[
'num_obligatory'] = $grouped_items[
'num_obligatory'];
457 $table_item[
'grouping_id'] = $grouped_items[
'grouping_id'];
459 $done[] = $grouped_item_id;
463 $data[] = $table_item;
471 $table_item = $a_item;
472 $table_item[
'id'] = $a_id;
476 $table_item[
'mode_id'] = $olp->getCurrentMode();
477 $table_item[
'mode'] = $olp->getModeText($table_item[
'mode_id']);
478 $table_item[
'anonymized'] = $olp->isAnonymized();
489 $query =
"SELECT grouping_id FROM ut_lp_collections".
490 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
491 " AND item_id = ".$ilDB->quote($item_id,
"integer");
494 $grouping_id =
$row->grouping_id;
497 $query =
"SELECT item_id, num_obligatory FROM ut_lp_collections".
498 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
499 " AND grouping_id = ".$ilDB->quote($grouping_id,
"integer");
504 $items[
'num_obligatory'] =
$row->num_obligatory;
505 $items[
'grouping_id'] = $grouping_id;
518 $query =
" SELECT * FROM ut_lp_collections".
519 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
520 " AND active = ".$ilDB->quote(1,
"integer");
528 $grouped[
$row->grouping_id][
'items'][] =
$row->item_id;
529 $grouped[
$row->grouping_id][
'num_obligatory'] =
$row->num_obligatory;
releaseGrouping(array $a_item_ids)
static isTypePluginWithLP($a_type, $a_active_status=true)
Check whether a repository type is a plugin which has active learning progress.
cloneCollection($a_target_id, $a_copy_id)
getGroupingIds(array $a_item_ids)
getGroupedItemsForLPStatus()
getTableGUIData($a_parent_ref_id)
saveObligatoryMaterials(array $a_obl)
createNewGrouping(array $a_item_ids, $a_num_obligatory=1)
static _getAllReferences($a_id)
get all reference ids of object
LP collection of repository objects.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static _lookupObjId($a_id)
static hasGroupedItems($a_obj_id)
deactivateEntries(array $a_item_ids)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
LP collection base class.
activateEntries(array $a_item_ids)
parseTableGUIItem($a_id, array $a_item)
isAssignedEntry($a_item_id)
static getInstance($a_obj_id)
getPossibleItems($a_ref_id, $a_full_data=false)
getTableGUItemGroup($item_id)
validateEntry($a_item_ref_id, $a_item_type=null)