ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCmiXapiScoringTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
31{
32 public const TABLE_ID = 'cmix_scoring_table_';
33
34 protected bool $isMultiActorReport;
35
36 private \ilCmiXapiScoringGUI $_parent;
37
38 private bool $hasOutcomeAccess;
39
40 private \ILIAS\DI\Container $dic;
41
43
47 public function __construct(
48 ilCmiXapiScoringGUI $a_parent_obj,
49 string $a_parent_cmd,
51 string $tableId,
53 ) {
54 global $DIC; /* @var \ILIAS\DI\Container $DIC */
55 $this->dic = $DIC;
56
57 $this->isMultiActorReport = $isMultiActorReport;
58
59 $this->setId(self::TABLE_ID . $tableId);
60 parent::__construct($a_parent_obj, $a_parent_cmd);
61 $this->_parent = $a_parent_obj;
62
63 $DIC->language()->loadLanguageModule('assessment');
64 $this->language = $DIC->language();
65 $this->setRowTemplate('tpl.cmix_scoring_table_row.html', 'components/ILIAS/CmiXapi');
66
67 if ($tableId === 'highscore') {
68 $this->setTitle(
69 sprintf($this->language->txt('toplist_top_n_results'), $this->_parent->object->getHighscoreTopNum())
70 );
71 } else {
72 $this->setTitle($this->language->txt('toplist_your_result'));
73 }
74
75 $this->initColumns();
76
77 $this->setExternalSegmentation(true);
78 $this->setExternalSorting(true);
79 $this->setMaxCount(0);
80 $this->resetOffset();
81 $this->setDefaultOrderField('rank');
82 $this->setDefaultOrderDirection('asc');
83
84 $this->hasOutcomeAccess = $hasOutcomeAccess;
85 }
86
87 protected function initColumns(): void
88 {
89 $this->addColumn($this->language->txt('toplist_col_rank'));
90 $this->addColumn($this->language->txt('toplist_col_participant'));
91
92 if ($this->_parent->object->getHighscoreAchievedTS()) {
93 $this->addColumn($this->language->txt('toplist_col_achieved'));
94 }
95
96 if ($this->_parent->object->getHighscorePercentage()) {
97 $this->addColumn($this->language->txt('toplist_col_percentage'));
98 }
99
100 if ($this->_parent->object->getHighscoreWTime()) {
101 $this->addColumn($this->language->txt('toplist_col_wtime'));
102 }
103
104 $this->setEnableNumInfo(false);
105 $this->setLimit($this->_parent->object->getHighscoreTopNum());
106 }
107
108 protected function fillRow(array $a_set): void
109 {
110 $this->tpl->setVariable('SCORE_RANK', $a_set['rank']);
111
112 $this->tpl->setCurrentBlock('personal');
113 $this->tpl->setVariable('SCORE_USER', $this->getUsername($a_set));
114 $this->tpl->parseCurrentBlock();
115
116 if ($this->_parent->object->getHighscoreAchievedTS()) {
117 $this->tpl->setCurrentBlock('achieved');
118 $this->tpl->setVariable('SCORE_ACHIEVED', $a_set['date']);
119 $this->tpl->parseCurrentBlock();
120 }
121
122 if ($this->_parent->object->getHighscorePercentage()) {
123 $this->tpl->setCurrentBlock('percentage');
124 $this->tpl->setVariable('SCORE_PERCENTAGE', (float) $a_set['score'] * 100);
125 $this->tpl->parseCurrentBlock();
126 }
127
128 if ($this->_parent->object->getHighscoreWTime()) {
129 $this->tpl->setCurrentBlock('wtime');
130 $this->tpl->setVariable('SCORE_DURATION', $a_set['duration']);
131 $this->tpl->parseCurrentBlock();
132 }
133
134 $highlight = $a_set['ilias_user_id'] == $this->dic->user()->getId() ? 'tblrowmarked' : '';
135 $this->tpl->setVariable('HIGHLIGHT', $highlight);
136 }
137
143 protected function getUsername(array $data): string
144 {
145 $user = ilObjectFactory::getInstanceByObjId($data['ilias_user_id'], false);
146 if ($this->hasOutcomeAccess) {
147 if ($user) {
148 return $user->getFullname();
149 }
150 return $this->language->txt('deleted_user');
151 } else {
152 if ($user->getId() == $this->dic->user()->getId()) {
153 return $user->getFullname();
154 }
155 }
156 return "";
157 }
158}
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(ilCmiXapiScoringGUI $a_parent_obj, string $a_parent_cmd, bool $isMultiActorReport, string $tableId, bool $hasOutcomeAccess)
ilCmiXapiScoringTableGUI constructor.
language handling
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setEnableNumInfo(bool $a_val)
setExternalSegmentation(bool $a_val)
resetOffset(bool $a_in_determination=false)
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)
setDefaultOrderField(string $a_defaultorderfield)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setMaxCount(int $a_max_count)
set max.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26