ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilSurveyQuestionsTableGUI.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
10{
14 protected $rbacreview;
15
19 protected $user;
20
21 protected $editable = true;
22 protected $writeAccess = false;
23
31 public function __construct($a_parent_obj, $a_parent_cmd, $a_write_access = false)
32 {
33 global $DIC;
34
35 $this->rbacreview = $DIC->rbac()->review();
36 $this->user = $DIC->user();
37 $this->setId("spl");
38 $this->setPrefix('q_id'); // #16982
39
40 parent::__construct($a_parent_obj, $a_parent_cmd);
41
42 $lng = $DIC->language();
43 $ilCtrl = $DIC->ctrl();
44
45 $this->lng = $lng;
46 $this->ctrl = $ilCtrl;
47
48 $this->setWriteAccess($a_write_access);
49
50 //$qplSetting = new ilSetting("spl");
51
52 //$this->setFormName('questionbrowser');
53 //$this->setStyle('table', 'fullwidth');
54
55 if ($this->getWriteAccess()) {
56 $this->addColumn('', '', '1%');
57 }
58
59 $this->addColumn($this->lng->txt("title"), 'title', '');
60 $this->addColumn($this->lng->txt("obligatory"), "");
61
62 foreach ($this->getSelectedColumns() as $c) {
63 if (strcmp($c, 'description') == 0) {
64 $this->addColumn($this->lng->txt("description"), 'description', '');
65 }
66 if (strcmp($c, 'type') == 0) {
67 $this->addColumn($this->lng->txt("question_type"), 'type', '');
68 }
69 if (strcmp($c, 'author') == 0) {
70 $this->addColumn($this->lng->txt("author"), 'author', '');
71 }
72 if (strcmp($c, 'created') == 0) {
73 $this->addColumn($this->lng->txt("create_date"), 'created', '');
74 }
75 if (strcmp($c, 'updated') == 0) {
76 $this->addColumn($this->lng->txt("last_update"), 'tstamp', '');
77 }
78 }
79
80 $this->addColumn("", "");
81
82 if ($this->getWriteAccess()) {
83 $this->setSelectAllCheckbox('q_id');
84
85 $this->addMultiCommand('copy', $this->lng->txt('copy'));
86 $this->addMultiCommand('move', $this->lng->txt('move'));
87 $this->addMultiCommand('exportQuestion', $this->lng->txt('export'));
88 $this->addMultiCommand('deleteQuestions', $this->lng->txt('delete'));
89
90 if (array_key_exists("spl_clipboard", $_SESSION)) {
91 $this->addCommandButton('paste', $this->lng->txt('paste'));
92 }
93
94 $this->addCommandButton("saveObligatory", $this->lng->txt("spl_save_obligatory_state"));
95 }
96
97
98 $this->setRowTemplate("tpl.il_svy_qpl_questions_row.html", "Modules/SurveyQuestionPool");
99
100 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
101 $this->setDefaultOrderField("title");
102 $this->setDefaultOrderDirection("asc");
103
104 $this->setShowRowsSelector(true);
105
106 //$this->enable('sort');
107 //$this->enable('header');
108 //$this->enable('select_all');
109 $this->setFilterCommand('filterQuestionBrowser');
110 $this->setResetCommand('resetfilterQuestionBrowser');
111
112 $this->initFilter();
113 }
114
118 public function initFilter()
119 {
123
124 // title
125 $ti = new ilTextInputGUI($lng->txt("title"), "title");
126 $ti->setMaxLength(64);
127 $ti->setSize(20);
128 $ti->setValidationRegexp('/^[^%]+$/is');
129 $this->addFilterItem($ti);
130 $ti->readFromSession();
131 $this->filter["title"] = $ti->getValue();
132
133 // description
134 $ti = new ilTextInputGUI($lng->txt("description"), "description");
135 $ti->setMaxLength(64);
136 $ti->setSize(20);
137 $ti->setValidationRegexp('/^[^%]+$/is');
138 $this->addFilterItem($ti);
139 $ti->readFromSession();
140 $this->filter["description"] = $ti->getValue();
141
142 // author
143 $ti = new ilTextInputGUI($lng->txt("author"), "author");
144 $ti->setMaxLength(64);
145 $ti->setSize(20);
146 $ti->setValidationRegexp('/^[^%]+$/is');
147 $this->addFilterItem($ti);
148 $ti->readFromSession();
149 $this->filter["author"] = $ti->getValue();
150
151 // questiontype
152 $types = ilObjSurveyQuestionPool::_getQuestionTypes();
153 $options = array();
154 $options[""] = $lng->txt('filter_all_question_types');
155 foreach ($types as $translation => $row) {
156 $options[$row['type_tag']] = $translation;
157 }
158
159 $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
160 $si->setOptions($options);
161 $this->addFilterItem($si);
162 $si->readFromSession();
163 $this->filter["type"] = $si->getValue();
164 }
165
166 public function getSelectableColumns()
167 {
169 $cols["description"] = array(
170 "txt" => $lng->txt("description"),
171 "default" => true
172 );
173 $cols["type"] = array(
174 "txt" => $lng->txt("question_type"),
175 "default" => true
176 );
177 $cols["author"] = array(
178 "txt" => $lng->txt("author"),
179 "default" => true
180 );
181 $cols["created"] = array(
182 "txt" => $lng->txt("create_date"),
183 "default" => true
184 );
185 $cols["updated"] = array(
186 "txt" => $lng->txt("last_update"),
187 "default" => true
188 );
189 return $cols;
190 }
191
199 public function fillRow($data)
200 {
201 $class = strtolower(SurveyQuestionGUI::_getGUIClassNameForId($data["question_id"]));
202 $guiclass = $class . "GUI";
203 $this->ctrl->setParameterByClass(strtolower($guiclass), "q_id", $data["question_id"]);
204
205 if ($this->getEditable()) {
206 $url_edit = $this->ctrl->getLinkTargetByClass(strtolower($guiclass), "editQuestion");
207
208 $this->tpl->setCurrentBlock("title_link_bl");
209 $this->tpl->setVariable("QUESTION_TITLE_LINK", $data["title"]);
210 $this->tpl->setVariable("URL_TITLE", $url_edit);
211 $this->tpl->parseCurrentBlock();
212 } else {
213 $this->tpl->setCurrentBlock("title_nolink_bl");
214 $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
215 $this->tpl->parseCurrentBlock();
216 }
217
218 if ($data["complete"] == 0) {
219 $this->tpl->setCurrentBlock("qpl_warning");
220 $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("icon_alert.svg"));
221 $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
222 $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
223 $this->tpl->parseCurrentBlock();
224 }
225
226 foreach ($this->getSelectedColumns() as $c) {
227 if (strcmp($c, 'description') == 0) {
228 $this->tpl->setCurrentBlock('description');
229 $this->tpl->setVariable("QUESTION_COMMENT", (strlen($data["description"])) ? $data["description"] : "&nbsp;");
230 $this->tpl->parseCurrentBlock();
231 }
232 if (strcmp($c, 'type') == 0) {
233 $this->tpl->setCurrentBlock('type');
234 $this->tpl->setVariable("QUESTION_TYPE", SurveyQuestion::_getQuestionTypeName($data["type_tag"]));
235 $this->tpl->parseCurrentBlock();
236 }
237 if (strcmp($c, 'author') == 0) {
238 $this->tpl->setCurrentBlock('author');
239 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
240 $this->tpl->parseCurrentBlock();
241 }
242 if (strcmp($c, 'created') == 0) {
243 $this->tpl->setCurrentBlock('created');
244 $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'], IL_CAL_UNIX)));
245 $this->tpl->parseCurrentBlock();
246 }
247 if (strcmp($c, 'updated') == 0) {
248 $this->tpl->setCurrentBlock('updated');
249 $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data["tstamp"], IL_CAL_UNIX)));
250 $this->tpl->parseCurrentBlock();
251 }
252 }
253
254 // actions
255 $list = new ilAdvancedSelectionListGUI();
256 $list->setId($data["question_id"]);
257 $list->setListTitle($this->lng->txt("actions"));
258 if ($url_edit) {
259 $list->addItem($this->lng->txt("edit"), "", $url_edit);
260 }
261 $list->addItem($this->lng->txt("preview"), "", $this->ctrl->getLinkTargetByClass(strtolower($guiclass), "preview"));
262 $this->tpl->setVariable("ACTION", $list->getHTML());
263 $this->tpl->parseCurrentBlock();
264
265 // obligatory
266 if ($this->getEditable()) {
267 $checked = $data["obligatory"] ? " checked=\"checked\"" : "";
268 $obligatory = "<input type=\"checkbox\" name=\"obligatory_" .
269 $data["question_id"] . "\" value=\"1\"" . $checked . " />";
270 } elseif ($data["obligatory"]) {
271 $obligatory = "<img src=\"" . ilUtil::getImagePath("obligatory.png", "Modules/Survey") .
272 "\" alt=\"" . $this->lng->txt("question_obligatory") .
273 "\" title=\"" . $this->lng->txt("question_obligatory") . "\" />";
274 }
275 $this->tpl->setVariable("OBLIGATORY", $obligatory);
276
277 if ($this->getWriteAccess()) {
278 $this->tpl->setVariable('CBOX_ID', $data["question_id"]);
279 }
280 $this->tpl->setVariable('QUESTION_ID', $data["question_id"]);
281 }
282
283 public function setEditable($value)
284 {
285 $this->editable = $value;
286 }
287
288 public function getEditable()
289 {
290 return $this->editable;
291 }
292
293 public function setWriteAccess($value)
294 {
295 $this->writeAccess = $value;
296 }
297
298 public function getWriteAccess()
299 {
300 return $this->writeAccess;
301 }
302}
user()
Definition: user.php:4
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
static _getGUIClassNameForId($a_q_id)
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
const IL_CAL_UNIX
User interface class for advanced drop-down selection lists.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
Class for single dates.
This class represents a selection list property in a property form.
__construct($a_parent_obj, $a_parent_cmd, $a_write_access=false)
Constructor.
getSelectableColumns()
Get selectable columns.
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
This class represents a text property in a property form.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$c
Definition: cli.php:37
filter()
Definition: filter.php:2
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$cols
Definition: xhr_table.php:11