ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilAssLacCompositeValidator Class Reference

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

+ Collaboration diagram for ilAssLacCompositeValidator:

Public Member Functions

 __construct ($object_loader)
 
 validate (ilAssLacAbstractComposite $composite)
 

Protected Member Functions

 getNonShuffler ()
 

Protected Attributes

 $object_loader
 

Private Member Functions

 validateSubTree (ilAssLacAbstractComposite $composite)
 
 validateClozeTest ($answer_index, $question, $answer_expression, $question_index)
 
 checkIfAnswerIndexOfQuestionExists ($question, $question_index, $answer_index)
 
 checkQuestionExists ($question, $index)
 
 isResultOfAnswerExpression ($expression)
 
 checkAnswerExpressionExist ($expressions, $answer_expression, $question_index)
 
 checkOperatorExistForExpression ($operators, $answer_expression, $pattern)
 

Private Attributes

RandomGroup $randomGroup
 

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 CompositeValidator

Date: 04.12.13 Time: 14:19

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

Definition at line 28 of file ilAssLacCompositeValidator.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssLacCompositeValidator::__construct (   $object_loader)
Parameters
ilAssLacQuestionProvider$object_loader

Definition at line 42 of file ilAssLacCompositeValidator.php.

43 {
44 global $DIC;
45
46 $this->object_loader = $object_loader;
47 $this->randomGroup = $DIC->refinery()->random();
48 }
global $DIC
Definition: shib_login.php:26

References $DIC, and $object_loader.

Member Function Documentation

◆ checkAnswerExpressionExist()

ilAssLacCompositeValidator::checkAnswerExpressionExist (   $expressions,
  $answer_expression,
  $question_index 
)
private
Parameters
array$expressions
ilAssLacExpressionInterface$answer_expression
int$question_index
Exceptions
ilAssLacExpressionNotSupportedByQuestion

Definition at line 239 of file ilAssLacCompositeValidator.php.

239 : void
240 {
241 if (!in_array($answer_expression::$identifier, $expressions)) {
242 throw new ilAssLacExpressionNotSupportedByQuestion($answer_expression->getValue(), $question_index);
243 }
244 }

Referenced by validateSubTree().

+ Here is the caller graph for this function:

◆ checkIfAnswerIndexOfQuestionExists()

ilAssLacCompositeValidator::checkIfAnswerIndexOfQuestionExists (   $question,
  $question_index,
  $answer_index 
)
private
Parameters
iQuestionCondition$question
int$question_index
int$answer_index
Exceptions
ilAssLacAnswerIndexNotExist

Definition at line 191 of file ilAssLacCompositeValidator.php.

191 : void
192 {
193 $answer_options = $question->getAvailableAnswerOptions($answer_index);
194 if ($answer_options == null) {
195 throw new ilAssLacAnswerIndexNotExist($question_index, $answer_index + 1);
196 }
197 }

Referenced by validateSubTree().

+ Here is the caller graph for this function:

◆ checkOperatorExistForExpression()

ilAssLacCompositeValidator::checkOperatorExistForExpression (   $operators,
  $answer_expression,
  $pattern 
)
private
Parameters
array$operators
ilAssLacExpressionInterface$answer_expression
string$pattern
Exceptions
ilAssLacOperatorNotSupportedByExpression

Definition at line 253 of file ilAssLacCompositeValidator.php.

253 : void
254 {
255 if (!in_array($pattern, $operators)) {
256 throw new ilAssLacOperatorNotSupportedByExpression($answer_expression->getValue(), $pattern);
257 }
258 }

Referenced by validateSubTree().

+ Here is the caller graph for this function:

◆ checkQuestionExists()

ilAssLacCompositeValidator::checkQuestionExists (   $question,
  $index 
)
private
Parameters
assQuestion | null$question
int$index
Exceptions
ilAssLacQuestionNotExist

Definition at line 205 of file ilAssLacCompositeValidator.php.

205 : void
206 {
207 if ($question == null) {
208 throw new ilAssLacQuestionNotExist($index);
209 }
210 }

Referenced by validateSubTree().

+ Here is the caller graph for this function:

◆ getNonShuffler()

ilAssLacCompositeValidator::getNonShuffler ( )
protected

Definition at line 260 of file ilAssLacCompositeValidator.php.

261 {
262 return $this->randomGroup->dontShuffle();
263 }
A transformation is a function from one datatype to another.

◆ isResultOfAnswerExpression()

ilAssLacCompositeValidator::isResultOfAnswerExpression (   $expression)
private
Parameters
ilAssLacExpressionInterface$expression
Returns
bool

Definition at line 217 of file ilAssLacCompositeValidator.php.

217 : bool
218 {
219 // @PHP8-CR I suspect this cluster of typizations is broken in some way. I still leave these remarks "intact"
220 // to assist a more thorough analysis.
221 if ($expression instanceof ilAssLacResultOfAnswerOfQuestionExpression) {
222 return true;
223 }
224
225 if ($expression instanceof ilAssLacResultOfAnswerOfCurrentQuestionExpression) {
226 return true;
227 }
228
229 return false;
230 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by validateSubTree().

+ Here is the caller graph for this function:

◆ validate()

ilAssLacCompositeValidator::validate ( ilAssLacAbstractComposite  $composite)
Exceptions
ilAssLacException

Definition at line 53 of file ilAssLacCompositeValidator.php.

53 : void
54 {
55 if ($composite->nodes !== []) {
56 $this->validate($composite->nodes[0]);
57 $this->validate($composite->nodes[1]);
58 $this->validateSubTree($composite);
59 }
60 }
validateSubTree(ilAssLacAbstractComposite $composite)
validate(ilAssLacAbstractComposite $composite)

References validate(), and validateSubTree().

Referenced by validate().

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

◆ validateClozeTest()

ilAssLacCompositeValidator::validateClozeTest (   $answer_index,
  $question,
  $answer_expression,
  $question_index 
)
private
Parameters
int$answer_index
assQuestion | iQuestionCondition$question
ilAssLacExpressionInterface$answer_expression
int$question_index
Exceptions
ilAssLacAnswerValueNotExist

Definition at line 138 of file ilAssLacCompositeValidator.php.

138 : void
139 {
140 if ($answer_index !== null) {
141 $options = $question->getAvailableAnswerOptions($answer_index);
142 $found = false;
143 switch ($options->getType()) {
144 case 0: // text
145 if (
146 $answer_expression instanceof ilAssLacStringResultExpression
147 ) {
148 $found = true;
149 }
150
151 break;
152 case 1: // select
153
154 if ($answer_expression instanceof ilAssLacStringResultExpression) {
155 foreach ($options->getItems($this->getNonShuffler()) as $item) {
156 if ($item->getAnswertext() == $answer_expression->getText()) {
157 $found = true;
158 }
159 }
160 } elseif ($answer_expression instanceof ilAssLacNumberOfResultExpression) {
161 foreach ($options->getItems($question->getShuffler()) as $item) {
162 if ($item->getOrder() == $answer_expression->getNumericValue() - 1) {
163 $found = true;
164 }
165 }
166 }
167 break;
168 case 2: // numeric
169 if ($answer_expression instanceof ilAssLacNumericResultExpression) {
170 $found = true;
171 }
172 break;
173 }
174
175 if ($answer_expression instanceof ilAssLacEmptyAnswerExpression) {
176 $found = true;
177 }
178 if (!$found && !($answer_expression instanceof ilAssLacPercentageResultExpression)) {
179 throw new ilAssLacAnswerValueNotExist($question_index, $answer_expression->getValue(), $answer_index + 1);
180 }
181 }
182 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\UI\Implementation\Component\Input\Field\$options.

Referenced by validateSubTree().

+ Here is the caller graph for this function:

◆ validateSubTree()

ilAssLacCompositeValidator::validateSubTree ( ilAssLacAbstractComposite  $composite)
private

Definition at line 62 of file ilAssLacCompositeValidator.php.

62 : void
63 {
64 if ($composite->nodes[0] instanceof ilAssLacQuestionExpressionInterface &&
65 $composite->nodes[1] instanceof ilAssLacSolutionExpressionInterface
66 ) {
67 $question_expression = $composite->nodes[0];
68 $answer_expression = $composite->nodes[1];
69 $question_index = $composite->nodes[0]->getQuestionIndex();
70 $answer_index = null;
71 $question = $this->object_loader->getQuestion();
72
73 $this->checkQuestionExists($question, $question_index);
74 //$this->checkQuestionIsReachable($question, $question_index);
75
76 if ($this->isResultOfAnswerExpression($question_expression)) {
77 $answer_index = $question_expression->getAnswerIndex() - 1;
78 // @PHP8-CR I suspect this cluster of typizations is broken in some way. I still leave these remarks "intact"
79 // to assist a more thorough analysis.
80 $this->checkIfAnswerIndexOfQuestionExists($question, $question_index, $answer_index);
81 }
82 if ($answer_expression instanceof ilAssLacNumberOfResultExpression && !($question instanceof assClozeTest)) {
83 // @PHP8-CR I suspect this cluster of typizations is broken in some way. I still leave these remarks "intact"
84 // to assist a more thorough analysis.
85 $this->checkIfAnswerIndexOfQuestionExists($question, $question_index, $answer_expression->getNumericValue() - 1);
86 }
87
88 $this->checkAnswerExpressionExist($question->getExpressionTypes(), $answer_expression, $question_index);
89 $this->checkOperatorExistForExpression($question->getOperators($answer_expression::$identifier), $answer_expression, $composite::$pattern);
90
91 if ($answer_expression instanceof ilAssLacOrderingResultExpression &&
92 ($question instanceof assOrderingHorizontal || $question instanceof assOrderingQuestion)
93 ) {
94 foreach ($answer_expression->getOrdering() as $order) {
95 $count = 0;
96 foreach ($answer_expression->getOrdering() as $element) {
97 if ($element == $order) {
98 $count++;
99 }
100 }
101 if ($count > 1) {
102 throw new ilAssLacDuplicateElement($order);
103 }
104
105 $this->checkIfAnswerIndexOfQuestionExists($question, $question_index, $order - 1);
106 }
107 }
108 if ($question instanceof assClozeTest) {
109 $this->validateClozeTest($answer_index, $question, $answer_expression, $question_index);
110 } elseif (
111 $answer_expression instanceof ilAssLacPercentageResultExpression &&
112 // @PHP8-CR I suspect this cluster of typizations is broken in some way. I still leave these remarks "intact"
113 // to assist a more thorough analysis.
114 $this->isResultOfAnswerExpression($question_expression) &&
115 !($question instanceof assFormulaQuestion)
116 ) {
117 throw new ilAssLacExpressionNotSupportedByQuestion($answer_expression->getValue(), $question_index . "[" . ($answer_index + 1) . "]");
118 }
119 } elseif (
120 ($composite->nodes[0] instanceof ilAssLacAbstractOperation &&
121 $composite->nodes[1] instanceof ilAssLacExpressionInterface) ||
122 ($composite->nodes[0] instanceof ilAssLacExpressionInterface &&
123 $composite->nodes[1] instanceof ilAssLacAbstractOperation) ||
124 ($composite->nodes[0] instanceof ilAssLacSolutionExpressionInterface)
125 ) {
126 throw new ilAssLacUnableToParseCondition("");
127 }
128 }
Class for cloze tests.
Class for single choice questions assFormulaQuestion is a class for single choice questions.
Class for horizontal ordering questions.
Class for ordering questions.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
validateClozeTest($answer_index, $question, $answer_expression, $question_index)
checkAnswerExpressionExist($expressions, $answer_expression, $question_index)
checkOperatorExistForExpression($operators, $answer_expression, $pattern)
checkIfAnswerIndexOfQuestionExists($question, $question_index, $answer_index)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References checkAnswerExpressionExist(), checkIfAnswerIndexOfQuestionExists(), checkOperatorExistForExpression(), checkQuestionExists(), isResultOfAnswerExpression(), and validateClozeTest().

Referenced by validate().

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

Field Documentation

◆ $object_loader

ilAssLacCompositeValidator::$object_loader
protected

Definition at line 35 of file ilAssLacCompositeValidator.php.

Referenced by __construct().

◆ $randomGroup

RandomGroup ilAssLacCompositeValidator::$randomGroup
private

Definition at line 37 of file ilAssLacCompositeValidator.php.


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