ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
LinearNavigator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27{
32 public function getSuccessors(array $items, \LSLearnerItem $current): array
33 {
34 $position = $this->findPosition($items, $current);
35 $next = $position + 1;
36 if ($next >= 0 && $next < count($items)) {
37 return [$items[$next]];
38 }
39 return [];
40 }
41
46 public function getStructuralSuccessors(array $items, \LSItem $current): array
47 {
48 $position = $this->findPosition($items, $current);
49 $next = $position + 1;
50 if ($next >= 0 && $next < count($items)) {
51 return [$items[$next]];
52 }
53 return [];
54 }
55
60 public function getPredecessors(array $items, \LSLearnerItem $current): array
61 {
62 $position = $this->findPosition($items, $current);
63 $previous = $position - 1;
64 if ($previous >= 0 && $previous < count($items)) {
65 return [$items[$previous]];
66 }
67 return [];
68 }
69
73 public function canLeave(\LSLearnerItem $current): bool
74 {
75 return true;
76 }
77
81 public function canEnter(\LSLearnerItem $target): bool
82 {
83 return true;
84 }
85
90 {
91 return true;
92 }
93
97 public function canEnterFrom(\LSLearnerItem $current, \LSLearnerItem $target): bool
98 {
99 return true;
100 }
101
107 public function preload(array $items): void
108 {
109 }
110
116 public function getInputConditionIds(\LSLearnerItem $item): array
117 {
118 return [];
119 }
120
126 public function getOutputConditionIds(\LSLearnerItem $item): array
127 {
128 return [];
129 }
130
137 protected function findPosition(array $items, \LSItem $item): int
138 {
139 foreach ($items as $index => $candidate) {
140 if ($candidate->getRefId() === $item->getRefId()) {
141 return $index;
142 }
143 }
144 throw new \Exception("This is not a valid item.", 1);
145 }
146}
Provides index-based navigation through the items of a learning sequence.
getStructuralSuccessors(array $items, \LSItem $current)
canEnterIgnoringEdges(\LSLearnerItem $target)
Allows entering every item because linear navigation has no edge conditions.
canEnter(\LSLearnerItem $target)
Allows entering every item in linear navigation.
canEnterFrom(\LSLearnerItem $current, \LSLearnerItem $target)
Allows entering every target from every current item.
getPredecessors(array $items, \LSLearnerItem $current)
findPosition(array $items, \LSItem $item)
Finds the array index of an item by its reference identifier.
canLeave(\LSLearnerItem $current)
Allows leaving every item in linear navigation.
preload(array $items)
Does not preload data because linear navigation has no state to load.
getOutputConditionIds(\LSLearnerItem $item)
Returns no output-condition identifiers because linear navigation has no conditions.
getInputConditionIds(\LSLearnerItem $item)
Returns no input-condition identifiers because linear navigation has no conditions.
getSuccessors(array $items, \LSLearnerItem $current)
Data holding class LSItem .
Definition: LSItem.php:25
getRefId()
Definition: LSItem.php:93
Add learning progress and availability information to the LSItem.
Abstraction of the navigation between the objects of a learning sequence.
Definition: LSNavigator.php:31