private function initTestQuestionData() { foreach ($this->testOBJ->getTestQuestions() as $question) { $this->questions[] = $question['question_id']; $this->maxPointsByQuestion[$question['question_id']] = $question['points']; } }
private function isTestQuestion($questionId) { foreach ($this->testOBJ->getTestQuestions() as $question) { if ($question['question_id'] == $questionId) { return true; } } return false; }
protected function questionsObject() { /** @var $ilAccess ilAccessHandler */ global $ilAccess; if (!$ilAccess->checkAccess("write", "", $this->ref_id)) { // allow only write access ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true); $this->ctrl->redirect($this, "infoScreen"); } if ($_GET['browse']) { exit('Browse??'); return $this->object->questionbrowser(); } if ($_GET["eqid"] && $_GET["eqpl"]) { $this->ctrl->setParameter($this, 'q_id', $_GET["eqid"]); $this->ctrl->setParameter($this, 'qpl_id', $_GET["eqpl"]); $this->ctrl->redirect($this, 'adjustscoringfortest'); } $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test"); $this->tpl->setCurrentBlock("adm_content"); include_once "./Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php"; $checked_move = is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()]) && count($_SESSION['tst_qst_move_' . $this->object->getTestId()]); $table_gui = new ilTestQuestionsTableGUI($this, 'showquestionlist', $ilAccess->checkAccess("write", "", $this->ref_id) ? true : false, $checked_move, 0); $data = $this->object->getTestQuestions(); // @TODO Ask object for random test. if (!$data) { $this->object->getPotentialRandomTestQuestions(); } $filtered_data = array(); foreach ($data as $question) { $question_object = assQuestion::instantiateQuestionGUI($question['question_id']); if ($this->supportsAdjustment($question_object) && $this->allowedInAdjustment($question_object)) { $filtered_data[] = $question; } } $table_gui->setData($filtered_data); $table_gui->clearActionButtons(); $table_gui->clearCommandButtons(); $table_gui->multi = array(); $table_gui->setRowTemplate('tpl.il_as_tst_adjust_questions_row.html', 'Modules/Test'); $table_gui->header_commands = array(); $table_gui->setSelectAllCheckbox(null); $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML()); $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this, 'showquestionlist')); $this->tpl->parseCurrentBlock(); }
function questionsObject() { global $ilAccess, $ilTabs; $ilTabs->activateTab('assQuestions'); // #12590 $this->ctrl->setParameter($this, 'test_express_mode', ''); if (!$ilAccess->checkAccess("write", "", $this->ref_id)) { // allow only write access ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true); $this->ctrl->redirect($this, "infoScreen"); } if ($_GET['browse']) { return $this->questionbrowser(); } $this->getQuestionsSubTabs(); // #11631, #12994 $this->ctrl->setParameter($this, 'q_id', ''); if ($_GET["eqid"] && $_GET["eqpl"]) { ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=" . $_GET["ref_id"] . "&q_id=" . $_GET["eqid"]); } if ($_GET["up"] > 0) { $this->object->questionMoveUp($_GET["up"]); } if ($_GET["down"] > 0) { $this->object->questionMoveDown($_GET["down"]); } if ($_GET["add"]) { $selected_array = array(); array_push($selected_array, $_GET["add"]); $total = $this->object->evalTotalPersons(); if ($total) { // the test was executed previously ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total)); } else { ilUtil::sendInfo($this->lng->txt("tst_insert_questions")); } $this->insertQuestions($selected_array); return; } $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test"); $total = $this->object->evalTotalPersons(); if ($ilAccess->checkAccess("write", "", $this->ref_id)) { if ($total != 0) { $link = $this->ctrl->getLinkTarget($this, "participants"); $link = "<a href=\"" . $link . "\">" . $this->lng->txt("test_has_datasets_warning_page_view_link") . "</a>"; ilUtil::sendInfo($this->lng->txt("test_has_datasets_warning_page_view") . " " . $link); } else { global $ilToolbar; $ilToolbar->addButton($this->lng->txt("ass_create_question"), $this->ctrl->getLinkTarget($this, "addQuestion")); if ($this->object->getPoolUsage()) { $ilToolbar->addSeparator(); require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php'; $this->populateQuestionBrowserToolbarButtons($ilToolbar, ilTestQuestionBrowserTableGUI::CONTEXT_LIST_VIEW); } $ilToolbar->addSeparator(); $ilToolbar->addButton($this->lng->txt("random_selection"), $this->ctrl->getLinkTarget($this, "randomselect")); global $ilAccess, $ilUser, $lng, $ilCtrl; $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(); $testSequence = $this->testSequenceFactory->getSequenceByTestSession($testSession); $testPlayerGUI = $this->testPlayerFactory->getPlayerGUI(); $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = TRUE); if ($executable["executable"]) { if ($testSession->getActiveId() > 0) { // resume test if ($testSequence->hasStarted($testSession)) { $execTestLabel = $this->lng->txt("tst_resume_test"); $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'resumePlayer'); } else { $execTestLabel = $this->object->getStartTestLabel($testSession->getActiveId()); $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'startPlayer'); } } else { // start new test $execTestLabel = $this->object->getStartTestLabel($testSession->getActiveId()); $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'startPlayer'); } $ilToolbar->addSeparator(); $ilToolbar->addButton($execTestLabel, $execTestLink); } } } } } $this->tpl->setCurrentBlock("adm_content"); include_once "./Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php"; $checked_move = is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()]) && count($_SESSION['tst_qst_move_' . $this->object->getTestId()]); $table_gui = new ilTestQuestionsTableGUI($this, 'questions', $ilAccess->checkAccess("write", "", $this->ref_id) ? true : false, $checked_move, $total); $data = $this->object->getTestQuestions(); $table_gui->setData($data); $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML()); $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this)); $this->tpl->parseCurrentBlock(); }
function questionsObject() { global $ilAccess, $ilTabs; $ilTabs->activateTab('assQuestions'); if (!$ilAccess->checkAccess("write", "", $this->ref_id)) { // allow only write access ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true); $this->ctrl->redirect($this, "infoScreen"); } if ($_GET['browse']) { return $this->questionbrowser(); } $this->getQuestionsSubTabs(); if ($this->object->isRandomTest()) { $this->randomQuestionsObject(); return; } if ($_GET["eqid"] && $_GET["eqpl"]) { ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=" . $_GET["ref_id"] . "&q_id=" . $_GET["eqid"]); } if ($_GET["up"] > 0) { $this->object->questionMoveUp($_GET["up"]); } if ($_GET["down"] > 0) { $this->object->questionMoveDown($_GET["down"]); } if ($_GET["add"]) { $selected_array = array(); array_push($selected_array, $_GET["add"]); $total = $this->object->evalTotalPersons(); if ($total) { // the test was executed previously ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total)); } else { ilUtil::sendInfo($this->lng->txt("tst_insert_questions")); } $this->insertQuestions($selected_array); return; } $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test"); $total = $this->object->evalTotalPersons(); if ($ilAccess->checkAccess("write", "", $this->ref_id)) { if ($total != 0) { $link = $this->ctrl->getLinkTarget($this, "participants"); $link = "<a href=\"" . $link . "\">" . $this->lng->txt("test_has_datasets_warning_page_view_link") . "</a>"; ilUtil::sendInfo($this->lng->txt("test_has_datasets_warning_page_view") . " " . $link); } else { global $ilToolbar; $qtypes = array(); include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php"; foreach (ilObjQuestionPool::_getQuestionTypes(false, true) as $trans => $data) { $qtypes[$data['type_tag']] = $trans; } $ilToolbar->setFormAction($this->ctrl->getFormAction($this)); include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $types = new ilSelectInputGUI($this->lng->txt("create_new"), "sel_question_types"); $types->setOptions($qtypes); $ilToolbar->addInputItem($types); $ilToolbar->addFormButton($this->lng->txt("test_create_question"), "createQuestion"); if ($this->object->getPoolUsage()) { $ilToolbar->addSeparator(); $ilToolbar->addButton($this->lng->txt("tst_browse_for_questions"), $this->ctrl->getLinkTarget($this, 'browseForQuestions')); } $ilToolbar->addSeparator(); $ilToolbar->addButton($this->lng->txt("random_selection"), $this->ctrl->getLinkTarget($this, "randomselect")); global $ilAccess, $ilUser, $lng, $ilCtrl; $seq = $this->object->getTestSession()->getLastSequence(); $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()) { if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) { $executable = $this->object->isExecutable($ilUser->getId(), $allowPassIncrease = TRUE); if ($executable["executable"]) { if ($this->object->getTestSession()->getActiveId() > 0) { $ilToolbar->addSeparator(); $ilToolbar->addButton($lng->txt('tst_resume_test'), $ilCtrl->getLinkTargetByClass('iltestoutputgui', 'resume')); } else { $ilToolbar->addSeparator(); $ilToolbar->addButton($lng->txt('tst_start_test'), $ilCtrl->getLinkTargetByClass('iltestoutputgui', 'startTest')); } } } } } } $this->tpl->setCurrentBlock("adm_content"); include_once "./Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php"; $checked_move = is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()]) && count($_SESSION['tst_qst_move_' . $this->object->getTestId()]); $table_gui = new ilTestQuestionsTableGUI($this, 'questions', $ilAccess->checkAccess("write", "", $this->ref_id) ? true : false, $checked_move, $total); $data = $this->object->getTestQuestions(); $table_gui->setData($data); $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML()); $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this)); $this->tpl->parseCurrentBlock(); }