37 $ilLog->write($a_type);
39 $ilLog->write($a_answer);
40 include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
42 $tries = $answer->tries;
43 $passed = $answer->passed;
44 $choice = $answer->choice;
46 $ilLog->write(
"Points: ".
$points);
48 $set = $ilDB->query(
"SELECT * FROM page_qst_answer WHERE ".
49 " qst_id = ".$ilDB->quote($a_id,
"integer").
" AND ".
50 " user_id = ".$ilDB->quote($ilUser->getId(),
"integer")
52 if ($rec = $ilDB->fetchAssoc($set))
54 $ilDB->manipulate(
"UPDATE page_qst_answer SET ".
56 " passed = ".$ilDB->quote($passed,
"integer").
",".
57 " points = ".$ilDB->quote(
$points,
"float").
58 " WHERE qst_id = ".$ilDB->quote($a_id,
"integer").
60 $ilDB->quote($ilUser->getId(),
"integer")
65 $ilDB->manipulate(
"INSERT INTO page_qst_answer ".
66 "(qst_id, user_id, try, passed, points) VALUES (".
67 $ilDB->quote($a_id,
"integer").
",".
68 $ilDB->quote($ilUser->getId(),
"integer").
",".
69 $ilDB->quote(1,
"integer").
",".
70 $ilDB->quote($passed,
"integer").
",".
92 $set = $ilDB->query(
"SELECT count(user_id) usr_cnt FROM page_qst_answer WHERE ".
93 " qst_id = ".$ilDB->quote($a_q_id,
"integer")
95 $rec = $ilDB->fetchAssoc($set);
96 $all = $rec[
"usr_cnt"];
100 $third_or_more =
false;
104 $set = $ilDB->query(
"SELECT count(user_id) usr_cnt FROM page_qst_answer WHERE ".
105 " qst_id = ".$ilDB->quote($a_q_id,
"integer").
" AND ".
106 " passed = ".$ilDB->quote(1,
"integer").
" AND ".
107 " try = ".$ilDB->quote(1,
"integer")
109 $rec = $ilDB->fetchAssoc($set);
110 $first = $rec[
"usr_cnt"];
112 $set = $ilDB->query(
"SELECT count(user_id) usr_cnt FROM page_qst_answer WHERE ".
113 " qst_id = ".$ilDB->quote($a_q_id,
"integer").
" AND ".
114 " passed = ".$ilDB->quote(1,
"integer").
" AND ".
115 " try = ".$ilDB->quote(2,
"integer")
117 $rec = $ilDB->fetchAssoc($set);
118 $second = $rec[
"usr_cnt"];
120 $set = $ilDB->query($q =
"SELECT count(user_id) usr_cnt FROM page_qst_answer WHERE ".
121 " qst_id = ".$ilDB->quote($a_q_id,
"integer").
" AND ".
122 " passed = ".$ilDB->quote(1,
"integer").
" AND ".
123 " try >= ".$ilDB->quote(3,
"integer")
125 $rec = $ilDB->fetchAssoc($set);
126 $third_or_more = $rec[
"usr_cnt"];
129 return array(
"all" => $all,
"first" => $first,
"second" => $second,
"third_or_more" => $third_or_more);
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;
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;
218 for ($order = 0; $order < $gap->getItemCount(); $order++)
220 $answer = $gap->getItem($order);
221 if ($choice == $answer->getOrder())
223 $answerpoints = $answer->getPoints();
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))
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)
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();