Beispiel #1
0
     // we need to know the total number of answer given
     $multipleChoiceTotal = 0;
     $i = 0;
     foreach ($question->answer->answerList as $answer) {
         $results[$i] = $answer;
         $results[$i]['nbr'] = 0;
         foreach ($trackedAnswers as $trackedAnswer) {
             if ($results[$i]['answer'] == $trackedAnswer['answer']) {
                 $results[$i]['nbr'] = $trackedAnswer['nbr'];
                 $multipleChoiceTotal += $trackedAnswer['nbr'];
                 break;
             }
         }
         $i++;
     }
     $displayedStatement = $question->getDescription();
 } elseif ($question->getType() == 'TF') {
     // get the list of all possible answer and the number of times it was choose
     $sql = "SELECT `TEA`.`answer`, COUNT(`TEA`.`answer`) as `nbr`\n                        FROM (`" . $tbl_qwz_question . "` AS `Q` ,\n                            `" . $tbl_qwz_rel_exercise_question . "` AS `RTQ`)\n                    LEFT JOIN `" . $tbl_qwz_tracking . "` AS `TE`\n                        ON `TE`.`exo_id` = `RTQ`.`exerciseId`\n                    LEFT JOIN `" . $tbl_qwz_tracking_questions . "` AS `TED`\n                        ON `TED`.`exercise_track_id` = `TE`.`id`\n                        AND `TED`.`question_id` = `Q`.`id`\n                    LEFT JOIN `" . $tbl_qwz_tracking_answers . "` AS `TEA`\n                        ON `TEA`.`details_id` = `TED`.`id`\n                    WHERE `Q`.`id` = `RTQ`.`questionId`\n                        AND `Q`.`id` = " . (int) $questionId . "\n                        AND `RTQ`.`exerciseId` = " . (int) $exId . "\n                        AND ( `TEA`.`answer` = 'TRUE' OR `TEA`.`answer` = 'FALSE' )\n                    GROUP BY `TEA`.`answer`";
     $results = claro_sql_query_fetch_all($sql);
     // we need to know the total number of answer given
     $multipleChoiceTotal = 0;
     foreach ($results as $result) {
         $multipleChoiceTotal += $result['nbr'];
     }
     $displayedStatement = $question->getDescription();
 } elseif ($question->getType() == 'FIB') {
     // get the list of all word used in each blank
     // we take id to have a unique key for answer, answer with same id are
     // from the same attempt
     $sql = "SELECT `TED`.`id`,`TEA`.`answer`\n                    FROM (\n                        `" . $tbl_qwz_rel_exercise_question . "` AS `RTQ`,\n                        `" . $tbl_qwz_answer_fib . "` AS `A`,\n                        `" . $tbl_qwz_tracking . "` AS `TE`,\n                        `" . $tbl_qwz_tracking_questions . "` AS `TED`,\n                        `" . $tbl_user . "` AS `U`\n                       )\n                    LEFT JOIN `" . $tbl_qwz_tracking_answers . "` AS `TEA`\n                        ON `TEA`.`details_id` = `TED`.`id`\n                    WHERE `RTQ`.`questionId` = " . (int) $questionId . "\n                        AND `RTQ`.`questionId` = `A`.`questionId`\n                        AND `RTQ`.`questionId` = `TED`.`question_id`\n                        AND `RTQ`.`exerciseId` = `TE`.`exo_id`\n                        AND `TE`.`id` = `TED`.`exercise_track_id`\n                        AND `U`.`user_id` = `TE`.`user_id`\n                        AND `RTQ`.`exerciseId` = '" . (int) $exId . "'\n                    ORDER BY `TED`.`id` ASC, `TEA`.`id` ASC";
Beispiel #2
0
 function test_update()
 {
     //Arrange
     $test_field = "What is their name?";
     $test_description = "What you want to call your character.";
     $test_question = new Question($test_field, $test_description);
     $test_question->save();
     $new_quest = "How tall are they?";
     $new_desc = "The height you want your character to be.";
     //Act
     $test_question->update($new_quest, $new_desc);
     //Assert
     $this->assertEquals(["How tall are they?", "The height you want your character to be."], [$test_question->getQuestion(), $test_question->getDescription()]);
 }
Beispiel #3
0
 }
 //-- export pdf
 if ($cmd == 'exExportPDF' && $exId) {
     require_once './lib/question.class.php';
     $exercise = new Exercise();
     $exercise->load($exId);
     if ($exercise->getShuffle() && isset($_REQUEST['shuffle']) && $_REQUEST['shuffle'] == 1) {
         $questionList = $exercise->getRandomQuestionList();
     } else {
         $questionList = $exercise->getQuestionList();
     }
     foreach ($questionList as $_id => $question) {
         $questionObj = new Question();
         $questionObj->setExerciseId($exId);
         if ($questionObj->load($question['id'])) {
             $questionList[$_id]['description'] = $questionObj->getDescription();
             $questionList[$_id]['attachment'] = $questionObj->getAttachment();
             if (!empty($questionList[$_id]['attachment'])) {
                 $questionList[$_id]['attachmentURL'] = get_conf('rootWeb') . 'courses/' . claro_get_current_course_id() . '/exercise/question_' . $questionObj->getId() . '/' . $questionObj->getAttachment();
             }
             switch ($questionObj->getType()) {
                 case 'MCUA':
                 case 'MCMA':
                     $questionList[$_id]['answers'] = $questionObj->answer->answerList;
                     break;
                 case 'TF':
                     $questionList[$_id]['answers'][0]['answer'] = get_lang('True');
                     $questionList[$_id]['answers'][0]['feedback'] = $questionObj->answer->trueFeedback;
                     $questionList[$_id]['answers'][1]['answer'] = get_lang('False');
                     $questionList[$_id]['answers'][1]['feedback'] = $questionObj->answer->falseFeedback;
                     break;