ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAssLacNumericResultExpression Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilAssLacNumericResultExpression:
+ Collaboration diagram for ilAssLacNumericResultExpression:

Public Member Functions

 getNumericValue ()
 
 getValue ()
 Get the value of this Expression. More...
 
 getDescription ()
 Get a human readable description of the Composite element. More...
 
 checkResult ($result, $comperator, $index=null)
 
- Public Member Functions inherited from ilAssLacAbstractExpression
 parseValue ($value)
 Parses the delivered Value and sets the relevant information for an Expression as attributes. More...
 
- Public Member Functions inherited from ilAssLacAbstractComposite
 addNode (ilAssLacCompositeInterface $node)
 Adds an ilAssLacCompositeInterface object to the node array which represents the condition tree structure. More...
 
 describe ()
 Describes a Composite tree Structure as human readable string. More...
 
 addNode (ilAssLacCompositeInterface $node)
 Adds an CompositeInterface object to the node array which represents the condition tree structure. More...
 
 describe ()
 Describes a Composite tree Structure as human readable string. More...
 
 getDescription ()
 Get a human readable description of the Composite element. More...
 
 getValue ()
 Get the value of this Expression. More...
 
 parseValue ($value)
 Parses the delivered Value and sets the relevant information for an Expression as attributes. More...
 
 checkResult ($result, $comperator, $index=null)
 

Static Public Attributes

static $pattern = '/#-?[0-9\.]+#/'
 
static $identifier = "#n#"
 

Protected Member Functions

 setMatches ($matches)
 Sets the result of the parsed value by a specific expression pattern. More...
 
- Protected Member Functions inherited from ilAssLacAbstractExpression
 getPattern ()
 Get the Pattern to match relevant informations for an Expression. More...
 
 setMatches ($matches)
 Sets the result of the parsed value by a specific expression pattern. More...
 

Protected Attributes

 $numeric_value
 

Private Member Functions

 compare ($comperator, $value)
 

Additional Inherited Members

- Data Fields inherited from ilAssLacAbstractComposite
 $nodes = []
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class NumericResultExpression for the expression #n#

Date: 25.03.13 Time: 16:41

Author
Thomas Joußen tjous.nosp@m.sen@.nosp@m.datab.nosp@m.ay.d.nosp@m.e

Definition at line 26 of file ilAssLacNumericResultExpression.php.

Member Function Documentation

◆ checkResult()

ilAssLacNumericResultExpression::checkResult (   $result,
  $comperator,
  $index = null 
)
Parameters
ilUserQuestionResult$result
string$comperator
null | int$index
Returns
bool

Implements ilAssLacSolutionExpressionInterface.

Definition at line 98 of file ilAssLacNumericResultExpression.php.

98 : bool
99 {
100 $isTrue = false;
101 if ($index == null) {
102 $values = $result->getUserSolutionsByIdentifier("value");
103
104 foreach ($values as $value) {
105 $isTrue = $isTrue || $this->compare($comperator, $value);
106 }
107 } else {
108 $solution = $result->getSolutionForKey($index);
109 if($solution !== null) {
110 $isTrue = $this->compare($comperator, $solution["value"] ?? "");
111 }
112 }
113
114 return $isTrue;
115 }

References compare().

+ Here is the call graph for this function:

◆ compare()

ilAssLacNumericResultExpression::compare (   $comperator,
  $value 
)
private

Definition at line 117 of file ilAssLacNumericResultExpression.php.

117 : bool
118 {
119 switch ($comperator) {
120 case "<":
121 return $value < $this->getNumericValue();
122 break;
123 case "<=":
124 return $value <= $this->getNumericValue();
125 break;
126 case "=":
127 return $value == $this->getNumericValue();
128 break;
129 case ">=":
130 return $value >= $this->getNumericValue();
131 break;
132 case ">":
133 return $value > $this->getNumericValue();
134 break;
135 case "<>":
136 return $value != $this->getNumericValue();
137 break;
138 default:
139 return false;
140 }
141 }

References getNumericValue().

Referenced by checkResult().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescription()

ilAssLacNumericResultExpression::getDescription ( )

Get a human readable description of the Composite element.

Returns
string

Implements ilAssLacCompositeInterface.

Definition at line 86 of file ilAssLacNumericResultExpression.php.

86 : string
87 {
88 return $this->numeric_value . " beantwortet ";
89 }

◆ getNumericValue()

ilAssLacNumericResultExpression::getNumericValue ( )
Returns
float

Definition at line 68 of file ilAssLacNumericResultExpression.php.

References $numeric_value.

Referenced by compare().

+ Here is the caller graph for this function:

◆ getValue()

ilAssLacNumericResultExpression::getValue ( )

Get the value of this Expression.

Returns
string

Implements ilAssLacExpressionInterface.

Definition at line 77 of file ilAssLacNumericResultExpression.php.

77 : string
78 {
79 return "#" . $this->numeric_value . "#";
80 }

◆ setMatches()

ilAssLacNumericResultExpression::setMatches (   $matches)
protected

Sets the result of the parsed value by a specific expression pattern.

See also
ExpressionInterface::parseValue()
ExpressionInterface::getPattern()
Parameters
array$matches

Reimplemented from ilAssLacAbstractExpression.

Definition at line 60 of file ilAssLacNumericResultExpression.php.

60 : void
61 {
62 $this->numeric_value = $matches[0][0];
63 }

Field Documentation

◆ $identifier

ilAssLacNumericResultExpression::$identifier = "#n#"
static

Definition at line 44 of file ilAssLacNumericResultExpression.php.

◆ $numeric_value

ilAssLacNumericResultExpression::$numeric_value
protected

Definition at line 51 of file ilAssLacNumericResultExpression.php.

Referenced by getNumericValue().

◆ $pattern

ilAssLacNumericResultExpression::$pattern = '/#-?[0-9\.]+#/'
static

The documentation for this class was generated from the following file: