ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTestAverageReachedPointsTableGUI.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');
6
13{
20 public function __construct($a_parent_obj, $a_parent_cmd)
21 {
22 $this->setId('tstAvgReachedPointsTbl');
23 $this->setPrefix('tstAvgReachedPointsTbl');
24
25 parent::__construct($a_parent_obj, $a_parent_cmd);
26
27 global $DIC;
28 $lng = $DIC['lng'];
29 $ilCtrl = $DIC['ilCtrl'];
30
31 $this->lng = $lng;
32 $this->ctrl = $ilCtrl;
33
34 $this->setFormName('average_reached_points');
35 $this->setTitle($this->lng->txt('average_reached_points'));
36 $this->setStyle('table', 'fullwidth');
37 $this->addColumn($this->lng->txt("question_id"), 'qid', '');
38 $this->addColumn($this->lng->txt("question_title"), 'title', '');
39 $this->addColumn($this->lng->txt("points"), 'points', '');
40 $this->addColumn($this->lng->txt("percentage"), 'percentage', '');
41 $this->addColumn($this->lng->txt("number_of_answers"), 'answers', '');
42
43 $this->setRowTemplate("tpl.il_as_tst_average_reached_points_row.html", "Modules/Test");
44
45 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
46
47 $this->setDefaultOrderField("title");
48 $this->setDefaultOrderDirection("asc");
49 $this->enable('sort');
50 $this->enable('header');
51 $this->disable('select_all');
52 }
53
58 public function numericOrdering($a_field)
59 {
60 switch ($a_field) {
61 case 'points':
62 return true;
63
64 case 'qid':
65 return true;
66
67 case 'percentage':
68 return true;
69
70 default:
71 return false;
72 }
73 }
74
81 public function fillRow($data)
82 {
83 $this->tpl->setVariable("ID", $data["qid"]);
84 $this->tpl->setVariable("TITLE", $data["title"]);
85 $this->tpl->setVariable("POINTS", $this->formatPoints($data));
86 $this->tpl->setVariable("PERCENTAGE", sprintf("%.2f", $data["percentage"]) . "%");
87 $this->tpl->setVariable("ANSWERS", $data["answers"]);
88 }
89
94 protected function formatPoints(array $data)
95 {
96 return sprintf("%.2f", $data['points_reached']) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%.2f", $data['points_max']);
97 }
98}
An exception for terminatinating execution or to throw for unit testing.
Class ilTable2GUI.
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
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.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
disable($a_module_name)
diesables particular modules of table
setStyle($a_element, $a_style)
enable($a_module_name)
enables particular modules of table
__construct($a_parent_obj, $a_parent_cmd)
Constructor @access public.
numericOrdering($a_field)
Should this field be sorted numeric?
global $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7