ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
4require_once './Services/Table/classes/class.ilTable2GUI.php';
5
15{
16 protected $writeAccess = false;
17
28 public function __construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_write_access = false)
29 {
30 $this->setId('qst_browser_' . $a_ref_id);
31 parent::__construct($a_parent_obj, $a_parent_cmd);
32
33 global $lng, $ilCtrl;
34
35 $this->lng = $lng;
36 $this->ctrl = $ilCtrl;
37
38 $this->setWriteAccess($a_write_access);
39
40 $this->setFormName('questionbrowser');
41 $this->setStyle('table', 'fullwidth');
42 $this->addColumn('','','1%', true);
43 $this->addColumn($this->lng->txt("tst_question_title"),'title', '');
44 $this->addColumn($this->lng->txt("description"),'description', '');
45 $this->addColumn($this->lng->txt("tst_question_type"),'ttype', '');
46 $this->addColumn($this->lng->txt("author"),'author', '');
47 $this->addColumn($this->lng->txt("create_date"),'created', '');
48 $this->addColumn($this->lng->txt("last_update"),'tstamp', ''); // name of col is proper "updated" but in data array the key is "tstamp"
49 $this->addColumn($this->lng->txt("qpl"),'qpl', '');
50 $this->addColumn($this->lng->txt("working_time"),'working_time', '');
51 if ($this->getWriteAccess())
52 {
53 $this->addMultiCommand('insertQuestions', $this->lng->txt('insert'));
54 }
55
56 $this->setSelectAllCheckbox('q_id');
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 $this->setDisableFilterHiding(true);
70 }
71
75 function initFilter()
76 {
77 global $lng;
78
79 // title
80 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
81 $ti = new ilTextInputGUI($lng->txt("tst_qbt_filter_question_title"), "title");
82 $ti->setMaxLength(64);
83 $ti->setSize(20);
84 $ti->setValidationRegexp('/(^[^%]+$)|(^$)/is');
85 $this->addFilterItem($ti);
86 $ti->readFromSession();
87 $this->filter["title"] = $ti->getValue();
88
89 // description
90 $ti = new ilTextInputGUI($lng->txt("description"), "description");
91 $ti->setMaxLength(64);
92 $ti->setSize(20);
93 $ti->setValidationRegexp('/(^[^%]+$)|(^$)/is');
94 $this->addFilterItem($ti);
95 $ti->readFromSession();
96 $this->filter["description"] = $ti->getValue();
97
98 // questiontype
99 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
100 include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
102 $options = array();
103 $options[""] = $lng->txt('filter_all_question_types');
104 foreach ($types as $translation => $row)
105 {
106 $options[$row['type_tag']] = $translation;
107 }
108
109 $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
110 $si->setOptions($options);
111 $this->addFilterItem($si);
112 $si->readFromSession();
113 $this->filter["type"] = $si->getValue();
114
115 // author
116 $ti = new ilTextInputGUI($lng->txt("author"), "author");
117 $ti->setMaxLength(64);
118 $ti->setSize(20);
119 $this->addFilterItem($ti);
120 $ti->setValidationRegexp('/(^[^%]+$)|(^$)/is');
121 $ti->readFromSession();
122 $this->filter["author"] = $ti->getValue();
123
124 // question pool
125 $ti = new ilTextInputGUI($lng->txt("qpl"), "qpl");
126 $ti->setMaxLength(64);
127 $ti->setSize(20);
128 $ti->setValidationRegexp('/(^[^%]+$)|(^$)/is');
129 $this->addFilterItem($ti);
130 $ti->readFromSession();
131 $this->filter["qpl"] = $ti->getValue();
132
133 }
134
142 public function fillRow($data)
143 {
144 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
145 $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
146 $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
147 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
148 $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
149 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
150 $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'],IL_CAL_UNIX)));
151 $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data["tstamp"],IL_CAL_UNIX)));
152 $this->tpl->setVariable("QUESTION_POOL", $data['qpl']);
153 $this->tpl->setVariable("WORKING_TIME", $data['working_time']);
154 }
155
156 public function setWriteAccess($value)
157 {
158 $this->writeAccess = $value;
159 }
160
161 public function getWriteAccess()
162 {
163 return $this->writeAccess;
164 }
165}
const IL_CAL_UNIX
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
static formatDate(ilDateTime $date)
Format a date @access public.
Class for single dates.
& _getQuestionTypes($all_tags=FALSE, $fixOrder=false)
This class represents a selection list property in a property form.
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setFormName($a_formname)
Set Form name.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
setStyle($a_element, $a_style)
enable($a_module_name)
enables particular modules of table
__construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_write_access=false)
Constructor.
This class represents a text property in a property form.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
if(!is_array($argv)) $options