ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilSurveyQuestionbrowserTableGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once('./Services/Table/classes/class.ilTable2GUI.php');
25
35{
39 protected $rbacreview;
40
44 protected $user;
45
49 protected $access;
50
51 protected $editable = true;
52 protected $writeAccess = false;
53 protected $browsercolumns = array();
54 protected $questionpools = null;
55
63 public function __construct($a_parent_obj, $a_parent_cmd, $a_object, $a_write_access = false)
64 {
65 global $DIC;
66
67 $this->rbacreview = $DIC->rbac()->review();
68 $this->user = $DIC->user();
69 $this->access = $DIC->access();
70 parent::__construct($a_parent_obj, $a_parent_cmd);
71
72 $lng = $DIC->language();
73 $ilCtrl = $DIC->ctrl();
74
75 $this->lng = $lng;
76 $this->ctrl = $ilCtrl;
77
78 $this->setWriteAccess($a_write_access);
79
80 $this->setFormName('surveyquestionbrowser');
81 $this->setStyle('table', 'fullwidth');
82 $this->addColumn('', 'f', '1%');
83 $this->addColumn($this->lng->txt("title"), 'title', '');
84 $this->addColumn('', 'preview', '');
85 $this->addColumn($this->lng->txt("description"), 'description', '');
86 $this->addColumn($this->lng->txt("question_type"), 'ttype', '');
87 $this->addColumn($this->lng->txt("author"), 'author', '');
88 $this->addColumn($this->lng->txt("create_date"), 'created', '');
89 $this->addColumn($this->lng->txt("last_update"), 'updated', '');
90 $this->addColumn($this->lng->txt("obj_spl"), 'spl', '');
91
92 $this->setPrefix('q_id');
93 $this->setSelectAllCheckbox('q_id');
94
95 $this->addMultiCommand('insertQuestions', $this->lng->txt('insert'));
96
97 $this->setRowTemplate("tpl.il_svy_svy_questionbrowser_row.html", "Modules/Survey");
98
99 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
100 $this->setDefaultOrderField("title");
101 $this->setDefaultOrderDirection("asc");
102 include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
103 $this->questionpools = ilObjSurveyQuestionPool::_getAvailableQuestionpools(true, false, true);
104
105 $this->enable('sort');
106 $this->enable('header');
107 $this->enable('select_all');
108 $this->setFilterCommand('filterQuestionBrowser');
109 $this->setResetCommand('resetfilterQuestionBrowser');
110
111 $this->initFilter();
112 $this->initData($a_object);
113 }
114
115 public function initData($a_object)
116 {
117 $arrFilter = array();
118 foreach ($this->getFilterItems() as $item) {
119 if ($item->getValue() !== false) {
120 $arrFilter[$item->getPostVar()] = $item->getValue();
121 }
122 }
123 $data = $a_object->getQuestionsTable($arrFilter);
124
125 // translate pools for proper sorting
126 if (sizeof($data)) {
127 $pools = $this->getQuestionPools();
128 foreach ($data as $idx => $row) {
129 $data[$idx]["spl"] = $pools[$row["obj_fi"]];
130 }
131 }
132
133 $this->setData($data);
134 }
135
136 public function getQuestionPools()
137 {
139 }
140
144 public function initFilter()
145 {
149
150 // title
151 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
152 $ti = new ilTextInputGUI($lng->txt("survey_question_title"), "title");
153 $ti->setMaxLength(64);
154 $ti->setValidationRegexp('/^[^%]+$/is');
155 $ti->setSize(20);
156 $this->addFilterItem($ti);
157 $ti->readFromSession();
158 $this->filter["title"] = $ti->getValue();
159
160 // description
161 $ti = new ilTextInputGUI($lng->txt("description"), "description");
162 $ti->setMaxLength(64);
163 $ti->setValidationRegexp('/^[^%]+$/is');
164 $ti->setSize(20);
165 $this->addFilterItem($ti);
166 $ti->readFromSession();
167 $this->filter["description"] = $ti->getValue();
168
169 // author
170 $ti = new ilTextInputGUI($lng->txt("author"), "author");
171 $ti->setMaxLength(64);
172 $ti->setValidationRegexp('/^[^%]+$/is');
173 $ti->setSize(20);
174 $this->addFilterItem($ti);
175 $ti->readFromSession();
176 $this->filter["author"] = $ti->getValue();
177
178 // questiontype
179 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
180 include_once("./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php");
181 $types = ilObjSurveyQuestionPool::_getQuestionTypes();
182 $options = array();
183 $options[""] = $lng->txt('filter_all_question_types');
184 foreach ($types as $translation => $row) {
185 $options[$row['type_tag']] = $translation;
186 }
187
188 $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
189 $si->setOptions($options);
190 $this->addFilterItem($si);
191 $si->readFromSession();
192 $this->filter["type"] = $si->getValue();
193
194
195 // questionpool text
196 $ti = new ilTextInputGUI($lng->txt("survey_question_pool_title"), "spl_txt");
197 $ti->setMaxLength(64);
198 $ti->setSize(20);
199 $this->addFilterItem($ti);
200 $ti->readFromSession();
201 $this->filter["spl_txt"] = $ti->getValue();
202
203 // questionpool select
204 $options = array();
205 $options[""] = $lng->txt('filter_all_questionpools');
206 natcasesort($this->questionpools);
207 foreach ($this->questionpools as $obj_id => $title) {
208 $options[$obj_id] = $title;
209 }
210 $si = new ilSelectInputGUI($this->lng->txt("survey_available_question_pools"), "spl");
211 $si->setOptions($options);
212 $this->addFilterItem($si);
213 $si->readFromSession();
214 $this->filter["type"] = $si->getValue();
215 }
216
224 public function fillRow($data)
225 {
227 $ilAccess = $this->access;
228
229 $this->tpl->setVariable('QUESTION_ID', $data["question_id"]);
230 $this->tpl->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($data["title"]));
231
232 $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview"));
233 $guiclass = strtolower($data['type_tag']) . "gui";
234 $this->ctrl->setParameterByClass($guiclass, "q_id", $data["question_id"]);
235 $this->tpl->setVariable("LINK_PREVIEW", "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&amp;ref_id=" . $data["ref_id"] . "&amp;cmd=preview&amp;preview=" . $data["question_id"]);
236
237 $this->tpl->setVariable("QUESTION_DESCRIPTION", ilUtil::prepareFormOutput((strlen($data["description"])) ? $data["description"] : ""));
238 $this->tpl->setVariable("QUESTION_TYPE", $data["ttype"]);
239 $this->tpl->setVariable("QUESTION_AUTHOR", ilUtil::prepareFormOutput($data["author"]));
240 $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'], IL_CAL_UNIX)));
241 $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data["tstamp"], IL_CAL_UNIX)));
242 $this->tpl->setVariable("QPL", ilUtil::prepareFormOutput($data["spl"]));
243 }
244
245 public function setEditable($value)
246 {
247 $this->editable = $value;
248 }
249
250 public function getEditable()
251 {
252 return $this->editable;
253 }
254
255 public function setWriteAccess($value)
256 {
257 $this->writeAccess = $value;
258 }
259
260 public function getWriteAccess()
261 {
262 return $this->writeAccess;
263 }
264}
user()
Definition: user.php:4
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
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)
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.
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.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
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
global $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18