ILIAS  release_7 Revision v7.30-3-g800a261c036
ilAssLacNumberOfResultExpression.php
Go to the documentation of this file.
1<?php
2
3include_once "Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Expressions/ilAssLacAbstractExpression.php";
4include_once "Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Expressions/ilAssLacSolutionExpressionInterface.php";
5
14{
26 public static $pattern = "/\\+[0-9]+\\+/";
27
31 public static $identifier = "+n+";
32
38 protected $numeric_value;
39
47 protected function setMatches($matches)
48 {
49 $this->numeric_value = $matches[0][0];
50 }
51
55 public function getNumericValue()
56 {
58 }
59
64 public function getValue()
65 {
66 return '+' . $this->numeric_value . "+";
67 }
68
73 public function getDescription()
74 {
75 return "Anwort " . $this->numeric_value . " beantwortet ";
76 }
77
85 public function checkResult($result, $comperator, $index = null)
86 {
87 $isTrue = false;
88 if ($index == null) {
89 $values = $result->getUserSolutionsByIdentifier("key");
90
91 foreach ($values as $value) {
92 $isTrue = $isTrue || $this->compare($comperator, $value);
93 }
94 } else {
95 $solution = $result->getSolutionForKey($index);
96 $isTrue = $this->compare($comperator, $solution["value"]);
97 }
98
99 return $isTrue;
100 }
101
102 private function compare($comperator, $value)
103 {
104 switch ($comperator) {
105 case "=":
106 return $value == $this->getNumericValue();
107 break;
108 case "<>":
109 return $value != $this->getNumericValue();
110 break;
111 default:
112 return false;
113 }
114 }
115}
$result
An exception for terminatinating execution or to throw for unit testing.
Class NumberOfResultExpression fot the expression +n+.
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.
$index
Definition: metadata.php:128