ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilListOfQuestionsTableGUI.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
5include_once('./Services/Table/classes/class.ilTable2GUI.php');
6require_once 'Modules/Test/classes/class.ilTestPlayerCommands.php';
7
17{
18 protected $showPointsEnabled = false;
19 protected $showMarkerEnabled = false;
20
21 protected $showObligationsEnabled = false;
22 protected $obligationsFilterEnabled = false;
23
24 protected $obligationsNotAnswered = false;
25
26 protected $finishTestButtonEnabled = false;
27
35 public function __construct($a_parent_obj, $a_parent_cmd)
36 {
37 parent::__construct($a_parent_obj, $a_parent_cmd);
38
39 global $DIC;
40 $lng = $DIC['lng'];
41 $ilCtrl = $DIC['ilCtrl'];
42
43 $this->lng = $lng;
44 $this->ctrl = $ilCtrl;
45
46 $this->setFormName('listofquestions');
47 $this->setStyle('table', 'fullwidth');
48
49 $this->setRowTemplate("tpl.il_as_tst_list_of_questions_row.html", "Modules/Test");
50
51 $this->setLimit(999);
52
53 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
54
55 $this->enable('header');
56 $this->disable('sort');
57 $this->disable('select_all');
58 }
59
60 public function init()
61 {
62 // table title
63
64 if ($this->isObligationsFilterEnabled()) {
65 $this->setTitle($this->lng->txt('obligations_summary'));
66 } else {
67 $this->setTitle($this->lng->txt('question_summary'));
68 }
69
70 // columns
71
72 $this->addColumn($this->lng->txt("tst_qst_order"), 'order', '');
73 $this->addColumn($this->lng->txt("tst_question_title"), 'title', '');
74
75 if ($this->isShowObligationsEnabled()) {
76 $this->addColumn($this->lng->txt("obligatory"), 'obligatory', '');
77 }
78
79 $this->addColumn('', 'postponed', '');
80
81 if ($this->isShowPointsEnabled()) {
82 $this->addColumn($this->lng->txt("tst_maximum_points"), 'points', '');
83 }
84
85 #$this->addColumn($this->lng->txt("worked_through"),'worked_through', '');
86 $this->addColumn($this->lng->txt("answered"), 'answered', '');
87
88 if (false && $this->isShowObligationsEnabled()) {
89 $this->addColumn($this->lng->txt("answered"), 'answered', '');
90 }
91
92 if ($this->isShowMarkerEnabled()) {
93 $this->addColumn($this->lng->txt("tst_question_marker"), 'marked', '');
94 }
95
96 // command buttons
97
98 $this->addCommandButton(
100 $this->lng->txt('tst_resume_test')
101 );
102
103 if (!$this->areObligationsNotAnswered() && $this->isFinishTestButtonEnabled()) {
104 $button = ilSubmitButton::getInstance();
105 $button->setCaption('finish_test');
106 $button->setCommand(ilTestPlayerCommands::FINISH_TEST);
107 $this->addCommandButtonInstance($button);
108 }
109 }
110
118 public function fillRow($data)
119 {
120 if ($this->isShowPointsEnabled()) {
121 $this->tpl->setCurrentBlock('points');
122 $this->tpl->setVariable("POINTS", $data['points'] . '&nbsp;' . $this->lng->txt("points_short"));
123 $this->tpl->parseCurrentBlock();
124 }
125 if (strlen($data['description'])) {
126 $this->tpl->setCurrentBlock('description');
127 $this->tpl->setVariable("DESCRIPTION", ilUtil::prepareFormOutput($data['description']));
128 $this->tpl->parseCurrentBlock();
129 }
130 if ($this->isShowMarkerEnabled()) {
131 if ($data['marked']) {
132 $this->tpl->setCurrentBlock('marked_img');
133 $this->tpl->setVariable(
134 "HREF_MARKED",
136 ilUtil::getImagePath('marked.svg'),
137 $this->lng->txt("tst_question_marked"),
138 '24px',
139 '24px'
140 )
141 );
142 $this->tpl->parseCurrentBlock();
143 } else {
144 $this->tpl->touchBlock('marker');
145 }
146 }
147 if ($this->isShowObligationsEnabled()) {
148 // obligatory answer status
149 if (false) {
150 $value = '&nbsp;';
151 if ($data['isAnswered']) {
152 $value = $this->lng->txt("yes");
153 }
154 $this->tpl->setCurrentBlock('answered_col');
155 $this->tpl->setVariable('ANSWERED', $value);
156 $this->tpl->parseCurrentBlock();
157 }
158
159 // obligatory icon
160 if ($data["obligatory"]) {
161 require_once 'Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php';
162 $OBLIGATORY = ilGlyphGUI::get(ilGlyphGUI::EXCLAMATION, $this->lng->txt('question_obligatory'));
163 } else {
164 $OBLIGATORY = '';
165 }
166 $this->tpl->setVariable("QUESTION_OBLIGATORY", $OBLIGATORY);
167 }
168
169 $postponed = (
170 $data['postponed'] ? $this->lng->txt('postponed') : ''
171 );
172
173 if ($data['disabled']) {
174 $this->tpl->setCurrentBlock('static_title');
175 $this->tpl->setVariable("STATIC_TITLE", ilUtil::prepareFormOutput($data['title']));
176 $this->tpl->parseCurrentBlock();
177 } else {
178 $this->ctrl->setParameter($this->parent_obj, 'sequence', $data['sequence']);
179 $this->ctrl->setParameter($this->parent_obj, 'pmode', '');
180 $href = $this->ctrl->getLinkTarget($this->parent_obj, ilTestPlayerCommands::SHOW_QUESTION);
181
182 $this->tpl->setCurrentBlock('linked_title');
183 $this->tpl->setVariable("LINKED_TITLE", ilUtil::prepareFormOutput($data['title']));
184 $this->tpl->setVariable("HREF", $href);
185 $this->tpl->parseCurrentBlock();
186 }
187
188 $this->tpl->setVariable("ORDER", $data['order']);
189 $this->tpl->setVariable("POSTPONED", $postponed);
190 if ($data["worked_through"]) {
191 $this->tpl->setVariable("WORKED_THROUGH", $this->lng->txt("yes"));
192 } else {
193 $this->tpl->setVariable("WORKED_THROUGH", '&nbsp;');
194 }
195 }
196
197 public function isShowPointsEnabled()
198 {
200 }
201
203 {
204 $this->showPointsEnabled = $showPointsEnabled;
205 }
206
207 public function isShowMarkerEnabled()
208 {
210 }
211
213 {
214 $this->showMarkerEnabled = $showMarkerEnabled;
215 }
216
217 public function isShowObligationsEnabled()
218 {
220 }
221
223 {
224 $this->showObligationsEnabled = $showObligationsEnabled;
225 }
226
228 {
230 }
231
233 {
234 $this->obligationsFilterEnabled = $obligationsFilterEnabled;
235 }
236
238 {
240 }
241
243 {
244 $this->obligationsNotAnswered = $obligationsNotAnswered;
245 }
246
251 {
253 }
254
259 {
260 $this->finishTestButtonEnabled = $finishTestButtonEnabled;
261 }
262}
An exception for terminatinating execution or to throw for unit testing.
static get($a_glyph, $a_text="")
Get glyph html.
setFinishTestButtonEnabled($finishTestButtonEnabled)
__construct($a_parent_obj, $a_parent_cmd)
Constructor.
setShowObligationsEnabled($showObligationsEnabled)
setObligationsFilterEnabled($obligationsFilterEnabled)
setObligationsNotAnswered($obligationsNotAnswered)
static getInstance()
Factory.
Class ilTable2GUI.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
addCommandButtonInstance(ilButtonBase $a_button)
Add Command button instance.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
setStyle($a_element, $a_style)
enable($a_module_name)
enables particular modules of table
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc