Calculate points.
This function calculates the points for a given answer. Better would be to re-use from T&A here in the future. When this code has been written this has not been possible yet.
148 case "assSingleChoice":
149 include_once(
"./Modules/TestQuestionPool/classes/class.assSingleChoice.php");
151 $q->loadFromDb($a_id);
153 foreach ($q->getAnswers() as $key => $answer)
155 if (isset($a_choice[0]) && $key == $a_choice[0])
157 $points += $answer->getPoints();
162 case "assMultipleChoice":
163 include_once(
"./Modules/TestQuestionPool/classes/class.assMultipleChoice.php");
165 $q->loadFromDb($a_id);
167 foreach ($q->getAnswers() as $key => $answer)
169 if (is_array($a_choice) && in_array($key, $a_choice))
171 $points += $answer->getPoints();
175 $points += $answer->getPointsUnchecked();
181 include_once(
"./Modules/TestQuestionPool/classes/class.assClozeTest.php");
183 $q->loadFromDb($a_id);
185 foreach ($q->getGaps() as $id => $gap)
187 $choice = $a_choice[$id];
188 switch ($gap->getType())
192 for ($order = 0; $order < $gap->getItemCount(); $order++)
194 $answer = $gap->getItem($order);
195 $gotpoints = $q->getTextgapPoints($answer->getAnswertext(),
196 $choice, $answer->getPoints());
197 if ($gotpoints > $gappoints) $gappoints = $gotpoints;
199 $points += $gappoints;
205 for ($order = 0; $order < $gap->getItemCount(); $order++)
207 $answer = $gap->getItem($order);
208 $gotpoints = $q->getNumericgapPoints($answer->getAnswertext(),
209 $choice, $answer->getPoints(),
210 $answer->getLowerBound(), $answer->getUpperBound());
211 if ($gotpoints > $gappoints) $gappoints = $gotpoints;
213 $points += $gappoints;
218 for ($order = 0; $order < $gap->getItemCount(); $order++)
220 $answer = $gap->getItem($order);
221 if ($choice == $answer->getOrder())
223 $answerpoints = $answer->getPoints();
224 $points += $answerpoints;
233 case "assMatchingQuestion":
234 include_once(
"./Modules/TestQuestionPool/classes/class.assMatchingQuestion.php");
236 $q->loadFromDb($a_id);
238 for ($i = 0; $i < $q->getMatchingPairCount(); $i++)
240 $pair = $q->getMatchingPair($i);
241 if (is_array($a_choice) && in_array($pair->definition->identifier.
"-".$pair->term->identifier, $a_choice))
243 $points += $pair->points;
248 case "assOrderingQuestion":
249 include_once(
"./Modules/TestQuestionPool/classes/class.assOrderingQuestion.php");
251 $q->loadFromDb($a_id);
255 foreach ($q->getAnswers() as $answer)
257 if ($a_choice[$cnt - 1] != $cnt)
265 $points = $q->getPoints();
269 case "assImagemapQuestion":
270 include_once(
"./Modules/TestQuestionPool/classes/class.assImagemapQuestion.php");
272 $q->loadFromDb($a_id);
275 foreach ($q->getAnswers() as $key => $answer)
277 if (is_array($a_choice) && in_array($key, $a_choice))
279 $points += $answer->getPoints();
291 return (
int) $points;
const CLOZE_TEXT
Cloze question constants.
Class for multiple choice tests.
Class for matching questions.
Class for single choice questions.
Class for image map questions.
Class for ordering questions.