ILIAS  release_8 Revision v8.24
class.ilTestToplistGUI.php
Go to the documentation of this file.
1<?php
2
21
27{
29 protected $ctrl;
31 protected $tabs;
33 protected $tpl;
35 protected $lng;
37 protected $user;
39 protected $object;
41 protected $toplist;
43 private $uiFactory;
45 private $uiRenderer;
46
50 public function __construct(ilObjTest $testOBJ)
51 {
52 global $DIC;
53 /* @var ILIAS\DI\Container $DIC */
54
55 $this->ctrl = $DIC['ilCtrl'];
56 $this->tpl = $DIC['tpl'];
57 $this->lng = $DIC['lng'];
58 $this->user = $DIC['ilUser'];
59 $this->uiFactory = $DIC->ui()->factory();
60 $this->uiRenderer = $DIC->ui()->renderer();
61
62 $this->object = $testOBJ;
63 $this->toplist = new ilTestTopList($testOBJ);
64 }
65
69 public function executeCommand(): void
70 {
71 if (!$this->object->getHighscoreEnabled()) {
72 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
73 $this->ctrl->redirectByClass(ilObjTestGUI::class);
74 }
75
76 $this->ctrl->saveParameter($this, 'active_id');
77
78 $cmd = $this->ctrl->getCmd();
79
80 switch ($cmd) {
81 default:
83 }
84 }
85
86 protected function showResultsToplistsCmd(): void
87 {
88 $this->tpl->setContent(implode('', [
89 $this->renderMedianMarkPanel(),
92 ]));
93 }
94
98 protected function renderMedianMarkPanel(): string
99 {
100 $title = $this->lng->txt('tst_median_mark_panel');
101
102 // BH: this really is the "mark of median" ??!
103 $activeId = $this->object->getActiveIdOfUser($this->user->getId());
104 $data = $this->object->getCompleteEvaluationData();
105 $median = $data->getStatistics()->getStatistics()->median();
106 $pct = $data->getParticipant($activeId)->getMaxpoints() ? ($median / $data->getParticipant($activeId)->getMaxpoints()) * 100.0 : 0;
107 $mark = $this->object->mark_schema->getMatchingMark($pct);
108 $content = $mark->getShortName();
109
110 $panel = $this->uiFactory->panel()->standard(
111 $title,
112 $this->uiFactory->legacy($content)
113 );
114
115 return $this->uiRenderer->render($panel);
116 }
117
121 protected function renderResultsToplistByScore(): string
122 {
123 $title = $this->lng->txt('toplist_by_score');
124 $html = '';
125
126 if ($this->isTopTenRankingTableRequired()) {
127 $topData = $this->toplist->getGeneralToplistByPercentage(
128 $this->object->getRefId(),
129 (int) $this->user->getId()
130 );
131
132 $table = $this->buildTableGUI();
133 $table->setData($topData);
134 $table->setTitle($title);
135
136 $html .= $table->getHTML();
137 }
138
139 if ($this->isOwnRankingTableRequired()) {
140 $ownData = $this->toplist->getUserToplistByPercentage(
141 $this->object->getRefId(),
142 (int) $this->user->getId()
143 );
144
145 $table = $this->buildTableGUI();
146 $table->setData($ownData);
147 if (!$this->isTopTenRankingTableRequired()) {
148 $table->setTitle($title);
149 }
150
151 $html .= $table->getHTML();
152 }
153
154 return $html;
155 }
156
160 protected function renderResultsToplistByTime(): string
161 {
162 $title = $this->lng->txt('toplist_by_time');
163 $html = '';
164
165 if ($this->isTopTenRankingTableRequired()) {
166 $topData = $this->toplist->getGeneralToplistByWorkingtime(
167 $this->object->getRefId(),
168 $this->user->getId()
169 );
170
171 $table = $this->buildTableGUI();
172 $table->setData($topData);
173 $table->setTitle($title);
174
175 $html .= $table->getHTML();
176 }
177
178 if ($this->isOwnRankingTableRequired()) {
179 $ownData = $this->toplist->getUserToplistByWorkingtime(
180 $this->object->getRefId(),
181 (int) $this->user->getId()
182 );
183
184 $table = $this->buildTableGUI();
185 $table->setData($ownData);
186
187 if (!$this->isTopTenRankingTableRequired()) {
188 $table->setTitle($title);
189 }
190
191 $html .= $table->getHTML();
192 }
193
194 return $html;
195 }
196
201 {
202 $table = new ilTestTopListTableGUI($this, $this->object);
203
204 return $table;
205 }
206
210 protected function isTopTenRankingTableRequired(): bool
211 {
212 return $this->object->getHighscoreTopTable();
213 }
214
218 protected function isOwnRankingTableRequired(): bool
219 {
220 return $this->object->getHighscoreOwnTable();
221 }
222}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilObjTest $testOBJ)
global $DIC
Definition: feed.php:28
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:198
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31