ILIAS  Release_4_4_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 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once './Services/Table/classes/class.ilTable2GUI.php';
5 
15 {
16  protected $writeAccess = false;
17 
27  public function __construct($a_parent_obj, $a_parent_cmd, $a_write_access = false)
28  {
29  parent::__construct($a_parent_obj, $a_parent_cmd);
30 
31  global $lng, $ilCtrl;
32 
33  $this->lng = $lng;
34  $this->ctrl = $ilCtrl;
35 
36  $this->setWriteAccess($a_write_access);
37 
38  $this->setFormName('questionbrowser');
39  $this->setStyle('table', 'fullwidth');
40  $this->addColumn('','','1%', true);
41  $this->addColumn($this->lng->txt("tst_question_title"),'title', '');
42  $this->addColumn($this->lng->txt("description"),'description', '');
43  $this->addColumn($this->lng->txt("tst_question_type"),'ttype', '');
44  $this->addColumn($this->lng->txt("author"),'author', '');
45  $this->addColumn($this->lng->txt("create_date"),'created', '');
46  $this->addColumn($this->lng->txt("last_update"),'tstamp', ''); // name of col is proper "updated" but in data array the key is "tstamp"
47  $this->addColumn($this->lng->txt("qpl"),'qpl', '');
48 
49  if ($this->getWriteAccess())
50  {
51  $this->addMultiCommand('insertQuestions', $this->lng->txt('insert'));
52  }
53 
54  $this->setPrefix('q_id');
55  $this->setSelectAllCheckbox('q_id');
56 
57  $this->setRowTemplate("tpl.il_as_tst_question_browser_row.html", "Modules/Test");
58 
59  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
60  $this->setDefaultOrderField("title");
61  $this->setDefaultOrderDirection("asc");
62 
63  $this->enable('sort');
64  $this->enable('header');
65  $this->enable('select_all');
66  $this->setFilterCommand('filterAvailableQuestions');
67  $this->setResetCommand('resetfilterAvailableQuestions');
68  $this->initFilter();
69  }
70 
74  function initFilter()
75  {
76  global $lng;
77 
78  // title
79  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
80  $ti = new ilTextInputGUI($lng->txt("title"), "title");
81  $ti->setMaxLength(64);
82  $ti->setSize(20);
83  $ti->setValidationRegexp('/^[^%]+$/is');
84  $this->addFilterItem($ti);
85  $ti->readFromSession();
86  $this->filter["title"] = $ti->getValue();
87 
88  // description
89  $ti = new ilTextInputGUI($lng->txt("description"), "description");
90  $ti->setMaxLength(64);
91  $ti->setSize(20);
92  $ti->setValidationRegexp('/^[^%]+$/is');
93  $this->addFilterItem($ti);
94  $ti->readFromSession();
95  $this->filter["description"] = $ti->getValue();
96 
97  // questiontype
98  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
99  include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
101  $options = array();
102  $options[""] = $lng->txt('filter_all_question_types');
103  foreach ($types as $translation => $row)
104  {
105  $options[$row['type_tag']] = $translation;
106  }
107 
108  $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
109  $si->setOptions($options);
110  $this->addFilterItem($si);
111  $si->readFromSession();
112  $this->filter["type"] = $si->getValue();
113 
114  // author
115  $ti = new ilTextInputGUI($lng->txt("author"), "author");
116  $ti->setMaxLength(64);
117  $ti->setSize(20);
118  $this->addFilterItem($ti);
119  $ti->setValidationRegexp('/^[^%]+$/is');
120  $ti->readFromSession();
121  $this->filter["author"] = $ti->getValue();
122 
123  // question pool
124  $ti = new ilTextInputGUI($lng->txt("qpl"), "qpl");
125  $ti->setMaxLength(64);
126  $ti->setSize(20);
127  $ti->setValidationRegexp('/^[^%]+$/is');
128  $this->addFilterItem($ti);
129  $ti->readFromSession();
130  $this->filter["qpl"] = $ti->getValue();
131 
132  }
133 
141  public function fillRow($data)
142  {
143  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
144  $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
145  $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
146  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
147  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
148  $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
149  $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'],IL_CAL_UNIX)));
150  $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data["tstamp"],IL_CAL_UNIX)));
151  $this->tpl->setVariable("QUESTION_POOL", $data['qpl']);
152  }
153 
154  public function setWriteAccess($value)
155  {
156  $this->writeAccess = $value;
157  }
158 
159  public function getWriteAccess()
160  {
161  return $this->writeAccess;
162  }
163 }