ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.ilLSLocalDI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\DI\ServiceContainer as Container;
22use ILIAS\Data\Factory as DataFactory;
31
36class ilLSLocalDI extends Container
37{
38 public function init(
39 ArrayAccess $dic,
40 ArrayAccess $lsdic,
41 DataFactory $data_factory,
43 ): void {
44 $obj_id = (int) $object->getId();
45
46 $current_user = $dic['ilUser'];
47 $current_user_id = (int) $current_user->getId();
48
49 $this["obj.ref_id"] = function ($c) use ($object): int {
50 $ref = $object->getRefId();
51 if (!$ref) {
52 $refs = ilObject::_getAllReferences($object->getId());
53 $ref = array_shift($refs);
54 }
55 return (int) $ref;
56 };
57
58 $this["obj.obj_id"] = $obj_id;
59
60 $this["usr.id"] = $current_user_id;
61
62 $this["obj.sorting"] = function ($c): ilContainerSorting {
63 return ilContainerSorting::_getInstance($c["obj.obj_id"]);
64 };
65
66 $this["db.lsitems"] = function ($c) use ($dic, $lsdic): ilLSItemsDB {
67 $online_status = new LSItemOnlineStatus();
68 return new ilLSItemsDB(
69 $dic["tree"],
70 $c["obj.sorting"],
71 $lsdic["db.postconditions"],
72 $online_status
73 );
74 };
75
76 $this["db.progress"] = function ($c) use ($dic): ilLearnerProgressDB {
77 return new ilLearnerProgressDB(
78 $c["db.lsitems"],
79 $dic["ilAccess"],
80 $dic['ilObjDataCache']
81 );
82 };
83
84 $this["learneritems"] = function ($c) use ($dic, $lsdic): ilLSLearnerItemsQueries {
85 return new ilLSLearnerItemsQueries(
86 $c["db.progress"],
87 $lsdic["db.states"],
88 $c["obj.ref_id"],
89 $c["usr.id"]
90 );
91 };
92
93
94 $this["get.params"] = function ($c) use ($dic): ArrayBasedRequestWrapper {
95 return $dic["http"]->wrapper()->query();
96 };
97
98
99 $this["gui.learner"] = function ($c) use ($dic, $lsdic, $object): ilObjLearningSequenceLearnerGUI {
100 $intro = $object->getContentPageHTML(LSOPageType::INTRO);
101 $extro = $object->getContentPageHTML(LSOPageType::EXTRO);
102
104 $c["usr.id"],
105 $dic["ilAccess"],
106 $dic["ilCtrl"],
107 $dic["lng"],
108 $dic["tpl"],
109 $dic["ilToolbar"],
110 $dic["ui.factory"],
111 $dic["ui.renderer"],
112 $c["roles"],
113 $lsdic["db.settings"]->getSettingsFor($c["obj.obj_id"]),
114 $c["player.launchlinksbuilder"],
115 $c["learneritems"],
116 $c["player"],
117 $intro,
118 $extro,
119 $c["get.params"]
120 );
121 };
122
123 $this["player.urlbuilder.lp"] = function ($c) use ($dic, $data_factory): LSUrlBuilder {
124 $player_base_url = $dic['ilCtrl']->getLinkTargetByClass(
125 'ilObjLearningSequenceLPPollingGUI',
127 '',
128 false,
129 false
130 );
131 $player_base_url = $data_factory->uri(ILIAS_HTTP_PATH . '/' . $player_base_url);
132
133 return new LSUrlBuilder($player_base_url);
134 };
135 $this["gui.learner.lp"] = function ($c) use ($dic): ilObjLearningSequenceLPPollingGUI {
137 $dic["ilCtrl"],
138 $c["usr.id"],
139 $dic['ilObjDataCache'],
140 $dic->refinery(),
141 $dic->http()->wrapper()->query()
142 );
143 };
144
145 $this["gui.toc"] = function ($c) use ($dic): ilLSTOCGUI {
146 return new ilLSTOCGUI(
147 $c["player.urlbuilder"],
148 $dic["ilCtrl"]
149 );
150 };
151
152 $this["gui.loc"] = function ($c) use ($dic): ilLSLocatorGUI {
153 return new ilLSLocatorGUI(
154 $c["player.urlbuilder"],
155 $dic["ui.factory"]
156 );
157 };
158
159 $this["player.viewfactory"] = function ($c) use ($dic): ilLSViewFactory {
160 return new ilLSViewFactory(
161 $dic['service.kiosk_mode'],
162 $dic["lng"],
163 $dic["ilAccess"],
164 $dic['learning_object_metadata']
165 );
166 };
167
168 $this["player.urlbuilder"] = function ($c) use ($dic, $data_factory): LSUrlBuilder {
169 $player_base_url = $dic['ilCtrl']->getLinkTargetByClass(
170 'ilObjLearningSequenceLearnerGUI',
172 '',
173 false,
174 false
175 );
176 $player_base_url = $data_factory->uri(ILIAS_HTTP_PATH . '/' . $player_base_url);
177
178 return new LSUrlBuilder($player_base_url);
179 };
180
181 $this["globalsetttings"] = function ($c) use ($dic): \LSGlobalSettings {
182 $db = new ilLSGlobalSettingsDB($dic['ilSetting']);
183 return $db->getSettings();
184 };
185
186 $this["player.controlbuilder"] = function ($c) use ($dic): LSControlBuilder {
187 return new LSControlBuilder(
188 $dic["ui.factory"],
189 $c["player.urlbuilder"],
190 $dic["lng"],
191 $c["globalsetttings"],
192 $c["player.urlbuilder.lp"]
193 );
194 };
195
196 $this["player.kioskrenderer"] = function ($c) use ($dic): ilKioskPageRenderer {
197 $kiosk_template = new ilTemplate("tpl.kioskpage.html", true, true, 'components/ILIAS/LearningSequence');
198 $window_title = $dic['ilSetting']->get('short_inst_name', 'ILIAS');
199
200 return new ilKioskPageRenderer(
201 $dic["global_screen"]->layout()->meta(),
202 $dic["ui.factory"],
203 $dic["ui.renderer"],
204 $dic['lng'],
205 $kiosk_template,
206 $c["gui.toc"],
207 $c["gui.loc"],
208 $window_title
209 );
210 };
211
212
213 $this["player.launchlinksbuilder"] = function ($c) use ($dic): ilLSLaunchlinksBuilder {
214 $first_access = $c["learneritems"]->getFirstAccess();
215
216 return new ilLSLaunchlinksBuilder(
217 $dic["lng"],
218 $dic["ilAccess"],
219 $dic["ilCtrl"],
220 $dic["ui.factory"],
221 $c["obj.ref_id"],
222 $c["usr.id"],
223 $first_access,
224 $c["roles"],
225 $c["learneritems"]
226 );
227 };
228
229 $this["player"] = function ($c) use ($dic, $lsdic, $object): ilLSPlayer {
230 $mode = $lsdic["db.settings"]->getSettingsFor($c["obj.obj_id"])->getMode();
231 $navigator = ($mode === ilLearningSequenceSettings::MODE_ADAPTIVE)
232 ? new AdaptiveNavigator($lsdic["conditions.factory"])
233 : new LinearNavigator();
234
235 $item_path = $lsdic["db.item_path"];
236 $boundaries = $lsdic["db.boundaries"];
237
238 // Position ("where is the learner in the LSO") and the reusable
239 // choice-page template are injected so that both can be reused
240 // (e.g. by the upcoming map view) independently of the player.
241 $position = new LSOLearningMapPosition(
242 $navigator,
243 $item_path,
244 $boundaries,
245 $c["obj.obj_id"],
246 $c["usr.id"],
247 $dic["ilDB"]
248 );
249 $choice_page_builder = new LSChoicePageBuilder(
250 $dic["ui.factory"],
251 $dic["lng"],
252 $dic["ilObjDataCache"],
253 $c["player.urlbuilder"],
255 );
256
257 // Resolved here, before the player renders the current object: the
258 // kiosk view of an ILIAS learning module changes the ilCtrl context,
259 // and the player url of the map could not be built afterwards.
260 $learning_map_data_builder = $c["learning_map.data_builder"];
261 $learning_map = static fn(): string
262 => $object->renderLearningMap($learning_map_data_builder, false);
263
264 return new ilLSPlayer(
265 $c["learneritems"],
266 $c["player.controlbuilder"],
267 $c["player.urlbuilder"],
268 $c["player.viewfactory"],
269 $c["player.kioskrenderer"],
270 $dic["ui.factory"],
271 $lsdic["gs.current_context"],
272 $dic["refinery"],
273 $dic["lng"],
274 $dic["ilCtrl"],
275 $navigator,
276 $mode,
277 $item_path,
278 $boundaries,
279 $c["obj.obj_id"],
280 $c["usr.id"],
281 $position,
282 $choice_page_builder,
283 $learning_map
284 );
285 };
286
287 // Learning map data layer: assembles the object graph plus per-learner state
288 // (LSOLearningMap/LSOLearningMapNode) reusing the position/navigator of the
289 // respective operation mode. Adaptive: condition graph (AdaptiveNavigator plus
290 // LSOLearningMapPosition with the configured start/end object). Sequential: the
291 // plain chain in the configured order (LSOLearningMapSequentialNavigator plus
292 // LSOLearningMapSequentialPosition, where first/last item are start/end).
293 $this["learning_map.data_builder"] = function ($c) use ($dic, $lsdic): LSOLearningMapDataBuilder {
294 $is_adaptive = $lsdic["db.settings"]->getSettingsFor($c["obj.obj_id"])->getMode()
296
297 $navigator = $is_adaptive
298 ? new AdaptiveNavigator($lsdic["conditions.factory"])
300 $item_path = $lsdic["db.item_path"];
301 $boundaries = $lsdic["db.boundaries"];
302
303 $lso_obj_id = $c["obj.obj_id"];
304 $ref_id = $c["obj.ref_id"];
305 $db = $dic["ilDB"];
306 $progress_db = $c["db.progress"];
307
308 // Position and learner items are user-specific, so we hand the
309 // builder two factories keyed by user_id instead of ready-made
310 // objects. This way build($mode, $usr_id) can produce the map of any
311 // learner (e.g. a future tutor view over all participants), while
312 // the default (current) user stays $c["usr.id"].
313 $position_factory = static function (int $usr_id) use ($is_adaptive, $navigator, $item_path, $boundaries, $lso_obj_id, $db): LSOLearningMapPosition {
314 // The sequential mode derives start and end from the order of
315 // the items, but still needs the visit log to determine when an
316 // "always" post-condition has actually been fulfilled.
317 if (!$is_adaptive) {
319 $navigator,
320 $item_path,
321 $boundaries,
322 $lso_obj_id,
323 $usr_id,
324 $db
325 );
326 }
327 return new LSOLearningMapPosition(
328 $navigator,
329 $item_path,
330 $boundaries,
331 $lso_obj_id,
332 $usr_id,
333 $db
334 );
335 };
336 // In the sequential mode the map is the chain of the objects in their
337 // configured order, so the items are sorted by their order number.
338 $items_factory = static function (int $usr_id) use ($is_adaptive, $progress_db, $ref_id): array {
339 $items = $progress_db->getLearnerItems($usr_id, $ref_id);
340 if (!$is_adaptive) {
341 usort(
342 $items,
343 static fn(LSLearnerItem $a, LSLearnerItem $b): int
344 => $a->getOrderNumber() <=> $b->getOrderNumber()
345 );
346 }
347 return $items;
348 };
349
350 return new LSOLearningMapDataBuilder(
351 $navigator,
352 $c["player.urlbuilder"],
353 // the map addresses one specific object, which is not
354 // necessarily a successor of the object worked on last
356 $lso_obj_id,
357 $c["usr.id"],
358 $position_factory,
359 $items_factory,
360 !$is_adaptive
361 );
362 };
363
364 $this["participants"] = function ($c) use ($dic): ilLearningSequenceParticipants {
366 $c["obj.obj_id"],
367 $dic["ilLoggerFactory"]->getComponentLogger('lso'),
368 $dic["ilAppEventHandler"],
369 $dic["ilSetting"]
370 );
371 };
372
373 $this["roles"] = function ($c) use ($dic, $current_user): ilLearningSequenceRoles {
374 return new ilLearningSequenceRoles(
375 $c["obj.ref_id"],
376 $c["obj.obj_id"],
377 $c["participants"],
378 $dic["ilCtrl"],
379 $dic["rbacadmin"],
380 $dic["rbacreview"],
381 $dic["ilDB"],
382 $current_user,
383 $dic['lng']
384 );
385 };
386
387 $this["ui.renderer"] = function ($c) use ($dic): ILIAS\UI\Renderer {
388 return $dic['ui.renderer'];
389 };
390 }
391}
@ EXTRO
Definition: LSOPageType.php:24
Dependency injection container for the global as well as for local, component specific containers.
Builds data types.
Definition: Factory.php:36
Builds learning map data for a user and view mode.
Tracks a user's position and visit history in a learning map.
Provides condition-based navigation through an adaptive learning sequence.
Reusable "template" for the adaptive branch-selection page.
Provides index-based navigation through the items of a learning sequence.
Global Settings of the Learning Sequence.
Add learning progress and availability information to the LSItem.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstance(int $a_obj_id)
Repository for LSGlobalSettings over ILIAS global settings.
Class ilLSItemsDB.
Definition: ilLSItemsDB.php:25
Builds the links to join/(re-)start the LearningSequence.
This combines calls to ProgressDB and StateDB to handle learner-items in the context of a specific LS...
init(ArrayAccess $dic, ArrayAccess $lsdic, DataFactory $data_factory, ilObjLearningSequence $object)
GUI for Locator element.
Implementation of KioskMode Player.
Tree-GUI for ToC.
Get LearningProgress and availability of items in sequence.
@ilCtrl_Calls ilObjLearningSequenceLearnerGUI: ilCommonActionDispatcherGUI
getContentPageHTML(LSOPageType $page_type)
static _getAllReferences(int $id)
get all reference ids for object ID
special template class to simplify handling of ITX/PEAR
An entity that renders components to a string output.
Definition: Renderer.php:31
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples