ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
LSOAdaptiveItemStatus.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use ILIAS\UI\Factory as UIFactory;
27
32final readonly class LSOAdaptiveItemStatus
33{
34 public function __construct(
35 private UIFactory $ui_factory,
36 private \ilLanguage $lng
37 ) {
38 }
39
45 public function getTags(\ilObjLearningSequenceContentData $record): array
46 {
47 $tags = [
48 $record->is_online
49 ? $this->buildTag('table_online', Tag::REL_LOW)
50 : $this->buildTag('lso_adaptive_offline', Tag::REL_MID)
51 ];
52 if ($record->start_object !== '') {
53 $tags[] = $this->buildTag('lso_adaptive_start', Tag::REL_LOW);
54 }
55 if ($record->end_object !== '') {
56 $tags[] = $this->buildTag('lso_adaptive_end', Tag::REL_LOW);
57 }
58 if ($record->end_object === '' && !$record->has_structural_successor) {
59 $tags[] = $this->buildTag('lso_adaptive_dead_end', Tag::REL_HIGH);
60 }
61 if ($record->has_conflicting_input_configuration) {
62 $tags[] = $this->buildTag('lso_adaptive_misconfigured', Tag::REL_HIGH);
63 }
64 if ($record->start_object === '' && !$record->has_structural_predecessor) {
65 $tags[] = $this->buildTag('lso_adaptive_entry_point', Tag::REL_LOW);
66 }
67
68 return $tags;
69 }
70
76 {
77 if (!$record->has_conflicting_input_configuration) {
78 return null;
79 }
80 if ($record->static_input_configuration_issue_details === []) {
81 return $this->lng->txt('lso_adaptive_misconfigured_info');
82 }
83
84 $listing = $this->ui_factory->listing()->property();
85 foreach ($record->static_input_configuration_issue_details as $detail) {
86 $title = $this->lng->txt($detail->title_language_var);
87 $description = $this->buildIssueDescription($detail);
88 $listing = $listing->withProperty(
89 $title,
90 $description === '' ? $title : $title . ' ' . $description,
91 false
92 );
93 }
94
95 return $listing;
96 }
97
98 private function buildTag(string $language_var, string $relevance): Tag
99 {
100 return $this->ui_factory->button()
101 ->tag($this->lng->txt($language_var), '')
102 ->withRelevance($relevance);
103 }
104
106 {
107 $parts = [];
108 if ($detail->description_language_var !== null) {
109 $parts[] = $this->lng->txt($detail->description_language_var);
110 }
111 foreach ($detail->properties_by_language_var as $language_var => $value) {
112 $parts[] = sprintf(
113 '%s: %s',
114 $this->lng->txt($language_var),
115 is_array($value) ? $this->buildPropertyList($value) : $value
116 );
117 }
118
119 return implode(' ', $parts);
120 }
121
125 private function buildPropertyList(array $values): string
126 {
127 $items = array_map(
128 fn(int|string $value): string => is_int($value) ? $this->lookupTitle($value) : $value,
129 $values
130 );
131 sort($items);
132
133 return implode(', ', $items);
134 }
135
136 private function lookupTitle(int $ref_id): string
137 {
138 return \ilObject::_lookupTitle(\ilObject::_lookupObjId($ref_id));
139 }
140}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Describes the status of an item in the adaptive content table: the tags shown below its title and the...
buildIssueDescription(StaticInputConfigurationIssueDetail $detail)
getTags(\ilObjLearningSequenceContentData $record)
The status tags of the item.
__construct(private UIFactory $ui_factory, private \ilLanguage $lng)
getConfigurationIssues(\ilObjLearningSequenceContentData $record)
The configuration issues of a misconfigured item, or null if its configuration is fine.
language handling
Data transfer object for an item in the learning sequence content table.
static _lookupObjId(int $ref_id)
This describes a tag(-button).
Definition: Tag.php:29
withRelevance(string $relevance)
Set relevance of Tag (e.g.
global $lng
Definition: privfeed.php:26