ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSurveyQuestionbrowserTableGUI.php
Go to the documentation of this file.
1<?php
2
23{
25 protected ilObjUser $user;
27 protected bool $editable = true;
28 protected bool $writeAccess = false;
29 protected array $browsercolumns = array();
30 protected ?array $questionpools = null;
31 protected array $filter = [];
32
33 public function __construct(
34 object $a_parent_obj,
35 string $a_parent_cmd,
36 ilObjSurvey $a_object,
37 bool $a_write_access = false
38 ) {
39 global $DIC;
40
41 $this->rbacreview = $DIC->rbac()->review();
42 $this->user = $DIC->user();
43 $this->access = $DIC->access();
44 parent::__construct($a_parent_obj, $a_parent_cmd);
45
46 $lng = $DIC->language();
47 $ilCtrl = $DIC->ctrl();
48
49 $this->lng = $lng;
50 $this->ctrl = $ilCtrl;
51
52 $this->setWriteAccess($a_write_access);
53
54 $this->setFormName('surveyquestionbrowser');
55 $this->setStyle('table', 'fullwidth');
56 $this->addColumn('', 'f', '1%');
57 $this->addColumn($this->lng->txt("title"), 'title', '');
58 $this->addColumn('', 'preview', '');
59 $this->addColumn($this->lng->txt("description"), 'description', '');
60 $this->addColumn($this->lng->txt("question_type"), 'ttype', '');
61 $this->addColumn($this->lng->txt("author"), 'author', '');
62 $this->addColumn($this->lng->txt("create_date"), 'created', '');
63 $this->addColumn($this->lng->txt("last_update"), 'updated', '');
64 $this->addColumn($this->lng->txt("obj_spl"), 'spl', '');
65
66 $this->setPrefix('q_id');
67 $this->setSelectAllCheckbox('q_id');
68
69 $this->addMultiCommand('insertQuestions', $this->lng->txt('insert'));
70
71 $this->setRowTemplate("tpl.il_svy_svy_questionbrowser_row.html", "components/ILIAS/Survey");
72
73 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
74 $this->setDefaultOrderField("title");
75 $this->setDefaultOrderDirection("asc");
76 $this->questionpools = ilObjSurveyQuestionPool::_getAvailableQuestionpools(true, false, true);
77
78 $this->enable('sort');
79 $this->enable('header');
80 $this->enable('select_all');
81 $this->setFilterCommand('filterQuestionBrowser');
82 $this->setResetCommand('resetfilterQuestionBrowser');
83
84 $this->initFilter();
85 $this->initData($a_object);
86 }
87
88 public function initData(ilObjSurvey $a_object): void
89 {
90 $arrFilter = array();
91 foreach ($this->getFilterItems() as $item) {
92 if ($item->getValue() !== false) {
93 $arrFilter[$item->getPostVar()] = $item->getValue();
94 }
95 }
96 $data = $a_object->getQuestionsTable($arrFilter);
97
98 // translate pools for proper sorting
99 if (count($data)) {
100 $pools = $this->getQuestionPools();
101 foreach ($data as $idx => $row) {
102 $data[$idx]["spl"] = $pools[$row["obj_fi"]];
103 }
104 }
105
106 $this->setData($data);
107 }
108
109 public function getQuestionPools(): array
110 {
112 }
113
117 public function initFilter(): void
118 {
120
121 // title
122 $ti = new ilTextInputGUI($lng->txt("survey_question_title"), "title");
123 $ti->setMaxLength(64);
124 $ti->setValidationRegexp('/^[^%]+$/is');
125 $ti->setSize(20);
126 $this->addFilterItem($ti);
127 $ti->readFromSession();
128 $this->filter["title"] = $ti->getValue();
129
130 // description
131 $ti = new ilTextInputGUI($lng->txt("description"), "description");
132 $ti->setMaxLength(64);
133 $ti->setValidationRegexp('/^[^%]+$/is');
134 $ti->setSize(20);
135 $this->addFilterItem($ti);
136 $ti->readFromSession();
137 $this->filter["description"] = $ti->getValue();
138
139 // author
140 $ti = new ilTextInputGUI($lng->txt("author"), "author");
141 $ti->setMaxLength(64);
142 $ti->setValidationRegexp('/^[^%]+$/is');
143 $ti->setSize(20);
144 $this->addFilterItem($ti);
145 $ti->readFromSession();
146 $this->filter["author"] = $ti->getValue();
147
148 // questiontype
150 $options = array();
151 $options[""] = $lng->txt('filter_all_question_types');
152 foreach ($types as $translation => $row) {
153 $options[$row['type_tag']] = $translation;
154 }
155
156 $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
157 $si->setOptions($options);
158 $this->addFilterItem($si);
159 $si->readFromSession();
160 $this->filter["type"] = $si->getValue();
161
162
163 // questionpool text
164 $ti = new ilTextInputGUI($lng->txt("survey_question_pool_title"), "spl_txt");
165 $ti->setMaxLength(64);
166 $ti->setSize(20);
167 $this->addFilterItem($ti);
168 $ti->readFromSession();
169 $this->filter["spl_txt"] = $ti->getValue();
170
171 // questionpool select
172 $options = array();
173 $options[""] = $lng->txt('filter_all_questionpools');
174 natcasesort($this->questionpools);
175 foreach ($this->questionpools as $obj_id => $title) {
176 $options[$obj_id] = $title;
177 }
178 $si = new ilSelectInputGUI($this->lng->txt("survey_available_question_pools"), "spl");
179 $si->setOptions($options);
180 $this->addFilterItem($si);
181 $si->readFromSession();
182 $this->filter["type"] = $si->getValue();
183 }
184
185 protected function fillRow(array $a_set): void
186 {
187 $this->tpl->setVariable('QUESTION_ID', $a_set["question_id"]);
188 $this->tpl->setVariable("QUESTION_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($a_set["title"]));
189
190 $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview"));
191 $guiclass = strtolower($a_set['type_tag']) . "gui";
192 $this->ctrl->setParameterByClass($guiclass, "q_id", $a_set["question_id"]);
193 $this->tpl->setVariable("LINK_PREVIEW", "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&amp;ref_id=" . $a_set["ref_id"] . "&amp;cmd=preview&amp;preview=" . $a_set["question_id"]);
194
195 $this->tpl->setVariable(
196 "QUESTION_DESCRIPTION",
197 ilLegacyFormElementsUtil::prepareFormOutput(($a_set["description"] ?? '') !== '' ? $a_set["description"] : "")
198 );
199 $this->tpl->setVariable("QUESTION_TYPE", $a_set["ttype"]);
200 $this->tpl->setVariable("QUESTION_AUTHOR", ilLegacyFormElementsUtil::prepareFormOutput($a_set["author"]));
201 $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($a_set['created'], IL_CAL_UNIX)));
202 $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($a_set["tstamp"], IL_CAL_UNIX)));
203 $this->tpl->setVariable("QPL", ilLegacyFormElementsUtil::prepareFormOutput($a_set["spl"]));
204 }
205
206 public function setEditable(bool $value): void
207 {
208 $this->editable = $value;
209 }
210
211 public function getEditable(): bool
212 {
213 return $this->editable;
214 }
215
216 public function setWriteAccess(bool $value): void
217 {
218 $this->writeAccess = $value;
219 }
220
221 public function getWriteAccess(): bool
222 {
223 return $this->writeAccess;
224 }
225}
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
Class for single dates.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static prepareFormOutput($a_str, bool $a_strip=false)
static _getQuestiontypes()
Get all available question types.
static _getAvailableQuestionpools(bool $use_object_id=false, bool $could_be_offline=false, bool $showPath=false, string $permission="read")
Returns the available question pools for the active user.
getQuestionsTable(array $arrFilter)
Retrieve data for question browser.
User class.
class ilRbacReview Contains Review functions of core Rbac.
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_parent_obj, string $a_parent_cmd, ilObjSurvey $a_object, bool $a_write_access=false)
fillRow(array $a_set)
Standard Version of Fill Row.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFilterCommand(string $a_val, string $a_caption="")
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setFormName(string $a_name="")
addMultiCommand(string $a_cmd, string $a_text)
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
getFilterItems(bool $a_optionals=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setResetCommand(string $a_val, string $a_caption="")
setData(array $a_data)
Set table data.
ilLanguage $lng
enable(string $a_module_name)
setStyle(string $a_element, string $a_style)
This class represents a text property in a property form.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
global $DIC
Definition: shib_login.php:26