ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjSurveyAdministrationGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
13 {
17  protected $tabs;
18 
23  public $conditions;
24 
25  public function __construct($a_data, $a_id, $a_call_by_reference)
26  {
27  global $DIC;
28 
29  $this->lng = $DIC->language();
30  $this->tabs = $DIC->tabs();
31  $this->tpl = $DIC["tpl"];
32  $this->access = $DIC->access();
33  $this->ctrl = $DIC->ctrl();
34  $lng = $DIC->language();
35 
36  $this->type = "svyf";
37  $lng->loadLanguageModule("survey");
38  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
39  }
40 
41  public function executeCommand()
42  {
43  $ilTabs = $this->tabs;
44 
45  $next_class = $this->ctrl->getNextClass($this);
46  $cmd = $this->ctrl->getCmd();
47  $this->prepareOutput();
48 
49  switch ($next_class) {
50  case 'ilpermissiongui':
51  $ilTabs->activateTab("perm_settings");
52  $perm_gui = new ilPermissionGUI($this);
53  $ret = &$this->ctrl->forwardCommand($perm_gui);
54  break;
55 
56  case 'ilsettingstemplategui':
57  $ilTabs->activateTab("templates");
58  $set_tpl_gui = new ilSettingsTemplateGUI($this->getSettingsTemplateConfig());
59  $this->ctrl->forwardCommand($set_tpl_gui);
60  break;
61 
62  default:
63  if ($cmd == "" || $cmd == "view") {
64  $cmd = "settings";
65  }
66  $cmd .= "Object";
67  $this->$cmd();
68 
69  break;
70  }
71  return true;
72  }
73 
74 
82  public function settingsObject(ilPropertyFormGUI $a_form = null)
83  {
84  $tpl = $this->tpl;
85  $ilTabs = $this->tabs;
86 
87  $ilTabs->activateTab("settings");
88 
89  if (!$a_form) {
90  $a_form = $this->initSettingsForm();
91  }
92 
93  $tpl->setContent($a_form->getHTML());
94  }
95 
96  protected function initSettingsForm()
97  {
98  $ilAccess = $this->access;
99  $lng = $this->lng;
101 
102  $surveySetting = new ilSetting("survey");
103  $unlimited_invitation = array_key_exists("unlimited_invitation", $_GET) ? $_GET["unlimited_invitation"] : $surveySetting->get("unlimited_invitation");
104  $use_anonymous_id = array_key_exists("use_anonymous_id", $_GET) ? $_GET["use_anonymous_id"] : $surveySetting->get("use_anonymous_id");
105 
106  $form = new ilPropertyFormGUI();
107  $form->setFormAction($ilCtrl->getFormAction($this));
108  $form->setTitle($lng->txt("survey_defaults"));
109 
110  // unlimited invitation
111  /*
112  $enable = new ilCheckboxInputGUI($lng->txt("survey_unlimited_invitation"), "unlimited_invitation");
113  $enable->setChecked($unlimited_invitation);
114  $enable->setInfo($lng->txt("survey_unlimited_invitation_desc"));
115  $form->addItem($enable);*/
116 
117  // Survey Code
118  $code = new ilCheckboxInputGUI($lng->txt("use_anonymous_id"), "use_anonymous_id");
119  $code->setChecked($use_anonymous_id);
120  $code->setInfo($lng->txt("use_anonymous_id_desc"));
121  $form->addItem($code);
122 
123  // Skipped
124  $eval_skipped = new ilRadioGroupInputGUI($lng->txt("svy_eval_skipped_value"), "skcust");
125  $eval_skipped->setRequired(true);
126  $form->addItem($eval_skipped);
127 
128  $eval_skipped->setValue($surveySetting->get("skipped_is_custom", false)
129  ? "cust"
130  : "lng");
131 
132  $skipped_lng = new ilRadioOption($lng->txt("svy_eval_skipped_value_lng"), "lng");
133  $skipped_lng->setInfo(sprintf($lng->txt("svy_eval_skipped_value_lng_info"), $lng->txt("skipped")));
134  $eval_skipped->addOption($skipped_lng);
135  $skipped_cust = new ilRadioOption($lng->txt("svy_eval_skipped_value_custom"), "cust");
136  $skipped_cust->setInfo($lng->txt("svy_eval_skipped_value_custom_info"));
137  $eval_skipped->addOption($skipped_cust);
138 
139  $skipped_cust_value = new ilTextInputGUI($lng->txt("svy_eval_skipped_value_custom_value"), "cust_value");
140  $skipped_cust_value->setSize(15);
141  $skipped_cust_value->setValue($surveySetting->get("skipped_custom_value", ""));
142  $skipped_cust->addSubItem($skipped_cust_value);
143 
144  $anon_part = new ilCheckboxInputGUI($lng->txt("svy_anonymous_participants"), "anon_part");
145  $anon_part->setInfo($lng->txt("svy_anonymous_participants_info"));
146  $anon_part->setChecked($surveySetting->get("anonymous_participants", false));
147  $form->addItem($anon_part);
148 
149  $anon_part_min = new ilNumberInputGUI($lng->txt("svy_anonymous_participants_min"), "anon_part_min");
150  $anon_part_min->setInfo($lng->txt("svy_anonymous_participants_min_info"));
151  $anon_part_min->setSize(4);
152  $anon_part_min->setMinValue(1);
153  $anon_part_min->setValue($surveySetting->get("anonymous_participants_min", null));
154  $anon_part->addSubItem($anon_part_min);
155 
156  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
157  $form->addCommandButton("saveSettings", $lng->txt("save"));
158  }
159 
160  return $form;
161  }
162 
166  public function saveSettingsObject()
167  {
169  $ilAccess = $this->access;
170 
171  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
172  $ilCtrl->redirect($this, "settings");
173  }
174 
175  $form = $this->initSettingsForm();
176  if ($form->checkInput()) {
177  $surveySetting = new ilSetting("survey");
178  //$surveySetting->set("unlimited_invitation", ($_POST["unlimited_invitation"]) ? "1" : "0");
179  $surveySetting->set("use_anonymous_id", ($_POST["use_anonymous_id"]) ? "1" : "0");
180  $surveySetting->set("anonymous_participants", ($_POST["anon_part"]) ? "1" : "0");
181  $surveySetting->set("anonymous_participants_min", (trim($_POST["anon_part_min"])) ? (int) $_POST["anon_part_min"] : null);
182 
183  if ($_POST["skcust"] == "lng") {
184  $surveySetting->set("skipped_is_custom", false);
185  } else {
186  $surveySetting->set("skipped_is_custom", true);
187  $surveySetting->set("skipped_custom_value", trim($_POST["cust_value"]));
188  }
189 
190  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
191  $ilCtrl->redirect($this, "settings");
192  }
193 
194  $form->setValuesByPost();
195  $this->settingsObject($form);
196  }
197 
198  public function getAdminTabs()
199  {
200  $this->getTabs();
201  }
202 
208  public function getTabs()
209  {
210  $lng = $this->lng;
211 
212  if ($this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
213  $this->tabs_gui->addTab(
214  "settings",
215  $lng->txt("settings"),
216  $this->ctrl->getLinkTarget($this, "settings")
217  );
218 
219  // #7927: special users are deprecated
220  /*
221  $tabs_gui->addTab("specialusers",
222  $lng->txt("specialusers"),
223  $this->ctrl->getLinkTarget($this, "specialusers"));
224  */
225 
226  $this->tabs_gui->addTab(
227  "templates",
228  $lng->txt("adm_settings_templates"),
229  $this->ctrl->getLinkTargetByClass("ilsettingstemplategui", "")
230  );
231  }
232  if ($this->checkPermissionBool("edit_permission")) {
233  $this->tabs_gui->addTab(
234  "perm_settings",
235  $lng->txt("perm_settings"),
236  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
237  );
238  }
239  }
240 
246  private function getSettingsTemplateConfig()
247  {
248  $lng = $this->lng;
249 
250  $lng->loadLanguageModule("survey");
251 
252  $config = new ilSettingsTemplateConfig("svy");
253 
254  $config->addHidableTab("survey_question_editor", $lng->txt("survey_question_editor_settings_template"));
255  $config->addHidableTab("constraints", $lng->txt("constraints"));
256  //$config->addHidableTab("invitation", $lng->txt("invitation"));
257  $config->addHidableTab("meta_data", $lng->txt("meta_data"));
258  $config->addHidableTab("export", $lng->txt("export"));
259 
260  $config->addSetting(
261  "use_pool",
263  $lng->txt("survey_question_pool_usage"),
264  true,
265  0,
266  array(1 => $this->lng->txt("survey_question_pool_usage_active"),
267  0 => $this->lng->txt("survey_question_pool_usage_inactive"))
268  );
269 
270 
271  $config->addSetting(
272  "enabled_start_date",
274  $lng->txt("start_date"),
275  true
276  );
277 
278  $config->addSetting(
279  "enabled_end_date",
281  $lng->txt("end_date"),
282  true
283  );
284 
285  $config->addSetting(
286  "show_question_titles",
288  $lng->txt("svy_show_questiontitles"),
289  true
290  );
291 
292 
293  // #17585
294 
295  $config->addSetting(
296  "acc_codes",
298  $lng->txt("survey_access_codes"),
299  true
300  );
301 
302  $config->addSetting(
303  "evaluation_access",
305  $lng->txt("evaluation_access"),
306  true,
307  0,
308  array(ilObjSurvey::EVALUATION_ACCESS_OFF => $this->lng->txt("evaluation_access_off"),
309  ilObjSurvey::EVALUATION_ACCESS_ALL => $this->lng->txt("evaluation_access_all"),
310  ilObjSurvey::EVALUATION_ACCESS_PARTICIPANTS => $this->lng->txt("evaluation_access_participants"))
311  );
312 
313  $config->addSetting(
314  "anonymization_options",
316  $lng->txt("survey_results_anonymization"),
317  true,
318  0,
319  array("statpers" => $this->lng->txt("survey_results_personalized"),
320  "statanon" => $this->lng->txt("survey_results_anonymized"))
321  );
322 
323  /*
324  $config->addSetting(
325  "rte_switch",
326  ilSettingsTemplateConfig::SELECT,
327  $lng->txt("set_edit_mode"),
328  true,
329  0,
330  array(0 => $this->lng->txt("rte_editor_disabled"),
331  1 => $this->lng->txt("rte_editor_enabled"))
332  );
333  */
334 
335  return $config;
336  }
337 } // END class.ilObjSurveyAdministrationGUI
This class represents an option in a radio group.
getSettingsTemplateConfig()
Get settings template configuration object.
const EVALUATION_ACCESS_OFF
This class represents a property form user interface.
const EVALUATION_ACCESS_PARTICIPANTS
$_GET["client_id"]
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Info.
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
setChecked($a_checked)
Set Checked.
prepareOutput($a_show_subobjects=true)
prepare output
This class represents a property in a property form.
This class represents a number property in a property form.
Class ilObjectGUI Basic methods of all Output classes.
Settings template config class.
const EVALUATION_ACCESS_ALL
__construct(Container $dic, ilPlugin $plugin)
$ret
Definition: parser.php:6
$DIC
Definition: xapitoken.php:46
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
settingsObject(ilPropertyFormGUI $a_form=null)
display survey settings form
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
Class ilObjSurveyAdministrationGUI.
$_POST["username"]
__construct($a_data, $a_id, $a_call_by_reference)
setRequired($a_required)
Set Required.