19declare(strict_types=1);
44use Psr\Http\Message\ServerRequestInterface;
123 $this->parent_gui->showPossibleSubObjects();
125 $lso = $this->getLSO();
128 $navigator->preload($items);
129 $structural_successors = [];
130 foreach ($items as $item) {
131 $structural_successors[$item->getRefId()] = array_map(
133 $navigator->getStructuralSuccessors($items, $item)
137 $filter = $filter_gui->getFilter(
141 )->withRequest($this->request);
143 $filter_data = $filter->getData();
146 $misconfigured_ref_ids = array_fill_keys(
147 $analyzer->getAffectedRefIds($static_input_configuration_issues),
150 $issue_details_by_ref_id = $analyzer->getIssueDetailsByRefId($static_input_configuration_issues);
154 $structural_successors,
155 $misconfigured_ref_ids,
156 $issue_details_by_ref_id
160 $boundary_data = $boundaries_db->getBoundariesFor($this->obj_id);
163 if ((
int) $boundary_data[
'start_ref_id'] === 0) {
164 $missing_hints[] = $this->
lng->txt(
'lso_adaptive_missing_start_object');
166 if ((
int) $boundary_data[
'end_ref_id'] === 0) {
167 $missing_hints[] = $this->
lng->txt(
'lso_adaptive_missing_end_object');
169 if ($missing_hints !== []) {
170 $this->tpl->setOnScreenMessage(
'info', implode(
'<br>', $missing_hints));
178 (
int) $boundary_data[
'start_ref_id'],
179 (
int) $boundary_data[
'end_ref_id'],
188 $this->parent_gui->setContent(
199 $conditions_by_ref_id = [];
200 foreach ($items as $item) {
212 return isset($misconfigured_ref_ids[
$ref_id]);
223 foreach (array_unique($ref_ids) as
$ref_id) {
228 if ($titles === []) {
229 return $this->
lng->txt(
'no_conditions');
232 return implode(
', ', $titles);
248 array $structural_successors,
249 array $misconfigured_ref_ids,
250 array $issue_details_by_ref_id
253 $boundary_data = $boundaries_db->getBoundariesFor($this->obj_id);
254 $start_ref_id = $boundary_data[
'start_ref_id'];
255 $end_ref_id = $boundary_data[
'end_ref_id'];
257 $structural_predecessors = [];
258 foreach ($structural_successors as $source_ref_id => $successor_ref_ids) {
259 foreach ($successor_ref_ids as $successor_ref_id) {
260 $structural_predecessors[$successor_ref_id][] = (
int) $source_ref_id;
264 $name_filter = $filter_data[
'name'] ??
'';
265 $input_filter = $filter_data[
'input_conditions'] ?? [];
266 $output_filter = $filter_data[
'output_conditions'] ?? [];
267 $online_filter = $filter_data[
'online_status'] ??
null;
268 $position_filter = $filter_data[
'position'] ?? [];
270 usort($items,
function (
$a,
$b) use ($start_ref_id, $end_ref_id) {
271 if (
$a->getRefId() === $start_ref_id) {
274 if (
$b->getRefId() === $start_ref_id) {
277 if (
$a->getRefId() === $end_ref_id) {
280 if (
$b->getRefId() === $end_ref_id) {
283 return $a->getOrderNumber() <=>
$b->getOrderNumber();
286 $condition_handler = $this->getLSO()->getDI()[
"conditions.handler"];
290 foreach ($items as $index => $item) {
295 if ($name_filter !==
'' && mb_stripos($title, $name_filter) ===
false) {
299 if ($online_filter !==
null && $online_filter !==
'') {
300 $is_online = $item->isOnline();
301 if ($online_filter ===
'online' && !$is_online) {
304 if ($online_filter ===
'offline' && $is_online) {
309 if (count($position_filter) > 0) {
310 $is_start = (
$ref_id === $start_ref_id);
311 $is_end = (
$ref_id === $end_ref_id);
313 (in_array(
'start', $position_filter,
true) && $is_start)
314 || (in_array(
'end', $position_filter,
true) && $is_end);
315 if (!$matches_position) {
320 $type = $item->getType();
322 $input_conditions = [];
323 $db_input_conditions = $condition_handler->getInputConditionsByRefId($lso_ref_id,
$ref_id);
324 foreach ($db_input_conditions as $db_cond) {
326 title: $db_cond[
'title'],
327 value: $db_cond[
'value'],
328 internal_name: $db_cond[
'internal_name']
332 $output_conditions = [];
333 $db_output_conditions = $condition_handler->getOutputConditionsByRefId($lso_ref_id,
$ref_id);
334 foreach ($db_output_conditions as $db_cond) {
336 title: $db_cond[
'title'],
337 value: $db_cond[
'value'],
338 internal_name: $db_cond[
'internal_name']
342 if (count($input_filter) > 0) {
344 foreach ($input_conditions as $ic) {
345 if (in_array($ic->internal_name, $input_filter)) {
355 if (count($output_filter) > 0) {
357 foreach ($output_conditions as $oc) {
358 if (in_array($oc->internal_name, $output_filter)) {
373 $actions = $this->parent_gui->getTableActionHandler()->collectActions(
390 ilLink::_getLink(
$ref_id, $type),
392 (
$ref_id === $start_ref_id) ?
'Start' :
'',
393 (
$ref_id === $end_ref_id) ?
'End' :
'',
398 $this->isMisconfiguredRefId(
$ref_id, $misconfigured_ref_ids),
399 $issue_details_by_ref_id[
$ref_id] ?? [],
400 ($structural_predecessors[
$ref_id] ?? []) !== [],
401 ($structural_successors[
$ref_id] ?? []) !== [],
418 return $this->buildConditionOptions(
419 $this->getConditionTypes()->getAllInputConditions()
430 return $this->buildConditionOptions(
431 $this->getConditionTypes()->getAllOutputConditions()
440 return $this->getLSO()->getDI()[
"conditions.types"];
448 return $this->getLSO()->getDI()[
"db.boundaries"];
458 if ($this->lso ===
null) {
474 private function buildConditionOptions(array $condition_classes): array
477 foreach ($condition_classes as $class) {
479 $condition =
new $class();
492 $specific_actions = [];
495 $this->
ctrl->setParameterByClass(ilObjLearningSequenceConditionsGUI::class,
'item_ref_id', $ref_id);
496 $link = $this->
ctrl->getLinkTargetByClass(ilObjLearningSequenceConditionsGUI::class,
'manageConditions');
498 label: $this->
lng->txt(
'conditions'),
504 if ($ref_id === $start_ref_id) {
505 $label = $this->
lng->txt(
'unset_start_object');
509 $label = $this->
lng->txt(
'set_start_object');
513 $this->
ctrl->setParameter($this->parent_gui,
'item_ref_id', $ref_id);
514 $link = $this->
ctrl->getLinkTarget($this->parent_gui, $link);
517 if ($ref_id === $end_ref_id) {
518 $label = $this->
lng->txt(
'unset_end_object');
522 $label = $this->
lng->txt(
'set_end_object');
526 $this->
ctrl->setParameter($this->parent_gui,
'item_ref_id', $ref_id);
527 $link = $this->
ctrl->getLinkTarget($this->parent_gui, $link);
532 label: $this->
lng->txt(
'set_start_object'),
536 label: $this->
lng->txt(
'unset_start_object'),
540 label: $this->
lng->txt(
'set_end_object'),
544 label: $this->
lng->txt(
'unset_end_object'),
549 $this->
ctrl->setParameterByClass(ilObjLearningSequenceConditionsGUI::class,
'item_ref_id',
'');
550 return $specific_actions;
558 $ref_id = $this->parent_gui->extractItemRefId();
560 $boundaries = $this->getBoundaries();
561 $current = $boundaries->getBoundariesFor($this->obj_id);
562 if ((
int) $current[
'end_ref_id'] === $ref_id) {
564 $this->tpl->setOnScreenMessage(
566 $this->
lng->txt(
'lso_adaptive_start_end_not_same'),
571 $boundaries->setStartRefId($this->obj_id, $ref_id);
572 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
582 $boundaries = $this->getBoundaries();
583 $boundaries->unsetStartRefId($this->obj_id);
584 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
595 $ref_id = $this->parent_gui->extractItemRefId();
597 $boundaries = $this->getBoundaries();
598 $current = $boundaries->getBoundariesFor($this->obj_id);
599 if ((
int) $current[
'start_ref_id'] === $ref_id) {
601 $this->tpl->setOnScreenMessage(
603 $this->
lng->txt(
'lso_adaptive_start_end_not_same'),
608 $boundaries->setEndRefId($this->obj_id, $ref_id);
609 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
619 $boundaries = $this->getBoundaries();
620 $boundaries->unsetEndRefId($this->obj_id);
621 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
Stores start and end object boundaries of adaptive learning sequences.
Controls adaptive learning sequence content management.
ilGlobalTemplateInterface $tpl
Global template.
__construct(ilObjLearningSequenceContentGUI $parent_gui, Factory $ui_factory, Renderer $ui_renderer, ilLanguage $lng, ilCtrl $ctrl, ServerRequestInterface $request, ilGlobalTemplateInterface $tpl, int $ref_id, int $obj_id)
Creates the adaptive content controller.
setEndObject()
Sets the selected item as the end object.
ilCtrl $ctrl
Controller service.
ilObjLearningSequenceContentGUI $parent_gui
Parent content GUI.
manageContent()
Renders the adaptive content management view.
getConditionTypes()
Gets the condition types contributed to the learning sequence.
ilLanguage $lng
Language service.
getOutputConditionOptions()
Gets output condition filter options.
getTableData(array $items, ?array $filter_data, array $structural_successors, array $misconfigured_ref_ids, array $issue_details_by_ref_id)
Gets the filtered content table data.
getStaticInputConfigurationIssues(array $items, AdaptiveNavigator $navigator)
getSupportedCommands()
Gets the commands supported by the controller.
int $ref_id
Learning sequence repository reference ID.
getBoundaries()
Gets the repository of the start and end objects.
Factory $ui_factory
UI factory.
getObjectTitleList(array $ref_ids)
Builds a readable list of object titles for the given ref ids.
getInputConditionOptions()
Gets input condition filter options.
isMisconfiguredRefId(int $ref_id, array $misconfigured_ref_ids)
Renderer $ui_renderer
UI renderer.
setStartObject()
Sets the selected item as the start object.
int $obj_id
Learning sequence object ID.
unsetStartObject()
Removes the start object.
getSpecificActions(int $ref_id, int $start_ref_id, int $end_ref_id)
Gets actions specific to an adaptive learning sequence item.
ilObjLearningSequence $lso
Learning sequence object, loaded on first use.
ServerRequestInterface $request
Server request.
unsetEndObject()
Removes the end object.
Creates the filter for adaptive learning sequence content.
Renders the adaptive learning sequence content table.
static getIdentifierForClass(string $class)
Extracts the identifier for the condition type from the class name.
Provides condition-based navigation through an adaptive learning sequence.
getInputConditions(\LSItem $item)
Data holding class LSItem .
Class ilCtrl provides processing control methods.
Data transfer object for an action in the learning sequence content table.
Data transfer object for a learning sequence condition.
@ilCtrl_isCalledBy ilObjLearningSequenceConditionsGUI: ilObjLearningSequenceContentGUI
Data transfer object for an item in the learning sequence content table.
const string CMD_SET_START_OBJECT
const string CMD_UNSET_END_OBJECT
const string CMD_UNSET_START_OBJECT
const string CMD_MANAGE_CONTENT
const string CMD_SET_END_OBJECT
static getInstanceByRefId(int $ref_id)
Class ilObject Basic functions for all objects.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
All condition types known to the system.
Contract for the mode specific content controllers (adaptive / sequential).
This is how the factory for UI elements looks.
An entity that renders components to a string output.
enforceOfflineForMissingBoundaries(\ilObjLearningSequence $lso)
An adaptive learning sequence may only be online if it has a start AND an end object.
link(string $caption, string $href, bool $new_viewport=false)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
if(!file_exists('../ilias.ini.php'))