ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
90 $values = $result->getUserSolutionsByIdentifier("key");
91
92 foreach($values as $value)
93 {
94 $isTrue = $isTrue || $this->compare($comperator, $value);
95 }
96 }
97 else
98 {
99 $solution = $result->getSolutionForKey($index);
100 $isTrue = $this->compare($comperator, $solution["value"]);
101 }
102
103 return $isTrue;
104 }
105
106 private function compare($comperator, $value)
107 {
108 switch($comperator)
109 {
110 case "=":
111 return $value == $this->getNumericValue();
112 break;
113 case "<>":
114 return $value != $this->getNumericValue();
115 break;
116 default:
117 return false;
118 }
119 }
120}
$result
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.