ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
72 $this->disable('linkbar');
73 $this->disable('numinfo');
74 $this->disable('numinfo_header');
75 $this->disable('hits');
76 }
77 }
78
83 public function numericOrdering($field)
84 {
85 switch($field)
86 {
87 case 'pass':
88 case 'date':
89 case 'percentage':
90 return true;
91 }
92
93 return false;
94 }
95
99 public function fillRow(array $row)
100 {
101 if(array_key_exists('percentage', $row))
102 {
103 $row['percentage'] = sprintf('%.2f', $row['percentage']) . '%';
104 }
105
106 // fill columns
107
109 {
110 if($this->isResultPresentationEnabled())
111 {
112 $this->tpl->setVariable('VAL_SCORED', $row['scored'] ? '&otimes;' : '');
113 }
114
115 $this->tpl->setVariable('VAL_PASS', $row['pass'] + 1);
116 }
117
118 $this->tpl->setVariable('VAL_DATE', $this->formatDate($row['date']));
119
121 {
122 $this->tpl->setVariable('VAL_LO_OBJECTIVES', $row['objectives']);
123
124 $this->tpl->setVariable('VAL_LO_TRY', sprintf(
125 $this->lng->txt('tst_res_lo_try_n'), $row['pass']
126 ));
127 }
128
129 if( $this->isResultPresentationEnabled() )
130 {
131 $this->tpl->setVariable('VAL_ANSWERED', $this->buildWorkedThroughQuestionsString(
132 $row['num_workedthrough_questions'], $row['num_questions_total']
133 ));
134
135 if( $this->getParentObject()->object->isOfferingQuestionHintsEnabled() )
136 {
137 $this->tpl->setVariable('VAL_HINTS', $row['hints']);
138 }
139
140 $this->tpl->setVariable('VAL_REACHED', $this->buildReachedPointsString(
141 $row['reached_points'], $row['max_points']
142 ));
143
144 $this->tpl->setVariable('VAL_PERCENTAGE', $row['percentage']);
145 }
146
147 if(!$this->isPdfPresentationEnabled())
148 {
149 $actions = $this->getRequiredActions($row['scored']);
150 $this->tpl->setVariable('VAL_ACTIONS', $this->buildActionsHtml($actions, $row['pass']));
151 }
152 }
153
154 protected function initColumns()
155 {
157 {
158 $this->addColumn($this->lng->txt('scored_pass'), '', '150');
159 }
160
162 {
163 $this->addColumn($this->lng->txt('pass'), '', '1%');
164 }
165
166 $this->addColumn($this->lng->txt('date'));
167
169 {
170 $this->addColumn($this->lng->txt('tst_res_lo_objectives_header'), '');
171 $this->addColumn($this->lng->txt('tst_res_lo_try_header'), '');
172 }
173
174 if($this->isResultPresentationEnabled())
175 {
176 $this->addColumn($this->lng->txt('tst_answered_questions'));
177 if($this->getParentObject()->object->isOfferingQuestionHintsEnabled())
178 {
179 $this->addColumn($this->lng->txt('tst_question_hints_requested_hint_count_header'));
180 }
181 $this->addColumn($this->lng->txt('tst_reached_points'));
182 $this->addColumn($this->lng->txt('tst_percent_solved'));
183 }
184
185 // actions
186 if(!$this->isPdfPresentationEnabled())
187 {
188 $this->addColumn('', '', '10%' );
189 }
190 }
191
196 {
198 }
199
204 {
205 $this->resultPresentationEnabled = $resultPresentationEnabled;
206 }
207
211 public function isPdfPresentationEnabled()
212 {
214 }
215
220 {
221 $this->pdfPresentationEnabled = $pdfPresentationEnabled;
222 }
223
228 {
230 }
231
236 {
237 $this->objectiveOrientedPresentationEnabled = $objectiveOrientedPresentationEnabled;
238 }
239
243 public function getActiveId()
244 {
245 return $this->activeId;
246 }
247
251 public function setActiveId($activeId)
252 {
253 $this->activeId = $activeId;
254 }
255
259 public function getPassDetailsCommand()
260 {
262 }
263
268 {
269 $this->passDetailsCommand = $passDetailsCommand;
270 }
271
275 public function getPassDeletionCommand()
276 {
278 }
279
284 {
285 $this->passDeletionCommand = $passDeletionCommand;
286 }
287
292 private function formatDate($date)
293 {
298 return $date;
299 }
300
301 private function buildWorkedThroughQuestionsString($numQuestionsWorkedThrough, $numQuestionsTotal)
302 {
303 return "{$numQuestionsWorkedThrough} {$this->lng->txt('of')} {$numQuestionsTotal}";
304 }
305
306 private function buildReachedPointsString($reachedPoints, $maxPoints)
307 {
308 return "{$reachedPoints} {$this->lng->txt('of')} {$maxPoints}";
309 }
310
311 private function getRequiredActions($isScoredPass)
312 {
313 $actions = array();
314
315 if( $this->getPassDetailsCommand() )
316 {
317 $actions[$this->getPassDetailsCommand()] = $this->lng->txt('tst_pass_details');
318 }
319
320 if( !$isScoredPass && $this->getPassDeletionCommand() )
321 {
322 $actions[$this->getPassDeletionCommand()] = $this->lng->txt('delete');
323 }
324
325 return $actions;
326 }
327
328 private function buildActionsHtml($actions, $pass)
329 {
330 global $ilCtrl;
331
332 if( !count($actions) )
333 {
334 return '';
335 }
336
337 $ilCtrl->setParameter($this->parent_obj, 'pass', $pass);
338
339 if( count($actions) > 1 )
340 {
341 $aslgui = new ilAdvancedSelectionListGUI();
342 $aslgui->setListTitle($this->lng->txt('actions'));
343 $aslgui->setId($pass);
344
345 foreach($actions as $cmd => $label)
346 {
347 $aslgui->addItem($label, $cmd, $ilCtrl->getLinkTarget($this->parent_obj, $cmd));
348 }
349
350 $html = $aslgui->getHTML();
351 }
352 else
353 {
354 $cmd = key($actions);
355 $label = current($actions);
356
357 $href = $ilCtrl->getLinkTarget($this->parent_obj, $cmd);
358 $html = '<a href="'.$href.'">'.$label.'</a>';
359 }
360
361 $ilCtrl->setParameter($this->parent_obj, 'pass', '');
362
363 return $html;
364 }
365}
const IL_CAL_UNIX
User interface class for advanced drop-down selection lists.
static setUseRelativeDates($a_status)
set use relative dates
static formatDate(ilDateTime $date)
Format a date @access public.
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
Class ilTable2GUI.
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.
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.
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
$cmd
Definition: sahs_server.php:35