ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
ilLPCollection Class Reference

LP collection base class. More...

+ Inheritance diagram for ilLPCollection:
+ Collaboration diagram for ilLPCollection:

Public Member Functions

 __construct (int $a_obj_id, int $a_mode)
 
 hasSelectableItems ()
 
 cloneCollection (int $a_target_id, int $a_copy_id)
 
 getItems ()
 
 delete ()
 
 isAssignedEntry (int $a_item_id)
 
 deactivateEntries (array $a_item_ids)
 
 activateEntries (array $a_item_ids)
 

Static Public Member Functions

static getInstanceByMode (int $a_obj_id, int $a_mode)
 
static getCollectionModes ()
 

Protected Member Functions

 read (int $a_obj_id)
 
 validateEntry (int $a_item_id)
 
 addEntry (int $a_item_id)
 
 deleteEntry (int $a_item_id)
 

Protected Attributes

int $obj_id
 
int $mode
 
array $items = []
 
ilDBInterface $db
 
ilLogger $logger
 

Detailed Description

LP collection base class.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 11 of file class.ilLPCollection.php.

Constructor & Destructor Documentation

◆ __construct()

ilLPCollection::__construct ( int  $a_obj_id,
int  $a_mode 
)

Reimplemented in ilLPCollectionOfRepositoryObjects.

Definition at line 20 of file class.ilLPCollection.php.

21 {
22 global $DIC;
23
24 $this->db = $DIC->database();
25 $this->logger = $DIC->logger()->trac();
26
27 $this->obj_id = $a_obj_id;
28 $this->mode = $a_mode;
29
30 if ($a_obj_id) {
31 $this->read($a_obj_id);
32 }
33 }
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\Repository\logger(), and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ activateEntries()

ilLPCollection::activateEntries ( array  $a_item_ids)
Parameters
int[]$a_item_ids

Reimplemented in ilLPCollectionOfRepositoryObjects.

Definition at line 194 of file class.ilLPCollection.php.

194 : void
195 {
196 foreach ($a_item_ids as $item_id) {
197 $this->addEntry($item_id);
198 }
199 }
addEntry(int $a_item_id)

◆ addEntry()

ilLPCollection::addEntry ( int  $a_item_id)
protected

Reimplemented in ilLPCollectionOfRepositoryObjects.

Definition at line 157 of file class.ilLPCollection.php.

157 : bool
158 {
159 if (!$this->isAssignedEntry($a_item_id)) {
160 $query = "INSERT INTO ut_lp_collections" .
161 " (obj_id, lpmode, item_id)" .
162 " VALUES (" . $this->db->quote($this->obj_id, "integer") .
163 ", " . $this->db->quote($this->mode, "integer") .
164 ", " . $this->db->quote($a_item_id, "integer") .
165 ")";
166 $this->db->manipulate($query);
167 $this->items[] = $a_item_id;
168 }
169 return true;
170 }
isAssignedEntry(int $a_item_id)
$query

References $query.

◆ cloneCollection()

ilLPCollection::cloneCollection ( int  $a_target_id,
int  $a_copy_id 
)

Reimplemented in ilLPCollectionOfMediaObjects, ilLPCollectionOfRepositoryObjects, and ilLPCollectionOfSCOs.

Definition at line 87 of file class.ilLPCollection.php.

87 : void
88 {
89 $target_obj_id = ilObject::_lookupObjId($a_target_id);
90 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
91 $mappings = $cwo->getMappings();
92
93 // #12067
94 $new_collection = new static($target_obj_id, $this->mode);
95 foreach ($this->items as $item) {
96 if (!isset($mappings[$item]) or !$mappings[$item]) {
97 continue;
98 }
99
100 $new_collection->addEntry($mappings[$item]);
101 }
102 $this->logger->debug('cloned learning progress collection.');
103 }
static _getInstance(int $a_copy_id)
static _lookupObjId(int $ref_id)

