ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilSurveyQuestionbrowserTableGUI.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
24 protected $access;
25
26 protected $editable = true;
27 protected $writeAccess = false;
28 protected $browsercolumns = array();
29 protected $questionpools = null;
30
38 public function __construct($a_parent_obj, $a_parent_cmd, $a_object, $a_write_access = false)
39 {
40 global $DIC;
41
42 $this->rbacreview = $DIC->rbac()->review();
43 $this->user = $DIC->user();
44 $this->access = $DIC->access();
45 parent::__construct($a_parent_obj, $a_parent_cmd);
46
47 $lng = $DIC->language();
48 $ilCtrl = $DIC->ctrl();
49
50 $this->lng = $lng;
51 $this->ctrl = $ilCtrl;
52
53 $this->setWriteAccess($a_write_access);
54
55 $this->setFormName('surveyquestionbrowser');
56 $this->setStyle('table', 'fullwidth');
57 $this->addColumn('', 'f', '1%');
58 $this->addColumn($this->lng->txt("title"), 'title', '');
59 $this->addColumn('', 'preview', '');
60 $this->addColumn($this->lng->txt("description"), 'description', '');
61 $this->addColumn($this->lng->txt("question_type"), 'ttype', '');
62 $this->addColumn($this->lng->txt("author"), 'author', '');
63 $this->addColumn($this->lng->txt("create_date"), 'created', '');
64 $this->addColumn($this->lng->txt("last_update"), 'updated', '');
65 $this->addColumn($this->lng->txt("obj_spl"), 'spl', '');
66
67 $this->setPrefix('q_id');
68 $this->setSelectAllCheckbox('q_id');
69
70 $this->addMultiCommand('insertQuestions', $this->lng->txt('insert'));
71
72 $this->setRowTemplate("tpl.il_svy_svy_questionbrowser_row.html", "Modules/Survey");
73
74 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
75 $this->setDefaultOrderField("title");
76 $this->setDefaultOrderDirection("asc");
77 $this->questionpools = ilObjSurveyQuestionPool::_getAvailableQuestionpools(true, false, true);
78
79 $this->enable('sort');
80 $this->enable('header');
81 $this->enable('select_all');
82 $this->setFilterCommand('filterQuestionBrowser');
83 $this->setResetCommand('resetfilterQuestionBrowser');
84
85 $this->initFilter();
86 $this->initData($a_object);
87 }
88
89 public function initData($a_object)
90 {
91 $arrFilter = array();
92 foreach ($this->getFilterItems() as $item) {
93 if ($item->getValue() !== false) {
94 $arrFilter[$item->getPostVar()] = $item->getValue();
95 }
96 }
97 $data = $a_object->getQuestionsTable($arrFilter);
98
99 // translate pools for proper sorting
100 if (sizeof($data)) {
101 $pools = $this->getQuestionPools();
102 foreach ($data as $idx => $row) {
103 $data[$idx]["spl"] = $pools[$row["obj_fi"]];
104 }
105 }
106
107 $this->setData($data);
108 }
109
110 public function getQuestionPools()
111 {
113 }
114
118 public function initFilter()
119 {
123
124 // title
125 $ti = new ilTextInputGUI($lng->txt("survey_question_title"), "title");
126 $ti->setMaxLength(64);
127 $ti->setValidationRegexp('/^[^%]+$/is');
128 $ti->setSize(20);
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->setValidationRegexp('/^[^%]+$/is');
137 $ti->setSize(20);
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->setValidationRegexp('/^[^%]+$/is');
146 $ti->setSize(20);
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 // questionpool text
167 $ti = new ilTextInputGUI($lng->txt("survey_question_pool_title"), "spl_txt");
168 $ti->setMaxLength(64);
169 $ti->setSize(20);
170 $this->addFilterItem($ti);
171 $ti->readFromSession();
172 $this->filter["spl_txt"] = $ti->getValue();
173
174 // questionpool select
175 $options = array();
176 $options[""] = $lng->txt('filter_all_questionpools');
177 natcasesort($this->questionpools);
178 foreach ($this->questionpools as $obj_id => $title) {
179 $options[$obj_id] = $title;
180 }
181 $si = new ilSelectInputGUI($this->lng->txt("survey_available_question_pools"), "spl");
182 $si->setOptions($options);
183 $this->addFilterItem($si);
184 $si->readFromSession();
185 $this->filter["type"] = $si->getValue();
186 }
187
195 public function fillRow($data)
196 {
198 $ilAccess = $this->access;
199
200 $this->tpl->setVariable('QUESTION_ID', $data["question_id"]);
201 $this->tpl->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($data["title"]));
202
203 $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview"));
204 $guiclass = strtolower($data['type_tag']) . "gui";
205 $this->ctrl->setParameterByClass($guiclass, "q_id", $data["question_id"]);
206 $this->tpl->setVariable("LINK_PREVIEW", "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&amp;ref_id=" . $data["ref_id"] . "&amp;cmd=preview&amp;preview=" . $data["question_id"]);
207
208 $this->tpl->setVariable("QUESTION_DESCRIPTION", ilUtil::prepareFormOutput((strlen($data["description"])) ? $data["description"] : ""));
209 $this->tpl->setVariable("QUESTION_TYPE", $data["ttype"]);
210 $this->tpl->setVariable("QUESTION_AUTHOR", ilUtil::prepareFormOutput($data["author"]));
211 $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'], IL_CAL_UNIX)));
212 $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data["tstamp"], IL_CAL_UNIX)));
213 $this->tpl->setVariable("QPL", ilUtil::prepareFormOutput($data["spl"]));
214 }
215
216 public function setEditable($value)
217 {
218 $this->editable = $value;
219 }
220
221 public function getEditable()
222 {
223 return $this->editable;
224 }
225
226 public function setWriteAccess($value)
227 {
228 $this->writeAccess = $value;
229 }
230
231 public function getWriteAccess()
232 {
233 return $this->writeAccess;
234 }
235}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
Class for single dates.
static _getAvailableQuestionpools($use_object_id=false, $could_be_offline=false, $showPath=false, $permission="read")
Returns the available question pools for the active user.
This class represents a selection list property in a property form.
__construct($a_parent_obj, $a_parent_cmd, $a_object, $a_write_access=false)
Constructor.
Class ilTable2GUI.
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...
getFilterItems($a_optionals=false)
Get filter items.
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.
setData($a_data)
set table data @access public
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.
setFormName($a_formname="")
Set Form name.
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.
setStyle($a_element, $a_style)
enable($a_module_name)
enables particular modules of table
This class represents a text property in a property form.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
filter()
Definition: filter.php:2
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc