/** * 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')); } } } } }
/** * Render toolbar form * * @param array $a_pages */ protected function renderToolbar($a_pages) { global $ilToolbar, $ilCtrl, $lng, $ilUser; if (!$this->has_datasets) { $ilToolbar->addButton($lng->txt("survey_add_new_question"), $ilCtrl->getLinkTarget($this, "addQuestionToolbarForm")); if ($this->object->isPoolActive()) { $ilToolbar->addSeparator(); $last_on_page = 0; if ($a_pages) { $last_on_page = $a_pages[$this->current_page - 1]; $last_on_page = array_pop($last_on_page); $last_on_page = $last_on_page["question_id"]; } $ilCtrl->setParameter($this->editor_gui, "pgov", $this->current_page); $ilCtrl->setParameter($this->editor_gui, "pgov_pos", $last_on_page . "c"); $cmd = $ilUser->getPref('svy_insert_type') == 1 || strlen($ilUser->getPref('svy_insert_type')) == 0 ? 'browseForQuestions' : 'browseForQuestionblocks'; $ilToolbar->addButton($lng->txt("browse_for_questions"), $ilCtrl->getLinkTarget($this->editor_gui, $cmd)); $ilCtrl->setParameter($this->editor_gui, "pgov", ""); $ilCtrl->setParameter($this->editor_gui, "pgov_pos", ""); } if ($a_pages) { $ilToolbar->addSeparator(); } } // parse data for pages drop-down if ($a_pages) { // previous/next $ilCtrl->setParameter($this, "pg", $this->current_page - 1); $ilToolbar->addLink($lng->txt("survey_prev_question"), $ilCtrl->getLinkTarget($this, "renderPage"), !$this->has_previous_page); $ilCtrl->setParameter($this, "pg", $this->current_page + 1); $ilToolbar->addLink($lng->txt("survey_next_question"), $ilCtrl->getLinkTarget($this, "renderPage"), !$this->has_next_page); $ilCtrl->setParameter($this, "pg", $this->current_page); foreach ($a_pages as $idx => $questions) { $page = $questions; $page = array_shift($page); if ($page["questionblock_id"]) { $pages_drop[$idx + 1] = $page["questionblock_title"]; if (sizeof($questions) > 1) { foreach ($questions as $question) { $pages_drop[$idx + 1 . "__" . $question["question_id"]] = "- " . $question["title"]; } } } else { $pages_drop[$idx + 1] = strip_tags($page["title"]); } } } // jump to page if (sizeof($pages_drop) > 1) { $ilToolbar->addSeparator(); $ilToolbar->setFormAction($ilCtrl->getFormAction($this)); include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $si = new ilSelectInputGUI($lng->txt("survey_jump_to"), "jump"); $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\""); $si->setOptions($pages_drop); $si->setValue($this->current_page); $ilToolbar->addInputItem($si, true); // we need this to have to right cmd $cmd = new ilHiddenInputGUI("cmd[renderPage]"); $cmd->setValue("1"); $ilToolbar->addInputItem($cmd); if (!$this->has_datasets) { $ilToolbar->addSeparator(); $ilCtrl->setParameter($this, "csum", md5(print_r($a_pages[$this->current_page - 1], true))); $ilToolbar->addButton($lng->txt("survey_delete_page"), $ilCtrl->getLinkTarget($this, "deleteBlock")); $ilCtrl->setParameter($this, "csum", ""); $ilToolbar->addSeparator(); $ilToolbar->addButton($lng->txt("survey_move_page"), $ilCtrl->getLinkTarget($this, "movePageForm")); } } }
/** * init form * * @access protected * @param string mode ('edit' | 'create') * @return */ protected function initForm($a_mode, $a_as_milestone = false, $a_edit_single_app = false) { global $ilUser, $tpl; include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; include_once './Services/Calendar/classes/class.ilCalendarRecurrenceGUI.php'; include_once './Services/Calendar/classes/class.ilCalendarCategories.php'; include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; include_once './Services/Calendar/classes/class.ilCalendarCategory.php'; $this->form = new ilPropertyFormGUI(); include_once './Services/YUI/classes/class.ilYuiUtil.php'; ilYuiUtil::initDomEvent(); $resp_info = false; switch ($a_mode) { case 'create': $this->ctrl->saveParameter($this, array('seed', 'idate')); $this->form->setFormAction($this->ctrl->getFormAction($this)); if ($a_as_milestone) { $this->form->setTitle($this->lng->txt('cal_new_ms')); $this->form->addCommandButton('saveMilestone', $this->lng->txt('cal_add_milestone')); $this->form->addCommandButton('cancel', $this->lng->txt('cancel')); } else { $this->form->setTitle($this->lng->txt('cal_new_app')); $this->form->addCommandButton('save', $this->lng->txt('cal_add_appointment')); $this->form->addCommandButton('cancel', $this->lng->txt('cancel')); } break; case 'edit': if ($a_as_milestone) { $this->form->setTitle($this->lng->txt('cal_edit_milestone')); } else { $this->form->setTitle($this->lng->txt('cal_edit_appointment')); } $this->ctrl->saveParameter($this, array('seed', 'app_id', 'idate')); $this->form->setFormAction($this->ctrl->getFormAction($this)); $ass = new ilCalendarCategoryAssignments($this->app->getEntryId()); $cat = $ass->getFirstAssignment(); include_once './Services/Calendar/classes/class.ilCalendarCategory.php'; $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat); $type = ilObject::_lookupType($cat_info['obj_id']); if ($a_as_milestone && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ && ($type == "grp" || $type == "crs")) { $resp_info = true; $this->form->addCommandButton('editResponsibleUsers', $this->lng->txt('cal_change_responsible_users')); } $this->form->addCommandButton('update', $this->lng->txt('save')); // $this->form->addCommandButton('askDelete',$this->lng->txt('delete')); $this->form->addCommandButton('cancel', $this->lng->txt('cancel')); break; } // title $title = new ilTextInputGUI($this->lng->txt('title'), 'title'); $title->setValue($this->app->getTitle()); $title->setRequired(true); $title->setMaxLength(128); $title->setSize(32); $this->form->addItem($title); // calendar selection $calendar = new ilSelectInputGUI($this->lng->txt('cal_category_selection'), 'calendar'); if ($_POST['category']) { $calendar->setValue((int) $_POST['calendar']); $selected_calendar = (int) $_POST['calendar']; } else { if ($_GET['category_id']) { $calendar->setValue((int) $_GET['category_id']); $selected_calendar = (int) $_GET['category_id']; } elseif ($a_mode == 'edit') { $ass = new ilCalendarCategoryAssignments($this->app->getEntryId()); $cat = $ass->getFirstAssignment(); $calendar->setValue($cat); $selected_calendar = $cat; } elseif (isset($_GET['ref_id'])) { include_once './Services/Calendar/classes/class.ilCalendarCategories.php'; $obj_cal = ilObject::_lookupObjId($_GET['ref_id']); $calendar->setValue(ilCalendarCategories::_lookupCategoryIdByObjId($obj_cal)); $selected_calendar = ilCalendarCategories::_lookupCategoryIdByObjId($obj_cal); } } $calendar->setRequired(true); $cats = ilCalendarCategories::_getInstance($ilUser->getId()); $calendar->setOptions($cats->prepareCategoriesOfUserForSelection()); include_once './Services/Calendar/classes/class.ilCalendarSettings.php'; if (ilCalendarSettings::_getInstance()->isNotificationEnabled()) { $notification_cals = $cats->getNotificationCalendars(); $notification_cals = count($notification_cals) ? implode(',', $notification_cals) : ''; $calendar->addCustomAttribute("onchange=\"ilToggleNotification(new Array(" . $notification_cals . "));\""); } $this->form->addItem($calendar); if (!$a_as_milestone) { include_once './Services/Form/classes/class.ilDateDurationInputGUI.php'; $tpl->addJavaScript('./Services/Form/js/date_duration.js'); $dur = new ilDateDurationInputGUI($this->lng->txt('cal_fullday'), 'event'); $dur->setStartText($this->lng->txt('cal_start')); $dur->setEndText($this->lng->txt('cal_end')); $dur->enableToggleFullTime($this->lng->txt('cal_fullday_title'), $this->app->isFullday() ? true : false); $dur->setShowTime(true); $dur->setStart($this->app->getStart()); $dur->setEnd($this->app->getEnd()); $this->form->addItem($dur); // recurrence include_once './Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php'; $rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'), 'frequence'); $rec->setRecurrence($this->rec); $this->form->addItem($rec); // location $where = new ilTextInputGUI($this->lng->txt('cal_where'), 'location'); $where->setValue($this->app->getLocation()); $where->setMaxLength(128); $where->setSize(32); $this->form->addItem($where); } else { $deadline = new ilDateTimeInputGUI($this->lng->txt('cal_deadline'), 'event[start]'); $deadline->setDate($this->app->getStart()); $deadline->setShowTime(false); $deadline->setMinuteStepSize(5); $this->form->addItem($deadline); // completion $completion_vals = array(); for ($i = 0; $i <= 100; $i += 5) { $completion_vals[$i] = $i . " %"; } $compl = new ilSelectInputGUI($this->lng->txt('cal_task_completion'), 'completion'); $compl->setOptions($completion_vals); $compl->setValue($this->app->getCompletion()); $this->form->addItem($compl); } $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description'); $desc->setValue($this->app->getDescription()); $desc->setRows(5); $this->form->addItem($desc); if ($a_as_milestone && $a_mode == "edit" && $resp_info) { // users responsible $users = $this->app->readResponsibleUsers(); $resp = new ilNonEditableValueGUI($this->lng->txt('cal_responsible'), $users); $delim = ""; foreach ($users as $r) { $value .= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]"; $delim = "<br />"; } if (count($users) > 0) { $resp->setValue($value); } else { $resp->setValue("-"); } $this->form->addItem($resp); } if (ilCalendarSettings::_getInstance()->isUserNotificationEnabled()) { $notu = new ilTextWizardInputGUI($this->lng->txt('cal_user_notification'), 'notu'); $notu->setInfo($this->lng->txt('cal_user_notification_info')); $notu->setSize(20); $notu->setMaxLength(64); $values = array(); foreach ($this->notification->getRecipients() as $rcp) { switch ($rcp['type']) { case ilCalendarUserNotification::TYPE_USER: $values[] = ilObjUser::_lookupLogin($rcp['usr_id']); break; case ilCalendarUserNotification::TYPE_EMAIL: $values[] = $rcp['email']; break; } } if (count($values)) { $notu->setValues($values); } else { $notu->setValues(array('')); } $this->form->addItem($notu); } // Notifications include_once './Services/Calendar/classes/class.ilCalendarSettings.php'; if (ilCalendarSettings::_getInstance()->isNotificationEnabled() and count($cats->getNotificationCalendars())) { $selected_cal = new ilCalendarCategory($selected_calendar); $disabled = true; if ($selected_cal->getType() == ilCalendarCategory::TYPE_OBJ) { if (ilObject::_lookupType($selected_cal->getObjId()) == 'crs' or ilObject::_lookupType($selected_cal->getObjId()) == 'grp') { $disabled = false; } } $tpl->addJavaScript('./Services/Calendar/js/toggle_notification.js'); $not = new ilCheckboxInputGUI($this->lng->txt('cal_cg_notification'), 'not'); $not->setInfo($this->lng->txt('cal_notification_info')); $not->setValue(1); $not->setChecked($this->app->isNotificationEnabled()); $not->setDisabled($disabled); $this->form->addItem($not); } }