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")
 
   78                if (!
$ilDB->fetchAssoc($set))
 
   80                        $ilDB->replace(
"page_qst_answer",
 
   82                                        "qst_id" => array(
"integer", $a_id),
 
   83                                        "user_id" => array(
"integer", 
$ilUser->getId())
 
   86                                        "try" => array(
"integer", 1),
 
   87                                        "passed" => array(
"integer", $passed),
 
   88                                        "points" => array(
"float", $points)
 
   94                        $ilDB->manipulate(
"UPDATE page_qst_answer SET ".
 
   96                                " passed = ".
$ilDB->quote($passed, 
"integer").
",".
 
   97                                " points = ".$ilDB->quote($points, 
"float").
 
   98                                " WHERE qst_id = ".$ilDB->quote($a_id, 
"integer").
 
   99                                " AND user_id = ".$ilDB->quote(
$ilUser->getId(), 
"integer")
 
  114                $set = 
$ilDB->query(
"SELECT count(user_id) usr_cnt FROM page_qst_answer WHERE ".
 
  115                        " qst_id = ".
$ilDB->quote($a_q_id, 
"integer")
 
  117                $rec = 
$ilDB->fetchAssoc($set);
 
  118                $all = $rec[
"usr_cnt"];
 
  122                $third_or_more = 
false;
 
  126                        $set = 
$ilDB->query(
"SELECT count(user_id) usr_cnt FROM page_qst_answer WHERE ".
 
  127                                " qst_id = ".
$ilDB->quote($a_q_id, 
"integer").
" AND ".
 
  128                                " passed = ".$ilDB->quote(1, 
"integer").
" AND ".
 
  129                                " try = ".$ilDB->quote(1, 
"integer")
 
  131                        $rec = 
$ilDB->fetchAssoc($set);
 
  132                        $first = $rec[
"usr_cnt"];
 
  134                        $set = 
$ilDB->query(
"SELECT count(user_id) usr_cnt FROM page_qst_answer WHERE ".
 
  135                                " qst_id = ".
$ilDB->quote($a_q_id, 
"integer").
" AND ".
 
  136                                " passed = ".$ilDB->quote(1, 
"integer").
" AND ".
 
  137                                " try = ".$ilDB->quote(2, 
"integer")
 
  139                        $rec = 
$ilDB->fetchAssoc($set);
 
  140                        $second = $rec[
"usr_cnt"];
 
  142                        $set = 
$ilDB->query($q = 
"SELECT count(user_id) usr_cnt FROM page_qst_answer WHERE ".
 
  143                                " qst_id = ".
$ilDB->quote($a_q_id, 
"integer").
" AND ".
 
  144                                " passed = ".$ilDB->quote(1, 
"integer").
" AND ".
 
  145                                " try >= ".$ilDB->quote(3, 
"integer")
 
  147                        $rec = 
$ilDB->fetchAssoc($set);
 
  148                        $third_or_more = $rec[
"usr_cnt"];
 
  151                return array(
"all" => $all, 
"first" => $first, 
"second" => $second, 
"third_or_more" => $third_or_more);
 
  170                        case "assSingleChoice":
 
  171                                include_once(
"./Modules/TestQuestionPool/classes/class.assSingleChoice.php");
 
  173                                $q->loadFromDb($a_id);
 
  175                                foreach ($q->getAnswers() as $key => $answer)
 
  177                                        if (isset($a_choice[0]) && $key == $a_choice[0])
 
  179                                                $points += $answer->getPoints();
 
  184                        case "assMultipleChoice":
 
  185                                include_once(
"./Modules/TestQuestionPool/classes/class.assMultipleChoice.php");
 
  187                                $q->loadFromDb($a_id);
 
  189                                foreach ($q->getAnswers() as $key => $answer)
 
  191                                        if (is_array($a_choice) && in_array($key, $a_choice))
 
  193                                                $points += $answer->getPoints();
 
  197                                                $points += $answer->getPointsUnchecked();
 
  203                                include_once(
"./Modules/TestQuestionPool/classes/class.assClozeTest.php");
 
  205                                $q->loadFromDb($a_id);
 
  207                                foreach ($q->getGaps() as $id => $gap)
 
  209                                        $choice = $a_choice[$id];
 
  210                                        switch ($gap->getType())
 
  214                                                        for ($order = 0; $order < $gap->getItemCount(); $order++)
 
  216                                                                $answer = $gap->getItem($order);
 
  217                                                                $gotpoints = $q->getTextgapPoints($answer->getAnswertext(),
 
  218                                                                        $choice, $answer->getPoints());
 
  219                                                                if ($gotpoints > $gappoints) $gappoints = $gotpoints;
 
  221                                                        $points += $gappoints;
 
  227                                                        for ($order = 0; $order < $gap->getItemCount(); $order++)
 
  229                                                                $answer = $gap->getItem($order);
 
  230                                                                $gotpoints = $q->getNumericgapPoints($answer->getAnswertext(),
 
  231                                                                        $choice, $answer->getPoints(),
 
  232                                                                        $answer->getLowerBound(), $answer->getUpperBound());
 
  233                                                                if ($gotpoints > $gappoints) $gappoints = $gotpoints;
 
  235                                                        $points += $gappoints;
 
  240                                                        for ($order = 0; $order < $gap->getItemCount(); $order++)
 
  242                                                                $answer = $gap->getItem($order);
 
  243                                                                if ($choice == $answer->getOrder())
 
  245                                                                        $answerpoints = $answer->getPoints();
 
  246                                                                        $points += $answerpoints;
 
  255                        case "assMatchingQuestion":
 
  256                                include_once(
"./Modules/TestQuestionPool/classes/class.assMatchingQuestion.php");
 
  258                                $q->loadFromDb($a_id);
 
  260                                for ($i = 0; $i < $q->getMatchingPairCount(); $i++)
 
  262                                        $pair = $q->getMatchingPair($i);
 
  263                                        if (is_array($a_choice) && in_array($pair->definition->identifier.
"-".$pair->term->identifier, $a_choice))
 
  265                                                $points += $pair->points;
 
  270                        case "assOrderingQuestion":
 
  271                                include_once(
"./Modules/TestQuestionPool/classes/class.assOrderingQuestion.php");
 
  273                                $q->loadFromDb($a_id);
 
  277                                foreach ($q->getAnswers() as $answer)
 
  279                                        if ($a_choice[$cnt - 1] != $cnt)
 
  287                                        $points = $q->getPoints();
 
  291                        case "assImagemapQuestion":
 
  292                                include_once(
"./Modules/TestQuestionPool/classes/class.assImagemapQuestion.php");
 
  294                                $q->loadFromDb($a_id);
 
  297                                foreach ($q->getAnswers() as $key => $answer)
 
  299                                        if (is_array($a_choice) && in_array($key, $a_choice))
 
  301                                                $points += $answer->getPoints();
 
  313                return (
int) $points;
 
  326                $qst = (is_array($a_q_id))
 
  327                        ? 
$ilDB->in(
"qst_id", $a_q_id, 
false, 
"integer")
 
  328                        : 
" qst_id = ".$ilDB->quote($a_q_id, 
"integer");
 
  330                $and = ($a_user_id > 0)
 
  331                        ? 
" AND user_id = ".
$ilDB->quote($a_user_id, 
"integer")
 
  334                $set = 
$ilDB->query(
"SELECT * FROM page_qst_answer WHERE ".
 
  339                if (is_array($a_q_id))
 
  342                        while ($rec = 
$ilDB->fetchAssoc($set))
 
  344                                $recs[$rec[
"qst_id"]] = $rec;
 
  350                        return $ilDB->fetchAssoc($set);
 
  364                $ilDB->manipulate($q = 
"UPDATE page_qst_answer SET ".
 
  365                                " try = ".
$ilDB->quote(0, 
"integer").
",".
 
  366                                " passed = ".$ilDB->quote(0, 
"integer").
",".
 
  367                                " points = ".$ilDB->quote(0, 
"integer").
",".
 
  368                                " unlocked = ".$ilDB->quote(0, 
"integer").
 
  369                                " WHERE qst_id = ".$ilDB->quote($a_q_id, 
"integer").
 
  370                                " AND user_id = ".$ilDB->quote($a_user_id, 
"integer")
 
  380        static function unlock($a_q_id, $a_user_id)
 
  384                $ilDB->manipulate($q = 
"UPDATE page_qst_answer SET ".
 
  385                                " unlocked = ".
$ilDB->quote(1, 
"integer").
 
  386                                " WHERE qst_id = ".$ilDB->quote($a_q_id, 
"integer").
 
  387                                " AND user_id = ".$ilDB->quote($a_user_id, 
"integer")
 
Class for image map questions.
Class for matching questions.
Class for multiple choice tests.
Class for ordering questions.
Class for single choice questions.
static decode($json_notated_string, $suppress_native=false)
static getQuestionStatistics($a_q_id)
Get statistics for question.
static resetTries($a_q_id, $a_user_id)
Reset tries.
static calculatePoints($a_type, $a_id, $a_choice)
Calculate points.
static getAnswerStatus($a_q_id, $a_user_id=0)
Get statistics for question.
static saveQuestionAnswer($a_type, $a_id, $a_answer)
Save question answer.
static unlock($a_q_id, $a_user_id)
Reset tries.
const CLOZE_TEXT
Cloze question constants.