ILIAS  eassessment Revision 61809
 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 
97  function initFilter()
98  {
99  global $lng, $rbacreview, $ilUser;
100 
101  // title
102  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
103  $ti = new ilTextInputGUI($lng->txt("title"), "title");
104  $ti->setMaxLength(64);
105  $ti->setValidationRegexp('/^[^%]+$/is');
106  $ti->setSize(20);
107  $this->addFilterItem($ti);
108  $ti->readFromSession();
109  $this->filter["title"] = $ti->getValue();
110 
111  // description
112  $ti = new ilTextInputGUI($lng->txt("description"), "description");
113  $ti->setMaxLength(64);
114  $ti->setValidationRegexp('/^[^%]+$/is');
115  $ti->setSize(20);
116  $this->addFilterItem($ti);
117  $ti->readFromSession();
118  $this->filter["description"] = $ti->getValue();
119 
120  // author
121  $ti = new ilTextInputGUI($lng->txt("author"), "author");
122  $ti->setMaxLength(64);
123  $ti->setValidationRegexp('/^[^%]+$/is');
124  $ti->setSize(20);
125  $this->addFilterItem($ti);
126  $ti->readFromSession();
127  $this->filter["author"] = $ti->getValue();
128 
129  // questiontype
130  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
131  include_once("./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php");
132  $types = ilObjSurveyQuestionPool::_getQuestionTypes();
133  $options = array();
134  $options[""] = $lng->txt('filter_all_question_types');
135  foreach ($types as $translation => $row)
136  {
137  $options[$row['type_tag']] = $translation;
138  }
139 
140  $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
141  $si->setOptions($options);
142  $this->addFilterItem($si);
143  $si->readFromSession();
144  $this->filter["type"] = $si->getValue();
145 
146  // questionpool
147  $options = array();
148  $options[""] = $lng->txt('filter_all_questionpools');
149  foreach ($this->questionpools as $obj_id => $title)
150  {
151  $options[$obj_id] = $title;
152  }
153 
154  $si = new ilSelectInputGUI($this->lng->txt("obj_spl"), "spl");
155  $si->setOptions($options);
156  $this->addFilterItem($si);
157  $si->readFromSession();
158  $this->filter["type"] = $si->getValue();
159  }
160 
168  public function fillRow($data)
169  {
170  global $ilUser,$ilAccess;
171 
172  $this->tpl->setVariable('QUESTION_ID', $data["question_id"]);
173  $this->tpl->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($data["title"]));
174 
175  $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview"));
176  $guiclass = strtolower($data['type_tag']) . "gui";
177  $this->ctrl->setParameterByClass($guiclass, "q_id", $data["question_id"]);
178  $this->tpl->setVariable("LINK_PREVIEW", "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&amp;ref_id=" . $data["ref_id"] . "&amp;cmd=preview&amp;preview=" . $data["question_id"]);
179 
180  $this->tpl->setVariable("QUESTION_DESCRIPTION", ilUtil::prepareFormOutput((strlen($data["description"])) ? $data["description"] : ""));
181  $this->tpl->setVariable("QUESTION_TYPE", $data["ttype"]);
182  $this->tpl->setVariable("QUESTION_AUTHOR", ilUtil::prepareFormOutput($data["author"]));
183  include_once "./classes/class.ilFormat.php";
184  $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'],IL_CAL_UNIX)));
185  $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data["tstamp"],IL_CAL_UNIX)));
186  $this->tpl->setVariable("QPL", ilUtil::prepareFormOutput($this->questionpools[$data['obj_fi']]));
187  }
188 
189  public function setEditable($value)
190  {
191  $this->editable = $value;
192  }
193 
194  public function getEditable()
195  {
196  return $this->editable;
197  }
198 
199  public function setWriteAccess($value)
200  {
201  $this->writeAccess = $value;
202  }
203 
204  public function getWriteAccess()
205  {
206  return $this->writeAccess;
207  }
208 }
209 ?>