ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilAssLacMatchingResultExpression.php
Go to the documentation of this file.
1 <?php
2 
3 include_once "Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Expressions/ilAssLacAbstractExpression.php";
4 include_once "Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Expressions/ilAssLacSolutionExpressionInterface.php";
5 
14 {
27  public static $pattern = "/;[0-9]+:[0-9]+;/";
28 
32  public static $identifier = ";n:m;";
33 
40 
47 
48  protected function getPattern()
49  {
50  return '/;(\d+):(\d+);/';
51  }
52 
60  protected function setMatches($matches)
61  {
62  $this->left_numeric_value = $matches[1][0];
63  $this->right_numeric_value = $matches[2][0];
64  }
65 
69  public function getRightNumericValue()
70  {
72  }
73 
77  public function getLeftNumericValue()
78  {
80  }
81 
86  public function getValue()
87  {
88  return ";" . $this->left_numeric_value . ":" . $this->right_numeric_value . ";";
89  }
90 
95  public function getDescription()
96  {
97  return $this->numeric_value . " beantwortet ";
98  }
99 
107  public function checkResult($result, $comperator, $index = null)
108  {
109  $solutions = $result->getSolutions();
110  $isTrue = false;
111  foreach ($solutions as $solution) {
112  $isTrue = $isTrue || $this->compare($comperator, $solution["key"], $solution["value"]);
113  }
114  return $isTrue;
115  }
116 
124  private function compare($comperator, $left, $right)
125  {
126  switch ($comperator) {
127  case "=":
128  return $this->getLeftNumericValue() == $left && $this->getRightNumericValue() == $right;
129  break;
130  case "<>":
131  return $this->getLeftNumericValue() != $left || $this->getRightNumericValue() != $right;
132  break;
133  default:
134  return false;
135  }
136  }
137 }
$result
checkResult($result, $comperator, $index=null)
getDescription()
Get a human readable description of the Composite element.
$index
Definition: metadata.php:60
setMatches($matches)
Sets the result of the parsed value by a specific expression pattern.
getValue()
Get the value of this Expression.
Class MatchingResultExpression for the expression ;n:m;.