References ilCopyWizardOptions\_getInstance(), ilObject\_lookupObjId(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ deactivateEntries()

ilLPCollection::deactivateEntries ( array  $a_item_ids)
Parameters
int[]$a_item_ids

Reimplemented in ilLPCollectionOfRepositoryObjects.

Definition at line 184 of file class.ilLPCollection.php.

184 : void
185 {
186 foreach ($a_item_ids as $item_id) {
187 $this->deleteEntry($item_id);
188 }
189 }
deleteEntry(int $a_item_id)

◆ delete()

ilLPCollection::delete ( )

Definition at line 127 of file class.ilLPCollection.php.

127 : void
128 {
129 $query = "DELETE FROM ut_lp_collections" .
130 " WHERE obj_id = " . $this->db->quote($this->obj_id, "integer");
131 $this->db->manipulate($query);
132
133 $query = "DELETE FROM ut_lp_coll_manual" .
134 " WHERE obj_id = " . $this->db->quote($this->obj_id, "integer");
135 $this->db->manipulate($query);
136 // #15462 - reset internal data
137 $this->items = array();
138 }

References $query.

◆ deleteEntry()

ilLPCollection::deleteEntry ( int  $a_item_id)
protected

Reimplemented in ilLPCollectionOfRepositoryObjects.

Definition at line 172 of file class.ilLPCollection.php.

172 : bool
173 {
174 $query = "DELETE FROM ut_lp_collections" .
175 " WHERE obj_id = " . $this->db->quote($this->obj_id, "integer") .
176 " AND item_id = " . $this->db->quote($a_item_id, "integer");
177 $this->db->manipulate($query);
178 return true;
179 }

References $query.

◆ getCollectionModes()

◆ getInstanceByMode()

static ilLPCollection::getInstanceByMode ( int  $a_obj_id,
int  $a_mode 
)
static

Definition at line 35 of file class.ilLPCollection.php.

39 $path = "Services/Tracking/classes/collection/";
40
41 switch ($a_mode) {
45 $a_obj_id,
46 $a_mode
47 );
48
50 return new ilLPCollectionOfObjectives($a_obj_id, $a_mode);
51
53 return new ilLPCollectionOfSCOs($a_obj_id, $a_mode);
54
57 return new ilLPCollectionOfLMChapters($a_obj_id, $a_mode);
58
60 return new ilLPCollectionOfMediaObjects($a_obj_id, $a_mode);
61 }
62 return null;
63 }
LP collection of learning module chapters.
LP collection base class.
$path
Definition: ltiservices.php:32

References ilLPObjSettings\LP_MODE_COLLECTION, ilLPObjSettings\LP_MODE_COLLECTION_MANUAL, ilLPObjSettings\LP_MODE_COLLECTION_MOBS, ilLPObjSettings\LP_MODE_COLLECTION_TLT, ilLPObjSettings\LP_MODE_MANUAL_BY_TUTOR, ilLPObjSettings\LP_MODE_OBJECTIVES, and ilLPObjSettings\LP_MODE_SCORM.

Referenced by ilLearningSequenceImporter\buildLPSettings(), ilObjectLP\getCollectionInstance(), ilTrackingCollectionTest\testCollectionInstance(), and ilLearningSequenceXMLWriter\writeLPSettings().

+ Here is the caller graph for this function:

◆ getItems()

ilLPCollection::getItems ( )

Definition at line 105 of file class.ilLPCollection.php.

105 : array
106 {
107 return $this->items;
108 }

◆ hasSelectableItems()

ilLPCollection::hasSelectableItems ( )

Reimplemented in ilLPCollectionOfObjectives.

Definition at line 82 of file class.ilLPCollection.php.

82 : bool
83 {
84 return true;
85 }

◆ isAssignedEntry()

ilLPCollection::isAssignedEntry ( int  $a_item_id)

Definition at line 149 of file class.ilLPCollection.php.

149 : bool
150 {
151 if (is_array($this->items)) {
152 return in_array($a_item_id, $this->items);
153 }
154 return false;
155 }

Referenced by ilLPCollectionOfRepositoryObjects\getPossibleItems(), ilLPCollectionOfLMChapters\getTableGUIData(), ilLPCollectionOfMediaObjects\getTableGUIData(), and ilLPCollectionOfSCOs\getTableGUIData().

+ Here is the caller graph for this function:

◆ read()

ilLPCollection::read ( int  $a_obj_id)
protected

Reimplemented in ilLPCollectionOfObjectives, and ilLPCollectionOfRepositoryObjects.

Definition at line 110 of file class.ilLPCollection.php.

110 : void
111 {
112 $items = array();
113 $res = $this->db->query(
114 "SELECT * FROM ut_lp_collections" .
115 " WHERE obj_id = " . $this->db->quote($a_obj_id, "integer")
116 );
117 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
118 if ($this->validateEntry((int) $row->item_id)) {
119 $items[] = $row->item_id;
120 } else {
121 $this->deleteEntry($row->item_id);
122 }
123 }
124 $this->items = $items;
125 }
validateEntry(int $a_item_id)
$res
Definition: ltiservices.php:69

References $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ validateEntry()

ilLPCollection::validateEntry ( int  $a_item_id)
protected

Reimplemented in ilLPCollectionOfRepositoryObjects.

Definition at line 144 of file class.ilLPCollection.php.

144 : bool
145 {
146 return true;
147 }

Field Documentation

◆ $db

ilDBInterface ilLPCollection::$db
protected

Definition at line 17 of file class.ilLPCollection.php.

◆ $items

◆ $logger

ilLogger ilLPCollection::$logger
protected

Definition at line 18 of file class.ilLPCollection.php.

◆ $mode

int ilLPCollection::$mode
protected

◆ $obj_id


The documentation for this class was generated from the following file: