19declare(strict_types=0);
38 $this->db =
$DIC->database();
39 $this->
logger = $DIC->logger()->trac();
41 $this->obj_id = $a_obj_id;
42 $this->mode = $a_mode;
45 $this->
read($a_obj_id);
53 $path =
"components/ILIAS/Tracking/classes/collection/";
105 $mappings = $cwo->getMappings();
108 $new_collection =
new static($target_obj_id, $this->mode);
109 foreach ($this->items as $item) {
110 if (!isset($mappings[$item]) or !$mappings[$item]) {
114 $new_collection->addEntry($mappings[$item]);
116 $this->
logger->debug(
'cloned learning progress collection.');
124 protected function read(
int $a_obj_id): void
127 $res = $this->db->query(
128 "SELECT * FROM ut_lp_collections" .
129 " WHERE obj_id = " . $this->db->quote($a_obj_id,
"integer")
132 if ($this->validateEntry((
int) $row->item_id)) {
133 $items[] = $row->item_id;
135 $this->deleteEntry($row->item_id);
138 $this->items = $items;
141 public function delete():
void
143 $query =
"DELETE FROM ut_lp_collections" .
144 " WHERE obj_id = " . $this->db->quote($this->obj_id,
"integer");
145 $this->db->manipulate($query);
147 $query =
"DELETE FROM ut_lp_coll_manual" .
148 " WHERE obj_id = " . $this->db->quote($this->obj_id,
"integer");
149 $this->db->manipulate($query);
151 $this->items = array();
165 if (is_array($this->items)) {
166 return in_array($a_item_id, $this->items);
173 if (!$this->isAssignedEntry($a_item_id)) {
174 $query =
"INSERT INTO ut_lp_collections" .
175 " (obj_id, lpmode, item_id)" .
176 " VALUES (" . $this->db->quote($this->obj_id,
"integer") .
177 ", " . $this->db->quote($this->mode,
"integer") .
178 ", " . $this->db->quote($a_item_id,
"integer") .
180 $this->db->manipulate($query);
181 $this->items[] = $a_item_id;
188 $query =
"DELETE FROM ut_lp_collections" .
189 " WHERE obj_id = " . $this->db->quote($this->obj_id,
"integer") .
190 " AND item_id = " . $this->db->quote($a_item_id,
"integer");
191 $this->db->manipulate($query);
200 foreach ($a_item_ids as $item_id) {
201 $this->deleteEntry($item_id);
210 foreach ($a_item_ids as $item_id) {
211 $this->addEntry($item_id);
static _getInstance(int $a_copy_id)
LP collection of learning module chapters.
LP collection of objectives.
LP collection of repository objects.
LP collection base class.
validateEntry(int $a_item_id)
cloneCollection(int $a_target_id, int $a_copy_id)
isAssignedEntry(int $a_item_id)
deleteEntry(int $a_item_id)
__construct(int $a_obj_id, int $a_mode)
static getCollectionModes()
activateEntries(array $a_item_ids)
static getInstanceByMode(int $a_obj_id, int $a_mode)
deactivateEntries(array $a_item_ids)
const LP_MODE_COLLECTION_TLT
const LP_MODE_COLLECTION_MANUAL
const LP_MODE_MANUAL_BY_TUTOR
const LP_MODE_COLLECTION_MOBS
Component logger with individual log levels by component id.
static _lookupObjId(int $ref_id)