ILIAS  release_8 Revision v8.23
class.ilTestTopListTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
25 {
26  private ilObjTest $test;
27 
28  public function __construct(ilTestToplistGUI $a_parent_obj, ilObjTest $test)
29  {
30  $this->test = $test;
31 
32  $this->setId('tst_top_list_' . $this->test->getRefId());
33  parent::__construct($a_parent_obj, '', '');
34 
35  $this->setRowTemplate('tpl.toplist_tbl_rows.html', 'Modules/Test');
36 
37  $this->setEnableNumInfo(false);
38  $this->disable('sort');
39 
40  $this->buildColumns();
41  }
42 
43  private function buildColumns(): void
44  {
45  $this->addColumn($this->lng->txt('toplist_col_rank'));
46  $this->addColumn($this->lng->txt('toplist_col_participant'));
47 
48  if ($this->test->getHighscoreAchievedTS()) {
49  $this->addColumn($this->lng->txt('toplist_col_achieved'));
50  }
51 
52  if ($this->test->getHighscoreScore()) {
53  $this->addColumn($this->lng->txt('toplist_col_score'));
54  }
55 
56  if ($this->test->getHighscorePercentage()) {
57  $this->addColumn($this->lng->txt('toplist_col_percentage'));
58  }
59 
60  if ($this->test->getHighscoreHints()) {
61  $this->addColumn($this->lng->txt('toplist_col_hints'));
62  }
63 
64  if ($this->test->getHighscoreWTime()) {
65  $this->addColumn($this->lng->txt('toplist_col_wtime'));
66  }
67  }
68 
69  protected function fillRow(array $a_set): void
70  {
71  $rowHighlightClass = '';
72 
73  if ($a_set['is_actor']) {
74  $rowHighlightClass = 'tblrowmarked';
75  }
76  $this->tpl->setVariable('VAL_HIGHLIGHT', $rowHighlightClass);
77 
78  $this->tpl->setVariable('VAL_RANK', (string) $a_set['rank']);
79  $this->tpl->setVariable('VAL_PARTICIPANT', (string) $a_set['participant']);
80 
81  if ($this->test->getHighscoreAchievedTS()) {
82  $this->tpl->setVariable(
83  'VAL_ACHIEVED',
84  $a_set['achieved'] === '' ? '' : ilDatePresentation::formatDate($a_set['achieved'])
85  );
86  }
87 
88  if ($this->test->getHighscoreScore()) {
89  $this->tpl->setVariable('VAL_SCORE', (string) $a_set['score']);
90  }
91 
92  if ($this->test->getHighscorePercentage()) {
93  $this->tpl->setVariable('VAL_PERCENTAGE', (string) $a_set['percentage']);
94  }
95 
96  if ($this->test->getHighscoreHints()) {
97  $this->tpl->setVariable('VAL_HINTS', (string) $a_set['hints']);
98  }
99 
100  if ($this->test->getHighscoreWTime()) {
101  $this->tpl->setVariable('VAL_TIME', (string) $a_set['time']);
102  }
103  }
104 }
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
setId(string $a_val)
__construct(ilTestToplistGUI $a_parent_obj, ilObjTest $test)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setEnableNumInfo(bool $a_val)
__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)