ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 25 of file class.ilLPCollection.php.

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented in ilLPCollectionOfRepositoryObjects.

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

35 {
36 global $DIC;
37
38 $this->db = $DIC->database();
39 $this->logger = $DIC->logger()->trac();
40
41 $this->obj_id = $a_obj_id;
42 $this->mode = $a_mode;
43
44 if ($a_obj_id) {
45 $this->read($a_obj_id);
46 }
47 }
global $DIC
Definition: shib_login.php:26

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 208 of file class.ilLPCollection.php.

208 : void
209 {
210 foreach ($a_item_ids as $item_id) {
211 $this->addEntry($item_id);
212 }
213 }
addEntry(int $a_item_id)

◆ addEntry()

ilLPCollection::addEntry ( int  $a_item_id)
protected

Reimplemented in ilLPCollectionOfRepositoryObjects.

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

171 : bool
172 {
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") .
179 ")";
180 $this->db->manipulate($query);
181 $this->items[] = $a_item_id;
182 }
183 return true;
184 }
isAssignedEntry(int $a_item_id)

◆ cloneCollection()

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

Reimplemented in ilLPCollectionOfRepositoryObjects, and ilLPCollectionOfSCOs.

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

101 : void
102 {
103 $target_obj_id = ilObject::_lookupObjId($a_target_id);
104 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
105 $mappings = $cwo->getMappings();
106
107 // #12067
108 $new_collection = new static($target_obj_id, $this->mode);
109 foreach ($this->items as $item) {
110 if (!isset($mappings[$item]) or !$mappings[$item]) {
111 continue;
112 }
113
114 $new_collection->addEntry($mappings[$item]);
115 }
116 $this->logger->debug('cloned learning progress collection.');
117 }
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 198 of file class.ilLPCollection.php.

198 : void
199 {
200 foreach ($a_item_ids as $item_id) {
201 $this->deleteEntry($item_id);
202 }
203 }
deleteEntry(int $a_item_id)

◆ delete()

ilLPCollection::delete ( )

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

141 : void
142 {
143 $query = "DELETE FROM ut_lp_collections" .
144 " WHERE obj_id = " . $this->db->quote($this->obj_id, "integer");
145 $this->db->manipulate($query);
146
147 $query = "DELETE FROM ut_lp_coll_manual" .
148 " WHERE obj_id = " . $this->db->quote($this->obj_id, "integer");
149 $this->db->manipulate($query);
150 // #15462 - reset internal data
151 $this->items = array();
152 }

◆ deleteEntry()

ilLPCollection::deleteEntry ( int  $a_item_id)
protected

Reimplemented in ilLPCollectionOfRepositoryObjects.

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

186 : bool
187 {
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);
192 return true;
193 }

◆ getCollectionModes()

◆ getInstanceByMode()

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

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

53 $path = "components/ILIAS/Tracking/classes/collection/";
54
55 switch ($a_mode) {
59 $a_obj_id,
60 $a_mode
61 );
62
64 return new ilLPCollectionOfObjectives($a_obj_id, $a_mode);
65
67 return new ilLPCollectionOfSCOs($a_obj_id, $a_mode);
68
71 return new ilLPCollectionOfLMChapters($a_obj_id, $a_mode);
72
74 return new ilLPCollectionOfMediaObjects($a_obj_id, $a_mode);
75 }
76 return null;
77 }
LP collection of learning module chapters.
LP collection base class.
$path
Definition: ltiservices.php:30

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 119 of file class.ilLPCollection.php.

119 : array
120 {
121 return $this->items;
122 }

◆ hasSelectableItems()

ilLPCollection::hasSelectableItems ( )

Reimplemented in ilLPCollectionOfObjectives.

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

96 : bool
97 {
98 return true;
99 }

◆ isAssignedEntry()

ilLPCollection::isAssignedEntry ( int  $a_item_id)

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

163 : bool
164 {
165 if (is_array($this->items)) {
166 return in_array($a_item_id, $this->items);
167 }
168 return false;
169 }

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 124 of file class.ilLPCollection.php.

124 : void
125 {
126 $items = array();
127 $res = $this->db->query(
128 "SELECT * FROM ut_lp_collections" .
129 " WHERE obj_id = " . $this->db->quote($a_obj_id, "integer")
130 );
131 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
132 if ($this->validateEntry((int) $row->item_id)) {
133 $items[] = $row->item_id;
134 } else {
135 $this->deleteEntry($row->item_id);
136 }
137 }
138 $this->items = $items;
139 }
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 158 of file class.ilLPCollection.php.

158 : bool
159 {
160 return true;
161 }

Field Documentation

◆ $db

ilDBInterface ilLPCollection::$db
protected

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

◆ $items

◆ $logger

ilLogger ilLPCollection::$logger
protected

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

◆ $mode

int ilLPCollection::$mode
protected

◆ $obj_id


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