ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestQuestionBrowserTableGUI.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 $writeAccess = false;
37 
45  public function __construct($a_parent_obj, $a_parent_cmd, $a_write_access = false)
46  {
47  parent::__construct($a_parent_obj, $a_parent_cmd);
48 
49  global $lng, $ilCtrl;
50 
51  $this->lng = $lng;
52  $this->ctrl = $ilCtrl;
53 
54  $this->setWriteAccess($a_write_access);
55 
56  $this->setFormName('questionbrowser');
57  $this->setStyle('table', 'fullwidth');
58  $this->addColumn('','f','1%');
59  $this->addColumn($this->lng->txt("tst_question_title"),'title', '');
60  $this->addColumn($this->lng->txt("description"),'description', '');
61  $this->addColumn($this->lng->txt("tst_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("qpl"),'qpl', '');
66 
67  if ($this->getWriteAccess())
68  {
69  $this->addMultiCommand('insertQuestions', $this->lng->txt('insert'));
70  }
71 
72  $this->setPrefix('q_id');
73  $this->setSelectAllCheckbox('q_id');
74 
75  $this->setRowTemplate("tpl.il_as_tst_question_browser_row.html", "Modules/Test");
76 
77  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
78  $this->setDefaultOrderField("title");
79  $this->setDefaultOrderDirection("asc");
80 
81  $this->enable('sort');
82  $this->enable('header');
83  $this->enable('select_all');
84  $this->setFilterCommand('filterAvailableQuestions');
85  $this->setResetCommand('resetfilterAvailableQuestions');
86  $this->initFilter();
87  }
88 
92  function initFilter()
93  {
94  global $lng, $rbacreview, $ilUser;
95 
96  // title
97  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
98  $ti = new ilTextInputGUI($lng->txt("title"), "title");
99  $ti->setMaxLength(64);
100  $ti->setSize(20);
101  $ti->setValidationRegexp('/^[^%]+$/is');
102  $this->addFilterItem($ti);
103  $ti->readFromSession();
104  $this->filter["title"] = $ti->getValue();
105 
106  // description
107  $ti = new ilTextInputGUI($lng->txt("description"), "description");
108  $ti->setMaxLength(64);
109  $ti->setSize(20);
110  $ti->setValidationRegexp('/^[^%]+$/is');
111  $this->addFilterItem($ti);
112  $ti->readFromSession();
113  $this->filter["description"] = $ti->getValue();
114 
115  // questiontype
116  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
117  include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
119  $options = array();
120  $options[""] = $lng->txt('filter_all_question_types');
121  foreach ($types as $translation => $row)
122  {
123  $options[$row['type_tag']] = $translation;
124  }
125 
126  $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
127  $si->setOptions($options);
128  $this->addFilterItem($si);
129  $si->readFromSession();
130  $this->filter["type"] = $si->getValue();
131 
132  // author
133  $ti = new ilTextInputGUI($lng->txt("author"), "author");
134  $ti->setMaxLength(64);
135  $ti->setSize(20);
136  $ti->setValidationRegexp('/^[^%]+$/is');
137  $this->addFilterItem($ti);
138  $ti->readFromSession();
139  $this->filter["author"] = $ti->getValue();
140 
141  // question pool
142  $ti = new ilTextInputGUI($lng->txt("qpl"), "qpl");
143  $ti->setMaxLength(64);
144  $ti->setValidationRegexp('/^[^%]+$/is');
145  $ti->setSize(20);
146  $this->addFilterItem($ti);
147  $ti->readFromSession();
148  $this->filter["qpl"] = $ti->getValue();
149 
150  }
151 
159  public function fillRow($data)
160  {
161  global $ilUser,$ilAccess;
162 
163  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
164  $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
165  $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
166  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
167  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
168  $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
169  include_once "./classes/class.ilFormat.php";
170  $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'],IL_CAL_UNIX)));
171  $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data["tstamp"],IL_CAL_UNIX)));
172  $this->tpl->setVariable("QUESTION_POOL", $data['qpl']);
173  }
174 
175  public function setWriteAccess($value)
176  {
177  $this->writeAccess = $value;
178  }
179 
180  public function getWriteAccess()
181  {
182  return $this->writeAccess;
183  }
184 }
185 ?>