ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAssLacNumberOfResultExpression Class Reference

Class NumberOfResultExpression fot the expression +n+. More...

+ Inheritance diagram for ilAssLacNumberOfResultExpression:
+ Collaboration diagram for ilAssLacNumberOfResultExpression:

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...
 

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 = array()
 

Detailed Description

Class NumberOfResultExpression fot 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 13 of file ilAssLacNumberOfResultExpression.php.

Member Function Documentation

◆ checkResult()

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

Implements ilAssLacSolutionExpressionInterface.

Definition at line 85 of file ilAssLacNumberOfResultExpression.php.

References $index, $result, and compare().

86  {
87  $isTrue = false;
88  if ($index == null) {
89  $values = $result->getUserSolutionsByIdentifier("key");
90 
91  foreach ($values as $value) {
92  $isTrue = $isTrue || $this->compare($comperator, $value);
93  }
94  } else {
95  $solution = $result->getSolutionForKey($index);
96  $isTrue = $this->compare($comperator, $solution["value"]);
97  }
98 
99  return $isTrue;
100  }
$result
$index
Definition: metadata.php:60
+ Here is the call graph for this function:

◆ compare()

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

Definition at line 102 of file ilAssLacNumberOfResultExpression.php.

References getNumericValue().

Referenced by checkResult().

103  {
104  switch ($comperator) {
105  case "=":
106  return $value == $this->getNumericValue();
107  break;
108  case "<>":
109  return $value != $this->getNumericValue();
110  break;
111  default:
112  return false;
113  }
114  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescription()

ilAssLacNumberOfResultExpression::getDescription ( )

Get a human readable description of the Composite element.

Returns
string

Implements ilAssLacCompositeInterface.

Definition at line 73 of file ilAssLacNumberOfResultExpression.php.

74  {
75  return "Anwort " . $this->numeric_value . " beantwortet ";
76  }

◆ getNumericValue()

ilAssLacNumberOfResultExpression::getNumericValue ( )
Returns
int

Definition at line 55 of file ilAssLacNumberOfResultExpression.php.

References $numeric_value.

Referenced by compare().

+ Here is the caller graph for this function:

◆ getValue()

ilAssLacNumberOfResultExpression::getValue ( )

Get the value of this Expression.

Returns
string

Implements ilAssLacExpressionInterface.

Definition at line 64 of file ilAssLacNumberOfResultExpression.php.

65  {
66  return '+' . $this->numeric_value . "+";
67  }

◆ setMatches()

ilAssLacNumberOfResultExpression::setMatches (   $matches)
protected

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

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

Definition at line 47 of file ilAssLacNumberOfResultExpression.php.

48  {
49  $this->numeric_value = $matches[0][0];
50  }

Field Documentation

◆ $identifier

ilAssLacNumberOfResultExpression::$identifier = "+n+"
static

Definition at line 31 of file ilAssLacNumberOfResultExpression.php.

◆ $numeric_value

ilAssLacNumberOfResultExpression::$numeric_value
protected

Definition at line 38 of file ilAssLacNumberOfResultExpression.php.

Referenced by getNumericValue().

◆ $pattern

ilAssLacNumberOfResultExpression::$pattern = "/\\+[0-9]+\\+/"
static

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