ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLTIConsumerScoringTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21//use \ILIAS\UI\Component\Modal\RoundTrip;
32{
33 public const TABLE_ID = 'cmix_scoring_table_';
34
38 protected bool $isMultiActorReport;
39
43 protected bool $hasOutcomeAccess;
44
45 private \ilLTIConsumerScoringGUI $_parent;
46
50 public function __construct(ilLTIConsumerScoringGUI $a_parent_obj, string $a_parent_cmd, bool $isMultiActorReport, string $tableId, bool $hasOutcomeAccess)
51 {
52 global $DIC; /* @var \ILIAS\DI\Container $DIC */
53
54 $this->isMultiActorReport = $isMultiActorReport;
55
56 $this->setId(self::TABLE_ID . $tableId);
57 parent::__construct($a_parent_obj, $a_parent_cmd);
58 $this->_parent = $a_parent_obj;
59
60 $DIC->language()->loadLanguageModule('assessment');
61
62 $this->setRowTemplate('tpl.lti_consumer_scoring_table_row.html', 'components/ILIAS/LTIConsumer');
63
64 if ($tableId === 'highscore') {
65 $this->setTitle(
66 sprintf(
67 $DIC->language()->txt('toplist_top_n_results'),
68 $this->_parent->getObject()->getHighscoreTopNum()
69 )
70 );
71 } else {
72 $this->setTitle($DIC->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 global $DIC; /* @var \ILIAS\DI\Container $DIC */
90
91 $this->addColumn($DIC->language()->txt('toplist_col_rank'));
92 $this->addColumn($DIC->language()->txt('toplist_col_participant'));
93
94 if ($this->_parent->getObject()->getHighscoreAchievedTS()) {
95 $this->addColumn($DIC->language()->txt('toplist_col_achieved'));
96 }
97
98 if ($this->_parent->getObject()->getHighscorePercentage()) {
99 $this->addColumn($DIC->language()->txt('toplist_col_percentage'));
100 }
101
102 if ($this->_parent->getObject()->getHighscoreWTime()) {
103 $this->addColumn($DIC->language()->txt('toplist_col_wtime'));
104 }
105
106 $this->setEnableNumInfo(false);
107 $this->setLimit($this->_parent->getObject()->getHighscoreTopNum());
108 }
109
110 protected function fillRow(array $a_set): void
111 {
112 global $DIC; /* @var \ILIAS\DI\Container $DIC */
113
114 $this->tpl->setVariable('SCORE_RANK', $a_set['rank']);
115
116 $this->tpl->setCurrentBlock('personal');
117 $this->tpl->setVariable('SCORE_USER', $this->getUsername($a_set));
118 $this->tpl->parseCurrentBlock();
119
120 if ($this->_parent->getObject()->getHighscoreAchievedTS()) {
121 $this->tpl->setCurrentBlock('achieved');
122 $this->tpl->setVariable('SCORE_ACHIEVED', $a_set['date']);
123 $this->tpl->parseCurrentBlock();
124 }
125
126
127 if ($this->_parent->getObject()->getHighscorePercentage()) {
128 $this->tpl->setCurrentBlock('percentage');
129 $this->tpl->setVariable('SCORE_PERCENTAGE', (float) $a_set['score'] * 100);
130 $this->tpl->parseCurrentBlock();
131 }
132
133 if ($this->_parent->getObject()->getHighscoreWTime()) {
134 $this->tpl->setCurrentBlock('wtime');
135 $this->tpl->setVariable('SCORE_DURATION', $a_set['duration']);
136 $this->tpl->parseCurrentBlock();
137 }
138
139 $highlight = $a_set['ilias_user_id'] == $DIC->user()->getId() ? 'tblrowmarked' : '';
140 $this->tpl->setVariable('HIGHLIGHT', $highlight);
141 }
142
143 protected function getUsername(array $data): string
144 {
145 global $DIC; /* @var \ILIAS\DI\Container $DIC */
146
147 if ($this->hasOutcomeAccess) {
148 $user = ilObjectFactory::getInstanceByObjId($data['ilias_user_id'], false);
149
150 if ($user) {
151 return $user->getFullname();
152 }
153
154 return $DIC->language()->txt('deleted_user');
155 }
156
157 return $data['user'];
158 }
159}
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(ilLTIConsumerScoringGUI $a_parent_obj, string $a_parent_cmd, bool $isMultiActorReport, string $tableId, bool $hasOutcomeAccess)
ilLTIConsumerScoringTableGUI constructor.
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