ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTestPassOverviewTableGUI.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';
5require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
6
11{
15 protected $resultPresentationEnabled = false;
16
20 protected $pdfPresentationEnabled = false;
21
26
30 protected $activeId = null;
31
35 protected $passDetailsCommand = '';
36
40 protected $passDeletionCommand = '';
41
47 public function __construct($parent, $cmd)
48 {
49 $this->setId('tst_pass_overview_' . $parent->object->getId());
50 $this->setDefaultOrderField('pass');
51 $this->setDefaultOrderDirection('ASC');
52
53 parent::__construct($parent, $cmd);
54
55 // Don't set any limit because of print/pdf views. Furthermore, this view is part of different summary views, and no cmd ist passed to he calling method.
56 $this->setLimit(PHP_INT_MAX);
57 $this->disable('sort');
58
59 $this->setRowTemplate('tpl.il_as_tst_pass_overview_row.html', 'Modules/Test');
60 }
61
62 public function init()
63 {
64 global $ilCtrl;
65
66 $ilCtrl->setParameter($this->parent_obj, 'active_id', $this->getActiveId());
67
68 $this->initColumns();
69
70 if ($this->isPdfPresentationEnabled()) {
71 $this->disable('linkbar');
72 $this->disable('numinfo');
73 $this->disable('numinfo_header');
74 $this->disable('hits');
75 }
76 }
77
82 public function numericOrdering($field)
83 {
84 switch ($field) {
85 case 'pass':
86 case 'date':
87 case 'percentage':
88 return true;
89 }
90
91 return false;
92 }
93
97 public function fillRow($row)
98 {
99 if (array_key_exists('percentage', $row)) {
100 $row['percentage'] = sprintf('%.2f', $row['percentage']) . '%';
101 }
102
103 // fill columns
104
106 if ($this->isResultPresentationEnabled()) {
107 $this->tpl->setVariable('VAL_SCORED', $row['scored'] ? '&otimes;' : '');
108 }
109
110 $this->tpl->setVariable('VAL_PASS', $this->getPassNumberPresentation($row['pass']));
111 }
112
113 $this->tpl->setVariable('VAL_DATE', $this->formatDate($row['date']));
114
116 $this->tpl->setVariable('VAL_LO_OBJECTIVES', $row['objectives']);
117
118 $this->tpl->setVariable('VAL_LO_TRY', sprintf(
119 $this->lng->txt('tst_res_lo_try_n'),
120 $this->getPassNumberPresentation($row['pass'])
121 ));
122 }
123
124 if ($this->isResultPresentationEnabled()) {
125 $this->tpl->setVariable('VAL_ANSWERED', $this->buildWorkedThroughQuestionsString(
126 $row['num_workedthrough_questions'],
127 $row['num_questions_total']
128 ));
129
130 if ($this->getParentObject()->object->isOfferingQuestionHintsEnabled()) {
131 $this->tpl->setVariable('VAL_HINTS', $row['hints']);
132 }
133
134 $this->tpl->setVariable('VAL_REACHED', $this->buildReachedPointsString(
135 $row['reached_points'],
136 $row['max_points']
137 ));
138
139 $this->tpl->setVariable('VAL_PERCENTAGE', $row['percentage']);
140 }
141
142 if (!$this->isPdfPresentationEnabled()) {
143 $actions = $this->getRequiredActions($row['scored']);
144 $this->tpl->setVariable('VAL_ACTIONS', $this->buildActionsHtml($actions, $row['pass']));
145 }
146 }
147
148 protected function initColumns()
149 {
151 $this->addColumn($this->lng->txt('scored_pass'), '', '150');
152 }
153
155 $this->addColumn($this->lng->txt('pass'), '', '1%');
156 }
157
158 $this->addColumn($this->lng->txt('date'));
159
161 $this->addColumn($this->lng->txt('tst_res_lo_objectives_header'), '');
162 $this->addColumn($this->lng->txt('tst_res_lo_try_header'), '');
163 }
164
165 if ($this->isResultPresentationEnabled()) {
166 $this->addColumn($this->lng->txt('tst_answered_questions'));
167 if ($this->getParentObject()->object->isOfferingQuestionHintsEnabled()) {
168 $this->addColumn($this->lng->txt('tst_question_hints_requested_hint_count_header'));
169 }
170 $this->addColumn($this->lng->txt('tst_reached_points'));
171 $this->addColumn($this->lng->txt('tst_percent_solved'));
172 }
173
174 // actions
175 if (!$this->isPdfPresentationEnabled()) {
176 $this->addColumn('', '', '10%');
177 }
178 }
179
184 {
186 }
187
192 {
193 $this->resultPresentationEnabled = $resultPresentationEnabled;
194 }
195
199 public function isPdfPresentationEnabled()
200 {
202 }
203
208 {
209 $this->pdfPresentationEnabled = $pdfPresentationEnabled;
210 }
211
216 {
218 }
219
224 {
225 $this->objectiveOrientedPresentationEnabled = $objectiveOrientedPresentationEnabled;
226 }
227
231 public function getActiveId()
232 {
233 return $this->activeId;
234 }
235
239 public function setActiveId($activeId)
240 {
241 $this->activeId = $activeId;
242 }
243
247 public function getPassDetailsCommand()
248 {
250 }
251
256 {
257 $this->passDetailsCommand = $passDetailsCommand;
258 }
259
263 public function getPassDeletionCommand()
264 {
266 }
267
272 {
273 $this->passDeletionCommand = $passDeletionCommand;
274 }
275
280 private function formatDate($date)
281 {
286 return $date;
287 }
288
289 private function buildWorkedThroughQuestionsString($numQuestionsWorkedThrough, $numQuestionsTotal)
290 {
291 return "{$numQuestionsWorkedThrough} {$this->lng->txt('of')} {$numQuestionsTotal}";
292 }
293
294 private function buildReachedPointsString($reachedPoints, $maxPoints)
295 {
296 return "{$reachedPoints} {$this->lng->txt('of')} {$maxPoints}";
297 }
298
299 private function getRequiredActions($isScoredPass)
300 {
301 $actions = array();
302
303 if ($this->getPassDetailsCommand()) {
304 $actions[$this->getPassDetailsCommand()] = $this->lng->txt('tst_pass_details');
305 }
306
307 if (!$isScoredPass && $this->getPassDeletionCommand()) {
308 $actions[$this->getPassDeletionCommand()] = $this->lng->txt('delete');
309 }
310
311 return $actions;
312 }
313
314 private function buildActionsHtml($actions, $pass)
315 {
316 global $ilCtrl;
317
318 if (!count($actions)) {
319 return '';
320 }
321
322 $ilCtrl->setParameter($this->parent_obj, 'pass', $pass);
323
324 if (count($actions) > 1) {
325 $aslgui = new ilAdvancedSelectionListGUI();
326 $aslgui->setListTitle($this->lng->txt('actions'));
327 $aslgui->setId($pass);
328
329 foreach ($actions as $cmd => $label) {
330 $aslgui->addItem($label, $cmd, $ilCtrl->getLinkTarget($this->parent_obj, $cmd));
331 }
332
333 $html = $aslgui->getHTML();
334 } else {
335 $cmd = key($actions);
336 $label = current($actions);
337
338 $href = $ilCtrl->getLinkTarget($this->parent_obj, $cmd);
339 $html = '<a href="' . $href . '">' . $label . '</a>';
340 }
341
342 $ilCtrl->setParameter($this->parent_obj, 'pass', '');
343
344 return $html;
345 }
346
352 {
353 return $pass + 1;
354 }
355}
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
User interface class for advanced drop-down selection lists.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
Class ilTable2GUI.
getParentObject()
Get parent object.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setId($a_val)
Set id.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
disable($a_module_name)
diesables particular modules of table
Class ilTestPassOverviewTableGUI.
buildWorkedThroughQuestionsString($numQuestionsWorkedThrough, $numQuestionsTotal)
setResultPresentationEnabled($resultPresentationEnabled)
setObjectiveOrientedPresentationEnabled($objectiveOrientedPresentationEnabled)
setPdfPresentationEnabled($pdfPresentationEnabled)
buildReachedPointsString($reachedPoints, $maxPoints)
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18