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

Class for cloze question numeric answers. More...

+ Inheritance diagram for assAnswerCloze:
+ Collaboration diagram for assAnswerCloze:

Public Member Functions

 __construct ($answertext="", $points=0.0, $order=0)
 assAnswerCloze constructor More...
 
 setLowerBound ($bound)
 Sets the lower boind. More...
 
 setUpperBound ($bound)
 Sets the upper bound. More...
 
 getLowerBound ()
 Returns the lower bound. More...
 
 getUpperBound ()
 Returns the upper bound. More...
 
 setGapSize ($gap_size)
 
 getGapSize ()
 
- Public Member Functions inherited from ASS_AnswerSimple
 __construct ($answertext="", $points=0.0, $order=0, $id=-1)
 ASS_AnswerSimple constructor. More...
 
 getId ()
 Gets the answer id. More...
 
 getAnswertext ()
 Gets the answer text. More...
 
 getPoints ()
 Gets the points. More...
 
 checkPoints ($a_points)
 Checks, if the point value is numeric. More...
 
 getOrder ()
 Gets the sort/display order. More...
 
 setOrder ($order=0)
 Sets the order. More...
 
 setId ($id=-1)
 Sets the answer id. More...
 
 setAnswertext ($answertext="")
 Sets the answer text. More...
 
 setPoints ($points=0.0)
 Sets the points. More...
 

Protected Member Functions

 getNumericValueFromAnswerText ()
 
 getNumericValueFromText ($text)
 

Protected Attributes

 $lowerBound
 
 $upperBound
 
 $gap_size
 
- Protected Attributes inherited from ASS_AnswerSimple
 $answertext
 
 $points
 
 $order
 
 $id
 

Detailed Description

Class for cloze question numeric answers.

assAnswerCloze is a class for cloze questions numeric answers.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$
See also
ASS_AnswerBinaryState

Rework class to represent bounds as numerics instead of strings.

Definition at line 23 of file class.assAnswerCloze.php.

Constructor & Destructor Documentation

◆ __construct()

assAnswerCloze::__construct (   $answertext = "",
  $points = 0.0,
  $order = 0 
)

assAnswerCloze constructor

The constructor takes possible arguments an creates an instance of the assAnswerCloze object.

Parameters
string$answertextA string defining the answer text
double$pointsThe number of points given for the selected answer
integer$orderA nonnegative value representing a possible display or sort order
Returns
assAnswerCloze See if the initialization of the bounds to null can be avoided to have them string/numeric at all times.

Definition at line 64 of file class.assAnswerCloze.php.

References ASS_AnswerSimple\$answertext, ASS_AnswerSimple\$order, and ASS_AnswerSimple\$points.

65  {
66  parent::__construct($answertext, $points, $order, -1);
67  $this->lowerBound = null;
68  $this->upperBound = null;
69  $this->gap_size = 0;
70  }

Member Function Documentation

◆ getGapSize()

assAnswerCloze::getGapSize ( )
Returns
int

Definition at line 154 of file class.assAnswerCloze.php.

References $gap_size.

155  {
156  return $this->gap_size;
157  }

◆ getLowerBound()

assAnswerCloze::getLowerBound ( )

Returns the lower bound.

Returns
null|string

Definition at line 128 of file class.assAnswerCloze.php.

References $lowerBound.

129  {
130  return $this->lowerBound;
131  }

◆ getNumericValueFromAnswerText()

assAnswerCloze::getNumericValueFromAnswerText ( )
protected

Definition at line 109 of file class.assAnswerCloze.php.

References ASS_AnswerSimple\getAnswertext(), and getNumericValueFromText().

Referenced by setLowerBound(), and setUpperBound().

110  {
111  return $this->getNumericValueFromText($this->getAnswertext());
112  }
getAnswertext()
Gets the answer text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumericValueFromText()

assAnswerCloze::getNumericValueFromText (   $text)
protected

Definition at line 114 of file class.assAnswerCloze.php.

References $text, and ilUtil\stripSlashes().

Referenced by getNumericValueFromAnswerText(), setLowerBound(), and setUpperBound().

115  {
116  include_once("./Services/Math/classes/class.EvalMath.php");
117  $eval = new EvalMath();
118  $eval->suppress_errors = true;
119  return $eval->e(str_replace(",", ".", ilUtil::stripSlashes($text, false)));
120  }
$text
Definition: errorreport.php:18
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUpperBound()

assAnswerCloze::getUpperBound ( )

Returns the upper bound.

Returns
null|string

Definition at line 138 of file class.assAnswerCloze.php.

References $upperBound.

139  {
140  return $this->upperBound;
141  }

◆ setGapSize()

assAnswerCloze::setGapSize (   $gap_size)
Parameters
int$gap_size

Definition at line 146 of file class.assAnswerCloze.php.

References $gap_size.

147  {
148  $this->gap_size = $gap_size;
149  }

◆ setLowerBound()

assAnswerCloze::setLowerBound (   $bound)

Sets the lower boind.

Parameters
$boundstring A string defining the lower bound of an answer for numeric gaps. : Refactor method to get rid of "locale magic".

Definition at line 79 of file class.assAnswerCloze.php.

References ASS_AnswerSimple\getAnswertext(), getNumericValueFromAnswerText(), and getNumericValueFromText().

80  {
81  $boundvalue = $this->getNumericValueFromText($bound);
82  $value = $this->getNumericValueFromAnswerText();
83 
84  if ($boundvalue === false || $boundvalue > $value) {
85  $this->lowerBound = $this->getAnswertext();
86  } else {
87  $this->lowerBound = $bound;
88  }
89  }
getAnswertext()
Gets the answer text.
+ Here is the call graph for this function:

◆ setUpperBound()

assAnswerCloze::setUpperBound (   $bound)

Sets the upper bound.

Parameters
$boundstring A string defining the upper bound of an answer for numeric gaps. : Refactor method to get rid of "locale magic".

Definition at line 97 of file class.assAnswerCloze.php.

References ASS_AnswerSimple\getAnswertext(), getNumericValueFromAnswerText(), and getNumericValueFromText().

98  {
99  $boundvalue = $this->getNumericValueFromText($bound);
100  $value = $this->getNumericValueFromAnswerText();
101 
102  if ($boundvalue === false || $boundvalue < $value) {
103  $this->upperBound = $this->getAnswertext();
104  } else {
105  $this->upperBound = $bound;
106  }
107  }
getAnswertext()
Gets the answer text.
+ Here is the call graph for this function:

Field Documentation

◆ $gap_size

assAnswerCloze::$gap_size
protected

Definition at line 49 of file class.assAnswerCloze.php.

Referenced by getGapSize(), and setGapSize().

◆ $lowerBound

assAnswerCloze::$lowerBound
protected

Definition at line 33 of file class.assAnswerCloze.php.

Referenced by getLowerBound().

◆ $upperBound

assAnswerCloze::$upperBound
protected

Definition at line 43 of file class.assAnswerCloze.php.

Referenced by getUpperBound().


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