ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTestAverageReachedPointsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
25 {
26  public function __construct(?object $a_parent_obj, string $a_parent_cmd)
27  {
28  $this->setId('tstAvgReachedPointsTbl');
29  $this->setPrefix('tstAvgReachedPointsTbl');
30 
31  parent::__construct($a_parent_obj, $a_parent_cmd);
32 
33  global $DIC;
34  $lng = $DIC['lng'];
35  $ilCtrl = $DIC['ilCtrl'];
36 
37  $this->lng = $lng;
38  $this->ctrl = $ilCtrl;
39 
40  $this->setFormName('average_reached_points');
41  $this->setTitle($this->lng->txt('average_reached_points'));
42  $this->setStyle('table', 'fullwidth');
43  $this->addColumn($this->lng->txt("question_id"), 'qid', '');
44  $this->addColumn($this->lng->txt("question_title"), 'title', '');
45  $this->addColumn($this->lng->txt("points"), 'points', '');
46  $this->addColumn($this->lng->txt("percentage"), 'percentage', '');
47  $this->addColumn($this->lng->txt("number_of_answers"), 'answers', '');
48 
49  $this->setRowTemplate("tpl.il_as_tst_average_reached_points_row.html", "Modules/Test");
50 
51  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
52 
53  $this->setDefaultOrderField("title");
54  $this->setDefaultOrderDirection("asc");
55  $this->enable('sort');
56  $this->enable('header');
57  $this->disable('select_all');
58  }
59 
64  public function numericOrdering(string $a_field): bool
65  {
66  switch ($a_field) {
67  case 'percentage':
68  case 'qid':
69  case 'points':
70  return true;
71 
72  default:
73  return false;
74  }
75  }
76 
77  public function fillRow(array $a_set): void
78  {
79  $this->tpl->setVariable("ID", $a_set["qid"]);
80  $this->tpl->setVariable("TITLE", $a_set["title"]);
81  $this->tpl->setVariable("POINTS", $this->formatPoints($a_set));
82  $this->tpl->setVariable("PERCENTAGE", sprintf("%.2f", $a_set["percentage"]) . "%");
83  $this->tpl->setVariable("ANSWERS", $a_set["answers"]);
84  }
85 
86  protected function formatPoints(array $data): string
87  {
88  return sprintf("%.2f", $data['points_reached']) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%.2f", $data['points_max']);
89  }
90 }
enable(string $a_module_name)
setFormAction(string $a_form_action, bool $a_multipart=false)
__construct(?object $a_parent_obj, string $a_parent_cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFormName(string $a_name="")
ilLanguage $lng
setId(string $a_val)
global $DIC
Definition: feed.php:28
setStyle(string $a_element, string $a_style)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
numericOrdering(string $a_field)
Should this field be sorted numeric?
__construct(Container $dic, ilPlugin $plugin)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
disable(string $a_module_name)
setPrefix(string $a_prefix)