ILIAS  release_4-4 Revision
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 
24 include_once('./Services/Table/classes/class.ilTable2GUI.php');
25 
35 {
36  protected $editable = true;
37  protected $writeAccess = false;
38  protected $browsercolumns = array();
39  protected $questionpools = null;
40 
48  public function __construct($a_parent_obj, $a_parent_cmd, $a_object, $a_write_access = false)
49  {
50  parent::__construct($a_parent_obj, $a_parent_cmd);
51 
52  global $lng, $ilCtrl;
53 
54  $this->lng = $lng;
55  $this->ctrl = $ilCtrl;
56 
57  $this->setWriteAccess($a_write_access);
58 
59  $this->setFormName('surveyquestionbrowser');
60  $this->setStyle('table', 'fullwidth');
61  $this->addColumn('','f','1%');
62  $this->addColumn($this->lng->txt("title"),'title', '');
63  $this->addColumn('','preview', '');
64  $this->addColumn($this->lng->txt("description"),'description', '');
65  $this->addColumn($this->lng->txt("question_type"),'ttype', '');
66  $this->addColumn($this->lng->txt("author"),'author', '');
67  $this->addColumn($this->lng->txt("create_date"),'created', '');
68  $this->addColumn($this->lng->txt("last_update"),'updated', '');
69  $this->addColumn($this->lng->txt("obj_spl"),'spl', '');
70 
71  $this->setPrefix('q_id');
72  $this->setSelectAllCheckbox('q_id');
73 
74  $this->addMultiCommand('insertQuestions', $this->lng->txt('insert'));
75 
76  $this->setRowTemplate("tpl.il_svy_svy_questionbrowser_row.html", "Modules/Survey");
77 
78  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
79  $this->setDefaultOrderField("title");
80  $this->setDefaultOrderDirection("asc");
81  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
82  $this->questionpools = ilObjSurveyQuestionPool::_getAvailableQuestionpools(true, false, true);
83 
84  $this->enable('sort');
85  $this->enable('header');
86  $this->enable('select_all');
87  $this->setFilterCommand('filterQuestionBrowser');
88  $this->setResetCommand('resetfilterQuestionBrowser');
89 
90  $this->initFilter();
91  $this->initData($a_object);
92  }
93 
94  function initData($a_object)
95  {
96  $arrFilter = array();
97  foreach ($this->getFilterItems() as $item)
98  {
99  if ($item->getValue() !== false)
100  {
101  $arrFilter[$item->getPostVar()] = $item->getValue();
102  }
103  }
104  $data = $a_object->getQuestionsTable($arrFilter);
105 
106  // translate pools for proper sorting
107  if(sizeof($data))
108  {
109  $pools = $this->getQuestionPools();
110  foreach($data as $idx => $row)
111  {
112  $data[$idx]["spl"] = $pools[$row["obj_fi"]];
113  }
114  }
115 
116  $this->setData($data);
117  }
118 
119  function getQuestionPools()
120  {
121  return $this->questionpools;
122  }
123 
127  function initFilter()
128  {
129  global $lng, $rbacreview, $ilUser;
130 
131  // title
132  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
133  $ti = new ilTextInputGUI($lng->txt("survey_question_title"), "title");
134  $ti->setMaxLength(64);
135  $ti->setValidationRegexp('/^[^%]+$/is');
136  $ti->setSize(20);
137  $this->addFilterItem($ti);
138  $ti->readFromSession();
139  $this->filter["title"] = $ti->getValue();
140 
141  // description
142  $ti = new ilTextInputGUI($lng->txt("description"), "description");
143  $ti->setMaxLength(64);
144  $ti->setValidationRegexp('/^[^%]+$/is');
145  $ti->setSize(20);
146  $this->addFilterItem($ti);
147  $ti->readFromSession();
148  $this->filter["description"] = $ti->getValue();
149 
150  // author
151  $ti = new ilTextInputGUI($lng->txt("author"), "author");
152  $ti->setMaxLength(64);
153  $ti->setValidationRegexp('/^[^%]+$/is');
154  $ti->setSize(20);
155  $this->addFilterItem($ti);
156  $ti->readFromSession();
157  $this->filter["author"] = $ti->getValue();
158 
159  // questiontype
160  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
161  include_once("./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php");
162  $types = ilObjSurveyQuestionPool::_getQuestionTypes();
163  $options = array();
164  $options[""] = $lng->txt('filter_all_question_types');
165  foreach ($types as $translation => $row)
166  {
167  $options[$row['type_tag']] = $translation;
168  }
169 
170  $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
171  $si->setOptions($options);
172  $this->addFilterItem($si);
173  $si->readFromSession();
174  $this->filter["type"] = $si->getValue();
175 
176 
177  // questionpool text
178  $ti = new ilTextInputGUI($lng->txt("survey_question_pool_title"), "spl_txt");
179  $ti->setMaxLength(64);
180  $ti->setSize(20);
181  $this->addFilterItem($ti);
182  $ti->readFromSession();
183  $this->filter["spl_txt"] = $ti->getValue();
184 
185  // questionpool select
186  $options = array();
187  $options[""] = $lng->txt('filter_all_questionpools');
188  natcasesort($this->questionpools);
189  foreach ($this->questionpools as $obj_id => $title)
190  {
191  $options[$obj_id] = $title;
192  }
193  $si = new ilSelectInputGUI($this->lng->txt("survey_available_question_pools"), "spl");
194  $si->setOptions($options);
195  $this->addFilterItem($si);
196  $si->readFromSession();
197  $this->filter["type"] = $si->getValue();
198  }
199 
207  public function fillRow($data)
208  {
209  global $ilUser,$ilAccess;
210 
211  $this->tpl->setVariable('QUESTION_ID', $data["question_id"]);
212  $this->tpl->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($data["title"]));
213 
214  $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview"));
215  $guiclass = strtolower($data['type_tag']) . "gui";
216  $this->ctrl->setParameterByClass($guiclass, "q_id", $data["question_id"]);
217  $this->tpl->setVariable("LINK_PREVIEW", "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&amp;ref_id=" . $data["ref_id"] . "&amp;cmd=preview&amp;preview=" . $data["question_id"]);
218 
219  $this->tpl->setVariable("QUESTION_DESCRIPTION", ilUtil::prepareFormOutput((strlen($data["description"])) ? $data["description"] : ""));
220  $this->tpl->setVariable("QUESTION_TYPE", $data["ttype"]);
221  $this->tpl->setVariable("QUESTION_AUTHOR", ilUtil::prepareFormOutput($data["author"]));
222  $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'],IL_CAL_UNIX)));
223  $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data["tstamp"],IL_CAL_UNIX)));
224  $this->tpl->setVariable("QPL", ilUtil::prepareFormOutput($data["spl"]));
225  }
226 
227  public function setEditable($value)
228  {
229  $this->editable = $value;
230  }
231 
232  public function getEditable()
233  {
234  return $this->editable;
235  }
236 
237  public function setWriteAccess($value)
238  {
239  $this->writeAccess = $value;
240  }
241 
242  public function getWriteAccess()
243  {
244  return $this->writeAccess;
245  }
246 }
247 ?>
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
setFormName($a_formname)
Set Form name.
__construct($a_parent_obj, $a_parent_cmd, $a_object, $a_write_access=false)
Constructor.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
This class represents a selection list property in a property form.
setStyle($a_element, $a_style)
setFilterCommand($a_val)
Set filter command.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
const IL_CAL_UNIX
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
Class ilTable2GUI.
Class for single dates.
if(!is_array($argv)) $options
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
addMultiCommand($a_cmd, $a_text)
Add Command button.
enable($a_module_name)
enables particular modules of table
This class represents a text property in a property form.
static formatDate(ilDateTime $date)
Format a date public.
setPrefix($a_prefix)
setMaxLength($a_maxlength)
Set Max Length.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
setFormAction($a_form_action)
Set Form action parameter.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
getFilterItems($a_optionals=false)
Get filter items.
setResetCommand($a_val)
Set reset filter command.
_getAvailableQuestionpools($use_object_id=FALSE, $could_be_offline=FALSE, $showPath=FALSE, $permission="read")
Returns the available question pools for the active user.