public function fillRow(array $row)
 {
     $this->ctrl->setParameter($this->parent_obj, 'evaluation', $row['qid']);
     if (isset($row['pass'])) {
         $this->ctrl->setParameter($this->parent_obj, 'pass', $row['pass']);
     }
     if ($this->isQuestionTitleLinkPossible()) {
         $questionTitleLink = $this->getQuestionTitleLink($row['qid']);
         if (strlen($questionTitleLink)) {
             $this->tpl->setVariable('URL_QUESTION_TITLE', $questionTitleLink);
             $this->tpl->setCurrentBlock('title_link_end_tag');
             $this->tpl->touchBlock('title_link_end_tag');
             $this->tpl->parseCurrentBlock();
         }
     }
     if ($this->isObjectiveOrientedPresentationEnabled()) {
         $objectives = $this->questionRelatedObjectivesList->getQuestionRelatedObjectiveTitle($row['qid']);
         $this->tpl->setVariable('VALUE_LO_OBJECTIVES', strlen($objectives) ? $objectives : ' ');
     }
     if ($this->getShowHintCount()) {
         $this->tpl->setVariable('VALUE_HINT_COUNT', (int) $row['requested_hints']);
     }
     if ($this->getShowSuggestedSolution()) {
         $this->tpl->setVariable('SOLUTION_HINT', $row['solution']);
     }
     if ($this->areActionListsRequired()) {
         $this->tpl->setVariable('ACTIONS_MENU', $this->getActionList($row['qid']));
     }
     $this->tpl->setVariable('VALUE_QUESTION_TITLE', $row['title']);
     $this->tpl->setVariable('VALUE_QUESTION_ID', $row['qid']);
     if ($this->isPassColumnEnabled()) {
         $this->tpl->setVariable('VALUE_QUESTION_PASS', $row['pass'] + 1);
     } else {
         $this->tpl->setVariable('VALUE_QUESTION_COUNTER', $row['nr']);
     }
     $this->tpl->setVariable('VALUE_MAX_POINTS', $row['max']);
     $this->tpl->setVariable('VALUE_REACHED_POINTS', $row['reached']);
     $this->tpl->setVariable('VALUE_PERCENT_SOLVED', $row['percent']);
     $this->tpl->setVariable('ROW_ID', $this->getRowId($row['qid']));
 }
 /**
  * @param ilTestSequence $a_test_sequence
  * @param ilTestQuestionRelatedObjectivesList $a_objectives_list
  */
 public function buildQuestionRelatedObjectiveList(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
 {
     foreach ($a_test_sequence->getQuestionIds() as $questionId) {
         if ($a_test_sequence instanceof ilTestRandomQuestionSequence) {
             $definitionId = $a_test_sequence->getResponsibleSourcePoolDefinitionId($questionId);
             $objectiveId = $this->lookupObjectiveIdByRandomQuestionSelectionDefinitionId($definitionId);
         } else {
             $objectiveId = $this->lookupObjectiveIdByFixedQuestionId($questionId);
         }
         if ($objectiveId) {
             $a_objectives_list->addQuestionRelatedObjective($questionId, $objectiveId);
         }
     }
 }
示例#3
0
 /**
  * Returns an output of the solution to an answer compared to the correct solution
  *
  * @param integer $question_id Database ID of the question
  * @param integer $active_id Active ID of the active user
  * @param integer $pass Test pass
  * @return string HTML code of the correct solution comparison
  * @access public
  */
 function getCorrectSolutionOutput($question_id, $active_id, $pass, ilTestQuestionRelatedObjectivesList $objectivesList = null)
 {
     global $ilUser;
     $test_id = $this->object->getTestId();
     $question_gui = $this->object->createQuestionGUI("", $question_id);
     $template = new ilTemplate("tpl.il_as_tst_correct_solution_output.html", TRUE, TRUE, "Modules/Test");
     $show_question_only = $this->object->getShowSolutionAnswersOnly() ? TRUE : FALSE;
     $result_output = $question_gui->getSolutionOutput($active_id, $pass, TRUE, FALSE, $show_question_only, $this->object->getShowSolutionFeedback(), FALSE, FALSE, TRUE);
     $best_output = $question_gui->getSolutionOutput($active_id, $pass, FALSE, FALSE, $show_question_only, FALSE, TRUE, FALSE, FALSE);
     if ($this->object->getShowSolutionFeedback() && $_GET['cmd'] != 'outCorrectSolution') {
         $specificAnswerFeedback = $question_gui->getSpecificFeedbackOutput($active_id, $pass);
         if (strlen($specificAnswerFeedback)) {
             $template->setCurrentBlock("outline_specific_feedback");
             $template->setVariable("OUTLINE_SPECIFIC_FEEDBACK", $specificAnswerFeedback);
             $template->parseCurrentBlock();
         }
     }
     if ($this->object->isBestSolutionPrintedWithResult() && strlen($best_output)) {
         $template->setCurrentBlock("best_solution");
         $template->setVariable("TEXT_BEST_SOLUTION", $this->lng->txt("tst_best_solution_is"));
         $template->setVariable("BEST_OUTPUT", $best_output);
         $template->parseCurrentBlock();
     }
     $template->setVariable("TEXT_YOUR_SOLUTION", $this->lng->txt("tst_your_answer_was"));
     $maxpoints = $question_gui->object->getMaximumPoints();
     if ($maxpoints == 1) {
         $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()) . " (" . $maxpoints . " " . $this->lng->txt("point") . ")");
     } else {
         $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()) . " (" . $maxpoints . " " . $this->lng->txt("points") . ")");
     }
     if ($objectivesList !== null) {
         $objectives = $this->lng->txt('tst_res_lo_objectives_header') . ': ';
         $objectives .= $objectivesList->getQuestionRelatedObjectiveTitle($question_gui->object->getId());
         $template->setVariable('OBJECTIVES', $objectives);
     }
     $template->setVariable("SOLUTION_OUTPUT", $result_output);
     $template->setVariable("RECEIVED_POINTS", sprintf($this->lng->txt("you_received_a_of_b_points"), $question_gui->object->getReachedPoints($active_id, $pass), $maxpoints));
     $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
     $template->setVariable("BACKLINK_TEXT", "<< " . $this->lng->txt("back"));
     return $template->get();
 }
