ILIAS  trunk Revision v5.2.0beta1-34132-g2d4d73d4a0
assAnswerCloze 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 assAnswerCloze:
+ Collaboration diagram for assAnswerCloze:

Public Member Functions

 __construct (string $answertext="", float $points=0.0, int $order=0, int $id=-1, int $state=0)
 assAnswerCloze constructor More...
 
 setLowerBound (string $bound)
 Sets the lower boind. More...
 
 setUpperBound (string $bound)
 Sets the upper bound. More...
 
 getLowerBound ()
 Returns the lower bound. More...
 
 getUpperBound ()
 Returns the upper bound. More...
 
 setGapSize (int $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

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

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 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 35 of file class.assAnswerCloze.php.

Constructor & Destructor Documentation

◆ __construct()

assAnswerCloze::__construct ( string  $answertext = "",
float  $points = 0.0,
int  $order = 0,
int  $id = -1,
int  $state = 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 See if the initialization of the bounds to null can be avoided to have them string/numeric at all times.

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

References ASS_AnswerSimple\$answertext, ASS_AnswerSimple\$id, ASS_AnswerSimple\$order, ASS_AnswerSimple\$points, and ILIAS\GlobalScreen\Provider\__construct().

63  {
65  $this->lowerBound = null;
66  $this->upperBound = null;
67  $this->gap_size = 0;
68  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getGapSize()

assAnswerCloze::getGapSize ( )
Returns
int

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

References $gap_size.

149  : int
150  {
151  return $this->gap_size;
152  }

◆ getLowerBound()

assAnswerCloze::getLowerBound ( )

Returns the lower bound.

Returns
null|string

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

References $lowerBound.

123  : ?string
124  {
125  return $this->lowerBound;
126  }

◆ getNumericValueFromAnswerText()

assAnswerCloze::getNumericValueFromAnswerText ( )
protected

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

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

Referenced by setLowerBound(), and setUpperBound().

106  {
107  return $this->getNumericValueFromText($this->getAnswertext());
108  }
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 110 of file class.assAnswerCloze.php.

References ilUtil\stripSlashes().

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

111  {
112  $eval = new EvalMath();
113  $eval->suppress_errors = true;
114  return $eval->e(str_replace(",", ".", ilUtil::stripSlashes($text, false)));
115  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ 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 133 of file class.assAnswerCloze.php.

References $upperBound.

133  : ?string
134  {
135  return $this->upperBound;
136  }

◆ setGapSize()

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

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

References $gap_size.

141  : void
142  {
143  $this->gap_size = $gap_size;
144  }

◆ setLowerBound()

assAnswerCloze::setLowerBound ( string  $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 76 of file class.assAnswerCloze.php.

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

Referenced by assClozeTestGUI\saveNumericGapCorrectionFormProperty().

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

◆ setUpperBound()

assAnswerCloze::setUpperBound ( string  $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 93 of file class.assAnswerCloze.php.

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

Referenced by assClozeTestGUI\saveNumericGapCorrectionFormProperty().

93  : void
94  {
95  $boundvalue = $this->getNumericValueFromText($bound);
96  $value = $this->getNumericValueFromAnswerText();
97 
98  if ($boundvalue === false || $boundvalue < $value) {
99  $this->upperBound = $this->getAnswertext();
100  } else {
101  $this->upperBound = $bound;
102  }
103  }
getAnswertext()
Gets the answer text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $gap_size

int assAnswerCloze::$gap_size
protected

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

Referenced by getGapSize(), and setGapSize().

◆ $lowerBound

string assAnswerCloze::$lowerBound
protected

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

Referenced by getLowerBound().

◆ $upperBound

string assAnswerCloze::$upperBound
protected

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

Referenced by getUpperBound().


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