ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
LOMDictionaryInitiator.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 use ILIAS\MetaData\Vocabularies\FactoryInterface as VocabularyFactoryInterface;
30 
31 class LOMDictionaryInitiator extends BaseDictionaryInitiator implements DictionaryInitiatorInterface
32 {
33  public const SOURCE = 'LOMv1.0';
34 
35  protected VocabularyFactoryInterface $vocab_factory;
37 
38  public function __construct(
39  VocabularyFactoryInterface $vocab_factory,
40  TagFactory $tag_factory,
44  ) {
45  $this->vocab_factory = $vocab_factory;
46  $this->tag_factory = $tag_factory;
47  parent::__construct($path_factory, $navigator_factory, $structure);
48  }
49 
51  {
52  return $this->path_factory
53  ->custom()
54  ->withRelative(true)
55  ->withLeadsToExactlyOneElement(true)
56  ->withNextStepToSuperElement()
57  ->withNextStep('source')
58  ->get();
59  }
60 
61  public function get(): DictionaryInterface
62  {
63  $this->initDictionary();
64  return new LOMDictionary($this->path_factory, $this->navigator_factory, ...$this->getTagAssignments());
65  }
66 
67  protected function initDictionary(): void
68  {
69  $structure = $this->getStructure();
70 
79  }
80 
81  protected function setTagsForGeneral(
83  ): void {
84  $general = $structure->getRoot()->getSubElement('general');
85  $this->addTag(
86  $general->getSubElement('structure'),
87  'atomic',
88  'collection',
89  'networked',
90  'hierarchical',
91  'linear'
92  );
93  $this->addTag(
94  $general->getSubElement('aggregationLevel'),
95  '1',
96  '2',
97  '3',
98  '4'
99  );
100  }
101 
102  protected function setTagsForLifecycle(
104  ): void {
105  $life_cycle = $structure->getRoot()->getSubElement('lifeCycle');
106  $this->addTag(
107  $life_cycle->getSubElement('status'),
108  'draft',
109  'final',
110  'revised',
111  'unavailable'
112  );
113  $this->addTag(
114  $life_cycle->getSubElement('contribute')->getSubElement('role'),
115  'author',
116  'publisher',
117  'unknown',
118  'initiator',
119  'terminator',
120  'editor',
121  'graphical designer',
122  'technical implementer',
123  'content provider',
124  'technical validator',
125  'educational validator',
126  'script writer',
127  'instructional designer',
128  'subject matter expert'
129  );
130  }
131 
132  protected function setTagsForMetaMetadata(
134  ): void {
135  $meta = $structure->getRoot()->getSubElement('metaMetadata');
136  $this->addTag(
137  $meta->getSubElement('contribute')->getSubElement('role'),
138  'creator',
139  'validator'
140  );
141  }
142 
143  protected function setTagsForTechnical(
145  ): void {
146  $or = $structure->getRoot()
147  ->getSubElement('technical')
148  ->getSubElement('requirement')
149  ->getSubElement('orComposite');
150 
151  $this->addTag(
152  $or->getSubElement('type'),
153  'operating system',
154  'browser'
155  );
156  $this->addTagWithCondition(
157  $or->getSubElement('name'),
158  'operating system',
159  $or->getSubElement('type')->getSubElement('value'),
160  'pc-dos',
161  'ms-windows',
162  'macos',
163  'unix',
164  'multi-os',
165  'none'
166  );
167  $this->addTagWithCondition(
168  $or->getSubElement('name'),
169  'browser',
170  $or->getSubElement('type')->getSubElement('value'),
171  'any',
172  'netscape communicator',
173  'ms-internet explorer',
174  'opera',
175  'amaya'
176  );
177  }
178 
179  protected function setTagsForEducational(
181  ): void {
182  $educational = $structure->getRoot()->getSubElement('educational');
183  $this->addTag(
184  $educational->getSubElement('interactivityType'),
185  'active',
186  'expositive',
187  'mixed'
188  );
189  $this->addTag(
190  $educational->getSubElement('learningResourceType'),
191  'exercise',
192  'simulation',
193  'questionnaire',
194  'diagram',
195  'figure',
196  'graph',
197  'index',
198  'slide',
199  'table',
200  'narrative text',
201  'exam',
202  'experiment',
203  'problem statement',
204  'self assessment',
205  'lecture'
206  );
207  $this->addTag(
208  $educational->getSubElement('interactivityLevel'),
209  'very low',
210  'low',
211  'medium',
212  'high',
213  'very high'
214  );
215  $this->addTag(
216  $educational->getSubElement('semanticDensity'),
217  'very low',
218  'low',
219  'medium',
220  'high',
221  'very high'
222  );
223  $this->addTag(
224  $educational->getSubElement('intendedEndUserRole'),
225  'teacher',
226  'author',
227  'learner',
228  'manager'
229  );
230  $this->addTag(
231  $educational->getSubElement('context'),
232  'school',
233  'higher education',
234  'training',
235  'other'
236  );
237  $this->addTag(
238  $educational->getSubElement('difficulty'),
239  'very easy',
240  'easy',
241  'medium',
242  'difficult',
243  'very difficult'
244  );
245  }
246 
247  protected function setTagsForRights(
249  ): void {
250  $rights = $structure->getRoot()->getSubElement('rights');
251  $this->addTag(
252  $rights->getSubElement('cost'),
253  'yes',
254  'no'
255  );
256  $this->addTag(
257  $rights->getSubElement('copyrightAndOtherRestrictions'),
258  'yes',
259  'no'
260  );
261  }
262 
263  protected function setTagsForRelation(
265  ): void {
266  $kind = $structure->getRoot()->getSubElement('relation')
267  ->getSubElement('kind');
268  $this->addTag(
269  $kind,
270  'ispartof',
271  'haspart',
272  'isversionof',
273  'hasversion',
274  'isformatof',
275  'hasformat',
276  'references',
277  'isreferencedby',
278  'isbasedon',
279  'isbasisfor',
280  'requires',
281  'isrequiredby'
282  );
283  }
284 
285  protected function setTagsForClassification(
287  ): void {
288  $purpose = $structure->getRoot()->getSubElement('classification')
289  ->getSubElement('purpose');
290  $this->addTag(
291  $purpose,
292  'discipline',
293  'idea',
294  'prerequisite',
295  'educational objective',
296  'accessibility restrictions',
297  'educational level',
298  'skill level',
299  'security level',
300  'competency'
301  );
302  }
303 
304  protected function addTag(
305  StructureElementInterface $element,
306  string ...$values
307  ): void {
308  $tag = $this->tag_factory->tag(
309  $this->vocab_factory->vocabulary(self::SOURCE, ...$values)->get()
310  );
311  $this->addTagToSourceAndValue($tag, $element);
312  }
313 
314  protected function addTagWithCondition(
315  StructureElementInterface $element,
316  string $condition_value,
317  StructureElementInterface $conditional_on,
318  string ...$values
319  ): void {
320  $source = $element->getSubElement('source');
321  $value = $element->getSubElement('value');
322  $path_source = $this->path_factory->betweenElements(
323  $source,
324  $conditional_on,
325  true
326  );
327  $path_value = $this->path_factory->betweenElements(
328  $value,
329  $conditional_on,
330  true
331  );
332  $tag_source = $this->tag_factory->tag(
333  $this->vocab_factory->vocabulary(self::SOURCE, ...$values)
334  ->withCondition($condition_value, $path_source)
335  ->get()
336  );
337  $tag_value = $this->tag_factory->tag(
338  $this->vocab_factory->vocabulary(self::SOURCE, ...$values)
339  ->withCondition($condition_value, $path_value)
340  ->get()
341  );
342  $this->addTagToElement($tag_source, $source);
343  $this->addTagToElement($tag_value, $value);
344  }
345 
346  protected function addTagToSourceAndValue(
347  Tag $tag,
349  ): void {
350  $this->addTagToElement($tag, $element->getSubElement('source'));
351  $this->addTagToElement($tag, $element->getSubElement('value'));
352  }
353 }
addTagToSourceAndValue(Tag $tag, StructureElementInterface $element)
getSubElement(string $name)
Return the first sub-element with the given name, if one exists.
addTagWithCondition(StructureElementInterface $element, string $condition_value, StructureElementInterface $conditional_on, string ... $values)
addTag(StructureElementInterface $element, string ... $values)
getRoot()
Returns the root element of the metadata set.
$educational
__construct(VocabularyFactoryInterface $vocab_factory, TagFactory $tag_factory, PathFactoryInterface $path_factory, NavigatorFactoryInterface $navigator_factory, StructureSetInterface $structure)
__construct(VocabulariesInterface $vocabularies)
$general
SECTIONS.
addTagToElement(TagInterface $tag, StructureElementInterface $element)
When indices are added, the tag applies only to copies of the element with those indices (beginning w...
NavigatorFactoryInterface $navigator_factory
only needed to instantiate dictionaries, which is done in inheritors
$rights