ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAssLacMatchingResultExpression.php
Go to the documentation of this file.
1<?php
2
27{
40 public static $pattern = "/;[0-9]+:[0-9]+;/";
41
45 public static $identifier = ";n:m;";
46
53
60
61 protected function getPattern(): string
62 {
63 return '/;(\d+):(\d+);/';
64 }
65
73 protected function setMatches($matches): void
74 {
75 $this->left_numeric_value = $matches[1][0];
76 $this->right_numeric_value = $matches[2][0];
77 }
78
82 public function getRightNumericValue(): float
83 {
85 }
86
90 public function getLeftNumericValue(): float
91 {
93 }
94
99 public function getValue(): string
100 {
101 return ";" . $this->left_numeric_value . ":" . $this->right_numeric_value . ";";
102 }
103
108 public function getDescription(): string
109 {
110 return "0 beantwortet ";
111 }
112
120 public function checkResult($result, $comperator, $index = null): bool
121 {
122 $solutions = $result->getSolutions();
123 $isTrue = false;
124 foreach ($solutions as $solution) {
125 $isTrue = $isTrue || $this->compare($comperator, $solution["key"], $solution["value"]);
126 }
127 return $isTrue;
128 }
129
137 private function compare($comperator, $left, $right): bool
138 {
139 switch ($comperator) {
140 case "=":
141 return $this->getLeftNumericValue() == $left && $this->getRightNumericValue() == $right;
142 break;
143 case "<>":
144 return $this->getLeftNumericValue() != $left || $this->getRightNumericValue() != $right;
145 break;
146 default:
147 return false;
148 }
149 }
150}
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...
getDescription()
Get a human readable description of the Composite element.
getPattern()
Get the Pattern to match relevant informations for an Expression.
checkResult($result, $comperator, $index=null)
setMatches($matches)
Sets the result of the parsed value by a specific expression pattern.
getValue()
Get the value of this Expression.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...