示例#4
0
 /**
  * Creates the learners output of a question
  */
 protected function outWorkingForm($sequence = "", $test_id, $postpone_allowed, $directfeedback = false)
 {
     global $ilUser;
     if (!$this->isValidSequenceElement($sequence)) {
         $sequence = $this->testSequence->getFirstSequence();
     }
     $_SESSION["active_time_id"] = $this->object->startWorkingTime($this->testSession->getActiveId(), $this->testSession->getPass());
     $this->populateContentStyleBlock();
     $this->populateSyntaxStyleBlock();
     if ($this->object->getListOfQuestions()) {
         $this->showSideList();
     }
     $questionId = $this->testSequence->getQuestionForSequence($sequence);
     if (!(int) $questionId && $this->testSession->isObjectiveOriented()) {
         ilUtil::sendFailure(sprintf($this->lng->txt('tst_objective_oriented_test_pass_without_questions'), $this->object->getTitle()), true);
         $this->performCustomRedirect();
     }
     $question_gui = $this->object->createQuestionGUI("", $questionId);
     if (!is_object($question_gui)) {
         global $ilLog;
         $ilLog->write("INV SEQ: active={$this->testSession->getActiveId()} qId={$questionId} seq={$sequence} " . serialize($this->testSequence));
         $ilLog->logStack('INV SEQ');
         $this->ctrl->setParameter($this, 'gotosequence', $this->testSequence->getFirstSequence());
         $this->ctrl->setParameter($this, 'activecommand', 'gotoquestion');
         $this->ctrl->redirect($this, 'redirectQuestion');
     }
     $question_gui->setTargetGui($this);
     if ($this->object->getJavaScriptOutput()) {
         $question_gui->object->setOutputType(OUTPUT_JAVASCRIPT);
     }
     $is_postponed = $this->testSequence->isPostponedQuestion($question_gui->object->getId());
     $this->ctrl->setParameter($this, "sequence", "{$sequence}");
     $formaction = $this->ctrl->getFormAction($this, "gotoQuestion");
     $question_gui->setSequenceNumber($this->testSequence->getPositionOfSequence($sequence));
     $question_gui->setQuestionCount($this->testSequence->getUserQuestionCount());
     require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php';
     $headerBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng);
     $headerBlockBuilder->setHeaderMode($this->object->getTitleOutput());
     $headerBlockBuilder->setQuestionTitle($question_gui->object->getTitle());
     $headerBlockBuilder->setQuestionPoints($question_gui->object->getPoints());
     $headerBlockBuilder->setQuestionPosition($this->testSequence->getPositionOfSequence($sequence));
     $headerBlockBuilder->setQuestionCount($this->testSequence->getUserQuestionCount());
     $headerBlockBuilder->setQuestionPostponed($this->testSequence->isPostponedQuestion($questionId));
     $headerBlockBuilder->setQuestionObligatory($this->object->areObligationsEnabled() && ilObjTest::isQuestionObligatory($this->object->getId()));
     if ($this->testSession->isObjectiveOriented()) {
         require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
         $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->testSession);
         $objectivesAdapter->buildQuestionRelatedObjectiveList($this->testSequence, $this->questionRelatedObjectivesList);
         $this->questionRelatedObjectivesList->loadObjectivesTitles();
         $objectivesString = $this->questionRelatedObjectivesList->getQuestionRelatedObjectiveTitle($questionId);
         $headerBlockBuilder->setQuestionRelatedObjectives($objectivesString);
     }
     $question_gui->setQuestionHeaderBlockBuilder($headerBlockBuilder);
     // output question
     $user_post_solution = FALSE;
     if (array_key_exists("previouspost", $_SESSION)) {
         $user_post_solution = $_SESSION["previouspost"];
         unset($_SESSION["previouspost"]);
     }
     // Determine $answer_feedback: It should hold a boolean stating if answer-specific-feedback is to be given.
     // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Answer-Specific Feedback"
     // $directfeedback holds a boolean stating if the instant feedback was requested using the "Check" button.
     $answer_feedback = FALSE;
     if ($directfeedback && $this->object->getSpecificAnswerFeedback()) {
         $answer_feedback = TRUE;
     }
     if ($this->testSequence->isQuestionOptional($question_gui->object->getId())) {
         $info = $this->lng->txt('tst_wf_info_optional_question');
         if ($this->object->isFixedTest()) {
             $info .= ' ' . $this->lng->txt('tst_wf_info_answer_adopted_from_prev_pass');
         } else {
             $info .= ' ' . $this->lng->txt('tst_wf_info_answer_not_adopted');
         }
         ilUtil::sendInfo($info);
     }
     if ($this->isParticipantsAnswerFixed($questionId)) {
         $solutionoutput = $question_gui->getSolutionOutput($this->testSession->getActiveId(), NULL, FALSE, false, true, FALSE, false, FALSE, true);
         $pageoutput = $question_gui->outQuestionPage("", $this->testSequence->isPostponedQuestion($questionId), $this->testSession->getActiveId(), $solutionoutput);
         $this->tpl->setVariable("QUESTION_OUTPUT", $pageoutput);
         $this->tpl->setVariable("FORMACTION", $formaction);
         $directfeedback = true;
     } else {
         // Answer specific feedback is rendered into the display of the test question with in the concrete question types outQuestionForTest-method.
         // Notation of the params prior to getting rid of this crap in favor of a class
         $question_gui->outQuestionForTest($formaction, $this->testSession->getActiveId(), NULL, $is_postponed, $user_post_solution, $answer_feedback);
         // The display of specific inline feedback and specific feedback in an own block is to honor questions, which
         // have the possibility to embed the specific feedback into their output while maintaining compatibility to
         // questions, which do not have such facilities. E.g. there can be no "specific inline feedback" for essay
         // questions, while the multiple-choice questions do well.
         $this->fillQuestionRelatedNavigation($question_gui);
     }
     if ($directfeedback) {
         // This controls if the solution should be shown.
         // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Solutions"
         if ($this->object->getInstantFeedbackSolution()) {
             $show_question_inline_score = $this->determineInlineScoreDisplay();
             // Notation of the params prior to getting rid of this crap in favor of a class
             $solutionoutput = $question_gui->getSolutionOutput($this->testSession->getActiveId(), NULL, FALSE, $show_question_inline_score, FALSE, FALSE, TRUE, FALSE, FALSE);
             $this->populateSolutionBlock($solutionoutput);
         }
         // This controls if the score should be shown.
         // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Results (Only Points)"
         if ($this->object->getAnswerFeedbackPoints()) {
             $reachedPoints = $question_gui->object->getAdjustedReachedPoints($this->testSession->getActiveId(), NULL);
             $maxPoints = $question_gui->object->getMaximumPoints();
             $this->populateScoreBlock($reachedPoints, $maxPoints);
         }
         // This controls if the generic feedback should be shown.
         // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Solutions"
         if ($this->object->getGenericAnswerFeedback()) {
             $this->populateGenericFeedbackBlock($question_gui);
         }
         // This controls if the specific feedback should be shown.
         // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Answer-Specific Feedback"
         if ($this->object->getSpecificAnswerFeedback()) {
             $this->populateSpecificFeedbackBlock($question_gui);
         }
     }
     $this->populatePreviousButtons($sequence);
     if ($postpone_allowed && !$is_postponed) {
         $this->populatePostponeButtons();
     }
     if ($this->object->getListOfQuestions()) {
         $this->populateSummaryButtons();
     }
     if ($this->object->getShowCancel()) {
         $this->populateCancelButtonBlock();
     }
     if ($this->isLastQuestionInSequence($question_gui)) {
         if ($this->object->getListOfQuestionsEnd()) {
             $this->populateNextButtonsLeadingToSummary();
         } else {
             $this->populateNextButtonsLeadingToEndOfTest();
         }
     } else {
         $this->populateNextButtonsLeadingToQuestion();
     }
     if ($this->object->getShowMarker()) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $solved_array = ilObjTest::_getSolvedQuestions($this->testSession->getActiveId(), $question_gui->object->getId());
         $solved = 0;
         if (count($solved_array) > 0) {
             $solved = array_pop($solved_array);
             $solved = $solved["solved"];
         }
         if ($solved == 1) {
             $this->populateQuestionMarkingBlockAsMarked();
         } else {
             $this->populateQuestionMarkingBlockAsUnmarked();
         }
     }
     $this->populateCharSelector();
     if ($this->object->getJavaScriptOutput()) {
         $this->tpl->setVariable("JAVASCRIPT_TITLE", $this->lng->txt("disable_javascript"));
         $this->ctrl->setParameter($this, "tst_javascript", "0");
         $this->tpl->setVariable("JAVASCRIPT_URL", $this->ctrl->getLinkTarget($this, "gotoQuestion"));
     } else {
         $this->tpl->setVariable("JAVASCRIPT_TITLE", $this->lng->txt("enable_javascript"));
         $this->ctrl->setParameter($this, "tst_javascript", "1");
         $this->tpl->setVariable("JAVASCRIPT_URL", $this->ctrl->getLinkTarget($this, "gotoQuestion"));
     }
     if ($question_gui->object->supportsJavascriptOutput()) {
         $this->tpl->touchBlock("jsswitch");
     }
     $this->tpl->addJavaScript(ilUtil::getJSLocation("autosave.js", "Modules/Test"));
     $this->tpl->setVariable("AUTOSAVE_URL", $this->ctrl->getFormAction($this, "autosave", "", true));
     if ($question_gui->isAutosaveable() && $this->object->getAutosave()) {
         $this->tpl->touchBlock('autosave');
         //$this->tpl->setVariable("BTN_SAVE", "Zwischenspeichern");
         //$this->tpl->setVariable("CMD_SAVE", "gotoquestion_{$sequence}");
         //$this->tpl->setVariable("AUTOSAVEFORMACTION", str_replace("&", "&", $this->ctrl->getFormAction($this)));
         $this->tpl->setVariable("AUTOSAVEFORMACTION", str_replace("&", "&", $this->ctrl->getLinkTarget($this, "autosave")));
         $this->tpl->setVariable("AUTOSAVEINTERVAL", $this->object->getAutosaveIval());
     }
     if ($this->object->areObligationsEnabled() && ilObjTest::isQuestionObligatory($question_gui->object->getId())) {
         $this->tpl->touchBlock('question_obligatory');
         $this->tpl->setVariable('QUESTION_OBLIGATORY', $this->lng->txt('required_field'));
     }
 }