ILIAS  release_8 Revision v8.24
class.ilForumStatisticsTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 private bool $has_active_lp = false;
33 private array $completed = [];
35 private array $failed = [];
37 private array $in_progress = [];
38
39 public function __construct(
40 ilObjForumGUI $a_parent_obj,
41 string $a_parent_cmd,
42 ilObjForum $forum,
46 ) {
47 parent::__construct($a_parent_obj, $a_parent_cmd);
48
49 $lp = ilObjectLP::getInstance($forum->getId());
50 if ($lp->isActive()) {
51 $this->has_active_lp = true;
52 }
53 $this->has_general_lp_access = $has_general_lp_access;
54 $this->has_rbac_or_position_access = $has_rbac_or_position_access;
55 $this->actor = $actor;
56
57 $this->setRowTemplate('tpl.statistics_table_row.html', 'Modules/Forum');
58
59 $columns = $this->getColumnDefinition();
60 foreach ($columns as $index => $column) {
61 $this->addColumn(
62 $column['txt'],
63 isset($column['sortable']) && $column['sortable'] ? $column['field'] : '',
64 ((string) ceil((100 / count($columns)))) . '%s'
65 );
66 }
67
68 if ($this->has_active_lp && $this->has_general_lp_access) {
69 $this->lng->loadLanguageModule('trac');
70 $this->completed = ilLPStatusWrapper::_lookupCompletedForObject($forum->getId());
71 $this->in_progress = ilLPStatusWrapper::_lookupInProgressForObject($forum->getId());
72 $this->failed = ilLPStatusWrapper::_lookupFailedForObject($forum->getId());
73 }
74
75 $this->setDefaultOrderField('ranking');
76 $this->setDefaultOrderDirection('desc');
77
78 $this->enable('hits');
79 $this->enable('sort');
80 }
81
85 protected function getColumnDefinition(): array
86 {
87 $i = 0;
88
89 $columns = [];
90
91 $columns[++$i] = [
92 'field' => 'ranking',
93 'txt' => $this->lng->txt('frm_statistics_ranking'),
94 'sortable' => true,
95 ];
96 $columns[++$i] = [
97 'field' => 'login',
98 'txt' => $this->lng->txt('login'),
99 'sortable' => true,
100 ];
101 $columns[++$i] = [
102 'field' => 'lastname',
103 'txt' => $this->lng->txt('lastname'),
104 'sortable' => true,
105 ];
106 $columns[++$i] = [
107 'field' => 'firstname',
108 'txt' => $this->lng->txt('firstname'),
109 'sortable' => true,
110 ];
111 if ($this->has_active_lp && $this->has_general_lp_access) {
112 $columns[++$i] = [
113 'field' => 'progress',
114 'txt' => $this->lng->txt('learning_progress'),
115 'sortable' => false,
116 ];
117 }
118
119 return $columns;
120 }
121
122 protected function fillRow(array $a_set): void
123 {
124 parent::fillRow($a_set);
125
127
128 if ($this->has_active_lp && $this->has_general_lp_access) {
129 if ($this->has_rbac_or_position_access || $this->actor->getId() === (int) $a_set['usr_id']) {
130 $this->tpl->setCurrentBlock('val_lp');
131 switch (true) {
132 case in_array($a_set['usr_id'], $this->completed, false):
133 $this->tpl->setVariable('LP_STATUS_ALT', $this->lng->txt(ilLPStatus::LP_STATUS_COMPLETED));
134 $this->tpl->setVariable(
135 'LP_STATUS_ICON',
136 $icons->renderIconForStatus(ilLPStatus::LP_STATUS_COMPLETED_NUM)
137 );
138 break;
139
140 case in_array($a_set['usr_id'], $this->in_progress, false):
141 $this->tpl->setVariable('LP_STATUS_ALT', $this->lng->txt(ilLPStatus::LP_STATUS_IN_PROGRESS));
142 $this->tpl->setVariable(
143 'LP_STATUS_ICON',
144 $icons->renderIconForStatus(ilLPStatus::LP_STATUS_IN_PROGRESS_NUM)
145 );
146 break;
147
148 case in_array($a_set['usr_id'], $this->failed, false):
149 $this->tpl->setVariable('LP_STATUS_ALT', $this->lng->txt(ilLPStatus::LP_STATUS_FAILED));
150 $this->tpl->setVariable(
151 'LP_STATUS_ICON',
152 $icons->renderIconForStatus(ilLPStatus::LP_STATUS_FAILED_NUM)
153 );
154 break;
155
156 default:
157 $this->tpl->setVariable('LP_STATUS_ALT', $this->lng->txt(ilLPStatus::LP_STATUS_NOT_ATTEMPTED));
158 $this->tpl->setVariable(
159 'LP_STATUS_ICON',
160 $icons->renderIconForStatus(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM)
161 );
162 break;
163 }
164 $this->tpl->parseCurrentBlock();
165 } else {
166 $this->tpl->touchBlock('no_lp');
167 }
168 }
169 }
170
171 public function numericOrdering(string $a_field): bool
172 {
173 switch ($a_field) {
174 case 'ranking':
175 return true;
176
177 default:
178 return false;
179 }
180 }
181}
Class ilForumStatisticsTableGUI.
numericOrdering(string $a_field)
Should this field be sorted numeric?
__construct(ilObjForumGUI $a_parent_obj, string $a_parent_cmd, ilObjForum $forum, ilObjUser $actor, bool $has_general_lp_access, bool $has_rbac_or_position_access)
fillRow(array $a_set)
Standard Version of Fill Row.
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
static _lookupCompletedForObject(int $a_obj_id, ?array $a_user_ids=null)
static _lookupFailedForObject(int $a_obj_id, ?array $a_user_ids=null)
static _lookupInProgressForObject(int $a_obj_id, ?array $a_user_ids=null)
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_COMPLETED
const LP_STATUS_FAILED
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_FAILED_NUM
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
Class ilObjForumGUI.
Class ilObjForum.
User class.
static getInstance(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
enable(string $a_module_name)
$index
Definition: metadata.php:145
$i
Definition: metadata.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc