ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilCmiXapiScoringTableGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5//use \ILIAS\UI\Component\Modal\RoundTrip;
16{
17 const TABLE_ID = 'cmix_scoring_table_';
18
23
27 private $_parent;
28
33
41 public function __construct(ilCmiXapiScoringGUI $a_parent_obj, $a_parent_cmd, $isMultiActorReport, $tableId, $hasOutcomeAccess)
42 {
43 global $DIC; /* @var \ILIAS\DI\Container $DIC */
44
45 $this->isMultiActorReport = $isMultiActorReport;
46
47 $this->setId(self::TABLE_ID . $tableId);
48 parent::__construct($a_parent_obj, $a_parent_cmd);
49 $this->_parent = $a_parent_obj;
50
51 $DIC->language()->loadLanguageModule('assessment');
52
53 $this->setRowTemplate('tpl.cmix_scoring_table_row.html', 'Modules/CmiXapi');
54
55 if ($tableId === 'highscore') {
56 $this->setTitle(sprintf($DIC->language()->txt('toplist_top_n_results'), (int) $this->_parent->object->getHighscoreTopNum()));
57 } else {
58 $this->setTitle($DIC->language()->txt('toplist_your_result'));
59 }
60
61 $this->initColumns();
62
63 $this->setExternalSegmentation(true);
64 $this->setExternalSorting(true);
65 $this->setMaxCount(0);
66 $this->resetOffset();
67 $this->setDefaultOrderField('rank');
68 $this->setDefaultOrderDirection('asc');
69
70 $this->hasOutcomeAccess = $hasOutcomeAccess;
71 }
72
73 protected function initColumns()
74 {
75 global $DIC; /* @var \ILIAS\DI\Container $DIC */
76
77 $this->addColumn($DIC->language()->txt('toplist_col_rank'));
78 $this->addColumn($DIC->language()->txt('toplist_col_participant'));
79
80 if ($this->_parent->object->getHighscoreAchievedTS()) {
81 $this->addColumn($DIC->language()->txt('toplist_col_achieved'));
82 }
83
84 if ($this->_parent->object->getHighscorePercentage()) {
85 $this->addColumn($DIC->language()->txt('toplist_col_percentage'));
86 }
87
88 if ($this->_parent->object->getHighscoreWTime()) {
89 $this->addColumn($DIC->language()->txt('toplist_col_wtime'));
90 }
91
92 $this->setEnableNumInfo(false);
93 $this->setLimit((int) $this->_parent->object->getHighscoreTopNum());
94 }
95
96 public function fillRow($data)
97 {
98 global $DIC; /* @var \ILIAS\DI\Container $DIC */
99
100 $this->tpl->setVariable('SCORE_RANK', $data['rank']);
101
102 $this->tpl->setCurrentBlock('personal');
103 $this->tpl->setVariable('SCORE_USER', $this->getUsername($data));
104 $this->tpl->parseCurrentBlock();
105
106 if ($this->_parent->object->getHighscoreAchievedTS()) {
107 $this->tpl->setCurrentBlock('achieved');
108 $this->tpl->setVariable('SCORE_ACHIEVED', $data['date']);
109 $this->tpl->parseCurrentBlock();
110 }
111
112
113 if ($this->_parent->object->getHighscorePercentage()) {
114 $this->tpl->setCurrentBlock('percentage');
115 $this->tpl->setVariable('SCORE_PERCENTAGE', (float) $data['score'] * 100);
116 $this->tpl->parseCurrentBlock();
117 }
118
119 if ($this->_parent->object->getHighscoreWTime()) {
120 $this->tpl->setCurrentBlock('wtime');
121 $this->tpl->setVariable('SCORE_DURATION', $data['duration']);
122 $this->tpl->parseCurrentBlock();
123 }
124
125 $highlight = $data['ilias_user_id'] == $DIC->user()->getId() ? 'tblrowmarked' : '';
126 $this->tpl->setVariable('HIGHLIGHT', $highlight);
127 }
128
129 protected function getUsername($data)
130 {
131 global $DIC; /* @var \ILIAS\DI\Container $DIC */
132
133 if ($this->hasOutcomeAccess) {
134 $user = ilObjectFactory::getInstanceByObjId($data['ilias_user_id'], false);
135
136 if ($user) {
137 return $user->getFullname();
138 }
139
140 return $DIC->language()->txt('deleted_user');
141 }
142
143 return $data['user'];
144 }
145}
An exception for terminatinating execution or to throw for unit testing.
fillRow($data)
Standard Version of Fill Row.
__construct(ilCmiXapiScoringGUI $a_parent_obj, $a_parent_cmd, $isMultiActorReport, $tableId, $hasOutcomeAccess)
ilCmiXapiScoringTableGUI constructor.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilTable2GUI.
setExternalSorting($a_val)
Set external sorting.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setEnableNumInfo($a_val)
Set enable num info.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
resetOffset($a_in_determination=false)
Reset offset.
setLimit($a_limit=0, $a_default_limit=0)
set max.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setMaxCount($a_max_count)
set max.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc