/** * Questions per page * * @param * @return */ function buildPageViewToolbar($qid = 0) { if ($this->create_question_mode) { return; } global $ilToolbar, $ilCtrl, $lng; require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php'; $this->getQuestionsSubTabs(); $ilCtrl->saveParameter($this, 'q_mode'); $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'test_express_mode', 1); $ilCtrl->setParameter($this, 'test_express_mode', 1); $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']); $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']); $ilToolbar->setFormAction($ilCtrl->getFormActionByClass('iltestexpresspageobjectgui', 'edit')); if ($this->object->evalTotalPersons() == 0) { /* include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php'; $pool = new ilObjQuestionPool(); $questionTypes = $pool->getQuestionTypes();$options = array(); foreach($questionTypes as $label => $data) { $options[$data['question_type_id']] = $label; } include_once("./Services/Form/classes/class.ilSelectInputGUI.php"); $si = new ilSelectInputGUI($lng->txt("test_add_new_question"), "qtype"); $si->setOptions($options); $ilToolbar->addInputItem($si, true); /* // use pool if ($this->object->isExpressModeQuestionPoolAllowed()) { include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php"); $cb = new ilCheckboxInputGUI($lng->txt("test_use_pool"), "use_pool"); $ilToolbar->addInputItem($cb, true); } */ $ilToolbar->addFormButton($lng->txt("ass_create_question"), "addQuestion"); $ilToolbar->addSeparator(); if ($this->object->getPoolUsage()) { require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php'; $this->populateQuestionBrowserToolbarButtons($ilToolbar, ilTestQuestionBrowserTableGUI::CONTEXT_PAGE_VIEW); $show_separator = true; } } $questions = $this->object->getQuestionTitlesAndIndexes(); // desc $options = array(); foreach ($questions as $id => $label) { $options[$id] = $label . ' [' . $this->lng->txt('question_id_short') . ': ' . $id . ']'; } $optionKeys = array_keys($options); if (!$options) { $options[] = $lng->txt('none'); } //else if (count($options) > 1) { // $addSeparator = false; // if ($optionKeys[0] != $qid) { // //$ilToolbar->addFormButton($lng->txt("test_prev_question"), "prevQuestion"); // $ilToolbar->addLink($lng->txt("test_prev_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion')); // $addSeparator = true; // } // else { // $ilToolbar->addSpacer(45); // } // // if ($optionKeys[count($optionKeys)-1] != $qid) { // //$ilToolbar->addFormButton($lng->txt("test_next_question"), "nextQuestion"); // $ilToolbar->addLink($lng->txt("test_next_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion')); // $addSeparator = true; // } // else { // $ilToolbar->addSpacer(45); // } // // //if ($addSeparator) { // $ilToolbar->addSeparator(); // //} if (count($questions)) { if (isset($show_separator) && $show_separator) { $ilToolbar->addSeparator(); } $btn = ilLinkButton::getInstance(); $btn->setCaption("test_prev_question"); $btn->setUrl($ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion')); $ilToolbar->addButtonInstance($btn); if (count($options) <= 1 || $optionKeys[0] == $qid) { $btn->setDisabled(true); } $btn = ilLinkButton::getInstance(); $btn->setCaption("test_next_question"); $btn->setUrl($ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion')); $ilToolbar->addButtonInstance($btn); if (count($options) <= 1 || $optionKeys[count($optionKeys) - 1] == $qid) { $btn->setDisabled(true); } } if (count($questions) > 1) { $ilToolbar->addSeparator(); include_once "./Services/Form/classes/class.ilSelectInputGUI.php"; $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id"); $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\""); $si->setOptions($options); if ($qid) { $si->setValue($qid); } $ilToolbar->addInputItem($si, true); } $total = $this->object->evalTotalPersons(); /*if (count($options)) { include_once("./Services/Form/classes/class.ilSelectInputGUI.php"); $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id"); $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\""); $si->setOptions($options); if ($qid) { $si->setValue($qid); } $ilToolbar->addInputItem($si, true); }*/ if (count($questions) && !$total) { $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']); $ilToolbar->addSeparator(); $ilToolbar->addButton($lng->txt("test_delete_page"), $ilCtrl->getLinkTarget($this, "removeQuestions")); } if (count($questions) > 1 && !$total) { $ilToolbar->addSeparator(); $ilToolbar->addButton($lng->txt("test_move_page"), $ilCtrl->getLinkTarget($this, "movePageForm")); } global $ilAccess, $ilUser; $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; } } if ($this->object->isOnline() && $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig())) { if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) { $testSession = $this->testSessionFactory->getSession(); $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = TRUE); if ($executable["executable"]) { $player_factory = new ilTestPlayerFactory($this->object); $player_instance = $player_factory->getPlayerGUI(); if ($testSession->getActiveId() > 0) { $ilToolbar->addSeparator(); $ilToolbar->addButton($lng->txt('tst_resume_test'), $ilCtrl->getLinkTarget($player_instance, 'resumePlayer')); } else { $ilToolbar->addSeparator(); $ilToolbar->addButton($lng->txt('tst_start_test'), $ilCtrl->getLinkTarget($player_instance, 'startTest')); } } } } }
/** * */ protected function redirectLocToTestObject($a_force_new_run = NULL) { $objective_id = (int) $_REQUEST['objective_id']; $test_id = (int) $_REQUEST['tid']; include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php'; include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php'; $res = new ilLOUserResults($this->object->getId(), $GLOBALS['ilUser']->getId()); $passed = $res->getCompletedObjectiveIdsByType(ilLOSettings::getInstanceByObjId($this->object->getId())->getQualifiedTest() == $test_id ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL); if ($objective_id) { $objective_ids = array($objective_id); if (in_array($objective_id, $passed)) { $passed = array(); } } else { include_once './Modules/Course/classes/class.ilCourseObjective.php'; $objective_ids = ilCourseObjective::_getObjectiveIds($this->object->getId(), true); // do not disable objective question if all are passed if (count($objective_ids) == count($passed)) { $passed = array(); } } if (is_null($a_force_new_run)) { $resume_type = $this->handleActivePass($test_id, $objective_id); switch ($resume_type) { case 1: return TRUE; case 2: $a_force_new_run = TRUE; break; case 3: $a_force_new_run = FALSE; break; } } else { include_once './Modules/Test/classes/class.ilObjTest.php'; ilObjTest::ensureParticipantsLastActivePassFinished($test_id, $GLOBALS['ilUser']->getId(), $a_force_new_run); } if ($a_force_new_run === TRUE) { include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php'; ilLOTestRun::deleteRun($this->object->getId(), $GLOBALS['ilUser']->getId(), ilObject::_lookupObjId($test_id)); foreach ((array) $objective_ids as $oid) { if (!in_array($oid, $passed)) { $run = new ilLOTestRun($this->object->getId(), $GLOBALS['ilUser']->getId(), ilObject::_lookupObjId($test_id), $oid); $run->create(); } } } // Redirect to test player include_once './Services/Object/classes/class.ilObjectFactory.php'; $test_obj = ilObjectFactory::getInstanceByObjId(ilObject::_lookupObjId($test_id)); include_once 'Modules/Test/classes/class.ilTestPlayerFactory.php'; $testPlayerFactory = new ilTestPlayerFactory($test_obj); $playerGuiClass = get_class($testPlayerFactory->getPlayerGUI()); $sessionLock = md5($_COOKIE[session_name()] . time()); // do NOT set this into $_SESSION // resume or start new run if (ilObjTest::isParticipantsLastPassActive($test_id, $GLOBALS['ilUser']->getId())) { $test_cmd = 'resumePlayer'; } else { $test_cmd = 'startPlayer'; } $GLOBALS['ilCtrl']->setParameterByClass($playerGuiClass, 'ref_id', $test_id); $GLOBALS['ilCtrl']->setParameterByClass($playerGuiClass, 'crs_show_result', $this->object->getRefId()); $GLOBALS['ilCtrl']->setParameterByClass($playerGuiClass, 'lock', $sessionLock); $GLOBALS['ilCtrl']->redirectByClass(array('ilObjTestGUI', $playerGuiClass), $test_cmd); }