ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilAssLacNumberOfResultExpression.php
Go to the documentation of this file.
1 <?php
2 
27 {
39  public static $pattern = "/\\+[0-9]+\\+/";
40 
44  public static $identifier = "+n+";
45 
51  protected $numeric_value;
52 
60  protected function setMatches($matches): void
61  {
62  $this->numeric_value = $matches[0][0];
63  }
64 
68  public function getNumericValue(): int
69  {
70  return $this->numeric_value;
71  }
72 
77  public function getValue(): string
78  {
79  return '+' . $this->numeric_value . "+";
80  }
81 
86  public function getDescription(): string
87  {
88  return "Anwort " . $this->numeric_value . " beantwortet ";
89  }
90 
98  public function checkResult($result, $comperator, $index = null): bool
99  {
100  $isTrue = false;
101  if ($index == null) {
102  $values = $result->getUserSolutionsByIdentifier("key");
103 
104  foreach ($values as $value) {
105  $isTrue = $isTrue || $this->compare($comperator, $value);
106  }
107  } else {
108  $solution = $result->getSolutionForKey($index);
109  $isTrue = $this->compare($comperator, $solution["value"] ?? "");
110  }
111 
112  return $isTrue;
113  }
114 
115  private function compare($comperator, $value): bool
116  {
117  switch ($comperator) {
118  case "=":
119  return $value == $this->getNumericValue();
120  break;
121  case "<>":
122  return $value != $this->getNumericValue();
123  break;
124  default:
125  return false;
126  }
127  }
128 }
getValue()
Get the value of this Expression.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDescription()
Get a human readable description of the Composite element.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkResult($result, $comperator, $index=null)
setMatches($matches)
Sets the result of the parsed value by a specific expression pattern.