/** * Add all fields to the form */ protected function initForm() { $this->setFormAction($this->ctrl->getFormAction($this->parent_gui)); $this->setTitle($this->lng->txt('orgu_type_assign_amd_sets')); $options = array(); $records = ilOrgUnitType::getAvailableAdvancedMDRecords(); /** @var ilAdvancedMDRecord $record */ foreach ($records as $record) { $options[$record->getRecordId()] = $record->getTitle(); } $selected = array(); $records_selected = $this->type->getAssignedAdvancedMDRecordIds(); foreach ($records_selected as $record_id) { $selected[] = $record_id; } $item = new ilMultiSelectInputGUI($this->lng->txt('orgu_type_available_amd_sets'), 'amd_records'); $item->setOptions($options); $item->setValue($selected); $this->addItem($item); $this->addCommandButton('updateAMD', $this->lng->txt('save')); }
public function addCustomSettingsToForm(ilPropertyFormGUI $a_form) { global $lng, $rbacreview, $ilObjDataCache, $ilSetting; include_once 'Services/Form/classes/class.ilMultiSelectInputGUI.php'; $sub_mlist = new ilMultiSelectInputGUI($lng->txt('delete_inactive_user_accounts_include_roles'), 'cron_inactive_user_delete_include_roles'); $sub_mlist->setInfo($lng->txt('delete_inactive_user_accounts_include_roles_desc')); $roles = array(); foreach ($rbacreview->getGlobalRoles() as $role_id) { if ($role_id != ANONYMOUS_ROLE_ID) { $roles[$role_id] = $ilObjDataCache->lookupTitle($role_id); } } $sub_mlist->setOptions($roles); $setting = $ilSetting->get('cron_inactive_user_delete_include_roles', null); if ($setting === null) { $setting = array(); } else { $setting = explode(',', $setting); } $sub_mlist->setValue($setting); $sub_mlist->setWidth(300); #$sub_mlist->setHeight(100); $a_form->addItem($sub_mlist); $default_setting = self::DEFAULT_INACTIVITY_PERIOD; $sub_text = new ilTextInputGUI($lng->txt('delete_inactive_user_accounts_period'), 'cron_inactive_user_delete_period'); $sub_text->setInfo($lng->txt('delete_inactive_user_accounts_period_desc')); $sub_text->setValue($ilSetting->get("cron_inactive_user_delete_period", $default_setting)); $sub_text->setSize(2); $sub_text->setMaxLength(3); $sub_text->setRequired(true); $a_form->addItem($sub_text); /* $default_setting = ilCronDeleteInactiveUserAccounts::DEFAULT_SETTING_INCLUDE_ADMINS; $sub_cb = new ilCheckboxInputGUI($lng->txt('delete_inactive_user_accounts_include_admins'),'cron_inactive_user_delete_include_admins'); $sub_cb->setChecked($ilSetting->get("cron_inactive_user_delete_include_admins", $default_setting) ? 1 : 0 ); //$sub_cb->setOptionTitle($lng->txt('delete_inactive_user_accounts_include_admins')); $sub_cb->setInfo($lng->txt('delete_inactive_user_accounts_include_admins_desc')); $a_form->addItem($sub_cb); */ }
/** * Init form */ protected function initForm() { $this->setFormAction($this->ctrl->getFormAction($this->parent_gui)); $title = $this->isNew ? $this->pl->txt('add_new_type') : $this->pl->txt('edit_type'); $this->setTitle($title); $item = new ilTextInputGUI($this->lng->txt('title'), 'title'); $item->setRequired(true); $item->setValue($this->type->getTitle()); $this->addItem($item); $item = new ilTextAreaInputGUI($this->lng->txt('description'), 'description'); $item->setValue($this->type->getDescription()); $this->addItem($item); $item = new ilMultiSelectInputGUI($this->lng->txt('languages'), 'languages'); $item->setWidth(self::WIDTH_MULTISELECT_INPUT); $langs = $this->lng->getInstalledLanguages(); $options = array(); foreach ($langs as $lang_code) { $options[$lang_code] = $this->lng->txt("meta_l_{$lang_code}"); } $item->setOptions($options); $item->setValue($this->type->getLanguages()); $item->setRequired(true); $this->addItem($item); $item = new ilMultiSelectInputGUI($this->lng->txt('roles'), 'roles'); $item->setWidth(self::WIDTH_MULTISELECT_INPUT); $roles = $this->rbac->getRolesByFilter(ilRbacReview::FILTER_ALL, 0, ''); $options = array(); $hide_roles = array(14, 5); foreach ($roles as $role) { if (strpos($role['title'], 'il_') === 0 || in_array($role['obj_id'], $hide_roles)) { // Don't show auto-generated roles. If this takes to much performance, write query... continue; } $options[$role['obj_id']] = $role['title']; } $item->setOptions($options); $item->setValue($this->type->getRoles()); $item->setInfo($this->pl->txt('roles_info')); $this->addItem($item); $item = new ilMultiSelectInputGUI($this->pl->txt('available_objects'), 'available_objects'); $item->setWidth(self::WIDTH_MULTISELECT_INPUT); $options = array(); foreach (srCertificateType::getAllAvailableObjectTypes() as $type) { $options[$type] = $type; } $item->setOptions($options); $item->setValue($this->type->getAvailableObjects()); $item->setRequired(true); $item->setInfo($this->pl->txt('available_objects_info')); $this->addItem($item); $this->addCommandButton('saveType', $this->lng->txt('save')); }
protected function initTagsForm($a_id, $a_cmd, $a_title) { global $ilAccess; include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($this->ctrl->getFormAction($this, $a_cmd)); $form->setTitle($this->lng->txt($a_title)); $alltags = $this->object->getHTMLTags(); $alltags = array_combine($alltags, $alltags); include_once "Services/Form/classes/class.ilMultiSelectInputGUI.php"; $tags = new ilMultiSelectInputGUI($this->lng->txt("advanced_editing_allow_html_tags"), "html_tags"); $tags->setHeight(400); $tags->enableSelectAll(true); $tags->enableSelectedFirst(true); $tags->setOptions($alltags); $tags->setValue($this->object->_getUsedHTMLTags($a_id)); $form->addItem($tags); if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) { $form->addCommandButton($a_cmd, $this->lng->txt("save")); } return $form; }
/** * Init form */ protected function initForm() { $this->setFormAction($this->ctrl->getFormAction($this->parent_gui)); $title = sprintf($this->pl->txt('edit_setting'), $this->pl->txt("setting_id_{$this->identifier}")); $this->setTitle($title); $item = new ilHiddenInputGUI('identifier'); $item->setValue($this->identifier); $this->addItem($item); $item = $this->getInputByIdentifier(); if ($item !== null) { $this->addItem($item); } $item = new ilMultiSelectInputGUI($this->pl->txt('editable_in'), 'editable_in'); $options = array(); foreach (srCertificateType::getAllAvailableObjectTypes() as $type) { $options[$type] = $type; } $item->setOptions($options); $item->setValue($this->type->getSettingByIdentifier($this->identifier)->getEditableIn()); $this->addItem($item); $this->addCommandButton('updateSetting', $this->lng->txt('save')); }
/** * Init cron jobs form. */ public function initCronJobsForm() { global $lng, $ilSetting, $rbacreview, $ilObjDataCache; include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $this->form = new ilPropertyFormGUI(); $cls = new ilNonEditableValueGUI($this->lng->txt('cronjob_last_start'), 'cronjob_last_start'); if ($ilSetting->get('last_cronjob_start_ts')) { include_once './Services/Calendar/classes/class.ilDatePresentation.php'; $cls->setInfo(ilDatePresentation::formatDate(new ilDateTime($ilSetting->get('last_cronjob_start_ts'), IL_CAL_UNIX))); } else { $cls->setInfo($this->lng->txt('cronjob_last_start_unknown')); } $this->form->addItem($cls); // check user accounts $cb = new ilCheckboxInputGUI($this->lng->txt("check_user_accounts"), "cron_user_check"); $cb->setInfo($this->lng->txt("check_user_accounts_desc")); if ($ilSetting->get("cron_user_check")) { $cb->setChecked(true); } $this->form->addItem($cb); // delete inactive user accounts require_once 'Services/User/classes/class.ilCronDeleteInactiveUserAccounts.php'; $cb = new ilCheckboxInputGUI($this->lng->txt("delete_inactive_user_accounts"), "cron_inactive_user_delete"); $cb->setInfo($this->lng->txt("delete_inactive_user_accounts_desc")); if ($ilSetting->get("cron_inactive_user_delete", false)) { $cb->setChecked(true); } $sub_list = new ilSelectInputGUI($this->lng->txt('delete_inactive_user_accounts_interval'), 'cron_inactive_user_delete_interval'); $sub_list->setInfo($this->lng->txt('delete_inactive_user_accounts_interval_desc')); $sub_list->setOptions(ilCronDeleteInactiveUserAccounts::getPossibleIntervalsArray()); $sub_list->setValue($ilSetting->get('cron_inactive_user_delete_interval', ilCronDeleteInactiveUserAccounts::getDefaultIntervalKey())); $cb->addSubItem($sub_list); include_once 'Services/Form/classes/class.ilMultiSelectInputGUI.php'; $sub_mlist = new ilMultiSelectInputGUI($this->lng->txt('delete_inactive_user_accounts_include_roles'), 'cron_inactive_user_delete_include_roles'); $sub_mlist->setInfo($this->lng->txt('delete_inactive_user_accounts_include_roles_desc')); $roles = array(); foreach ($rbacreview->getGlobalRoles() as $role_id) { if ($role_id != ANONYMOUS_ROLE_ID) { $roles[$role_id] = $ilObjDataCache->lookupTitle($role_id); } } $sub_mlist->setOptions($roles); $setting = $ilSetting->get('cron_inactive_user_delete_include_roles', null); if ($setting === null) { $setting = array(); } else { $setting = explode(',', $setting); } $sub_mlist->setValue($setting); $sub_mlist->setWidth(300); #$sub_mlist->setHeight(100); $cb->addSubItem($sub_mlist); $default_setting = ilCronDeleteInactiveUserAccounts::DEFAULT_INACTIVITY_PERIOD; $sub_text = new ilTextInputGUI($this->lng->txt('delete_inactive_user_accounts_period'), 'cron_inactive_user_delete_period'); $sub_text->setInfo($this->lng->txt('delete_inactive_user_accounts_period_desc')); $sub_text->setValue($ilSetting->get("cron_inactive_user_delete_period", $default_setting)); $sub_text->setSize(2); $sub_text->setMaxLength(3); $cb->addSubItem($sub_text); /* $default_setting = ilCronDeleteInactiveUserAccounts::DEFAULT_SETTING_INCLUDE_ADMINS; $sub_cb = new ilCheckboxInputGUI($this->lng->txt('delete_inactive_user_accounts_include_admins'),'cron_inactive_user_delete_include_admins'); $sub_cb->setChecked($ilSetting->get("cron_inactive_user_delete_include_admins", $default_setting) ? 1 : 0 ); //$sub_cb->setOptionTitle($this->lng->txt('delete_inactive_user_accounts_include_admins')); $sub_cb->setInfo($this->lng->txt('delete_inactive_user_accounts_include_admins_desc')); $cb->addSubItem($sub_cb); */ $this->form->addItem($cb); // delete inactivated user accounts require_once 'Services/User/classes/class.ilCronDeleteInactivatedUserAccounts.php'; $cb = new ilCheckboxInputGUI($this->lng->txt("delete_inactivated_user_accounts"), "cron_inactivated_user_delete"); $cb->setInfo($this->lng->txt("delete_inactivated_user_accounts_desc")); if ($ilSetting->get("cron_inactivated_user_delete", false)) { $cb->setChecked(true); } $sub_list = new ilSelectInputGUI($this->lng->txt('delete_inactivated_user_accounts_interval'), 'cron_inactivated_user_delete_interval'); $sub_list->setInfo($this->lng->txt('delete_inactivated_user_accounts_interval_desc')); $sub_list->setOptions(ilCronDeleteInactiveUserAccounts::getPossibleIntervalsArray()); $sub_list->setValue($ilSetting->get('cron_inactivated_user_delete_interval', ilCronDeleteInactiveUserAccounts::getDefaultIntervalKey())); $cb->addSubItem($sub_list); include_once 'Services/Form/classes/class.ilMultiSelectInputGUI.php'; $sub_mlist = new ilMultiSelectInputGUI($this->lng->txt('delete_inactivated_user_accounts_include_roles'), 'cron_inactivated_user_delete_include_roles'); $sub_mlist->setInfo($this->lng->txt('delete_inactivated_user_accounts_include_roles_desc')); $roles = array(); foreach ($rbacreview->getGlobalRoles() as $role_id) { if ($role_id != ANONYMOUS_ROLE_ID) { $roles[$role_id] = $ilObjDataCache->lookupTitle($role_id); } } $sub_mlist->setOptions($roles); $setting = $ilSetting->get('cron_inactivated_user_delete_include_roles', null); if ($setting === null) { $setting = array(); } else { $setting = explode(',', $setting); } $sub_mlist->setValue($setting); $sub_mlist->setWidth(300); #$sub_mlist->setHeight(100); $cb->addSubItem($sub_mlist); $default_setting = ilCronDeleteInactiveUserAccounts::DEFAULT_INACTIVITY_PERIOD; $sub_text = new ilTextInputGUI($this->lng->txt('delete_inactivated_user_accounts_period'), 'cron_inactivated_user_delete_period'); $sub_text->setInfo($this->lng->txt('delete_inactivated_user_accounts_period_desc')); $sub_text->setValue($ilSetting->get("cron_inactivated_user_delete_period", $default_setting)); $sub_text->setSize(2); $sub_text->setMaxLength(3); $cb->addSubItem($sub_text); /* $default_setting = ilCronDeleteInactiveUserAccounts::DEFAULT_SETTING_INCLUDE_ADMINS; $sub_cb = new ilCheckboxInputGUI($this->lng->txt('delete_inactivated_user_accounts_include_admins'),'cron_inactivated_user_delete_include_admins'); $sub_cb->setChecked($ilSetting->get("cron_inactivated_user_delete_include_admins", $default_setting) ? 1 : 0 ); //$sub_cb->setOptionTitle($this->lng->txt('delete_inactivated_user_accounts_include_admins')); $sub_cb->setInfo($this->lng->txt('delete_inactivated_user_accounts_include_admins_desc')); $cb->addSubItem($sub_cb); */ $this->form->addItem($cb); // link check $cb = new ilCheckboxInputGUI($this->lng->txt("check_link"), "cron_link_check"); $cb->setInfo($this->lng->txt("check_link_desc")); if ($ilSetting->get("cron_link_check")) { $cb->setChecked(true); } $this->form->addItem($cb); // check web resources $options = array("0" => $lng->txt("never"), "1" => $lng->txt("daily"), "2" => $lng->txt("weekly"), "3" => $lng->txt("monthly"), "4" => $lng->txt("quarterly")); $si = new ilSelectInputGUI($this->lng->txt("check_web_resources"), "cron_web_resource_check"); $si->setOptions($options); $si->setInfo($this->lng->txt("check_web_resources_desc")); $si->setValue($ilSetting->get("cron_web_resource_check")); $this->form->addItem($si); // update lucene $cb = new ilCheckboxInputGUI($this->lng->txt("cron_lucene_index"), "cron_lucene_index"); $cb->setInfo($this->lng->txt("cron_lucene_index_info")); if ($ilSetting->get("cron_lucene_index")) { $cb->setChecked(true); } $this->form->addItem($cb); // forum notifications $options = array("0" => $lng->txt("cron_forum_notification_never"), "1" => $lng->txt("cron_forum_notification_directly"), "2" => $lng->txt("cron_forum_notification_cron")); $si = new ilSelectInputGUI($this->lng->txt("cron_forum_notification"), "forum_notification"); $si->setOptions($options); $si->setInfo($this->lng->txt("cron_forum_notification_desc")); $si->setValue($ilSetting->get("forum_notification")); $this->form->addItem($si); // mail notifications $options = array("0" => $lng->txt("cron_mail_notification_never"), "1" => $lng->txt("cron_mail_notification_cron")); $si = new ilSelectInputGUI($this->lng->txt("cron_mail_notification"), "mail_notification"); $si->setOptions($options); $si->setInfo($this->lng->txt("cron_mail_notification_desc")); $si->setValue($ilSetting->get("mail_notification")); $this->form->addItem($si); if ($ilSetting->get("mail_notification") == '1') { $cb = new ilCheckboxInputGUI($this->lng->txt("cron_mail_notification_message"), "mail_notification_message"); $cb->setInfo($this->lng->txt("cron_mail_notification_message_info")); if ($ilSetting->get("mail_notification_message")) { $cb->setChecked(true); } $this->form->addItem($cb); } // disk quota and disk quota reminder mail $dq_settings = new ilSetting('disk_quota'); $cb = new ilCheckboxInputGUI($this->lng->txt("enable_disk_quota"), "enable_disk_quota"); $cb->setInfo($this->lng->txt("enable_disk_quota_info")); if ($dq_settings->get('enabled')) { $cb->setChecked(true); } $this->form->addItem($cb); $cb_reminder = new ilCheckboxInputGUI($this->lng->txt("enable_disk_quota_reminder_mail"), "enable_disk_quota_reminder_mail"); $cb_reminder->setInfo($this->lng->txt("disk_quota_reminder_mail_desc")); if ($dq_settings->get('reminder_mail_enabled')) { $cb_reminder->setChecked(true); } $cb->addSubItem($cb_reminder); // Enable summary mail for certain users $cb_prop_summary = new ilCheckboxInputGUI($lng->txt("enable_disk_quota_summary_mail"), "enable_disk_quota_summary_mail"); $cb_prop_summary->setValue(1); $cb_prop_summary->setChecked((int) $dq_settings->get('summary_mail_enabled', 0) == 1); $cb_prop_summary->setInfo($lng->txt('enable_disk_quota_summary_mail_desc')); $cb->addSubItem($cb_prop_summary); // Edit disk quota recipients $summary_rcpt = new ilTextInputGUI($lng->txt("disk_quota_summary_rctp"), "disk_quota_summary_rctp"); $summary_rcpt->setValue($dq_settings->get('summary_rcpt', '')); $summary_rcpt->setInfo($lng->txt('disk_quota_summary_rctp_desc')); $cb_prop_summary->addSubItem($summary_rcpt); // Enable payment notifications $payment_noti = new ilCheckboxInputGUI($lng->txt("payment_notification"), "payment_notification"); $payment_noti->setValue(1); $payment_noti->setChecked((int) $ilSetting->get('payment_notification', 0) == 1); $payment_noti->setInfo($lng->txt('payment_notification_desc')); $num_days = new ilNumberInputGUI($this->lng->txt('payment_notification_days'), 'payment_notification_days'); $num_days->setSize(3); $num_days->setMinValue(0); $num_days->setMaxValue(120); $num_days->setRequired(true); $num_days->setValue($ilSetting->get('payment_notification_days')); $num_days->setInfo($lng->txt('payment_notification_days_desc')); $payment_noti->addSubItem($num_days); $this->form->addItem($payment_noti); // reset payment incremental invoice number $inv_options = array("1" => $lng->txt("yearly"), "2" => $lng->txt("monthly")); include_once './Services/Payment/classes/class.ilUserDefinedInvoiceNumber.php'; if (ilUserDefinedInvoiceNumber::_isUDInvoiceNumberActive()) { $inv_reset = new ilSelectInputGUI($this->lng->txt("invoice_number_reset_period"), "invoice_number_reset_period"); $inv_reset->setOptions($inv_options); $inv_reset->setInfo($this->lng->txt("invoice_number_reset_period_desc")); $inv_reset->setValue(ilUserDefinedInvoiceNumber::_getResetPeriod()); $this->form->addItem($inv_reset); } else { $inv_info = new ilNonEditableValueGUI($this->lng->txt('invoice_number_reset_period'), 'invoice_number_reset_period'); $inv_info->setInfo($lng->txt('payment_userdefined_invoice_number_not_activated')); $this->form->addItem($inv_info); } // course/group notifications $crsgrp_ntf = new ilCheckboxInputGUI($this->lng->txt("enable_course_group_notifications"), "crsgrp_ntf"); $crsgrp_ntf->setInfo($this->lng->txt("enable_course_group_notifications_desc")); if ($ilSetting->get('crsgrp_ntf')) { $crsgrp_ntf->setChecked(true); } $this->form->addItem($crsgrp_ntf); $this->form->addCommandButton("saveCronJobs", $lng->txt("save")); $this->form->setTitle($lng->txt("cron_jobs")); $this->form->setDescription($lng->txt("cron_jobs_desc")); $this->form->setFormAction($this->ctrl->getFormAction($this)); }
/** * Init your form * */ protected function initForm() { $title = $this->setting->getId() ? sprintf($this->pl->txt('edit_setting'), $this->setting->getIdentifier()) : $this->pl->txt('add_new_custom_setting'); $this->setTitle($title); $item = new ilHiddenInputGUI('custom_setting_id'); $item->setValue($this->setting->getId()); $this->addItem($item); $item = new ilTextInputGUI($this->pl->txt('identifier'), 'identifier'); $item->setRequired(true); $item->setValue($this->setting->getIdentifier()); $item->setInfo(sprintf($this->pl->txt('identifier_info'), srCertificatePlaceholder::REGEX_VALID_IDENTIFIER)); $this->addItem($item); $item = new ilRadioGroupInputGUI($this->pl->txt('custom_setting_type'), 'setting_type_id'); $item->setRequired(true); $option = new ilRadioOption($this->pl->txt('custom_setting_type_' . srCertificateCustomTypeSetting::SETTING_TYPE_BOOLEAN), srCertificateCustomTypeSetting::SETTING_TYPE_BOOLEAN); $item->addOption($option); $option = new ilRadioOption($this->pl->txt('custom_setting_type_' . srCertificateCustomTypeSetting::SETTING_TYPE_SELECT), srCertificateCustomTypeSetting::SETTING_TYPE_SELECT); $subitem = new ilTextAreaInputGUI($this->pl->txt('custom_setting_type_2_data'), 'data'); $subitem->setValue($this->setting->getData()); $subitem->setInfo($this->pl->txt('custom_setting_type_2_data_info')); $option->addSubItem($subitem); $item->setValue($this->setting->getSettingTypeId()); $item->addOption($option); $this->addItem($item); $item = new ilTextInputGUI($this->pl->txt('default_value'), "value"); $item->setInfo($this->pl->txt('custom_setting_default_value_info')); $item->setValue($this->setting->getValue()); $this->addItem($item); $item = new ilMultiSelectInputGUI($this->pl->txt('editable_in'), 'editable_in'); $options = array(); foreach (srCertificateType::getAllAvailableObjectTypes() as $type) { $options[$type] = $type; } $item->setOptions($options); $item->setValue($this->setting->getEditableIn()); $this->addItem($item); // Update definitions, add settings if (!$this->setting->getId()) { $item = new ilCheckboxInputGUI($this->pl->txt('update_cert_definitions'), 'update_definitions'); $item->setInfo($this->pl->txt('custom_setting_update_cert_definitions_info')); $this->addItem($item); } // Label per language /** @var srCertificateType $type */ $type = $this->setting->getId() ? srCertificateType::find($this->setting->getTypeId()) : srCertificateType::find((int) $_GET['type_id']); foreach ($type->getLanguages() as $lang_code) { $this->addLabelInput($lang_code); } }
/** * Init form */ protected function initForm() { $type = $this->placeholder->getCertificateType(); $this->setFormAction($this->ctrl->getFormAction($this->parent_gui)); $title = $this->placeholder->getId() ? $this->pl->txt('edit_placeholder') : $this->pl->txt('add_placeholder'); $this->setTitle($title); $item = new ilTextInputGUI($this->pl->txt('identifier'), 'identifier'); $item->setRequired(true); $item->setValue($this->placeholder->getIdentifier()); $item->setInfo(sprintf($this->pl->txt('identifier_info'), srCertificatePlaceholder::REGEX_VALID_IDENTIFIER)); $this->addItem($item); $item = new ilNumberInputGUI($this->pl->txt('max_characters'), 'max_characters'); $item->setRequired(true); $item->setSize(2); $item->setInfo($this->pl->txt('max_characters_info')); $item->setValue($this->placeholder->getMaxCharactersValue()); $this->addItem($item); $item = new ilCheckboxInputGUI($this->pl->txt('mandatory'), 'mandatory'); if ($this->placeholder->getIsMandatory()) { $item->setChecked(true); } $this->addItem($item); $item = new ilMultiSelectInputGUI($this->pl->txt('editable_in'), 'editable_in'); $options = array(); foreach ($type->getAllAvailableObjectTypes() as $obj_type) { $options[$obj_type] = $obj_type; } $item->setOptions($options); $item->setValue($this->placeholder->getEditableIn()); $this->addItem($item); $item = new ilHiddenInputGUI('placeholder_id'); $item->setValue($this->placeholder->getId()); $this->addItem($item); if (!$this->placeholder->getId()) { $item = new ilCheckboxInputGUI($this->pl->txt('update_cert_definitions'), 'update_definitions'); $item->setInfo($this->pl->txt('update_cert_definitions_info')); $this->addItem($item); } foreach ($type->getLanguages() as $lang_code) { $this->addLanguageInput($lang_code); } $command = $this->placeholder->getId() ? 'updatePlaceholder' : 'createPlaceholder'; $this->addCommandButton($command, $this->lng->txt('save')); }
/** * Creates an output of the edit form for the question * @param bool $checkonly * @return bool */ function editQuestion($checkonly = FALSE) { $save = $this->isSaveCommand(); $this->getQuestionTemplate(); include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($this->ctrl->getFormAction($this)); $form->setTitle($this->outQuestionType()); $form->setMultipart(FALSE); $form->setTableWidth('100%'); $form->setId('assformulaquestion'); // title, author, description, question, working time (assessment mode) $this->addBasicQuestionFormProperties($form); // Add info text $question = $form->getItemByPostVar('question'); $question->setInfo($this->lng->txt('fq_question_desc')); $variables = $this->object->getVariables(); $categorized_units = $this->object->getUnitrepository()->getCategorizedUnits(); $result_units = $this->object->__get('resultunits'); $unit_options = array(); $category_name = ''; $new_category = false; foreach ((array) $categorized_units as $item) { /** * @var $item assFormulaQuestionUnitCategory|assFormulaQuestionUnit */ if ($item instanceof assFormulaQuestionUnitCategory) { if ($category_name != $item->getDisplayString()) { $new_category = true; $category_name = $item->getDisplayString(); } continue; } $unit_options[$item->getId()] = $item->getDisplayString() . ($new_category ? ' (' . $category_name . ')' : ''); $new_category = false; } if (count($variables)) { uasort($variables, function (assFormulaQuestionVariable $v1, assFormulaQuestionVariable $v2) { $num_v1 = (int) substr($v1->getVariable(), 2); $num_v2 = (int) substr($v2->getVariable(), 2); if ($num_v1 > $num_v2) { return 1; } else { if ($num_v1 < $num_v2) { return -1; } } return 0; }); foreach ($variables as $variable) { /** * @var $variable assFormulaQuestionVariable */ $variable_header = new ilFormSectionHeaderGUI(); $variable_header->setTitle(sprintf($this->lng->txt('variable_x'), $variable->getVariable())); $range_min = new ilNumberInputGUI($this->lng->txt('range_min'), 'range_min_' . $variable->getVariable()); $range_min->allowDecimals(true); $range_min->setSize(3); $range_min->setRequired(true); $range_min->setValue($variable->getRangeMin()); $range_max = new ilNumberInputGUI($this->lng->txt('range_max'), 'range_max_' . $variable->getVariable()); $range_max->allowDecimals(true); $range_max->setSize(3); $range_max->setRequired(true); $range_max->setValue($variable->getRangeMax()); $units = new ilSelectInputGUI($this->lng->txt('unit'), 'unit_' . $variable->getVariable()); $units->setOptions(array(0 => $this->lng->txt('no_selection')) + $unit_options); if (is_object($variable->getUnit())) { $units->setValue($variable->getUnit()->getId()); } $precision = new ilNumberInputGUI($this->lng->txt('precision'), 'precision_' . $variable->getVariable()); $precision->setRequired(true); $precision->setSize(3); $precision->setMinValue(0); $precision->setValue($variable->getPrecision()); $precision->setInfo($this->lng->txt('fq_precision_info')); $intprecision = new ilNumberInputGUI($this->lng->txt('intprecision'), 'intprecision_' . $variable->getVariable()); $intprecision->setSize(3); $intprecision->setMinValue(1); $intprecision->setValue($variable->getIntprecision()); $intprecision->setInfo($this->lng->txt('intprecision_info')); $form->addItem($variable_header); $form->addItem($range_min); $form->addItem($range_max); $form->addItem($units); $form->addItem($precision); $form->addItem($intprecision); } } $results = $this->object->getResults(); if (count($results)) { require_once 'Services/Form/classes/class.ilMultiSelectInputGUI.php'; uasort($results, function (assFormulaQuestionResult $r1, assFormulaQuestionResult $r2) { $num_r1 = (int) substr($r1->getResult(), 2); $num_r2 = (int) substr($r2->getResult(), 2); if ($num_r1 > $num_r2) { return 1; } else { if ($num_r1 < $num_r2) { return -1; } } return 0; }); foreach ($results as $result) { /** * @var $result assFormulaQuestionResult */ $result_header = new ilFormSectionHeaderGUI(); $result_header->setTitle(sprintf($this->lng->txt('result_x'), $result->getResult())); $formula = new ilTextInputGUI($this->lng->txt('formula'), 'formula_' . $result->getResult()); $formula->setInfo($this->lng->txt('fq_formula_desc')); $formula->setRequired(true); $formula->setSize(50); $formula->setValue($result->getFormula()); $formula->setSuffix(' = ' . $result->getResult()); if (preg_match("/suggestrange_(.*)/", $this->ctrl->getCmd(), $matches) && strcmp($matches[1], $result->getResult()) == 0) { // suggest a range for the result if (strlen($result->substituteFormula($variables, $results))) { $result->suggestRange($variables, $results); } } $range_min = new ilNumberInputGUI($this->lng->txt('range_min'), 'range_min_' . $result->getResult()); $range_min->allowDecimals(true); $range_min->setSize(3); $range_min->setRequired(true); $range_min->setValue($result->getRangeMin()); $range_max = new ilNumberInputGUI($this->lng->txt('range_max'), 'range_max_' . $result->getResult()); $range_max->allowDecimals(true); $range_max->setSize(3); $range_max->setRequired(true); $range_max->setValue($result->getRangeMax()); $matches = array(); $precision = new ilNumberInputGUI($this->lng->txt('precision'), 'precision_' . $result->getResult()); $precision->setRequired(true); $precision->setSize(3); $precision->setMinValue(0); $precision->setInfo($this->lng->txt('fq_precision_info')); $precision->setValue($result->getPrecision()); $tolerance = new ilNumberInputGUI($this->lng->txt('tolerance'), 'tolerance_' . $result->getResult()); $tolerance->setSize(3); $tolerance->setMinValue(0); $tolerance->setMaxValue(100); $tolerance->allowDecimals(false); $tolerance->setInfo($this->lng->txt('tolerance_info')); $tolerance->setValue($result->getTolerance()); $suggest_range_button = new ilCustomInputGUI('', ''); $suggest_range_button->setHtml('<input type="submit" class="btn btn-default" name="cmd[suggestrange_' . $result->getResult() . ']" value="' . $this->lng->txt("suggest_range") . '" />'); $sel_result_units = new ilSelectInputGUI($this->lng->txt('unit'), 'unit_' . $result->getResult()); $sel_result_units->setOptions(array(0 => $this->lng->txt('no_selection')) + $unit_options); $sel_result_units->setInfo($this->lng->txt('result_unit_info')); if (is_object($result->getUnit())) { $sel_result_units->setValue($result->getUnit()->getId()); } $mc_result_units = new ilMultiSelectInputGUI($this->lng->txt('result_units'), 'units_' . $result->getResult()); $mc_result_units->setOptions($unit_options); $mc_result_units->setInfo($this->lng->txt('result_units_info')); $selectedvalues = array(); foreach ($unit_options as $unit_id => $txt) { if ($this->hasResultUnit($result, $unit_id, $result_units)) { $selectedvalues[] = $unit_id; } } $mc_result_units->setValue($selectedvalues); $result_type = new ilRadioGroupInputGUI($this->lng->txt('result_type_selection'), 'result_type_' . $result->getResult()); $result_type->setRequired(true); $no_type = new ilRadioOption($this->lng->txt('no_result_type'), 0); $no_type->setInfo($this->lng->txt('fq_no_restriction_info')); $result_dec = new ilRadioOption($this->lng->txt('result_dec'), 1); $result_dec->setInfo($this->lng->txt('result_dec_info')); $result_frac = new ilRadioOption($this->lng->txt('result_frac'), 2); $result_frac->setInfo($this->lng->txt('result_frac_info')); $result_co_frac = new ilRadioOption($this->lng->txt('result_co_frac'), 3); $result_co_frac->setInfo($this->lng->txt('result_co_frac_info')); $result_type->addOption($no_type); $result_type->addOption($result_dec); $result_type->addOption($result_frac); $result_type->addOption($result_co_frac); $result_type->setValue(strlen($result->getResultType()) ? $result->getResultType() : 0); $points = new ilNumberInputGUI($this->lng->txt('points'), 'points_' . $result->getResult()); $points->allowDecimals(true); $points->setRequired(true); $points->setSize(3); $points->setMinValue(0); $points->setValue(strlen($result->getPoints()) ? $result->getPoints() : 1); $rating_type = new ilCheckboxInputGUI($this->lng->txt('advanced_rating'), 'rating_advanced_' . $result->getResult()); $rating_type->setValue(1); $rating_type->setInfo($this->lng->txt('advanced_rating_info')); if (!$save) { $advanced_rating = $this->canUseAdvancedRating($result); if (!$advanced_rating) { $rating_type->setDisabled(true); $rating_type->setChecked(false); } else { $rating_type->setChecked(strlen($result->getRatingSimple()) && $result->getRatingSimple() ? false : true); } } $sign = new ilNumberInputGUI($this->lng->txt('rating_sign'), 'rating_sign_' . $result->getResult()); $sign->setRequired(true); $sign->setSize(3); $sign->setMinValue(0); $sign->setValue($result->getRatingSign()); $rating_type->addSubItem($sign); $value = new ilNumberInputGUI($this->lng->txt('rating_value'), 'rating_value_' . $result->getResult()); $value->setRequired(true); $value->setSize(3); $value->setMinValue(0); $value->setValue($result->getRatingValue()); $rating_type->addSubItem($value); $unit = new ilNumberInputGUI($this->lng->txt('rating_unit'), 'rating_unit_' . $result->getResult()); $unit->setRequired(true); $unit->setSize(3); $unit->setMinValue(0); $unit->setValue($result->getRatingUnit()); $rating_type->addSubItem($unit); $info_text = new ilNonEditableValueGUI($this->lng->txt('additional_rating_info')); $rating_type->addSubItem($info_text); $form->addItem($result_header); $form->addItem($formula); $form->addItem($range_min); $form->addItem($range_max); $form->addItem($suggest_range_button); $form->addItem($precision); $form->addItem($tolerance); $form->addItem($sel_result_units); $form->addItem($mc_result_units); $form->addItem($result_type); $form->addItem($points); $form->addItem($rating_type); } $defined_result_vars = array(); $quest_vars = array(); $defined_result_res = array(); $result_vars = array(); foreach ($variables as $key => $object) { $quest_vars[$key] = $key; } foreach ($results as $key => $object) { $result_vars[$key] = $key; } foreach ($results as $tmp_result) { /** * @var $tmp_result assFormulaQuestionResult */ $formula = $tmp_result->getFormula(); preg_match_all("/([\$][v][0-9]*)/", $formula, $form_vars); preg_match_all("/([\$][r][0-9]*)/", $formula, $form_res); foreach ($form_vars[0] as $res_var) { $defined_result_vars[$res_var] = $res_var; } foreach ($form_res[0] as $res_res) { $defined_result_res[$res_res] = $res_res; } } } $result_has_undefined_vars = array(); $question_has_unused_vars = array(); if (is_array($quest_vars) && count($quest_vars) > 0) { $result_has_undefined_vars = array_diff($defined_result_vars, $quest_vars); $question_has_unused_vars = array_diff($quest_vars, $defined_result_vars); } if (is_array($result_vars) && count($result_vars) > 0) { $result_has_undefined_res = array_diff($defined_result_res, $result_vars); } $error_message = ''; if (count($result_has_undefined_vars) > 0 || count($question_has_unused_vars) > 0) { if (count($result_has_undefined_vars) > 0) { $error_message .= $this->lng->txt("res_contains_undef_var") . '<br>'; } if (count($question_has_unused_vars) > 0) { $error_message .= $this->lng->txt("que_contains_unused_var") . '<br>'; } $checked = false; if ($save) { ilUtil::sendFailure($error_message); } } if (count($result_has_undefined_res) > 0) { $error_message .= $this->lng->txt("res_contains_undef_res") . '<br>'; $checked = false; } if ($save && !$checked) { ilUtil::sendFailure($error_message); } if ($this->object->getId()) { $hidden = new ilHiddenInputGUI("", "ID"); $hidden->setValue($this->object->getId()); $form->addItem($hidden); } $this->populateTaxonomyFormSection($form); $form->addCommandButton('parseQuestion', $this->lng->txt("parseQuestion")); $form->addCommandButton('saveReturnFQ', $this->lng->txt("save_return")); $form->addCommandButton('saveFQ', $this->lng->txt("save")); $errors = $checked; if ($save) { $found_vars = array(); $found_results = array(); foreach ((array) $_POST as $key => $value) { if (preg_match("/^unit_(\\\$v\\d+)\$/", $key, $matches)) { array_push($found_vars, $matches[1]); } if (preg_match("/^unit_(\\\$r\\d+)\$/", $key, $matches)) { array_push($found_results, $matches[1]); } } $form->setValuesByPost(); $errors = !$form->checkInput(); $custom_errors = false; if (count($variables)) { foreach ($variables as $variable) { /** * @var $variable assFormulaQuestionVariable */ $min_range = $form->getItemByPostVar('range_min_' . $variable->getVariable()); $max_range = $form->getItemByPostVar('range_max_' . $variable->getVariable()); if ($min_range->getValue() > $max_range->getValue()) { $min_range->setAlert($this->lng->txt('err_range')); $max_range->setAlert($this->lng->txt('err_range')); $custom_errors = true; } } } if (count($results)) { foreach ($results as $result) { /** * @var $result assFormulaQuestionResult */ $min_range = $form->getItemByPostVar('range_min_' . $result->getResult()); $max_range = $form->getItemByPostVar('range_max_' . $result->getResult()); if ($min_range->getValue() > $max_range->getValue()) { $min_range->setAlert($this->lng->txt('err_range')); $max_range->setAlert($this->lng->txt('err_range')); $custom_errors = true; } $formula = $form->getItemByPostVar('formula_' . $result->getResult()); if (strpos($formula->getValue(), $result->getResult()) !== FALSE) { $formula->setAlert($this->lng->txt('errRecursionInResult')); $custom_errors = true; } $result_unit = $form->getItemByPostVar('unit_' . $result->getResult()); $rating_advanced = $form->getItemByPostVar('rating_advanced_' . $result->getResult()); if ((int) $result_unit->getValue() <= 0 && $rating_advanced->getChecked()) { unset($_POST['rating_advanced_' . $result->getResult()]); $rating_advanced->setDisabled(true); $rating_advanced->setChecked(false); $rating_advanced->setAlert($this->lng->txt('err_rating_advanced_not_allowed')); $custom_errors = true; } else { if ($rating_advanced->getChecked()) { $rating_sign = $form->getItemByPostVar('rating_sign_' . $result->getResult()); $rating_value = $form->getItemByPostVar('rating_value_' . $result->getResult()); $rating_unit = $form->getItemByPostVar('rating_unit_' . $result->getResult()); $percentage = $rating_sign->getValue() + $rating_value->getValue() + $rating_unit->getValue(); if ($percentage != 100) { $rating_advanced->setAlert($this->lng->txt('err_wrong_rating_advanced')); $custom_errors = true; } } } preg_match_all("/([\$][v][0-9]*)/", $formula->getValue(), $form_vars); $result_has_undefined_vars = array_diff($form_vars[0], (array) $found_vars); if (count($result_has_undefined_vars)) { $errors = true; ilUtil::sendInfo($this->lng->txt('res_contains_undef_var')); } } } if ($custom_errors && !$errors) { $errors = true; ilUtil::sendFailure($this->lng->txt('form_input_not_valid')); } $form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes if ($errors) { $checkonly = false; } } if (!$checkonly) { $this->tpl->setVariable('QUESTION_DATA', $form->getHTML()); } return $errors; }