|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the xAPI package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Christian Flothmann <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Xabbuh\XApi\Model\Interaction; |
|
13
|
|
|
|
|
14
|
|
|
use Xabbuh\XApi\Model\Definition; |
|
15
|
|
|
use Xabbuh\XApi\Model\Extensions; |
|
16
|
|
|
use Xabbuh\XApi\Model\IRI; |
|
17
|
|
|
use Xabbuh\XApi\Model\IRL; |
|
18
|
|
|
use Xabbuh\XApi\Model\LanguageMap; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* An interaction that requires the learner to perform a task that requires |
|
22
|
|
|
* multiple steps. |
|
23
|
|
|
* |
|
24
|
|
|
* @author Christian Flothmann <[email protected]> |
|
25
|
|
|
*/ |
|
26
|
|
|
final class PerformanceInteractionDefinition extends InteractionDefinition |
|
27
|
|
|
{ |
|
28
|
|
|
private $steps; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param string[]|null $correctResponsesPattern |
|
32
|
|
|
* @param InteractionComponent[]|null $steps |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct(LanguageMap $name = null, LanguageMap $description = null, IRI $type = null, IRL $moreInfo = null, Extensions $extensions = null, array $correctResponsesPattern = null, array $steps = null) |
|
35
|
|
|
{ |
|
36
|
|
|
parent::__construct($name, $description, $type, $moreInfo, $extensions, $correctResponsesPattern); |
|
37
|
|
|
|
|
38
|
|
|
$this->steps = $steps; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param InteractionComponent[]|null $steps |
|
43
|
|
|
*/ |
|
44
|
|
|
public function withSteps(array $steps = null): self |
|
45
|
|
|
{ |
|
46
|
|
|
$interaction = clone $this; |
|
47
|
|
|
$interaction->steps = $steps; |
|
48
|
|
|
|
|
49
|
|
|
return $interaction; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return InteractionComponent[]|null |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getSteps(): ?array |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->steps; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function equals(Definition $definition): bool |
|
61
|
|
|
{ |
|
62
|
|
|
if (!parent::equals($definition)) { |
|
63
|
|
|
return false; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
if (!$definition instanceof PerformanceInteractionDefinition) { |
|
67
|
|
|
return false; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
if (null !== $this->steps xor null !== $definition->steps) { |
|
71
|
|
|
return false; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
if (null !== $this->steps) { |
|
75
|
|
|
if (count($this->steps) !== count($definition->steps)) { |
|
76
|
|
|
return false; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
foreach ($this->steps as $key => $step) { |
|
80
|
|
|
if (!isset($definition->steps[$key])) { |
|
81
|
|
|
return false; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
if (!$step->equals($definition->steps[$key])) { |
|
85
|
|
|
return false; |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
return true; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|