ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAssLacNumberOfResultExpression.php
Go to the documentation of this file.
1<?php
2
27{
39 public static $pattern = "/\\+[0-9]+\\+/";
40
44 public static $identifier = "+n+";
45
51 protected $numeric_value;
52
60 protected function setMatches($matches): void
61 {
62 $this->numeric_value = $matches[0][0];
63 }
64
68 public function getNumericValue(): int
69 {
71 }
72
77 public function getValue(): string
78 {
79 return '+' . $this->numeric_value . "+";
80 }
81
86 public function getDescription(): string
87 {
88 return "Anwort " . $this->numeric_value . " beantwortet ";
89 }
90
98 public function checkResult($result, $comperator, $index = null): bool
99 {
100 $isTrue = false;
101 if ($index == null) {
102 $values = $result->getUserSolutionsByIdentifier("key");
103
104 foreach ($values as $value) {
105 $isTrue = $isTrue || $this->compare($comperator, $value);
106 }
107 } else {
108 $solution = $result->getSolutionForKey($index);
109 $isTrue = $this->compare($comperator, $solution["value"] ?? "");
110 }
111
112 return $isTrue;
113 }
114
115 private function compare($comperator, $value): bool
116 {
117 switch ($comperator) {
118 case "=":
119 return $value == $this->getNumericValue();
120 break;
121 case "<>":
122 return $value != $this->getNumericValue();
123 break;
124 default:
125 return false;
126 }
127 }
128}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkResult($result, $comperator, $index=null)
getValue()
Get the value of this Expression.
getDescription()
Get a human readable description of the Composite element.
setMatches($matches)
Sets the result of the parsed value by a specific expression pattern.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...