/**
  * Constructor
  * 
  * @param object $a_parent_obj
  * @param string $a_parent_cmd
  * @param bool $a_pdf_export
  * @param array &$a_all_pages
  * @param array $a_page_ids
  */
 public function __construct($a_parent_obj, $a_parent_cmd = "", $a_pdf_export, array &$a_all_pages, array $a_page_ids)
 {
     global $ilCtrl, $lng;
     parent::__construct($a_parent_obj, $a_parent_cmd);
     if (!(bool) $a_pdf_export) {
         $title = "wiki_show_print_view";
         $cmd = "printView";
     } else {
         $title = "wiki_show_pdf_export";
         $cmd = "pdfExport";
     }
     $this->setTitle($lng->txt($title));
     $this->addColumn($lng->txt("wiki_ordering"), "", "1");
     $this->addColumn($lng->txt("wiki_page"));
     $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(), $this->getParentCmd()));
     $this->addCommandButton($this->getParentCmd(), $lng->txt("refresh"));
     include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
     $button = ilSubmitButton::getInstance();
     $button->setOmitPreventDoubleSubmission((bool) $a_pdf_export);
     $button->setCaption("continue");
     $button->setCommand($cmd);
     $this->addCommandButtonInstance($button);
     $this->setRowTemplate("tpl.table_row_export_order.html", "Modules/Wiki");
     $this->setLimit(9999);
     $this->getItems($a_all_pages, $a_page_ids);
 }
 public function init()
 {
     // table title
     if ($this->isObligationsFilterEnabled()) {
         $this->setTitle($this->lng->txt('obligations_summary'));
     } else {
         $this->setTitle($this->lng->txt('question_summary'));
     }
     // columns
     $this->addColumn($this->lng->txt("tst_qst_order"), 'order', '');
     $this->addColumn($this->lng->txt("tst_question_title"), 'title', '');
     if ($this->isShowObligationsEnabled()) {
         $this->addColumn($this->lng->txt("obligatory"), 'obligatory', '');
     }
     $this->addColumn('', 'postponed', '');
     if ($this->isShowPointsEnabled()) {
         $this->addColumn($this->lng->txt("tst_maximum_points"), 'points', '');
     }
     $this->addColumn($this->lng->txt("worked_through"), 'worked_through', '');
     if ($this->isShowObligationsEnabled()) {
         $this->addColumn($this->lng->txt("answered"), 'answered', '');
     }
     if ($this->isShowMarkerEnabled()) {
         $this->addColumn($this->lng->txt("tst_question_marker"), 'marked', '');
     }
     // command buttons
     $this->addCommandButton('backFromSummary', $this->lng->txt('back'));
     if (!$this->areObligationsNotAnswered()) {
         $button = ilSubmitButton::getInstance();
         $button->setCaption('save_finish');
         $button->setCommand('finishTest');
         $this->addCommandButtonInstance($button);
     }
 }
 /**
  * Constructor
  *
  * @access public
  * @param
  * @return
  */
 public function __construct($a_parent_obj, $a_parent_cmd)
 {
     parent::__construct($a_parent_obj, $a_parent_cmd);
     global $lng, $ilCtrl;
     $this->lng = $lng;
     $this->ctrl = $ilCtrl;
     $this->setFormName('codesform');
     $this->addColumn('', '', '1%');
     $this->addColumn($this->lng->txt("survey_code"), 'code', '');
     $this->addColumn($this->lng->txt("email"), 'email', '');
     $this->addColumn($this->lng->txt("lastname"), 'last_name', '');
     $this->addColumn($this->lng->txt("firstname"), 'first_name', '');
     $this->addColumn($this->lng->txt("create_date"), 'date', '');
     $this->addColumn($this->lng->txt("survey_code_used"), 'used', '');
     $this->addColumn($this->lng->txt("mail_sent_short"), 'sent', '');
     $this->addColumn($this->lng->txt("survey_code_url"));
     $this->setRowTemplate("tpl.il_svy_svy_codes_row.html", "Modules/Survey");
     $this->addMultiCommand('editCodes', $this->lng->txt('edit'));
     $this->addMultiCommand('exportCodes', $this->lng->txt('export'));
     $this->addMultiCommand('deleteCodesConfirm', $this->lng->txt('delete'));
     $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
     include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
     $button = ilSubmitButton::getInstance();
     $button->setCaption("export_all_survey_codes");
     $button->setCommand("exportAllCodes");
     $button->setOmitPreventDoubleSubmission(true);
     $this->addCommandButtonInstance($button);
     $this->setDefaultOrderField("code");
     $this->setDefaultOrderDirection("asc");
     $this->setPrefix('chb_code');
     $this->setSelectAllCheckbox('chb_code');
 }
 /**
  * Constructor
  */
 function __construct($a_parent_obj, $a_parent_cmd)
 {
     global $ilCtrl, $lng;
     $this->setId("user_account_code");
     parent::__construct($a_parent_obj, $a_parent_cmd);
     $this->addColumn("", "", "1", true);
     $this->addColumn($lng->txt("user_account_code"), "code");
     $this->addColumn($lng->txt("user_account_code_valid_until"), "valid_until");
     $this->addColumn($lng->txt("user_account_code_generated"), "generated");
     $this->addColumn($lng->txt("user_account_code_used"), "used");
     $this->setExternalSorting(true);
     $this->setExternalSegmentation(true);
     $this->setEnableHeader(true);
     $this->setFormAction($ilCtrl->getFormAction($this->parent_obj, "listCodes"));
     $this->setRowTemplate("tpl.code_list_row.html", "Services/User");
     $this->setEnableTitle(true);
     $this->initFilter();
     $this->setFilterCommand("applyCodesFilter");
     $this->setResetCommand("resetCodesFilter");
     $this->setDefaultOrderField("generated");
     $this->setDefaultOrderDirection("desc");
     $this->setSelectAllCheckbox("id[]");
     $this->setTopCommands(true);
     $this->addMultiCommand("deleteConfirmation", $lng->txt("delete"));
     include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
     $button = ilSubmitButton::getInstance();
     $button->setCaption("user_account_codes_export");
     $button->setCommand("exportCodes");
     $button->setOmitPreventDoubleSubmission(true);
     $this->addCommandButtonInstance($button);
     $this->getItems();
 }
 protected function populateUpperNextButtonBlockLeadingToSummary()
 {
     $button = ilSubmitButton::getInstance();
     $button->setPrimary(true);
     $button->setCommand('nextQuestion');
     $button->setCaption('question_summary');
     $button->setId('nextbutton');
     $this->tpl->setCurrentBlock("next");
     $this->tpl->setVariable("BTN_NEXT", $button->render());
     $this->tpl->parseCurrentBlock();
 }
 /**
  * Show participants
  */
 protected function participants()
 {
     global $ilTabs, $rbacreview, $ilUser;
     $ilTabs->activateTab('participants');
     $this->addSearchToolbar();
     $tpl = ilViteroPlugin::getInstance()->getTemplate('tpl.edit_participants.html');
     $this->setShowHidePrefs();
     if ($rbacreview->assignedUsers((int) $this->object->getDefaultAdminRole())) {
         if ($ilUser->getPref('xvit_admin_hide')) {
             $table_gui = new ilViteroParticipantsTableGUI($this, ilObjVitero::ADMIN, false);
             $table_gui->setVGroupId($this->object->getVGroupId());
             $this->ctrl->setParameter($this, 'admin_hide', 0);
             $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this, 'participants'), $this->lng->txt('show'));
             $this->ctrl->clearParameters($this);
         } else {
             $table_gui = new ilViteroParticipantsTableGUI($this, ilObjVitero::ADMIN, true);
             $table_gui->setVGroupId($this->object->getVGroupId());
             $this->ctrl->setParameter($this, 'admin_hide', 1);
             $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this, 'participants'), $this->lng->txt('hide'));
             $this->ctrl->clearParameters($this);
         }
         $table_gui->setTitle(ilViteroPlugin::getInstance()->txt('admins'), 'icon_usr.svg', $this->lng->txt('grp_admins'));
         $table_gui->parse($rbacreview->assignedUsers((int) $this->object->getDefaultAdminRole()));
         $tpl->setVariable('ADMINS', $table_gui->getHTML());
     }
     if ($rbacreview->assignedUsers((int) $this->object->getDefaultMemberRole())) {
         if ($ilUser->getPref('xvit_member_hide')) {
             $table_gui = new ilViteroParticipantsTableGUI($this, ilObjVitero::MEMBER, false);
             $table_gui->setVGroupId($this->object->getVGroupId());
             $this->ctrl->setParameter($this, 'member_hide', 0);
             $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this, 'participants'), $this->lng->txt('show'));
             $this->ctrl->clearParameters($this);
         } else {
             $table_gui = new ilViteroParticipantsTableGUI($this, ilObjVitero::MEMBER, true);
             $table_gui->setVGroupId($this->object->getVGroupId());
             $this->ctrl->setParameter($this, 'member_hide', 1);
             $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this, 'participants'), $this->lng->txt('hide'));
             $this->ctrl->clearParameters($this);
         }
         $table_gui->setTitle(ilViteroPlugin::getInstance()->txt('participants'), 'icon_usr.svg', $this->lng->txt('grp_members'));
         $table_gui->parse($rbacreview->assignedUsers((int) $this->object->getDefaultMemberRole()));
         $tpl->setVariable('MEMBERS', $table_gui->getHTML());
     }
     $remove = ilSubmitButton::getInstance();
     $remove->setCommand("confirmDeleteParticipants");
     $remove->setCaption("remove", true);
     $tpl->setVariable('BTN_REMOVE', $remove->render());
     if (ilViteroLockedUser::hasLockedAccounts($this->object->getVGroupId())) {
         $unlock = ilSubmitButton::getInstance();
         $unlock->setCommand("unlockUsers");
         $unlock->setCaption(ilViteroPlugin::getInstance()->txt('btn_unlock'), false);
         $tpl->setVariable('BTN_UNLOCK', $unlock->render());
     }
     $lock = ilSubmitButton::getInstance();
     $lock->setCommand("lockUsers");
     $lock->setCaption(ilViteroPlugin::getInstance()->txt('btn_lock'), false);
     $tpl->setVariable('BTN_LOCK', $lock->render());
     $mail = ilSubmitButton::getInstance();
     $mail->setCommand("sendMailToSelectedUsers");
     $mail->setCaption("grp_mem_send_mail", true);
     $tpl->setVariable('BTN_MAIL', $mail->render());
     $tpl->setVariable('ARROW_DOWN', ilUtil::getImagePath('arrow_downright.svg'));
     $tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this));
     $GLOBALS['tpl']->setContent($tpl->get());
 }
 /**
  * Display the survey access codes tab
  */
 public function codesObject()
 {
     global $ilUser, $ilToolbar;
     $this->parent_gui->handleWriteAccess();
     $this->setCodesSubtabs();
     if ($this->object->isAccessibleWithoutCode()) {
         return ilUtil::sendInfo($this->lng->txt("survey_codes_no_anonymization"));
     }
     $default_lang = $ilUser->getPref("survey_code_language");
     // creation buttons
     $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
     include_once "./Services/Form/classes/class.ilTextInputGUI.php";
     $si = new ilTextInputGUI($this->lng->txt("new_survey_codes"), "nrOfCodes");
     $si->setValue(1);
     $si->setSize(3);
     $ilToolbar->addInputItem($si, true);
     include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
     $button = ilSubmitButton::getInstance();
     $button->setCaption("create");
     $button->setCommand("createSurveyCodes");
     $ilToolbar->addButtonInstance($button);
     $ilToolbar->addSeparator();
     $button = ilSubmitButton::getInstance();
     $button->setCaption("import_from_file");
     $button->setCommand("importExternalMailRecipientsFromFileForm");
     $ilToolbar->addButtonInstance($button);
     $button = ilSubmitButton::getInstance();
     $button->setCaption("import_from_text");
     $button->setCommand("importExternalMailRecipientsFromTextForm");
     $ilToolbar->addButtonInstance($button);
     $ilToolbar->addSeparator();
     $button = ilSubmitButton::getInstance();
     $button->setCaption("svy_import_codes");
     $button->setCommand("importAccessCodes");
     $ilToolbar->addButtonInstance($button);
     $ilToolbar->addSeparator();
     $languages = $this->lng->getInstalledLanguages();
     $options = array();
     $this->lng->loadLanguageModule("meta");
     foreach ($languages as $lang) {
         $options[$lang] = $this->lng->txt("meta_l_" . $lang);
     }
     include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
     $si = new ilSelectInputGUI($this->lng->txt("survey_codes_lang"), "lang");
     $si->setOptions($options);
     $si->setValue($default_lang);
     $ilToolbar->addInputItem($si, true);
     $button = ilSubmitButton::getInstance();
     $button->setCaption("set");
     $button->setCommand("setCodeLanguage");
     $ilToolbar->addButtonInstance($button);
     include_once "./Modules/Survey/classes/tables/class.ilSurveyCodesTableGUI.php";
     $table_gui = new ilSurveyCodesTableGUI($this, 'codes');
     $survey_codes = $this->object->getSurveyCodesTableData(null, $default_lang);
     $table_gui->setData($survey_codes);
     $this->tpl->setContent($table_gui->getHTML());
 }
 public function questionsObject()
 {
     global $ilToolbar, $ilUser;
     // insert new questions?
     if ($_GET["new_id"] > 0) {
         // add a question to the survey previous created in a questionpool
         $existing = $this->object->getExistingQuestions();
         if (!in_array($_GET["new_id"], $existing)) {
             $inserted = $this->object->insertQuestion($_GET["new_id"]);
             if (!$inserted) {
                 ilUtil::sendFailure($this->lng->txt("survey_error_insert_incomplete_question"));
             }
         }
     }
     $this->questionsSubtabs("questions");
     $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
     $read_only = $hasDatasets;
     // toolbar
     if (!$read_only) {
         $qtypes = array();
         include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
         foreach (ilObjSurveyQuestionPool::_getQuestiontypes() as $translation => $data) {
             $qtypes[$data["type_tag"]] = $translation;
         }
         $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, "");
         include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
         include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
         $button = ilSubmitButton::getInstance();
         $button->setCaption("svy_create_question");
         $button->setCommand("createQuestion");
         $ilToolbar->addButtonInstance($button);
         if ($this->object->isPoolActive()) {
             $ilToolbar->addSeparator();
             $cmd = $ilUser->getPref('svy_insert_type') == 1 || strlen($ilUser->getPref('svy_insert_type')) == 0 ? 'browseForQuestions' : 'browseForQuestionblocks';
             $button = ilLinkButton::getInstance();
             $button->setCaption("browse_for_questions");
             $button->setUrl($this->ctrl->getLinkTarget($this, $cmd));
             $ilToolbar->addButtonInstance($button);
         }
         $ilToolbar->addSeparator();
         $button = ilLinkButton::getInstance();
         $button->setCaption("add_heading");
         $button->setUrl($this->ctrl->getLinkTarget($this, "addHeading"));
         $ilToolbar->addButtonInstance($button);
     }
     if ($hasDatasets) {
         $link = $this->ctrl->getLinkTargetByClass("ilsurveyparticipantsgui", "maintenance");
         $link = "<a href=\"" . $link . "\">" . $this->lng->txt("survey_has_datasets_warning_page_view_link") . "</a>";
         ilUtil::sendInfo($this->lng->txt("survey_has_datasets_warning_page_view") . " " . $link);
     }
     // table gui
     include_once "Modules/Survey/classes/class.ilSurveyQuestionTableGUI.php";
     $table = new ilSurveyQuestionTableGUI($this, "questions", $this->object, $read_only);
     $this->tpl->setContent($table->getHTML());
 }
 /**
 * Creates the finished page for a running survey
 *
 * Creates the finished page for a running survey
 *
 * @access public
 */
 function runShowFinishedPage()
 {
     global $ilToolbar, $ilUser;
     $has_button = false;
     include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
     if (!$this->preview) {
         if ($this->object->hasViewOwnResults()) {
             $button = ilLinkButton::getInstance();
             $button->setCaption("svy_view_own_results");
             $button->setUrl($this->ctrl->getLinkTarget($this, "viewUserResults"));
             $ilToolbar->addButtonInstance($button);
             $has_button = true;
         }
         if ($this->object->hasMailOwnResults()) {
             if ($has_button) {
                 $ilToolbar->addSeparator();
             }
             require_once "Services/Form/classes/class.ilTextInputGUI.php";
             $mail = new ilTextInputGUI($this->lng->txt("email"), "mail");
             $mail->setSize(25);
             if ($ilUser->getId() != ANONYMOUS_USER_ID) {
                 $mail->setValue($ilUser->getEmail());
             }
             $ilToolbar->addInputItem($mail, true);
             $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "mailUserResults"));
             include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
             $button = ilSubmitButton::getInstance();
             $button->setCaption("svy_mail_own_results");
             $button->setCommand("mailUserResults");
             $ilToolbar->addButtonInstance($button);
             $has_button = true;
         }
     }
     if (!$has_button && strlen($this->object->getOutro()) == 0) {
         $this->exitSurvey();
     } else {
         if ($has_button) {
             $ilToolbar->addSeparator();
         }
         $button = ilLinkButton::getInstance();
         $button->setCaption("survey_execution_exit");
         $button->setUrl($this->ctrl->getLinkTarget($this, "exitSurvey"));
         $ilToolbar->addButtonInstance($button);
         if (strlen($this->object->getOutro())) {
             include_once "Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
             $panel = ilPanelGUI::getInstance();
             $panel->setBody($this->object->prepareTextareaOutput($this->object->getOutro()));
             $this->tpl->setContent($panel->getHTML());
         }
     }
 }
 /**
  * Display mark schema
  * @param ilPropertyFormGUI $ects_form
  */
 protected function showMarkSchema(ilPropertyFormGUI $ects_form = null)
 {
     if (!$this->object->canEditMarks()) {
         ilUtil::sendInfo($this->lng->txt('cannot_edit_marks'));
     }
     $this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'showMarkSchema'));
     if ($this->object->canEditMarks()) {
         require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
         $create_simple_mark_schema_button = ilSubmitButton::getInstance();
         $create_simple_mark_schema_button->setCaption($this->lng->txt('tst_mark_create_simple_mark_schema'), false);
         $create_simple_mark_schema_button->setCommand('addSimpleMarkSchema');
         $this->toolbar->addButtonInstance($create_simple_mark_schema_button);
     }
     require_once 'Modules/Test/classes/tables/class.ilMarkSchemaTableGUI.php';
     $mark_schema_table = new ilMarkSchemaTableGUI($this, 'showMarkSchema', '', $this->object);
     $content_parts = array($mark_schema_table->getHTML());
     if ($this->objectSupportsEctsGrades() && $this->object->canEditEctsGrades()) {
         if (!$ects_form instanceof ilPropertyFormGUI) {
             $ects_form = $this->getEctsForm();
             $this->populateEctsForm($ects_form);
         }
         $content_parts[] = $ects_form->getHTML();
     }
     $this->tpl->setContent(implode('<br />', $content_parts));
 }
 protected function share()
 {
     global $ilToolbar, $tpl, $ilUser, $ilSetting;
     $options = array();
     $options["user"] = $this->lng->txt("wsp_set_permission_single_user");
     include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
     $grp_ids = ilGroupParticipants::_getMembershipByType($ilUser->getId(), 'grp');
     if (sizeof($grp_ids)) {
         $options["group"] = $this->lng->txt("wsp_set_permission_group");
     }
     include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
     $crs_ids = ilCourseParticipants::_getMembershipByType($ilUser->getId(), 'crs');
     if (sizeof($crs_ids)) {
         $options["course"] = $this->lng->txt("wsp_set_permission_course");
     }
     if (!$this->getAccessHandler()->hasRegisteredPermission($this->node_id)) {
         $options["registered"] = $this->lng->txt("wsp_set_permission_registered");
     }
     if ($ilSetting->get("enable_global_profiles")) {
         if (!$this->getAccessHandler()->hasGlobalPasswordPermission($this->node_id)) {
             $options["password"] = $this->lng->txt("wsp_set_permission_all_password");
         }
         if (!$this->getAccessHandler()->hasGlobalPermission($this->node_id)) {
             $options["all"] = $this->lng->txt("wsp_set_permission_all");
         }
     }
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $actions = new ilSelectInputGUI("", "action");
     $actions->setOptions($options);
     $ilToolbar->addInputItem($actions);
     $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
     include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
     $button = ilSubmitButton::getInstance();
     $button->setCaption("add");
     $button->setCommand("addpermissionhandler");
     $ilToolbar->addButtonInstance($button);
     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessTableGUI.php";
     $table = new ilWorkspaceAccessTableGUI($this, "share", $this->node_id, $this->getAccessHandler());
     $tpl->setContent($table->getHTML() . $this->footer);
 }
 /**
  * Show search form
  * @return boolean
  */
 protected function showSearchForm()
 {
     global $ilCtrl, $lng;
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lucene_usr_search.html', 'Services/Search');
     // include js needed
     include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
     ilOverlayGUI::initJavascript();
     $this->tpl->addJavascript("./Services/Search/js/Search.js");
     $this->tpl->setVariable('FORM_ACTION', $GLOBALS['ilCtrl']->getFormAction($this, 'performSearch'));
     $this->tpl->setVariable("TERM", ilUtil::prepareFormOutput($this->search_cache->getQuery()));
     include_once "./Services/UIComponent/Button/classes/class.ilSubmitButton.php";
     $btn = ilSubmitButton::getInstance();
     $btn->setCommand("performSearch");
     $btn->setCaption("search");
     $this->tpl->setVariable("SUBMIT_BTN", $btn->render());
     return true;
 }
 /**
  * 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';
     require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
     require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
     $testQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
     $testSession = $this->testSessionFactory->getSession();
     $testSequence = $this->testSequenceFactory->getSequence($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);
     if ($this->isCommandClassAnyInfoScreenChild()) {
         return $this->ctrl->forwardCommand($info);
     }
     $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) {
                         $btn = ilSubmitButton::getInstance();
                         $btn->setCaption('tst_resume_test');
                         $btn->setCommand('resumePlayer');
                         $btn->setPrimary(true);
                         $big_button[] = $btn;
                     } else {
                         $btn = ilSubmitButton::getInstance();
                         $btn->setCaption($this->object->getStartTestLabel($testSession->getActiveId()), false);
                         $btn->setCommand('startPlayer');
                         $btn->setPrimary(true);
                         $big_button[] = $btn;
                     }
                 } else {
                     // start new test
                     $btn = ilSubmitButton::getInstance();
                     $btn->setCaption($this->object->getStartTestLabel($testSession->getActiveId()), false);
                     $btn->setCommand('startPlayer');
                     $btn->setPrimary(true);
                     $big_button[] = $btn;
                 }
             } 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())) {
                     $btn = ilLinkButton::getInstance();
                     $btn->setCaption('tst_show_results');
                     $btn->setUrl($this->ctrl->getLinkTargetByClass('ilTestEvaluationGUI', 'outUserResultsOverview'));
                     $btn->setPrimary(false);
                     $big_button[] = $btn;
                     if ($this->object->getHighscoreEnabled()) {
                         // Can also compare results then
                         $btn = ilSubmitButton::getInstance();
                         $btn->setCaption('tst_show_toplist');
                         $btn->setCommand('outResultsToplist');
                         $btn->setPrimary(false);
                         $big_button[] = $btn;
                     }
                     if ($this->object->isSkillServiceToBeConsidered()) {
                         require_once 'Modules/Test/classes/class.ilTestSkillEvaluationGUI.php';
                         $btn = ilLinkButton::getInstance();
                         $btn->setCaption('tst_show_comp_results');
                         $btn->setUrl($this->ctrl->getLinkTargetByClass('ilTestSkillEvaluationGUI', ilTestSkillEvaluationGUI::CMD_SHOW));
                         $btn->setPrimary(false);
                         $big_button[] = $btn;
                     }
                 }
             }
         }
         if ($testSession->getActiveId() > 0) {
             if ($this->object->canShowSolutionPrintview($ilUser->getId())) {
                 $btn = ilSubmitButton::getInstance();
                 $btn->setCaption('tst_list_of_answers_show');
                 $btn->setCommand('outUserListOfAnswerPasses');
                 $btn->setPrimary(false);
                 $big_button[] = $btn;
             }
         }
         if ($this->isDeleteDynamicTestResultsButtonRequired($testSession, $testSequence)) {
             $this->populateDeleteDynamicTestResultsButton($testSession, $big_button);
         }
         if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID) {
             $enter_anonymous_code = true;
         }
     }
     if (!$this->object->isOnline() && !$testQuestionSetConfig->areDepenciesBroken()) {
         $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 ($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) {
             $ilToolbar->addButtonInstance($button);
         }
         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()) {
                 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 && $this->object->isStartingTimeEnabled()) {
             $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 && $this->object->isEndingTimeEnabled()) {
             $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);
 }
 /**
 * Output of anonymous aggregated results for the test
 *
 * Output of anonymous aggregated results for the test
 *
 * @access public
 */
 function eval_a()
 {
     /**
      * @var $ilAccess ilAccessHandler
      * @var $ilToolbar ilToolbarGUI
      */
     global $ilAccess, $ilToolbar;
     if (!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id) && !$ilAccess->checkAccess("write", "", $this->ref_id)) {
         // allow only evaluation access
         ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
         $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
     }
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_anonymous_aggregation.html", "Modules/Test");
     $eval =& $this->object->getCompleteEvaluationData();
     $data = array();
     $foundParticipants =& $eval->getParticipants();
     if (count($foundParticipants)) {
         $ilToolbar->setFormName('form_output_eval');
         $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'exportAggregatedResults'));
         require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
         $export_type = new ilSelectInputGUI($this->lng->txt('exp_eval_data'), 'export_type');
         $export_type->setOptions(array('excel' => $this->lng->txt('exp_type_excel'), 'csv' => $this->lng->txt('exp_type_spss')));
         $ilToolbar->addInputItem($export_type, true);
         require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
         $button = ilSubmitButton::getInstance();
         $button->setCommand('exportAggregatedResults');
         $button->setCaption('export');
         $button->getOmitPreventDoubleSubmission();
         $ilToolbar->addButtonInstance($button);
         array_push($data, array('result' => $this->lng->txt("tst_eval_total_persons"), 'value' => count($foundParticipants)));
         $total_finished = $this->object->evalTotalFinished();
         array_push($data, array('result' => $this->lng->txt("tst_eval_total_finished"), 'value' => $total_finished));
         $average_time = $this->object->evalTotalStartedAverageTime();
         $diff_seconds = $average_time;
         $diff_hours = floor($diff_seconds / 3600);
         $diff_seconds -= $diff_hours * 3600;
         $diff_minutes = floor($diff_seconds / 60);
         $diff_seconds -= $diff_minutes * 60;
         array_push($data, array('result' => $this->lng->txt("tst_eval_total_finished_average_time"), 'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)));
         $total_passed = 0;
         $total_passed_reached = 0;
         $total_passed_max = 0;
         $total_passed_time = 0;
         foreach ($foundParticipants as $userdata) {
             if ($userdata->getPassed()) {
                 $total_passed++;
                 $total_passed_reached += $userdata->getReached();
                 $total_passed_max += $userdata->getMaxpoints();
                 $total_passed_time += $userdata->getTimeOfWork();
             }
         }
         $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
         $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
         $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
         array_push($data, array('result' => $this->lng->txt("tst_eval_total_passed"), 'value' => $total_passed));
         array_push($data, array('result' => $this->lng->txt("tst_eval_total_passed_average_points"), 'value' => sprintf("%2.2f", $average_passed_reached) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%2.2f", $average_passed_max)));
         $average_time = $average_passed_time;
         $diff_seconds = $average_time;
         $diff_hours = floor($diff_seconds / 3600);
         $diff_seconds -= $diff_hours * 3600;
         $diff_minutes = floor($diff_seconds / 60);
         $diff_seconds -= $diff_minutes * 60;
         array_push($data, array('result' => $this->lng->txt("tst_eval_total_passed_average_time"), 'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)));
     }
     include_once "./Modules/Test/classes/tables/class.ilTestAggregatedResultsTableGUI.php";
     $table_gui = new ilTestAggregatedResultsTableGUI($this, 'eval_a');
     $table_gui->setData($data);
     $this->tpl->setVariable('AGGREGATED_RESULTS', $table_gui->getHTML());
     $rows = array();
     foreach ($eval->getQuestionTitles() as $question_id => $question_title) {
         $answered = 0;
         $reached = 0;
         $max = 0;
         foreach ($foundParticipants as $userdata) {
             for ($i = 0; $i <= $userdata->getLastPass(); $i++) {
                 if (is_object($userdata->getPass($i))) {
                     $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
                     if (is_array($question)) {
                         $answered++;
                         $reached += $question["reached"];
                         $max += $question["points"];
                     }
                 }
             }
         }
         $percent = $max ? $reached / $max * 100.0 : 0;
         $counter++;
         $this->ctrl->setParameter($this, "qid", $question_id);
         $points_reached = $answered ? $reached / $answered : 0;
         $points_max = $answered ? $max / $answered : 0;
         array_push($rows, array('qid' => $question_id, 'title' => $question_title, 'points' => $points_reached, 'points_reached' => $points_reached, 'points_max' => $points_max, 'percentage' => (double) $percent, 'answers' => $answered));
     }
     include_once "./Modules/Test/classes/tables/class.ilTestAverageReachedPointsTableGUI.php";
     $table_gui = new ilTestAverageReachedPointsTableGUI($this, 'eval_a');
     $table_gui->setData($rows);
     $this->tpl->setVariable('TBL_AVG_REACHED', $table_gui->getHTML());
 }
 /**
  * Render object context
  */
 function render()
 {
     global $tpl, $ilTabs, $ilCtrl, $lng, $ilToolbar, $ilUser, $tree;
     if (!$this->checkPermissionBool("read")) {
         ilUtil::sendInfo($lng->txt("no_permission"));
         return;
     }
     $ilTabs->activateTab("content");
     // toolbar
     if ($this->mayContribute()) {
         $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "createPosting"));
         include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
         $title = new ilTextInputGUI($lng->txt("title"), "title");
         $ilToolbar->addInputItem($title, $lng->txt("title"));
         include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
         $button = ilSubmitButton::getInstance();
         $button->setCaption("blog_add_posting");
         $button->setCommand("createPosting");
         $ilToolbar->addButtonInstance($button);
         // exercise blog?
         include_once "Modules/Exercise/classes/class.ilObjExercise.php";
         $exercises = ilObjExercise::findUserFiles($ilUser->getId(), $this->node_id);
         if ($exercises) {
             $info = array();
             foreach ($exercises as $exercise) {
                 // #9988
                 $active_ref = false;
                 foreach (ilObject::_getAllReferences($exercise["obj_id"]) as $ref_id) {
                     if (!$tree->isSaved($ref_id)) {
                         $active_ref = true;
                         break;
                     }
                 }
                 if ($active_ref) {
                     $part = $this->getExerciseInfo($exercise["ass_id"]);
                     if ($part) {
                         $info[] = $part;
                     }
                 }
             }
             if (sizeof($info)) {
                 ilUtil::sendInfo(implode("<br />", $info));
             }
         }
     }
     // $is_owner = ($this->object->getOwner() == $ilUser->getId());
     $is_owner = $this->mayContribute();
     $list_items = $this->getListItems($is_owner);
     $list = $nav = "";
     if ($list_items) {
         $list = $this->renderList($list_items, "preview", null, $is_owner);
         $nav = $this->renderNavigation($this->items, "render", "preview", null, $is_owner);
     }
     $this->setContentStyleSheet();
     $tpl->setContent($list);
     $tpl->setRightContent($nav);
 }
 /**
  * fill toolbar with
  * @param ilToolbarGUI $toolbar
  * @param array options:  all are optional e.g.
  * array(
  *		auto_complete_name = $lng->txt('user'),
  *		auto_complete_size = 15,
  *		user_type = array(ilCourseParticipants::CRS_MEMBER,ilCourseParticpants::CRS_TUTOR),
  *		submit_name = $lng->txt('add')
  * )
  *
  * @return ilToolbarGUI
  */
 public static function fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar = null, $a_options = array())
 {
     global $ilToolbar, $lng, $ilCtrl, $tree;
     if (!$toolbar instanceof ilToolbarGUI) {
         $toolbar = $ilToolbar;
     }
     // Fill default options
     if (!isset($a_options['auto_complete_name'])) {
         $a_options['auto_complete_name'] = $lng->txt('obj_user');
     }
     if (!isset($a_options['auto_complete_size'])) {
         $a_options['auto_complete_size'] = 15;
     }
     if (!isset($a_options['submit_name'])) {
         $a_options['submit_name'] = $lng->txt('btn_add');
     }
     $ajax_url = $ilCtrl->getLinkTargetByClass(array(get_class($parent_object), 'ilRepositorySearchGUI'), 'doUserAutoComplete', '', true, false);
     include_once "./Services/Form/classes/class.ilTextInputGUI.php";
     $ul = new ilTextInputGUI($a_options['auto_complete_name'], 'user_login');
     $ul->setDataSource($ajax_url);
     $ul->setSize($a_options['auto_complete_size']);
     $toolbar->addInputItem($ul, true);
     if (count((array) $a_options['user_type'])) {
         include_once './Services/Form/classes/class.ilSelectInputGUI.php';
         $si = new ilSelectInputGUI("", "user_type");
         $si->setOptions($a_options['user_type']);
         $toolbar->addInputItem($si);
     }
     include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
     $button = ilSubmitButton::getInstance();
     $button->setCaption($a_options['submit_name'], false);
     $button->setCommand('addUserFromAutoComplete');
     $toolbar->addButtonInstance($button);
     if ((bool) $a_options['add_search'] || is_numeric($a_options['add_from_container'])) {
         $lng->loadLanguageModule("search");
         $toolbar->addSeparator();
         if ((bool) $a_options['add_search']) {
             include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
             $button = ilLinkButton::getInstance();
             $button->setCaption("search_users");
             $button->setUrl($ilCtrl->getLinkTargetByClass('ilRepositorySearchGUI', ''));
             $toolbar->addButtonInstance($button);
         }
         if (is_numeric($a_options['add_from_container'])) {
             $parent_ref_id = (int) $a_options['add_from_container'];
             $parent_container_ref_id = $tree->checkForParentType($parent_ref_id, "grp");
             $parent_container_type = "grp";
             if (!$parent_container_ref_id) {
                 $parent_container_ref_id = $tree->checkForParentType($parent_ref_id, "crs");
                 $parent_container_type = "crs";
             }
             if ($parent_container_ref_id) {
                 if ((bool) $a_options['add_search']) {
                     $toolbar->addSpacer();
                 }
                 $ilCtrl->setParameterByClass('ilRepositorySearchGUI', "list_obj", ilObject::_lookupObjId($parent_container_ref_id));
                 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
                 $button = ilLinkButton::getInstance();
                 $button->setCaption("search_add_members_from_container_" . $parent_container_type);
                 $button->setUrl($ilCtrl->getLinkTargetByClass(array(get_class($parent_object), 'ilRepositorySearchGUI'), 'listUsers'));
                 $toolbar->addButtonInstance($button);
             }
         }
     }
     $toolbar->setFormAction($ilCtrl->getFormActionByClass(array(get_class($parent_object), 'ilRepositorySearchGUI')));
     return $toolbar;
 }
 /**
  * Show search form
  * @return boolean
  */
 protected function showSearchForm()
 {
     global $ilCtrl, $lng;
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lucene_search.html', 'Services/Search');
     // include js needed
     include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
     ilOverlayGUI::initJavascript();
     $this->tpl->addJavascript("./Services/Search/js/Search.js");
     include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
     $this->tpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this, 'performSearch'));
     $this->tpl->setVariable("TERM", ilUtil::prepareFormOutput($this->search_cache->getQuery()));
     include_once "./Services/UIComponent/Button/classes/class.ilSubmitButton.php";
     $btn = ilSubmitButton::getInstance();
     $btn->setCommand("performSearch");
     $btn->setCaption("search");
     $this->tpl->setVariable("SUBMIT_BTN", $btn->render());
     $this->tpl->setVariable("TXT_OPTIONS", $lng->txt("options"));
     $this->tpl->setVariable("ARR_IMG", ilGlyphGUI::get(ilGlyphGUI::CARET));
     $this->tpl->setVariable("TXT_COMBINATION", $lng->txt("search_term_combination"));
     $this->tpl->setVariable('TXT_COMBINATION_DEFAULT', ilSearchSettings::getInstance()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND ? $lng->txt('search_all_words') : $lng->txt('search_any_word'));
     $this->tpl->setVariable("TXT_AREA", $lng->txt("search_area"));
     if (ilSearchSettings::getInstance()->isLuceneItemFilterEnabled()) {
         $this->tpl->setCurrentBlock("type_sel");
         $this->tpl->setVariable('TXT_TYPE_DEFAULT', $lng->txt("search_off"));
         $this->tpl->setVariable("ARR_IMGT", ilGlyphGUI::get(ilGlyphGUI::CARET));
         $this->tpl->setVariable("TXT_FILTER_BY_TYPE", $lng->txt("search_filter_by_type"));
         $this->tpl->setVariable('FORM', $this->form->getHTML());
         $this->tpl->parseCurrentBlock();
     }
     // search area form
     $this->tpl->setVariable('SEARCH_AREA_FORM', $this->getSearchAreaForm()->getHTML());
     $this->tpl->setVariable("TXT_CHANGE", $lng->txt("change"));
     return true;
 }
 /**
  * Print the survey evaluation for a selected user
  *
  * Print the survey evaluation for a selected user
  *
  * @access private
  */
 function evaluationuser()
 {
     global $ilAccess, $ilToolbar;
     if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
         ilUtil::sendFailure($this->lng->txt("no_permission"), TRUE);
         $this->ctrl->redirectByClass("ilObjSurveyGUI", "infoScreen");
     }
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "evaluationuser"));
     if ($this->object->get360Mode()) {
         $appr_id = $this->getAppraiseeId();
         $this->addApprSelectionToToolbar();
     }
     $tabledata = null;
     if (!$this->object->get360Mode() || $appr_id) {
         $format = new ilSelectInputGUI("", "export_format");
         $format->setOptions(array(self::TYPE_XLS => $this->lng->txt('exp_type_excel'), self::TYPE_SPSS => $this->lng->txt('exp_type_csv')));
         $ilToolbar->addInputItem($format);
         $label = new ilSelectInputGUI("", "export_label");
         $label->setOptions(array('label_only' => $this->lng->txt('export_label_only'), 'title_only' => $this->lng->txt('export_title_only'), 'title_label' => $this->lng->txt('export_title_label')));
         $ilToolbar->addInputItem($label);
         include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
         $button = ilSubmitButton::getInstance();
         $button->setCaption("export");
         $button->setCommand('exportevaluationuser');
         $button->setOmitPreventDoubleSubmission(true);
         $ilToolbar->addButtonInstance($button);
         $ilToolbar->addSeparator();
         include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
         $button = ilLinkButton::getInstance();
         $button->setCaption("print");
         $button->setOnClick("window.print(); return false;");
         $button->setOmitPreventDoubleSubmission(true);
         $ilToolbar->addButtonInstance($button);
         $finished_ids = null;
         if ($appr_id) {
             $finished_ids = $this->object->getFinishedIdsForAppraiseeId($appr_id);
             if (!sizeof($finished_ids)) {
                 $finished_ids = array(-1);
             }
         }
         $userResults =& $this->object->getUserSpecificResults($finished_ids);
         $questions =& $this->object->getSurveyQuestions(true);
         $participants =& $this->object->getSurveyParticipants($finished_ids);
         $tabledata = array();
         $counter = -1;
         foreach ($participants as $data) {
             $questioncounter = 1;
             $question = "";
             $results = "";
             $first = true;
             foreach ($questions as $question_id => $question_data) {
                 $found = $userResults[$question_id][$data["active_id"]];
                 $text = "";
                 if (is_array($found)) {
                     $text = implode("<br />", $found);
                 } else {
                     $text = $found;
                 }
                 if (strlen($text) == 0) {
                     $text = ilObjSurvey::getSurveySkippedValue();
                 }
                 $wt = $this->object->getWorkingtimeForParticipant($data['active_id']);
                 if ($first) {
                     if ($data["finished"]) {
                         $finished = $data["finished_tstamp"];
                     } else {
                         $finished = false;
                     }
                     $tabledata[++$counter] = array('username' => $data["sortname"], 'question' => $questioncounter++ . ". " . $question_data["title"], 'results' => $text, 'workingtime' => $wt, 'finished' => $finished);
                     $first = false;
                 } else {
                     $tabledata[$counter]["subitems"][] = array('username' => " ", 'question' => $questioncounter++ . ". " . $question_data["title"], 'results' => $text, 'workingtime' => null, 'finished' => null);
                 }
             }
         }
     }
     $this->tpl->addCss("./Modules/Survey/templates/default/survey_print.css", "print");
     $this->tpl->setCurrentBlock("generic_css");
     $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./Modules/Survey/templates/default/evaluation_print.css");
     $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
     $this->tpl->parseCurrentBlock();
     include_once "./Modules/Survey/classes/tables/class.ilSurveyResultsUserTableGUI.php";
     $table_gui = new ilSurveyResultsUserTableGUI($this, 'evaluationuser', $this->object->hasAnonymizedResults());
     $table_gui->setData($tabledata);
     $this->tpl->setContent($table_gui->getHTML());
 }
 /**
  * List export files
  *
  * @param
  * @return
  */
 function listExportFiles()
 {
     global $tpl, $ilToolbar, $ilCtrl, $lng;
     include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
     $button = ilSubmitButton::getInstance();
     // creation buttons
     $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
     if (count($this->getFormats()) > 1) {
         // type selection
         foreach ($this->getFormats() as $f) {
             $options[$f["key"]] = $f["txt"];
         }
         include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
         $si = new ilSelectInputGUI($lng->txt("type"), "format");
         $si->setOptions($options);
         $ilToolbar->addInputItem($si, true);
         $button->setCaption("exp_create_file");
         $button->setCommand("createExportFile");
     } else {
         $format = $this->getFormats();
         $format = $format[0];
         $button->setCaption($lng->txt("exp_create_file") . " (" . $format["txt"] . ")", false);
         $button->setCommand("create_" . $format["key"]);
     }
     $ilToolbar->addButtonInstance($button);
     $table = $this->buildExportTableGUI();
     $table->setSelectAllCheckbox("file");
     foreach ($this->getCustomColumns() as $c) {
         $table->addCustomColumn($c["txt"], $c["obj"], $c["func"]);
     }
     foreach ($this->getCustomMultiCommands() as $c) {
         $table->addCustomMultiCommand($c["txt"], "multi_" . $c["func"]);
     }
     $tpl->setContent($table->getHTML());
 }
 /**
  * show information screen
  */
 function infoScreen()
 {
     global $ilAccess, $ilTabs, $ilUser, $ilToolbar;
     if (!$this->external_rater_360 && !$ilAccess->checkAccess("visible", "", $this->ref_id)) {
         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"), $this->ilias->error_obj->MESSAGE);
     }
     $ilTabs->activateTab("info_short");
     include_once "./Modules/Survey/classes/class.ilSurveyExecutionGUI.php";
     $output_gui =& new ilSurveyExecutionGUI($this->object);
     include_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php";
     $info = new ilInfoScreenGUI($this);
     $info->enablePrivateNotes();
     // "active" survey?
     $canStart = $this->object->canStartSurvey(null, $this->external_rater_360);
     $showButtons = $canStart["result"];
     if (!$showButtons) {
         if ($canStart["edit_settings"] && $ilAccess->checkAccess("write", "", $this->ref_id)) {
             $canStart["messages"][] = "<a href=\"" . $this->ctrl->getLinkTarget($this, "properties") . "\">&raquo; " . $this->lng->txt("survey_edit_settings") . "</a>";
         }
         ilUtil::sendInfo(implode("<br />", $canStart["messages"]));
     }
     $big_button = false;
     if ($showButtons) {
         // closing survey?
         $is_appraisee = false;
         if ($this->object->get360Mode() && $this->object->isAppraisee($ilUser->getId())) {
             $info->addSection($this->lng->txt("survey_360_appraisee_info"));
             $appr_data = $this->object->getAppraiseesData();
             $appr_data = $appr_data[$ilUser->getId()];
             $info->addProperty($this->lng->txt("survey_360_raters_status_info"), $appr_data["finished"]);
             if (!$appr_data["closed"]) {
                 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
                 $button = ilLinkButton::getInstance();
                 $button->setCaption("survey_360_appraisee_close_action");
                 $button->setUrl($this->ctrl->getLinkTargetByClass("ilsurveyparticipantsgui", "confirmappraiseeclose"));
                 $close_button_360 = '<div>' . $button->render() . '</div>';
                 $txt = "survey_360_appraisee_close_action_info";
                 if ($this->object->get360SkillService()) {
                     $txt .= "_skill";
                 }
                 $info->addProperty($this->lng->txt("status"), $close_button_360 . $this->lng->txt($txt));
             } else {
                 ilDatePresentation::setUseRelativeDates(false);
                 $dt = new ilDateTime($appr_data["closed"], IL_CAL_UNIX);
                 $info->addProperty($this->lng->txt("status"), sprintf($this->lng->txt("survey_360_appraisee_close_action_status"), ilDatePresentation::formatDate($dt)));
             }
             $is_appraisee = true;
         }
         // handle code
         // validate incoming
         $code_input = false;
         $anonymous_code = $_POST["anonymous_id"];
         if ($anonymous_code) {
             $code_input = true;
             // if(!$this->object->isUnusedCode($anonymous_code, $ilUser->getId()))
             if (!$this->object->checkSurveyCode($anonymous_code)) {
                 $anonymous_code = null;
             } else {
                 // #15860
                 $this->object->bindSurveyCodeToUser($ilUser->getId(), $anonymous_code);
             }
         }
         if ($anonymous_code) {
             $_SESSION["anonymous_id"][$this->object->getId()] = $anonymous_code;
         } else {
             $anonymous_code = $_SESSION["anonymous_id"][$this->object->getId()];
             if ($anonymous_code) {
                 $code_input = true;
             }
         }
         // try to find code for current (registered) user from existing run
         if ($this->object->getAnonymize() && !$anonymous_code) {
             $anonymous_code = $this->object->findCodeForUser($ilUser->getId());
         }
         // get existing runs for current user, might generate code
         $participant_status = $this->object->getUserSurveyExecutionStatus($anonymous_code);
         if ($participant_status) {
             $anonymous_code = $participant_status["code"];
             $participant_status = $participant_status["runs"];
         }
         // (final) check for proper anonymous code
         if (!$this->object->isAccessibleWithoutCode() && !$is_appraisee && $code_input && (!$anonymous_code || !$this->object->isAnonymousKey($anonymous_code))) {
             $anonymous_code = null;
             ilUtil::sendInfo($this->lng->txt("wrong_survey_code_used"));
         }
         // :TODO: really save in session?
         $_SESSION["anonymous_id"][$this->object->getId()] = $anonymous_code;
         // code is mandatory and not given yet
         if (!$is_appraisee && !$anonymous_code && !$this->object->isAccessibleWithoutCode()) {
             $info->setFormAction($this->ctrl->getFormAction($this, "infoScreen"));
             $info->addSection($this->lng->txt("anonymization"));
             $info->addProperty("", $this->lng->txt("anonymize_anonymous_introduction"));
             $info->addPropertyTextinput($this->lng->txt("enter_anonymous_id"), "anonymous_id", "", 8, "infoScreen", $this->lng->txt("submit"), true);
         } else {
             // trunk/default
             if (!$this->object->get360Mode()) {
                 if ($anonymous_code) {
                     $info->addHiddenElement("anonymous_id", $anonymous_code);
                 }
                 $survey_started = $this->object->isSurveyStarted($ilUser->getId(), $anonymous_code);
                 if ($survey_started === 1) {
                     if ($ilUser->getId() != ANONYMOUS_USER_ID) {
                         if ($this->object->hasViewOwnResults()) {
                             include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
                             $button = ilLinkButton::getInstance();
                             $button->setCaption("svy_view_own_results");
                             $button->setUrl($this->ctrl->getLinkTarget($this, "viewUserResults"));
                             $ilToolbar->addButtonInstance($button);
                         }
                         if ($this->object->hasMailOwnResults()) {
                             if ($this->object->hasViewOwnResults()) {
                                 $ilToolbar->addSeparator();
                             }
                             require_once "Services/Form/classes/class.ilTextInputGUI.php";
                             $mail = new ilTextInputGUI($this->lng->txt("email"), "mail");
                             $mail->setSize(25);
                             $mail->setValue($ilUser->getEmail());
                             $ilToolbar->addInputItem($mail, true);
                             $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "mailUserResults"));
                             include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
                             $button = ilSubmitButton::getInstance();
                             $button->setCaption("svy_mail_own_results");
                             $button->setCommand("mailUserResults");
                             $ilToolbar->addButtonInstance($button);
                         }
                     }
                     ilUtil::sendInfo($this->lng->txt("already_completed_survey"));
                 } elseif ($survey_started === 0) {
                     $big_button = array("resume", $this->lng->txt("resume_survey"));
                 } elseif ($survey_started === FALSE) {
                     $big_button = array("start", $this->lng->txt("start_survey"));
                 }
             } else {
                 $appr_ids = array();
                 // use given code (if proper external one)
                 if ($anonymous_code) {
                     $anonymous_id = $this->object->getAnonymousIdByCode($anonymous_code);
                     if ($anonymous_id) {
                         $appr_ids = $this->object->getAppraiseesToRate(0, $anonymous_id);
                     }
                 }
                 // registered user
                 // if an auto-code was generated, we still have to check for the original user id
                 if (!$appr_ids && $ilUser->getId() != ANONYMOUS_USER_ID) {
                     $appr_ids = $this->object->getAppraiseesToRate($ilUser->getId());
                 }
                 if (sizeof($appr_ids)) {
                     // map existing runs to appraisees
                     $active_appraisees = array();
                     if ($participant_status) {
                         foreach ($participant_status as $item) {
                             $active_appraisees[$item["appr_id"]] = $item["finished"];
                         }
                     }
                     $list = array();
                     foreach ($appr_ids as $appr_id) {
                         if ($this->object->isAppraiseeClosed($appr_id)) {
                             // closed
                             $list[$appr_id] = $this->lng->txt("survey_360_appraisee_is_closed");
                         } else {
                             if (array_key_exists($appr_id, $active_appraisees)) {
                                 // already done
                                 if ($active_appraisees[$appr_id]) {
                                     $list[$appr_id] = $this->lng->txt("already_completed_survey");
                                 } else {
                                     $list[$appr_id] = array("resume", $this->lng->txt("resume_survey"));
                                 }
                             } else {
                                 // start
                                 $list[$appr_id] = array("start", $this->lng->txt("start_survey"));
                             }
                         }
                     }
                     $info->addSection($this->lng->txt("survey_360_rate_other_appraisees"));
                     include_once "Services/User/classes/class.ilUserUtil.php";
                     foreach ($list as $appr_id => $item) {
                         $appr_name = ilUserUtil::getNamePresentation($appr_id, false, false, "", true);
                         if (!is_array($item)) {
                             $info->addProperty($appr_name, $item);
                         } else {
                             $this->ctrl->setParameter($output_gui, "appr_id", $appr_id);
                             $href = $this->ctrl->getLinkTarget($output_gui, $item[0]);
                             $this->ctrl->setParameter($output_gui, "appr_id", "");
                             include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
                             $button = ilLinkButton::getInstance();
                             $button->setCaption($item[1], false);
                             $button->setUrl($href);
                             $big_button_360 = '<div>' . $button->render() . '</div>';
                             $info->addProperty($appr_name, $big_button_360);
                         }
                     }
                 } else {
                     if (!$is_appraisee) {
                         ilUtil::sendFailure($this->lng->txt("survey_360_no_appraisees"));
                     }
                 }
             }
         }
         if ($this->object->get360Mode() && $this->object->get360SelfAppraisee() && !$this->object->isAppraisee($ilUser->getId()) && $ilUser->getId() != ANONYMOUS_USER_ID) {
             $link = $this->ctrl->getLinkTargetByClass("ilsurveyparticipantsgui", "addSelfAppraisee");
             $link = '<a href="' . $link . '">' . $this->lng->txt("survey_360_add_self_appraisee") . '</a>';
             $info->addProperty("&nbsp;", $link);
         }
     }
     if ($big_button) {
         $ilToolbar->setFormAction($this->ctrl->getFormAction($output_gui, "infoScreen"));
         include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
         $button = ilSubmitButton::getInstance();
         $button->setCaption($big_button[1], false);
         $button->setCommand($big_button[0]);
         $button->setPrimary(true);
         $ilToolbar->addButtonInstance($button);
         $ilToolbar->setCloseFormTag(false);
         $info->setOpenFormTag(false);
     }
     /* #12016
     		else
     		{
     			$info->setFormAction($this->ctrl->getFormAction($output_gui, "infoScreen"));
     		}
     		*/
     if (strlen($this->object->getIntroduction())) {
         $introduction = $this->object->getIntroduction();
         $info->addSection($this->lng->txt("introduction"));
         $info->addProperty("", $this->object->prepareTextareaOutput($introduction) . "<br />" . $info->getHiddenToggleButton());
     } else {
         $info->addSection("");
         $info->addProperty("", $info->getHiddenToggleButton());
     }
     $info->hideFurtherSections(false);
     if (!$this->object->get360Mode()) {
         $info->addSection($this->lng->txt("svy_general_properties"));
         $info->addProperty($this->lng->txt("survey_results_anonymization"), !$this->object->hasAnonymizedResults() ? $this->lng->txt("survey_results_personalized_info") : $this->lng->txt("survey_results_anonymized_info"));
         include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php";
         if ($ilAccess->checkAccess("write", "", $this->ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId())) {
             $info->addProperty($this->lng->txt("evaluation_access"), $this->lng->txt("evaluation_access_info"));
         }
     }
     $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
     $this->ctrl->forwardCommand($info);
 }
 /**
  * list questions of question pool
  */
 public function questionsObject($arrFilter = null)
 {
     global $rbacsystem;
     global $ilUser;
     global $ilToolbar;
     $this->object->purgeQuestions();
     $_SESSION['q_id_table_nav'] = $_GET['q_id_table_nav'];
     if ($rbacsystem->checkAccess('write', $_GET['ref_id'])) {
         include_once "Services/Form/classes/class.ilSelectInputGUI.php";
         $qtypes = new ilSelectInputGUI("", "sel_question_types");
         $qtypes->setValue($ilUser->getPref("svy_lastquestiontype"));
         $ilToolbar->addInputItem($qtypes);
         $options = array();
         foreach (ilObjSurveyQuestionPool::_getQuestionTypes() as $translation => $data) {
             $options[$data["type_tag"]] = $translation;
         }
         $qtypes->setOptions($options);
         $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
         include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
         $button = ilSubmitButton::getInstance();
         $button->setCaption("svy_create_question");
         $button->setCommand("createQuestion");
         $ilToolbar->addButtonInstance($button);
         $ilToolbar->addSeparator();
         $button = ilSubmitButton::getInstance();
         $button->setCaption("import");
         $button->setCommand("importQuestions");
         $ilToolbar->addButtonInstance($button);
     }
     include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
     $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions', $rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false);
     $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
     $arrFilter = array();
     foreach ($table_gui->getFilterItems() as $item) {
         if ($item->getValue() !== false) {
             $arrFilter[$item->getPostVar()] = $item->getValue();
         }
     }
     $table_gui->setData($this->object->getQuestionsData($arrFilter));
     $this->tpl->setContent($table_gui->getHTML());
 }
 /**
  * Get confirmation screen HTML.
  *
  * @return	string		HTML code.
  */
 public final function getHTML()
 {
     global $lng;
     ilUtil::sendQuestion($this->getHeaderText());
     include_once "./Services/Utilities/classes/class.ilConfirmationTableGUI.php";
     // delete/handle items
     if (count($this->item) > 0) {
         $ctab = new ilConfirmationTableGUI($this->use_images);
         $ctab->setData($this->item);
         // other buttons
         foreach ($this->buttons as $b) {
             $ctab->addCommandButton($b["cmd"], $b["txt"]);
         }
         $ctab->addCommandButton($this->confirm_cmd, $this->confirm_txt);
         $ctab->addCommandButton($this->cancel_cmd, $this->cancel_txt);
         $ctab->setFormAction($this->getFormAction());
         foreach ($this->hidden_item as $hidden_item) {
             $ctab->addHiddenInput($hidden_item["var"], $hidden_item["value"]);
         }
         if ($this->form_name) {
             $ctab->setFormName($this->form_name);
         }
         return $ctab->getHTML();
     } else {
         $tb = new ilToolbarGUI();
         $tb->setPreventDoubleSubmission(true);
         $tb->setFormAction($this->getFormAction());
         if ($this->hidden_item) {
             require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
             foreach ($this->hidden_item as $hidden_item) {
                 $hiddenInput = new ilHiddenInputGUI($hidden_item['var']);
                 $hiddenInput->setValue($hidden_item['value']);
                 $tb->addInputItem($hiddenInput);
             }
         }
         require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
         $confirm = ilSubmitButton::getInstance();
         $confirm->setCommand($this->confirm_cmd);
         $confirm->setCaption($this->confirm_txt, false);
         $cancel = ilSubmitButton::getInstance();
         $cancel->setCommand($this->cancel_cmd);
         $cancel->setCaption($this->cancel_txt, false);
         $tb->addButtonInstance($confirm);
         $tb->addButtonInstance($cancel);
         return $tb->getHTML();
     }
 }
 public function editFields()
 {
     global $ilToolbar;
     $this->ctrl->saveParameter($this, 'record_id');
     $this->initRecordObject();
     $perm = $this->getPermissions()->hasPermissions(ilAdvancedMDPermissionHelper::CONTEXT_RECORD, $this->record->getRecordId(), array(ilAdvancedMDPermissionHelper::ACTION_RECORD_CREATE_FIELD, ilAdvancedMDPermissionHelper::ACTION_RECORD_FIELD_POSITIONS));
     if ($perm[ilAdvancedMDPermissionHelper::ACTION_RECORD_CREATE_FIELD]) {
         // type selection
         include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
         $types = new ilSelectInputGUI("", "ftype");
         $options = array();
         foreach (ilAdvancedMDFieldDefinition::getValidTypes() as $type) {
             $field = ilAdvancedMDFieldDefinition::getInstance(null, $type);
             $options[$type] = $this->lng->txt($field->getTypeTitle());
         }
         $types->setOptions($options);
         $ilToolbar->addInputItem($types);
         $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "createField"));
         include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
         $button = ilSubmitButton::getInstance();
         $button->setCaption("add");
         $button->setCommand("createField");
         $ilToolbar->addButtonInstance($button);
     }
     // show field table
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
     $fields = ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->record->getRecordId());
     include_once "./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldTableGUI.php";
     $table_gui = new ilAdvancedMDFieldTableGUI($this, "editRecord", $this->getPermissions(), $perm[ilAdvancedMDPermissionHelper::ACTION_RECORD_FIELD_POSITIONS]);
     $table_gui->setTitle($this->lng->txt("md_adv_field_table"));
     $table_gui->parseDefinitions($fields);
     if (sizeof($fields)) {
         $table_gui->addCommandButton("updateFields", $this->lng->txt("save"));
     }
     $table_gui->addCommandButton("showRecords", $this->lng->txt('cancel'));
     $table_gui->addMultiCommand("confirmDeleteFields", $this->lng->txt("delete"));
     $table_gui->setSelectAllCheckbox("field_id");
     $this->tpl->setContent($table_gui->getHTML());
 }