ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTestToplistGUI Class Reference
+ Collaboration diagram for ilTestToplistGUI:

Public Member Functions

 __construct (private ilObjTest $test_obj, private ilTestTopList $toplist, private ilCtrl $ctrl, private ilGlobalTemplateInterface $tpl, private ilLanguage $lng, private ilObjUser $user, private UIFactory $ui_factory, private UIRenderer $ui_renderer)
 
 executeCommand ()
 

Protected Member Functions

 showResultsToplistsCmd ()
 
 renderMedianMarkPanel ()
 
 renderResultsToplistByScore ()
 
 renderResultsToplistByTime ()
 
 buildTableGUI ()
 
 isTopTenRankingTableRequired ()
 
 isOwnRankingTableRequired ()
 

Detailed Description

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de

Definition at line 28 of file class.ilTestToplistGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestToplistGUI::__construct ( private ilObjTest  $test_obj,
private ilTestTopList  $toplist,
private ilCtrl  $ctrl,
private ilGlobalTemplateInterface  $tpl,
private ilLanguage  $lng,
private ilObjUser  $user,
private UIFactory  $ui_factory,
private UIRenderer  $ui_renderer 
)

Definition at line 30 of file class.ilTestToplistGUI.php.

39  {
40  }

Member Function Documentation

◆ buildTableGUI()

ilTestToplistGUI::buildTableGUI ( )
protected
Returns
ilTestTopListTableGUI

Definition at line 176 of file class.ilTestToplistGUI.php.

Referenced by renderResultsToplistByScore(), and renderResultsToplistByTime().

177  {
178  $table = new ilTestTopListTableGUI($this, $this->test_obj);
179 
180  return $table;
181  }
Class ilTestTopListTableGUI.
+ Here is the caller graph for this function:

◆ executeCommand()

ilTestToplistGUI::executeCommand ( )

Definition at line 45 of file class.ilTestToplistGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and showResultsToplistsCmd().

45  : void
46  {
47  if (!$this->test_obj->getHighscoreEnabled()) {
48  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
49  $this->ctrl->redirectByClass(ilObjTestGUI::class);
50  }
51 
52  $this->ctrl->saveParameter($this, 'active_id');
53 
54  $cmd = $this->ctrl->getCmd();
55 
56  switch ($cmd) {
57  default:
58  $this->showResultsToplistsCmd();
59  }
60  }
+ Here is the call graph for this function:

◆ isOwnRankingTableRequired()

ilTestToplistGUI::isOwnRankingTableRequired ( )
protected
Returns
bool

Definition at line 194 of file class.ilTestToplistGUI.php.

Referenced by renderResultsToplistByScore(), and renderResultsToplistByTime().

194  : bool
195  {
196  return $this->test_obj->getHighscoreOwnTable();
197  }
+ Here is the caller graph for this function:

◆ isTopTenRankingTableRequired()

ilTestToplistGUI::isTopTenRankingTableRequired ( )
protected
Returns
bool

Definition at line 186 of file class.ilTestToplistGUI.php.

Referenced by renderResultsToplistByScore(), and renderResultsToplistByTime().

186  : bool
187  {
188  return $this->test_obj->getHighscoreTopTable();
189  }
+ Here is the caller graph for this function:

◆ renderMedianMarkPanel()

ilTestToplistGUI::renderMedianMarkPanel ( )
protected
Returns
string

Definition at line 74 of file class.ilTestToplistGUI.php.

References $data, ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by showResultsToplistsCmd().

74  : string
75  {
76  $title = $this->lng->txt('tst_median_mark_panel');
77 
78  // BH: this really is the "mark of median" ??!
79  $activeId = $this->test_obj->getActiveIdOfUser($this->user->getId());
80  $data = $this->test_obj->getCompleteEvaluationData();
81  $median = $data->getStatistics()->getStatistics()->median();
82  $pct = $data->getParticipant($activeId)->getMaxpoints() ? ($median / $data->getParticipant($activeId)->getMaxpoints()) * 100.0 : 0;
83  $mark = $this->test_obj->getMarkSchema()->getMatchingMark($pct);
84  $content = $mark->getShortName();
85 
86  $panel = $this->ui_factory->panel()->standard(
87  $title,
88  $this->ui_factory->legacy($content)
89  );
90 
91  return $this->ui_renderer->render($panel);
92  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderResultsToplistByScore()

ilTestToplistGUI::renderResultsToplistByScore ( )
protected
Returns
string

Definition at line 97 of file class.ilTestToplistGUI.php.

References buildTableGUI(), ILIAS\Repository\int(), isOwnRankingTableRequired(), isTopTenRankingTableRequired(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by showResultsToplistsCmd().

97  : string
98  {
99  $title = $this->lng->txt('toplist_by_score');
100  $html = '';
101 
102  if ($this->isTopTenRankingTableRequired()) {
103  $topData = $this->toplist->getGeneralToplistByPercentage(
104  $this->test_obj->getRefId(),
105  (int) $this->user->getId()
106  );
107 
108  $table = $this->buildTableGUI();
109  $table->setData($topData);
110  $table->setTitle($title);
111 
112  $html .= $table->getHTML();
113  }
114 
115  if ($this->isOwnRankingTableRequired()) {
116  $ownData = $this->toplist->getUserToplistByPercentage(
117  $this->test_obj->getRefId(),
118  (int) $this->user->getId()
119  );
120 
121  $table = $this->buildTableGUI();
122  $table->setData($ownData);
123  if (!$this->isTopTenRankingTableRequired()) {
124  $table->setTitle($title);
125  }
126 
127  $html .= $table->getHTML();
128  }
129 
130  return $html;
131  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderResultsToplistByTime()

ilTestToplistGUI::renderResultsToplistByTime ( )
protected
Returns
string

Definition at line 136 of file class.ilTestToplistGUI.php.

References buildTableGUI(), ILIAS\Repository\int(), isOwnRankingTableRequired(), isTopTenRankingTableRequired(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by showResultsToplistsCmd().

136  : string
137  {
138  $title = $this->lng->txt('toplist_by_time');
139  $html = '';
140 
141  if ($this->isTopTenRankingTableRequired()) {
142  $topData = $this->toplist->getGeneralToplistByWorkingtime(
143  $this->test_obj->getRefId(),
144  $this->user->getId()
145  );
146 
147  $table = $this->buildTableGUI();
148  $table->setData($topData);
149  $table->setTitle($title);
150 
151  $html .= $table->getHTML();
152  }
153 
154  if ($this->isOwnRankingTableRequired()) {
155  $ownData = $this->toplist->getUserToplistByWorkingtime(
156  $this->test_obj->getRefId(),
157  (int) $this->user->getId()
158  );
159 
160  $table = $this->buildTableGUI();
161  $table->setData($ownData);
162 
163  if (!$this->isTopTenRankingTableRequired()) {
164  $table->setTitle($title);
165  }
166 
167  $html .= $table->getHTML();
168  }
169 
170  return $html;
171  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showResultsToplistsCmd()

ilTestToplistGUI::showResultsToplistsCmd ( )
protected

Definition at line 62 of file class.ilTestToplistGUI.php.

References renderMedianMarkPanel(), renderResultsToplistByScore(), and renderResultsToplistByTime().

Referenced by executeCommand().

62  : void
63  {
64  $this->tpl->setContent(implode('', [
65  $this->renderMedianMarkPanel(),
68  ]));
69  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: