ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilContainerStartObjects Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilContainerStartObjects:

Public Member Functions

 __construct (int $a_object_ref_id, int $a_object_id)
 
 getObjId ()
 
 getRefId ()
 
 getStartObjects ()
 
 delete (int $a_crs_start_id)
 
 deleteItem (int $a_item_ref_id)
 
 exists (int $a_item_ref_id)
 
 add (int $a_item_ref_id)
 
 setObjectPos (int $a_start_id, int $a_pos)
 
 getPossibleStarters ()
 
 allFullfilled (int $a_user_id)
 
 isFullfilled (int $a_user_id, int $a_item_id)
 
 cloneDependencies (int $a_target_id, int $a_copy_id)
 

Static Public Member Functions

static isStartObject (int $a_container_id, int $a_item_ref_id)
 

Protected Member Functions

 setObjId (int $a_id)
 
 setRefId (int $a_ref_id)
 
 read ()
 

Protected Attributes

ilTree $tree
 
ilDBInterface $db
 
ilObjectDataCache $obj_data_cache
 
ilLogger $log
 
int $ref_id
 
int $obj_id
 
array $start_objs = []
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning ilContainerStartObjects

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 24 of file class.ilContainerStartObjects.php.

Constructor & Destructor Documentation

◆ __construct()

ilContainerStartObjects::__construct ( int  $a_object_ref_id,
int  $a_object_id 
)

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

37 {
38 global $DIC;
39
40 $this->tree = $DIC->repositoryTree();
41 $this->db = $DIC->database();
42 $this->obj_data_cache = $DIC["ilObjDataCache"];
43 $this->log = $DIC["ilLog"];
44 $this->setRefId($a_object_ref_id);
45 $this->setObjId($a_object_id);
46
47 $this->read();
48 }
global $DIC
Definition: shib_login.php:26

References $DIC, read(), setObjId(), and setRefId().

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilContainerStartObjects::add ( int  $a_item_ref_id)

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

127 : bool
128 {
130
131 if ($a_item_ref_id) {
132 $max_pos = $ilDB->query("SELECT max(pos) pos FROM crs_start" .
133 " WHERE crs_id = " . $ilDB->quote($this->getObjId(), "integer"));
134 $max_pos = $ilDB->fetchAssoc($max_pos);
135 $max_pos = ((int) $max_pos["pos"]) + 10;
136
137 $next_id = $ilDB->nextId('crs_start');
138 $query = "INSERT INTO crs_start" .
139 " (crs_start_id,crs_id,item_ref_id,pos)" .
140 " VALUES" .
141 " (" . $ilDB->quote($next_id, 'integer') .
142 ", " . $ilDB->quote($this->getObjId(), 'integer') .
143 ", " . $ilDB->quote($a_item_ref_id, 'integer') .
144 ", " . $ilDB->quote($max_pos, 'integer') .
145 ")";
146 $ilDB->manipulate($query);
147 return true;
148 }
149 return false;
150 }

References $db, $ilDB, getObjId(), and ILIAS\Repository\int().

Referenced by ilLOSettings\updateStartObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ allFullfilled()

ilContainerStartObjects::allFullfilled ( int  $a_user_id)

Definition at line 185 of file class.ilContainerStartObjects.php.

185 : bool
186 {
187 foreach ($this->getStartObjects() as $item) {
188 if (!$this->isFullfilled($a_user_id, $item['item_ref_id'])) {
189 return false;
190 }
191 }
192 return true;
193 }
isFullfilled(int $a_user_id, int $a_item_id)

◆ cloneDependencies()

ilContainerStartObjects::cloneDependencies ( int  $a_target_id,
int  $a_copy_id 
)

Definition at line 235 of file class.ilContainerStartObjects.php.

238 : void {
239 $ilObjDataCache = $this->obj_data_cache;
240 $ilLog = $this->log;
241
242 $ilLog->write(__METHOD__ . ': Begin course start objects...');
243
244 $new_obj_id = $ilObjDataCache->lookupObjId($a_target_id);
245 $start = new self($a_target_id, $new_obj_id);
246
247 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
248 $mappings = $cwo->getMappings();
249 foreach ($this->getStartObjects() as $data) {
250 $item_ref_id = $data['item_ref_id'];
251 if (isset($mappings[$item_ref_id]) && $mappings[$item_ref_id]) {
252 $ilLog->write(__METHOD__ . ': Clone start object nr. ' . $item_ref_id);
253 $start->add($mappings[$item_ref_id]);
254 } else {
255 $ilLog->write(__METHOD__ . ': No mapping found for start object nr. ' . $item_ref_id);
256 }
257 }
258 $ilLog->write(__METHOD__ . ': ... end course start objects');
259 }
static _getInstance(int $a_copy_id)
write(string $message, $level=ilLogLevel::INFO, array $context=[])
write log message

◆ delete()

ilContainerStartObjects::delete ( int  $a_crs_start_id)

Definition at line 95 of file class.ilContainerStartObjects.php.

95 : void
96 {
98
99 $query = "DELETE FROM crs_start" .
100 " WHERE crs_start_id = " . $ilDB->quote($a_crs_start_id, 'integer') .
101 " AND crs_id = " . $ilDB->quote($this->getObjId(), 'integer');
102 $ilDB->manipulate($query);
103 }

References $db, $ilDB, and getObjId().

+ Here is the call graph for this function:

◆ deleteItem()

ilContainerStartObjects::deleteItem ( int  $a_item_ref_id)

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

105 : void
106 {
108
109 $query = "DELETE FROM crs_start" .
110 " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
111 " AND item_ref_id = " . $ilDB->quote($a_item_ref_id, 'integer');
112 $ilDB->manipulate($query);
113 }

References $db, $ilDB, and getObjId().

Referenced by ilLOSettings\updateStartObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exists()

ilContainerStartObjects::exists ( int  $a_item_ref_id)

Definition at line 115 of file class.ilContainerStartObjects.php.

115 : bool
116 {
118
119 $query = "SELECT * FROM crs_start" .
120 " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
121 " AND item_ref_id = " . $ilDB->quote($a_item_ref_id, 'integer');
122 $res = $ilDB->query($query);
123
124 return (bool) $res->numRows();
125 }
$res
Definition: ltiservices.php:69

References $db, $ilDB, $res, and getObjId().

Referenced by ilLOSettings\updateStartObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjId()

ilContainerStartObjects::getObjId ( )

Definition at line 55 of file class.ilContainerStartObjects.php.

55 : int
56 {
57 return $this->obj_id;
58 }

References $obj_id.

Referenced by add(), delete(), deleteItem(), exists(), and read().

+ Here is the caller graph for this function:

◆ getPossibleStarters()

ilContainerStartObjects::getPossibleStarters ( )

Definition at line 168 of file class.ilContainerStartObjects.php.

168 : array
169 {
170 $poss_items = [];
171 foreach (ilObjectActivation::getItems($this->getRefId(), false) as $node) {
172 switch ($node['type']) {
173 case 'lm':
174 case 'sahs':
175 case 'svy':
176 case 'copa':
177 case 'tst':
178 $poss_items[] = $node['ref_id'];
179 break;
180 }
181 }
182 return $poss_items;
183 }
static getItems(int $parent_id, bool $with_list_data=true)
Get sub item data.

References ilObjectActivation\getItems().

+ Here is the call graph for this function:

◆ getRefId()

ilContainerStartObjects::getRefId ( )

Definition at line 65 of file class.ilContainerStartObjects.php.

65 : int
66 {
67 return $this->ref_id;
68 }

References $ref_id.

◆ getStartObjects()

ilContainerStartObjects::getStartObjects ( )

Definition at line 70 of file class.ilContainerStartObjects.php.

70 : array
71 {
72 return $this->start_objs ?: [];
73 }

◆ isFullfilled()

ilContainerStartObjects::isFullfilled ( int  $a_user_id,
int  $a_item_id 
)

Definition at line 195 of file class.ilContainerStartObjects.php.

195 : bool
196 {
197 $ilObjDataCache = $this->obj_data_cache;
198
199 $obj_id = $ilObjDataCache->lookupObjId($a_item_id);
200 $type = $ilObjDataCache->lookupType($obj_id);
201
202 switch ($type) {
203 case 'tst':
204 if (!ilObjTestAccess::checkCondition($obj_id, 'finished', '', $a_user_id)) { // #14000
205 return false;
206 }
207 break;
208
209 case 'svy':
210
212 return false;
213 }
214 break;
215
216 case 'copa':
217 case 'sahs':
218 if (!ilLPStatus::_hasUserCompleted($obj_id, $a_user_id)) {
219 return false;
220 }
221 break;
222
223 default:
224 $lm_continue = new ilCourseLMHistory($this->getRefId(), $a_user_id);
225 $continue_data = $lm_continue->getLMHistory();
226 if (!isset($continue_data[$a_item_id])) {
227 return false;
228 }
229 break;
230 }
231
232 return true;
233 }
class ilCourseLMHistory
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
static _lookupFinished(int $a_obj_id, int $a_user_id=0)
get finished status
static checkCondition(int $a_trigger_obj_id, string $a_operator, string $a_value, int $a_usr_id)
check condition for a specific user and object

References ilLPStatus\_hasUserCompleted(), ilObjSurveyAccess\_lookupFinished(), and ilConditionHandling\checkCondition().

+ Here is the call graph for this function:

◆ isStartObject()

static ilContainerStartObjects::isStartObject ( int  $a_container_id,
int  $a_item_ref_id 
)
static

Definition at line 261 of file class.ilContainerStartObjects.php.

264 : bool {
265 global $DIC;
266
267 $ilDB = $DIC->database();
268
269 $query = 'SELECT crs_start_id FROM crs_start ' .
270 'WHERE crs_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
271 'AND item_ref_id = ' . $ilDB->quote($a_item_ref_id, 'integer');
272 $res = $ilDB->query($query);
273
274 return $res->numRows() >= 1;
275 }

Referenced by ilLOTestQuestionAdapter\isQualifiedStartRun().

+ Here is the caller graph for this function:

◆ read()

ilContainerStartObjects::read ( )
protected

Definition at line 75 of file class.ilContainerStartObjects.php.

75 : void
76 {
79
80 $this->start_objs = [];
81
82 $query = "SELECT * FROM crs_start" .
83 " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
84 " ORDER BY pos, crs_start_id";
85 $res = $ilDB->query($query);
86 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
87 if ($tree->isInTree($row->item_ref_id)) {
88 $this->start_objs[$row->crs_start_id]['item_ref_id'] = (int) $row->item_ref_id;
89 } else {
90 $this->delete((int) $row->item_ref_id);
91 }
92 }
93 }
isInTree(?int $a_node_id)
get all information of a node.

References $db, $ilDB, $res, $tree, ilDBConstants\FETCHMODE_OBJECT, getObjId(), ILIAS\Repository\int(), and ilTree\isInTree().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setObjectPos()

ilContainerStartObjects::setObjectPos ( int  $a_start_id,
int  $a_pos 
)

Definition at line 152 of file class.ilContainerStartObjects.php.

155 : void {
157
158 if (!$a_start_id || !$a_pos) {
159 return;
160 }
161
162 $ilDB->manipulate("UPDATE crs_start" .
163 " SET pos = " . $ilDB->quote($a_pos, "integer") .
164 " WHERE crs_id = " . $ilDB->quote($this->getObjId(), 'integer') .
165 " AND crs_start_id = " . $ilDB->quote($a_start_id, 'integer'));
166 }

◆ setObjId()

ilContainerStartObjects::setObjId ( int  $a_id)
protected

Definition at line 50 of file class.ilContainerStartObjects.php.

50 : void
51 {
52 $this->obj_id = $a_id;
53 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setRefId()

ilContainerStartObjects::setRefId ( int  $a_ref_id)
protected

Definition at line 60 of file class.ilContainerStartObjects.php.

60 : void
61 {
62 $this->ref_id = $a_ref_id;
63 }

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilContainerStartObjects::$db
protected

Definition at line 27 of file class.ilContainerStartObjects.php.

Referenced by add(), delete(), deleteItem(), exists(), and read().

◆ $log

ilLogger ilContainerStartObjects::$log
protected

Definition at line 29 of file class.ilContainerStartObjects.php.

◆ $obj_data_cache

ilObjectDataCache ilContainerStartObjects::$obj_data_cache
protected

Definition at line 28 of file class.ilContainerStartObjects.php.

◆ $obj_id

int ilContainerStartObjects::$obj_id
protected

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

Referenced by getObjId().

◆ $ref_id

int ilContainerStartObjects::$ref_id
protected

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

Referenced by getRefId().

◆ $start_objs

array ilContainerStartObjects::$start_objs = []
protected

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

◆ $tree

ilTree ilContainerStartObjects::$tree
protected

Definition at line 26 of file class.ilContainerStartObjects.php.

Referenced by read().


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