ILIAS  release_7 Revision v7.30-3-g800a261c036
ilAssLacOrderingResultExpression.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{
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
An exception for terminatinating execution or to throw for unit testing.
Class OrderingResultExpression for the expression $a,..,n,m$.
getPattern()
Get the Pattern to match relevant informations for an Expression.
setMatches($matches)
Sets the result of the parsed value by a specific expression pattern.
getDescription()
Get a human readable description of the Composite element.
getValue()
Get the value of this Expression.
checkResult($result, $comperator, $index=null)
$index
Definition: metadata.php:128
$keys
Definition: metadata.php:187