ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilLPCollection Class Reference
+ 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

array $items
 
int $obj_id
 
int $mode
 
ilDBInterface $db
 
ilLogger $logger
 
TrackingDBFactoryInterface $tracking_db_factory
 

Detailed Description

Definition at line 24 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 $this->items = [];
38 $this->db = $DIC->database();
39 $this->logger = $DIC->logger()->trac();
40 $this->tracking_db_factory = new TrackingDBFactory($this->db);
41 $this->obj_id = $a_obj_id;
42 $this->mode = $a_mode;
43 $this->read($a_obj_id);
44 }
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 183 of file class.ilLPCollection.php.

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

◆ addEntry()

ilLPCollection::addEntry ( int  $a_item_id)
protected

Reimplemented in ilLPCollectionOfRepositoryObjects.

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

149 : bool
150 {
151 $element = $this->tracking_db_factory->lpCollection()->element()->lpCollectionElement()
152 ->withItemId($a_item_id)
153 ->withLPMode($this->mode)
154 ->withGroupingId(0)
155 ->withIsActive(true)
156 ->withNumObligatory(0);
157 $collection = $this->tracking_db_factory->lpCollection()->element()->lpCollection($element)
158 ->withObjectId($this->obj_id);
159 $this->tracking_db_factory->lpCollection()->repository()->writeLPCollection($collection);
160 $this->items[] = $a_item_id;
161 return true;
162 }

◆ cloneCollection()

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

Reimplemented in ilLPCollectionOfRepositoryObjects, and ilLPCollectionOfSCOs.

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

93 : void
94 {
95 $target_obj_id = ilObject::_lookupObjId($a_target_id);
96 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
97 $mappings = $cwo->getMappings();
98
99 // #12067
100 $new_collection = new static($target_obj_id, $this->mode);
101 foreach ($this->items as $item) {
102 if (!isset($mappings[$item]) or !$mappings[$item]) {
103 continue;
104 }
105
106 $new_collection->addEntry($mappings[$item]);
107 }
108 $this->logger->debug('cloned learning progress collection.');
109 }
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 173 of file class.ilLPCollection.php.

173 : void
174 {
175 foreach ($a_item_ids as $item_id) {
176 $this->deleteEntry($item_id);
177 }
178 }
deleteEntry(int $a_item_id)

◆ delete()

ilLPCollection::delete ( )

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

132 : void
133 {
134 $this->tracking_db_factory->lpCollection()->repository()->deleteLPCollection($this->obj_id);
135 $this->tracking_db_factory->lpCollection()->repository()->deleteLPCollectionManual($this->obj_id);
136 $this->items = [];
137 }

◆ deleteEntry()

ilLPCollection::deleteEntry ( int  $a_item_id)
protected

Reimplemented in ilLPCollectionOfRepositoryObjects.

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

164 : bool
165 {
166 $this->tracking_db_factory->lpCollection()->repository()->deleteLPCollectionEntry($this->obj_id, $a_item_id);
167 return true;
168 }

◆ getCollectionModes()

◆ getInstanceByMode()

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

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

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

111 : array
112 {
113 return $this->items;
114 }

◆ hasSelectableItems()

ilLPCollection::hasSelectableItems ( )

Reimplemented in ilLPCollectionOfObjectives.

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

88 : bool
89 {
90 return true;
91 }

◆ isAssignedEntry()

ilLPCollection::isAssignedEntry ( int  $a_item_id)

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

144 : bool
145 {
146 return in_array($a_item_id, $this->items ?? []);
147 }

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

116 : void
117 {
118 $items = [];
119 $lp_collection = $this->tracking_db_factory->lpCollection()->repository()->readLPCollection($a_obj_id);
120 if (!is_null($lp_collection)) {
121 foreach ($lp_collection as $lp_collection_entry) {
122 if ($this->validateEntry($lp_collection_entry->getItemId())) {
123 $items[] = $lp_collection_entry->getItemId();
124 } else {
125 $this->deleteEntry($lp_collection_entry->getItemId());
126 }
127 }
128 }
129 $this->items = $items;
130 }
validateEntry(int $a_item_id)

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

139 : bool
140 {
141 return true;
142 }

Field Documentation

◆ $db

ilDBInterface ilLPCollection::$db
protected

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

◆ $items

◆ $logger

ilLogger ilLPCollection::$logger
protected

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

◆ $mode

int ilLPCollection::$mode
protected

◆ $obj_id

◆ $tracking_db_factory

TrackingDBFactoryInterface ilLPCollection::$tracking_db_factory
protected

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


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