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 ||
73 $all_possible[] = $item_ref_id;
77 $all_possible[$item_ref_id] = array(
78 'ref_id' => $item_ref_id,
79 'obj_id' => $node[
'obj_id'],
80 'title' => $node[
'title'],
81 'description' => $node[
'description'],
82 'type' => $node[
'type']
88 case $objDefinition->isPluginTypeName($node[
'type']):
98 $all_possible[] = $item_ref_id;
102 $all_possible[$item_ref_id] = array(
103 'ref_id' => $item_ref_id,
104 'obj_id' => $node[
'obj_id'],
105 'title' => $node[
'title'],
106 'description' => $node[
'description'],
107 'type' => $node[
'type']
116 self::$possible_items[$cache_idx] = $all_possible;
119 return self::$possible_items[$cache_idx];
130 if($a_item_type ==
'tst')
135 if($olp->isAnonymized())
145 parent::cloneCollection($a_target_id, $a_copy_id);
147 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
149 $mappings = $cwo->getMappings();
152 $target_collection =
new static($target_obj_id,
$this->mode);
157 $target_item_ids = array();
158 foreach($group[
"items"] as $item)
160 if(!isset($mappings[$item]) or !$mappings[$item])
165 $target_item_ids[] = $mappings[$item];
169 if($grouping_id &&
sizeof($target_item_ids) > 1)
172 $num_obligatory = min(
sizeof($target_item_ids), $group[
"num_obligatory"]);
174 $target_collection->createNewGrouping($target_item_ids, $num_obligatory);
179 foreach($target_item_ids as $item_id)
202 $res = $ilDB->query(
"SELECT utc.item_id, obd.type".
203 " FROM ut_lp_collections utc".
204 " JOIN object_reference obr ON item_id = ref_id".
205 " JOIN object_data obd ON obr.obj_id = obd.obj_id".
206 " WHERE utc.obj_id = ".$ilDB->quote($this->obj_id,
"integer").
207 " AND active = ".$ilDB->quote(1,
"integer").
211 if(in_array(
$row->item_id, $possible) &&
235 $query =
"INSERT INTO ut_lp_collections".
236 " (obj_id, lpmode, item_id, grouping_id, num_obligatory, active)".
237 " VALUES (".$ilDB->quote($this->obj_id ,
"integer").
238 ", ".$ilDB->quote($this->mode,
"integer").
239 ", ".$ilDB->quote($a_item_id ,
"integer").
240 ", ".$ilDB->quote(0,
"integer").
241 ", ".$ilDB->quote(0,
"integer").
242 ", ".$ilDB->quote(1,
"integer").
244 $ilDB->manipulate(
$query);
245 $this->items[] = $a_item_id;
254 $query =
"DELETE FROM ut_lp_collections ".
255 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
256 " AND item_id = ".$ilDB->quote($a_item_id,
"integer").
257 " AND grouping_id = ".$ilDB->quote(0,
"integer");
258 $ilDB->manipulate(
$query);
271 $query =
"SELECT item_id FROM ut_lp_collections".
272 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer").
273 " AND grouping_id > ".$ilDB->quote(0,
"integer");
275 return $res->numRows() ? true :
false;
282 $grouping_ids = array();
284 $query =
"SELECT grouping_id FROM ut_lp_collections".
285 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
286 " AND ".$ilDB->in(
"item_id", $a_item_ids,
false,
"integer").
287 " AND grouping_id > ".$ilDB->quote(0,
"integer");
291 $grouping_ids[] =
$row->grouping_id;
294 return $grouping_ids;
301 parent::deactivateEntries($a_item_ids);
306 $query =
"UPDATE ut_lp_collections".
307 " SET active = ".$ilDB->quote(0,
"integer").
308 " WHERE ".$ilDB->in(
"grouping_id", $grouping_ids,
false,
"integer").
309 " AND obj_id = ".$ilDB->quote($this->obj_id,
"integer");
310 $ilDB->manipulate(
$query);
318 parent::activateEntries($a_item_ids);
323 $query =
"UPDATE ut_lp_collections".
324 " SET active = ".$ilDB->quote(1,
"integer").
325 " WHERE ".$ilDB->in(
"grouping_id", $grouping_ids,
false,
"integer").
326 " AND obj_id = ".$ilDB->quote($this->obj_id,
"integer");
327 $ilDB->manipulate(
$query);
337 $all_item_ids = array();
341 $query =
"SELECT item_id FROM ut_lp_collections".
342 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
343 " AND ".$ilDB->in(
"grouping_id", $grouping_ids,
false,
"integer");
347 $all_item_ids[] =
$row->item_id;
350 $all_item_ids = array_unique(array_merge($all_item_ids, $a_item_ids));
355 $query =
"SELECT MAX(grouping_id) grp FROM ut_lp_collections".
356 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
363 $query =
"UPDATE ut_lp_collections SET".
364 " grouping_id = ".$ilDB->quote($grp_id,
"integer").
365 ", num_obligatory = ".$ilDB->quote($a_num_obligatory,
"integer").
366 ", active = ".$ilDB->quote(1,
"integer").
367 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
368 " AND ".$ilDB->in(
"item_id", $all_item_ids,
false,
"integer");
369 $ilDB->manipulate(
$query);
380 $query =
"UPDATE ut_lp_collections".
381 " SET grouping_id = ".$ilDB->quote(0,
"integer").
382 ", num_obligatory = ".$ilDB->quote(0,
"integer").
383 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
384 " AND " . $ilDB->in(
"grouping_id", $grouping_ids,
false,
"integer");
385 $ilDB->manipulate(
$query);
392 foreach($a_obl as $grouping_id => $num)
394 $query =
"SELECT count(obj_id) num FROM ut_lp_collections".
395 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
396 " AND grouping_id = ".$ilDB->quote($grouping_id,
'integer').
401 if($num <= 0 || $num >=
$row->num)
403 throw new UnexpectedValueException();
407 foreach($a_obl as $grouping_id => $num)
409 $query =
"UPDATE ut_lp_collections".
410 " SET num_obligatory = ".$ilDB->quote($num,
"integer").
411 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
412 " AND grouping_id = ".$ilDB->quote($grouping_id,
"integer");
413 $ilDB->manipulate(
$query);
428 foreach(
$items as $item_id => $item)
430 if(in_array($item_id, $done))
438 $table_item[
'grouped'] = array();
440 if(count((array)$grouped_items[
'items']) > 1)
442 foreach($grouped_items[
'items'] as $grouped_item_id)
444 if($grouped_item_id == $item_id ||
445 !is_array(
$items[$grouped_item_id]))
451 $table_item[
'num_obligatory'] = $grouped_items[
'num_obligatory'];
452 $table_item[
'grouping_id'] = $grouped_items[
'grouping_id'];
454 $done[] = $grouped_item_id;
458 $data[] = $table_item;
466 $table_item = $a_item;
467 $table_item[
'id'] = $a_id;
471 $table_item[
'mode_id'] = $olp->getCurrentMode();
472 $table_item[
'mode'] = $olp->getModeText($table_item[
'mode_id']);
473 $table_item[
'anonymized'] = $olp->isAnonymized();
484 $query =
"SELECT grouping_id FROM ut_lp_collections".
485 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
486 " AND item_id = ".$ilDB->quote($item_id,
"integer");
489 $grouping_id =
$row->grouping_id;
492 $query =
"SELECT item_id, num_obligatory FROM ut_lp_collections".
493 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
494 " AND grouping_id = ".$ilDB->quote($grouping_id,
"integer");
499 $items[
'num_obligatory'] =
$row->num_obligatory;
500 $items[
'grouping_id'] = $grouping_id;
513 $query =
" SELECT * FROM ut_lp_collections".
514 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
515 " AND active = ".$ilDB->quote(1,
"integer");
523 $grouped[
$row->grouping_id][
'items'][] =
$row->item_id;
524 $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
const DB_FETCHMODE_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)
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)
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
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)