ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjSurveyAdministrationGUI.php
Go to the documentation of this file.
1<?php
2
24{
25 protected ilTabsGUI $tabs;
26
27 public function __construct(
28 $a_data,
29 int $a_id,
30 bool $a_call_by_reference
31 ) {
32 global $DIC;
33
34 $this->lng = $DIC->language();
35 $this->tabs = $DIC->tabs();
36 $this->tpl = $DIC["tpl"];
37 $this->access = $DIC->access();
38 $this->ctrl = $DIC->ctrl();
39 $lng = $DIC->language();
40
41 $this->type = "svyf";
42 $lng->loadLanguageModule("survey");
43 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
44 }
45
46 public function executeCommand(): void
47 {
48 $ilTabs = $this->tabs;
49
50 $next_class = $this->ctrl->getNextClass($this);
51 $cmd = $this->ctrl->getCmd();
52 $this->prepareOutput();
53
54 switch ($next_class) {
55 case 'ilpermissiongui':
56 $ilTabs->activateTab("perm_settings");
57 $perm_gui = new ilPermissionGUI($this);
58 $this->ctrl->forwardCommand($perm_gui);
59 break;
60
61 default:
62 if ($cmd === null || $cmd === "" || $cmd === "view") {
63 $cmd = "settings";
64 }
65 $cmd .= "Object";
66 $this->$cmd();
67 break;
68 }
69 }
70
74 public function settingsObject(
75 ?ilPropertyFormGUI $a_form = null
76 ): void {
77 $tpl = $this->tpl;
78 $ilTabs = $this->tabs;
79
80 $ilTabs->activateTab("settings");
81
82 if (!$a_form) {
83 $a_form = $this->initSettingsForm();
84 }
85
86 $tpl->setContent($a_form->getHTML());
87 }
88
89 protected function initSettingsForm(): ilPropertyFormGUI
90 {
91 $ilAccess = $this->access;
93 $ilCtrl = $this->ctrl;
94
95 $surveySetting = new ilSetting("survey");
96 $use_anonymous_id = (bool) $surveySetting->get("use_anonymous_id");
97
98 $form = new ilPropertyFormGUI();
99 $form->setFormAction($ilCtrl->getFormAction($this));
100 $form->setTitle($lng->txt("survey_defaults"));
101
102 // Survey Code
103 $code = new ilCheckboxInputGUI($lng->txt("use_anonymous_id"), "use_anonymous_id");
104 $code->setChecked($use_anonymous_id);
105 $code->setInfo($lng->txt("use_anonymous_id_desc"));
106 $form->addItem($code);
107
108 // Skipped
109 $eval_skipped = new ilRadioGroupInputGUI($lng->txt("svy_eval_skipped_value"), "skcust");
110 $eval_skipped->setRequired(true);
111 $form->addItem($eval_skipped);
112
113 $eval_skipped->setValue($surveySetting->get("skipped_is_custom", false)
114 ? "cust"
115 : "lng");
116
117 $skipped_lng = new ilRadioOption($lng->txt("svy_eval_skipped_value_lng"), "lng");
118 $skipped_lng->setInfo(sprintf($lng->txt("svy_eval_skipped_value_lng_info"), $lng->txt("skipped")));
119 $eval_skipped->addOption($skipped_lng);
120 $skipped_cust = new ilRadioOption($lng->txt("svy_eval_skipped_value_custom"), "cust");
121 $skipped_cust->setInfo($lng->txt("svy_eval_skipped_value_custom_info"));
122 $eval_skipped->addOption($skipped_cust);
123
124 $skipped_cust_value = new ilTextInputGUI($lng->txt("svy_eval_skipped_value_custom_value"), "cust_value");
125 $skipped_cust_value->setSize(15);
126 $skipped_cust_value->setValue($surveySetting->get("skipped_custom_value", ""));
127 $skipped_cust->addSubItem($skipped_cust_value);
128
129 $anon_part = new ilCheckboxInputGUI($lng->txt("svy_anonymous_participants"), "anon_part");
130 $anon_part->setInfo($lng->txt("svy_anonymous_participants_info"));
131 $anon_part->setChecked((bool) $surveySetting->get("anonymous_participants", '0'));
132 $form->addItem($anon_part);
133
134 $anon_part_min = new ilNumberInputGUI($lng->txt("svy_anonymous_participants_min"), "anon_part_min");
135 $anon_part_min->setInfo($lng->txt("svy_anonymous_participants_min_info"));
136 $anon_part_min->setSize(4);
137 $anon_part_min->setMinValue(1);
138 $anon_part_min->setValue($surveySetting->get("anonymous_participants_min", null));
139 $anon_part->addSubItem($anon_part_min);
140
141 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
142 $form->addCommandButton("saveSettings", $lng->txt("save"));
143 }
144
145 return $form;
146 }
147
148 public function saveSettingsObject(): void
149 {
150 $ilCtrl = $this->ctrl;
151 $ilAccess = $this->access;
152
153 if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
154 $ilCtrl->redirect($this, "settings");
155 }
156
157 $form = $this->initSettingsForm();
158 if ($form->checkInput()) {
159 $surveySetting = new ilSetting("survey");
160 $surveySetting->set("use_anonymous_id", $form->getInput("use_anonymous_id") ? "1" : "0");
161 $surveySetting->set("anonymous_participants", $form->getInput("anon_part") ? "1" : "0");
162 $surveySetting->set(
163 "anonymous_participants_min",
164 (trim($form->getInput("anon_part_min") ?? ""))
165 ? (string) (int) $form->getInput("anon_part_min")
166 : ""
167 );
168
169 if ($form->getInput("skcust") === "lng") {
170 $surveySetting->set("skipped_is_custom", false);
171 } else {
172 $surveySetting->set("skipped_is_custom", true);
173 $surveySetting->set("skipped_custom_value", trim($form->getInput("cust_value")));
174 }
175
176 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
177 $ilCtrl->redirect($this, "settings");
178 }
179
180 $form->setValuesByPost();
181 $this->settingsObject($form);
182 }
183
184 public function getAdminTabs(): void
185 {
186 $this->getTabs();
187 }
188
189 protected function getTabs(): void
190 {
192
193 if ($this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
194 $this->tabs_gui->addTab(
195 "settings",
196 $lng->txt("settings"),
197 $this->ctrl->getLinkTarget($this, "settings")
198 );
199 }
200 if ($this->checkPermissionBool("edit_permission")) {
201 $this->tabs_gui->addTab(
202 "perm_settings",
203 $lng->txt("perm_settings"),
204 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
205 );
206 }
207 }
208}
This class represents a checkbox property in a property form.
loadLanguageModule(string $a_module)
Load language module.
This class represents a number property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAdminTabs()
administration tabs show only permissions and trash folder
settingsObject(?ilPropertyFormGUI $a_form=null)
Display survey settings form.
__construct( $a_data, int $a_id, bool $a_call_by_reference)
getTabs()
@abstract overwrite in derived GUI class of your object type
Class ilObjectGUI Basic methods of all Output classes.
ilGlobalTemplateInterface $tpl
prepareOutput(bool $show_sub_objects=true)
ilLanguage $lng
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
activateTab(string $a_id)
This class represents a text property in a property form.
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26