protected function getTestSequence($activeId, $pass)
 {
     $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($activeId, $pass);
     $testSequence->loadFromDb();
     $testSequence->loadQuestions();
     $testSequence->setConsiderHiddenQuestionsEnabled(true);
     $testSequence->setConsiderOptionalQuestionsEnabled(true);
     return $testSequence;
 }
 /**
  * execute command
  */
 function executeCommand()
 {
     global $ilDB, $lng, $ilPluginAdmin, $ilTabs, $tree;
     $ilTabs->clearTargets();
     $this->ctrl->saveParameter($this, "sequence");
     $this->ctrl->saveParameter($this, "active_id");
     $this->initAssessmentSettings();
     require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfig.php';
     $this->dynamicQuestionSetConfig = new ilObjTestDynamicQuestionSetConfig($tree, $ilDB, $ilPluginAdmin, $this->object);
     $this->dynamicQuestionSetConfig->loadFromDb();
     $testSessionFactory = new ilTestSessionFactory($this->object);
     $this->testSession = $testSessionFactory->getSession($_GET['active_id']);
     $this->ensureExistingTestSession($this->testSession);
     $this->initProcessLocker($this->testSession->getActiveId());
     $testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this->object);
     $this->testSequence = $testSequenceFactory->getSequenceByTestSession($this->testSession);
     $this->testSequence->loadFromDb();
     include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
     iljQueryUtil::initjQuery();
     include_once "./Services/YUI/classes/class.ilYuiUtil.php";
     ilYuiUtil::initConnectionWithAnimation();
     if ($this->object->getKioskMode()) {
         include_once 'Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php';
         ilOverlayGUI::initJavascript();
     }
     $this->handlePasswordProtectionRedirect();
     $cmd = $this->ctrl->getCmd();
     $nextClass = $this->ctrl->getNextClass($this);
     switch ($nextClass) {
         case 'ilassquestionpagegui':
             $questionId = $this->testSequence->getQuestionForSequence($this->calculateSequence());
             require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php";
             $page_gui = new ilAssQuestionPageGUI($questionId);
             $ret = $this->ctrl->forwardCommand($page_gui);
             break;
         case 'ilassquestionhintrequestgui':
             $questionGUI = $this->object->createQuestionGUI("", $this->testSequenceFactory->getSequenceByTestSession()->getQuestionForSequence($this->calculateSequence()));
             require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintRequestGUI.php';
             $gui = new ilAssQuestionHintRequestGUI($this, self::CMD_SHOW_QUESTION, $this->testSession, $questionGUI);
             $this->ctrl->forwardCommand($gui);
             break;
         case 'ildynamicquestionsetstatistictablegui':
             $this->ctrl->forwardCommand($this->buildQuestionSetFilteredStatisticTableGUI());
             break;
         case 'iltestpasswordprotectiongui':
             require_once 'Modules/Test/classes/class.ilTestPasswordProtectionGUI.php';
             $gui = new ilTestPasswordProtectionGUI($this->ctrl, $this->tpl, $this->lng, $this, $this->passwordChecker);
             $ret = $this->ctrl->forwardCommand($gui);
             break;
         default:
             $cmd .= 'Cmd';
             $ret =& $this->{$cmd}();
             break;
     }
     return $ret;
 }
 /**
  * execute command
  */
 function executeCommand()
 {
     global $ilDB, $lng, $ilPluginAdmin, $ilTabs, $tree;
     $ilTabs->clearTargets();
     $this->ctrl->saveParameter($this, "sequence");
     $this->ctrl->saveParameter($this, "active_id");
     require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfig.php';
     $this->dynamicQuestionSetConfig = new ilObjTestDynamicQuestionSetConfig($tree, $ilDB, $ilPluginAdmin, $this->object);
     $this->dynamicQuestionSetConfig->loadFromDb();
     $testSessionFactory = new ilTestSessionFactory($this->object);
     $this->testSession = $testSessionFactory->getSession($_GET['active_id']);
     $testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this->object);
     $this->testSequence = $testSequenceFactory->getSequence($this->testSession);
     $this->testSequence->loadFromDb();
     include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
     iljQueryUtil::initjQuery();
     include_once "./Services/YUI/classes/class.ilYuiUtil.php";
     ilYuiUtil::initConnectionWithAnimation();
     if ($this->object->getKioskMode()) {
         include_once 'Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php';
         ilOverlayGUI::initJavascript();
     }
     $cmd = $this->ctrl->getCmd();
     $nextClass = $this->ctrl->getNextClass($this);
     switch ($nextClass) {
         case 'ilassquestionhintrequestgui':
             $questionGUI = $this->object->createQuestionGUI("", $this->testSequenceFactory->getSequence()->getQuestionForSequence($this->calculateSequence()));
             require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintRequestGUI.php';
             $gui = new ilAssQuestionHintRequestGUI($this, $this->testSession, $questionGUI);
             $this->ctrl->forwardCommand($gui);
             break;
         case 'ilfilteredquestionstablegui':
             $this->ctrl->forwardCommand($this->buildFilteredQuestionsTableGUI());
             break;
         default:
             $cmd .= 'Cmd';
             $ret =& $this->{$cmd}();
             break;
     }
     return $ret;
 }
 /**
  * Creates an output of the solution of an answer compared to the correct solution
  *
  * @access public
  */
 protected function outCorrectSolution()
 {
     if (!$this->object->getShowSolutionDetails()) {
         ilUtil::sendInfo($this->lng->txt("no_permission"), true);
         $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
     }
     $testSession = $this->testSessionFactory->getSession();
     $activeId = $testSession->getActiveId();
     if (!($activeId > 0)) {
         $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
     }
     $this->ctrl->saveParameter($this, "pass");
     $pass = (int) $_GET['pass'];
     $questionId = (int) $_GET['evaluation'];
     if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
         $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($activeId, $pass);
         $testSequence->loadFromDb();
         $testSequence->loadQuestions();
         require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
         $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession);
         $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
         $objectivesList->loadObjectivesTitles();
     } else {
         $objectivesList = null;
     }
     global $ilTabs;
     if ($this instanceof ilTestEvalObjectiveOrientedGUI) {
         $ilTabs->setBackTarget($this->lng->txt("tst_back_to_virtual_pass"), $this->ctrl->getLinkTarget($this, 'showVirtualPass'));
     } else {
         $ilTabs->setBackTarget($this->lng->txt("tst_back_to_pass_details"), $this->ctrl->getLinkTarget($this, 'outUserPassDetails'));
     }
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $this->tpl->setCurrentBlock("ContentStyle");
     $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
     $this->tpl->parseCurrentBlock();
     $this->tpl->setCurrentBlock("SyntaxStyle");
     $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
     $this->tpl->parseCurrentBlock();
     $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
     if ($this->object->getShowSolutionAnswersOnly()) {
         $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
     }
     $solution = $this->getCorrectSolutionOutput($questionId, $activeId, $pass, $objectivesList);
     $this->tpl->setContent($solution);
 }
Beispiel #5
0
 public static function isParticipantsLastPassActive($testRefId, $userId)
 {
     global $ilDB, $lng, $ilPluginAdmin;
     /* @var ilObjTest $testOBJ */
     $testOBJ = ilObjectFactory::getInstanceByRefId($testRefId, false);
     $activeId = $testOBJ->getActiveIdOfUser($userId);
     require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
     $testSessionFactory = new ilTestSessionFactory($testOBJ);
     // Added temporarily bugfix smeyer
     $testSessionFactory->reset();
     require_once 'Modules/Test/classes/class.ilTestSequenceFactory.php';
     $testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $testOBJ);
     $testSession = $testSessionFactory->getSession($activeId);
     $testSequence = $testSequenceFactory->getSequenceByActiveIdAndPass($activeId, $testSession->getPass());
     $testSequence->loadFromDb();
     return $testSequence->hasSequence();
 }
Beispiel #6
0
 /**
  * show information screen
  */
 function infoScreen($session_lock = "")
 {
     /**
      * @var $ilAccess  ilAccessHandler
      * @var $ilUser    ilObjUser
      * @var $ilToolbar ilToolbarGUI
      */
     global $ilAccess, $ilUser, $ilToolbar;
     require_once 'Modules/Test/classes/class.ilTestDynamicQuestionSetFilterSelection.php';
     $testQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
     $testSession = $this->testSessionFactory->getSession();
     $testSequence = $this->testSequenceFactory->getSequenceByTestSession($testSession);
     $testSequence->loadFromDb();
     $testSequence->loadQuestions($testQuestionSetConfig, new ilTestDynamicQuestionSetFilterSelection());
     $testPlayerGUI = $this->testPlayerFactory->getPlayerGUI();
     if ($_GET['createRandomSolutions']) {
         $this->object->createRandomSolutions($_GET['createRandomSolutions']);
     }
     if (!$ilAccess->checkAccess("read", "", $this->ref_id)) {
         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"), $this->ilias->error_obj->MESSAGE);
     }
     include_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php";
     $info = new ilInfoScreenGUI($this);
     $this->ctrl->setParameter($testPlayerGUI, "sequence", $testSession->getLastSequence());
     $info->setFormAction($this->ctrl->getFormAction($testPlayerGUI));
     if (strlen($session_lock)) {
         $info->addHiddenElement("lock", $session_lock);
     } else {
         $info->addHiddenElement("lock", md5($_COOKIE['PHPSESSID'] . time()));
     }
     $online_access = false;
     if ($this->object->getFixedParticipants()) {
         include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
         $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
         if ($online_access_result === true) {
             $online_access = true;
         } else {
             ilUtil::sendInfo($online_access_result);
         }
     }
     $enter_anonymous_code = false;
     if ($this->object->isOnline() && $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig())) {
         if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) {
             $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = TRUE);
             if ($executable["executable"]) {
                 if ($this->object->areObligationsEnabled() && $this->object->hasObligations($this->object->getTestId())) {
                     ilUtil::sendInfo($GLOBALS['lng']->txt('tst_test_contains_obligatory_questions'));
                 }
                 if ($testSession->getActiveId() > 0) {
                     // resume test
                     require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
                     $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
                     $testPassesSelector->setActiveId($testSession->getActiveId());
                     $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
                     $closedPasses = $testPassesSelector->getReportablePasses();
                     $existingPasses = $testPassesSelector->getExistingPasses();
                     if ($existingPasses > $closedPasses) {
                         $resumeTestLabel = $this->lng->txt("tst_resume_test");
                         $big_button[] = array('resumePlayer', $resumeTestLabel, true);
                     } else {
                         $resumeTestLabel = $this->object->getStartTestLabel($testSession->getActiveId());
                         $big_button[] = array('startPlayer', $resumeTestLabel, true);
                     }
                 } else {
                     // start new test
                     $big_button[] = array("startPlayer", $this->object->getStartTestLabel($testSession->getActiveId()), true);
                 }
             } else {
                 ilUtil::sendInfo($executable["errormessage"]);
             }
             if ($testSession->getActiveId() > 0) {
                 // test results button
                 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
                 $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
                 $testPassesSelector->setActiveId($testSession->getActiveId());
                 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
                 if ($this->object->canShowTestResults($testSession, $ilUser->getId()) && count($testPassesSelector->getReportablePasses())) {
                     //$info->addFormButton("outUserResultsOverview", $this->lng->txt("tst_show_results"));
                     $big_button[] = array(array('ilTestEvaluationGUI', 'outUserResultsOverview'), $this->lng->txt("tst_show_results"), false);
                     if ($this->object->getHighscoreEnabled()) {
                         // Can also compare results then
                         $big_button[] = array("outResultsToplist", $this->lng->txt("tst_show_toplist"), false);
                     }
                     if ($this->object->isSkillServiceToBeConsidered()) {
                         require_once 'Modules/Test/classes/class.ilTestSkillEvaluationGUI.php';
                         $big_button[] = array(array('ilTestSkillEvaluationGUI', ilTestSkillEvaluationGUI::CMD_SHOW), $this->lng->txt("tst_show_comp_results"), false);
                     }
                 }
             }
         }
         if ($testSession->getActiveId() > 0) {
             if ($this->object->canShowSolutionPrintview($ilUser->getId())) {
                 //$info->addFormButton("outUserListOfAnswerPasses", $this->lng->txt("tst_list_of_answers_show"));
                 $big_button[] = array("outUserListOfAnswerPasses", $this->lng->txt("tst_list_of_answers_show"), false);
             }
         }
         if ($this->isDeleteDynamicTestResultsButtonRequired($testSession, $testSequence)) {
             $this->populateDeleteDynamicTestResultsButton($testSession, $big_button);
         }
         if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID) {
             $enter_anonymous_code = true;
         }
     }
     if (!$this->object->isOnline()) {
         $message = $this->lng->txt("test_is_offline");
         if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
             $message .= "<br /><a href=\"" . $this->ctrl->getLinkTargetByClass('ilobjtestsettingsgeneralgui') . "\">" . $this->lng->txt("test_edit_settings") . "</a>";
         }
         ilUtil::sendInfo($message);
     }
     if ($this->areSkillLevelThresholdsMissing()) {
         ilUtil::sendFailure($this->getSkillLevelThresholdsMissingInfo());
     }
     if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
         $testQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
         if ($testQuestionSetConfig->areDepenciesBroken()) {
             ilUtil::sendFailure($testQuestionSetConfig->getDepenciesBrokenMessage($this->lng));
             $big_button = array();
             $enter_anonymous_code = false;
         } elseif ($testQuestionSetConfig->areDepenciesInVulnerableState()) {
             ilUtil::sendInfo($testQuestionSetConfig->getDepenciesInVulnerableStateMessage($this->lng));
         }
     }
     if ($this->object->getShowInfo()) {
         $info->enablePrivateNotes();
     }
     if ($big_button || $enter_anonymous_code) {
         $ilToolbar->setFormAction($this->ctrl->getFormAction($testPlayerGUI));
         foreach ($big_button as $button) {
             if (is_array($button[0])) {
                 $link = $this->ctrl->getLinkTargetByClass($button[0][0], $button[0][1]);
                 $ilToolbar->addButton($button[1], $link, '', '', '', '', $button[2] ? 'submit emphSubmit' : 'submit');
             } else {
                 $ilToolbar->addFormButton($button[1], $button[0], "", $button[2]);
             }
         }
         if ($enter_anonymous_code) {
             if ($big_button) {
                 $ilToolbar->addSeparator();
             }
             require_once 'Services/Form/classes/class.ilTextInputGUI.php';
             $anonymous_id = new ilTextInputGUI($this->lng->txt('enter_anonymous_code'), 'anonymous_id');
             $anonymous_id->setSize(8);
             $ilToolbar->addInputItem($anonymous_id, true);
             $ilToolbar->addFormButton($this->lng->txt('submit'), 'setAnonymousId');
         }
         $ilToolbar->setCloseFormTag(false);
         $info->setOpenFormTag(false);
     }
     if (strlen($this->object->getIntroduction())) {
         $info->addSection($this->lng->txt("tst_introduction"));
         $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction(), true) . $info->getHiddenToggleButton());
     } else {
         $info->addSection("");
         $info->addProperty("", $info->getHiddenToggleButton());
     }
     $info->addSection($this->lng->txt("tst_general_properties"));
     if ($this->object->getShowInfo()) {
         $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
         $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
     }
     if ($this->object->isOnline() && $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig())) {
         if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) {
             if ($this->object->getShowInfo() || !$this->object->getForceJS()) {
                 // use javascript
                 $checked_javascript = false;
                 if ($this->object->getJavaScriptOutput()) {
                     $checked_javascript = true;
                 }
             }
             // hide previous results
             if (!$this->object->isRandomTest() && !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
                 if ($this->object->getNrOfTries() != 1) {
                     if ($this->object->getUsePreviousAnswers() == 0) {
                         if ($this->object->getShowInfo()) {
                             $info->addProperty($this->lng->txt("tst_use_previous_answers"), $this->lng->txt("tst_dont_use_previous_answers"));
                         }
                     } else {
                         $use_previous_answers = FALSE;
                         if ($ilUser->prefs["tst_use_previous_answers"]) {
                             $checked_previous_answers = TRUE;
                         }
                         $info->addPropertyCheckbox($this->lng->txt("tst_use_previous_answers"), "chb_use_previous_answers", 1, $this->lng->txt("tst_use_previous_answers_user"), $checked_previous_answers);
                     }
                 }
             }
         }
     }
     $info->hideFurtherSections(false);
     if ($this->object->getShowInfo()) {
         $info->addSection($this->lng->txt("tst_sequence_properties"));
         $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE ? "tst_sequence_fixed" : "tst_sequence_postpone"));
         $info->addSection($this->lng->txt("tst_heading_scoring"));
         $info->addProperty($this->lng->txt("tst_text_count_system"), $this->lng->txt($this->object->getCountSystem() == COUNT_PARTIAL_SOLUTIONS ? "tst_count_partial_solutions" : "tst_count_correct_solutions"));
         $info->addProperty($this->lng->txt("tst_score_mcmr_questions"), $this->lng->txt($this->object->getMCScoring() == SCORE_ZERO_POINTS_WHEN_UNANSWERED ? "tst_score_mcmr_zero_points_when_unanswered" : "tst_score_mcmr_use_scoring_system"));
         if ($this->object->isRandomTest()) {
             $info->addProperty($this->lng->txt("tst_pass_scoring"), $this->lng->txt($this->object->getPassScoring() == SCORE_BEST_PASS ? "tst_pass_best_pass" : "tst_pass_last_pass"));
         }
         $info->addSection($this->lng->txt("tst_score_reporting"));
         $score_reporting_text = "";
         switch ($this->object->getScoreReporting()) {
             case REPORT_AFTER_TEST:
                 $score_reporting_text = $this->lng->txt("tst_report_after_test");
                 break;
             case REPORT_ALWAYS:
                 $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
                 break;
             case REPORT_AFTER_DATE:
                 $score_reporting_text = $this->lng->txt("tst_report_after_date");
                 break;
             case 4:
                 $score_reporting_text = $this->lng->txt("tst_report_never");
                 break;
         }
         $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text);
         $reporting_date = $this->object->getReportingDate();
         if ($reporting_date) {
             #preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
             #$txt_reporting_date = date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]));
             #$info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
             $info->addProperty($this->lng->txt('tst_score_reporting_date'), ilDatePresentation::formatDate(new ilDateTime($reporting_date, IL_CAL_TIMESTAMP)));
         }
         $info->addSection($this->lng->txt("tst_session_settings"));
         $info->addProperty($this->lng->txt("tst_nr_of_tries"), $this->object->getNrOfTries() == 0 ? $this->lng->txt("unlimited") : $this->object->getNrOfTries());
         if ($this->object->getNrOfTries() != 1) {
             $info->addProperty($this->lng->txt("tst_nr_of_tries_of_user"), $testSession->getPass() == false ? $this->lng->txt("tst_no_tries") : $testSession->getPass());
         }
         if ($this->object->getEnableProcessingTime()) {
             $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
         }
         if (strlen($this->object->getAllowedUsers()) && $this->object->getAllowedUsersTimeGap()) {
             $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
         }
         $starting_time = $this->object->getStartingTime();
         if ($starting_time) {
             $info->addProperty($this->lng->txt("tst_starting_time"), ilDatePresentation::formatDate(new ilDateTime($starting_time, IL_CAL_TIMESTAMP)));
         }
         $ending_time = $this->object->getEndingTime();
         if ($ending_time) {
             $info->addProperty($this->lng->txt("tst_ending_time"), ilDatePresentation::formatDate(new ilDateTime($ending_time, IL_CAL_TIMESTAMP)));
         }
         $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
         // forward the command
     }
     $this->ctrl->forwardCommand($info);
 }
 /**
  * Execute Command
  */
 public function executeCommand()
 {
     global $ilUser, $ilDB, $ilPluginAdmin, $lng, $ilTabs;
     $ilTabs->clearTargets();
     $cmd = $this->ctrl->getCmd();
     $next_class = $this->ctrl->getNextClass($this);
     $this->ctrl->saveParameter($this, "sequence");
     $this->ctrl->saveParameter($this, "active_id");
     if (preg_match("/^gotoquestion_(\\d+)\$/", $cmd, $matches)) {
         $cmd = "gotoquestion";
         if (strlen($matches[1])) {
             $this->ctrl->setParameter($this, 'gotosequence', $matches[1]);
         }
     }
     $testSessionFactory = new ilTestSessionFactory($this->object);
     $this->testSession = $testSessionFactory->getSession($_GET['active_id']);
     $this->ensureExistingTestSession($this->testSession);
     $this->initProcessLocker($this->testSession->getActiveId());
     $testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this->object);
     $this->testSequence = $testSequenceFactory->getSequence($this->testSession);
     $this->testSequence->loadFromDb();
     $this->testSequence->loadQuestions();
     include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
     iljQueryUtil::initjQuery();
     include_once "./Services/YUI/classes/class.ilYuiUtil.php";
     ilYuiUtil::initConnectionWithAnimation();
     $this->handlePasswordProtectionRedirect();
     $cmd = $this->getCommand($cmd);
     switch ($next_class) {
         case 'ilassquestionpagegui':
             $questionId = $this->testSequence->getQuestionForSequence($this->calculateSequence());
             require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php";
             $page_gui = new ilAssQuestionPageGUI($questionId);
             $ret = $this->ctrl->forwardCommand($page_gui);
             break;
         case 'iltestsubmissionreviewgui':
             require_once './Modules/Test/classes/class.ilTestSubmissionReviewGUI.php';
             $gui = new ilTestSubmissionReviewGUI($this, $this->object, $this->testSession);
             $ret = $this->ctrl->forwardCommand($gui);
             break;
         case 'ilassquestionhintrequestgui':
             $questionGUI = $this->object->createQuestionGUI("", $this->testSequence->getQuestionForSequence($this->calculateSequence()));
             require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
             $questionHintTracking = new ilAssQuestionHintTracking($questionGUI->object->getId(), $this->testSession->getActiveId(), $this->testSession->getPass());
             require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintRequestGUI.php';
             $gui = new ilAssQuestionHintRequestGUI($this, 'redirectQuestion', $questionGUI, $questionHintTracking);
             $ret = $this->ctrl->forwardCommand($gui);
             break;
         case 'iltestsignaturegui':
             require_once './Modules/Test/classes/class.ilTestSignatureGUI.php';
             $gui = new ilTestSignatureGUI($this);
             $ret = $this->ctrl->forwardCommand($gui);
             break;
         case 'iltestpasswordprotectiongui':
             require_once 'Modules/Test/classes/class.ilTestPasswordProtectionGUI.php';
             $gui = new ilTestPasswordProtectionGUI($this->ctrl, $this->tpl, $this->lng, $this, $this->passwordChecker);
             $ret = $this->ctrl->forwardCommand($gui);
             break;
         default:
             $cmd .= 'Cmd';
             $ret =& $this->{$cmd}();
             break;
     }
     return $ret;
 }
 /**
 * Retrieves the number of answered questions for a given user in a given test
 *
 * @param integer $user_id The user id
 * @param integer $test_id The test id
 * @param integer $pass The pass of the test (optional)
 * @return integer The number of answered questions
 * @access public
 */
 function getAnsweredQuestionCount($active_id, $pass = NULL)
 {
     if ($this->isDynamicTest()) {
         global $tree, $ilDB, $lng, $ilPluginAdmin;
         require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
         $testSessionFactory = new ilTestSessionFactory($this);
         $testSession = $testSessionFactory->getSession($active_id);
         require_once 'Modules/Test/classes/class.ilTestSequenceFactory.php';
         $testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this);
         $testSequence = $testSequenceFactory->getSequence($testSession);
         require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfig.php';
         $dynamicQuestionSetConfig = new ilObjTestDynamicQuestionSetConfig($tree, $ilDB, $ilPluginAdmin, $this);
         $dynamicQuestionSetConfig->loadFromDb();
         $testSequence->loadFromDb($dynamicQuestionSetConfig);
         $testSequence->loadQuestions($dynamicQuestionSetConfig, array());
         return $testSequence->getTrackedQuestionCount();
     }
     if ($this->isRandomTest()) {
         $this->loadQuestions($active_id, $pass);
     }
     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
     $workedthrough = 0;
     foreach ($this->questions as $value) {
         if (assQuestion::_isWorkedThrough($active_id, $value, $pass)) {
             $workedthrough += 1;
         }
     }
     return $workedthrough;
 }
 /**
  * Execute Command
  */
 public function executeCommand()
 {
     global $ilUser, $ilDB, $ilPluginAdmin, $lng, $ilTabs;
     $ilTabs->clearTargets();
     $cmd = $this->ctrl->getCmd();
     $next_class = $this->ctrl->getNextClass($this);
     $this->ctrl->saveParameter($this, "sequence");
     $this->ctrl->saveParameter($this, "active_id");
     if (preg_match("/^gotoquestion_(\\d+)\$/", $cmd, $matches)) {
         $cmd = "gotoquestion";
         if (strlen($matches[1])) {
             $this->ctrl->setParameter($this, 'gotosequence', $matches[1]);
         }
     }
     $testSessionFactory = new ilTestSessionFactory($this->object);
     $this->testSession = $testSessionFactory->getSession($_GET['active_id']);
     if (!$this->testSession->getActiveId()) {
         $this->testSession->setUserId($ilUser->getId());
         $this->testSession->setAnonymousId($_SESSION["tst_access_code"][$this->object->getTestId()]);
         $this->testSession->saveToDb();
     }
     $testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this->object);
     $this->testSequence = $testSequenceFactory->getSequence($this->testSession);
     $this->testSequence->loadFromDb();
     $this->testSequence->loadQuestions();
     include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
     iljQueryUtil::initjQuery();
     include_once "./Services/YUI/classes/class.ilYuiUtil.php";
     ilYuiUtil::initConnectionWithAnimation();
     // Ensure that the selector for unicode characters respects the test settings
     // This should be done before ilMainMenu gets the current selector for display
     global $ilSetting;
     if ($ilSetting->get('char_selector_availability') > 0) {
         require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
         ilCharSelectorGUI::_getCurrentGUI($this->object);
     }
     $cmd = $this->getCommand($cmd);
     switch ($next_class) {
         case 'iltestsubmissionreviewgui':
             require_once './Modules/Test/classes/class.ilTestSubmissionReviewGUI.php';
             $gui = new ilTestSubmissionReviewGUI($this, $this->object);
             $ret = $this->ctrl->forwardCommand($gui);
             break;
         case 'ilassquestionhintrequestgui':
             $questionGUI = $this->object->createQuestionGUI("", $this->testSequence->getQuestionForSequence($this->calculateSequence()));
             require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintRequestGUI.php';
             $gui = new ilAssQuestionHintRequestGUI($this, $this->testSession, $questionGUI);
             $ret = $this->ctrl->forwardCommand($gui);
             break;
         case 'iltestsignaturegui':
             require_once './Modules/Test/classes/class.ilTestSignatureGUI.php';
             $gui = new ilTestSignatureGUI($this);
             $ret = $this->ctrl->forwardCommand($gui);
             break;
         default:
             $cmd .= 'Cmd';
             $ret =& $this->{$cmd}();
             break;
     }
     return $ret;
 }