ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
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_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($use_object_id = TRUE, false, true);
83 
84 
85  $this->enable('sort');
86  $this->enable('header');
87  $this->enable('select_all');
88  $this->setFilterCommand('filterQuestionBrowser');
89  $this->setResetCommand('resetfilterQuestionBrowser');
90 
91  $this->initFilter();
92  }
93 
94  function getQuestionPools()
95  {
96  return $this->questionpools;
97  }
98 
102  function initFilter()
103  {
104  global $lng, $rbacreview, $ilUser;
105 
106  // title
107  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
108  $ti = new ilTextInputGUI($lng->txt("survey_question_title"), "title");
109  $ti->setMaxLength(64);
110  $ti->setValidationRegexp('/^[^%]+$/is');
111  $ti->setSize(20);
112  $this->addFilterItem($ti);
113  $ti->readFromSession();
114  $this->filter["title"] = $ti->getValue();
115 
116  // description
117  $ti = new ilTextInputGUI($lng->txt("description"), "description");
118  $ti->setMaxLength(64);
119  $ti->setValidationRegexp('/^[^%]+$/is');
120  $ti->setSize(20);
121  $this->addFilterItem($ti);
122  $ti->readFromSession();
123  $this->filter["description"] = $ti->getValue();
124 
125  // author
126  $ti = new ilTextInputGUI($lng->txt("author"), "author");
127  $ti->setMaxLength(64);
128  $ti->setValidationRegexp('/^[^%]+$/is');
129  $ti->setSize(20);
130  $this->addFilterItem($ti);
131  $ti->readFromSession();
132  $this->filter["author"] = $ti->getValue();
133 
134  // questiontype
135  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
136  include_once("./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php");
137  $types = ilObjSurveyQuestionPool::_getQuestionTypes();
138  $options = array();
139  $options[""] = $lng->txt('filter_all_question_types');
140  foreach ($types as $translation => $row)
141  {
142  $options[$row['type_tag']] = $translation;
143  }
144 
145  $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
146  $si->setOptions($options);
147  $this->addFilterItem($si);
148  $si->readFromSession();
149  $this->filter["type"] = $si->getValue();
150 
151 
152  // questionpool text
153  $ti = new ilTextInputGUI($lng->txt("survey_question_pool_title"), "spl_txt");
154  $ti->setMaxLength(64);
155  $ti->setSize(20);
156  $this->addFilterItem($ti);
157  $ti->readFromSession();
158  $this->filter["spl_txt"] = $ti->getValue();
159 
160  // questionpool select
161  $options = array();
162  $options[""] = $lng->txt('filter_all_questionpools');
163  natcasesort($this->questionpools);
164  foreach ($this->questionpools as $obj_id => $title)
165  {
166  $options[$obj_id] = $title;
167  }
168  $si = new ilSelectInputGUI($this->lng->txt("survey_available_question_pools"), "spl");
169  $si->setOptions($options);
170  $this->addFilterItem($si);
171  $si->readFromSession();
172  $this->filter["type"] = $si->getValue();
173  }
174 
182  public function fillRow($data)
183  {
184  global $ilUser,$ilAccess;
185 
186  $this->tpl->setVariable('QUESTION_ID', $data["question_id"]);
187  $this->tpl->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($data["title"]));
188 
189  $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview"));
190  $guiclass = strtolower($data['type_tag']) . "gui";
191  $this->ctrl->setParameterByClass($guiclass, "q_id", $data["question_id"]);
192  $this->tpl->setVariable("LINK_PREVIEW", "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&amp;ref_id=" . $data["ref_id"] . "&amp;cmd=preview&amp;preview=" . $data["question_id"]);
193 
194  $this->tpl->setVariable("QUESTION_DESCRIPTION", ilUtil::prepareFormOutput((strlen($data["description"])) ? $data["description"] : ""));
195  $this->tpl->setVariable("QUESTION_TYPE", $data["ttype"]);
196  $this->tpl->setVariable("QUESTION_AUTHOR", ilUtil::prepareFormOutput($data["author"]));
197  include_once "./classes/class.ilFormat.php";
198  $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'],IL_CAL_UNIX)));
199  $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data["tstamp"],IL_CAL_UNIX)));
200  $this->tpl->setVariable("QPL", ilUtil::prepareFormOutput($data["spl"]));
201  }
202 
203  public function setEditable($value)
204  {
205  $this->editable = $value;
206  }
207 
208  public function getEditable()
209  {
210  return $this->editable;
211  }
212 
213  public function setWriteAccess($value)
214  {
215  $this->writeAccess = $value;
216  }
217 
218  public function getWriteAccess()
219  {
220  return $this->writeAccess;
221  }
222 }
223 ?>