ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilAssLacOrderingResultExpression.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 {
25  public static $pattern = '/\$[0-9]+(?:,[0-9]+)*\$/';
26 
30  public static $identifier = '$n,m,o,p$';
31 
37  protected $ordering;
38 
39  protected function getPattern()
40  {
41  return '/(\d+)/';
42  }
43 
51  protected function setMatches($matches)
52  {
53  $this->ordering = array();
54 
55  foreach ($matches[0] as $match) {
56  $this->ordering[] = $match;
57  }
58  }
59 
63  public function getOrdering()
64  {
65  return $this->ordering;
66  }
67 
72  public function getValue()
73  {
74  return "$" . join(",", $this->ordering) . "$";
75  }
76 
81  public function getDescription()
82  {
83  return join(",", $this->ordering) . " beantwortet ";
84  }
85 
93  public function checkResult($result, $comperator, $index = null)
94  {
95  $keys = $result->getUserSolutionsByIdentifier("key");
96  $keys = array_filter($keys, function ($element) {
97  return $element != null;
98  });
99 
100  switch ($comperator) {
101  case "=":
102  return $keys == $this->getOrdering();
103  break;
104  case "<>":
105  return $keys != $this->getOrdering();
106  break;
107  default:
108  return false;
109  }
110  }
111 }
$result
getValue()
Get the value of this Expression.
$index
Definition: metadata.php:60
$keys
getDescription()
Get a human readable description of the Composite element.
checkResult($result, $comperator, $index=null)
setMatches($matches)
Sets the result of the parsed value by a specific expression pattern.
Class OrderingResultExpression for the expression $a,..,n,m$.