ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssQuestionSkillUsagesTableGUI.php
Go to the documentation of this file.
1<?php
2
26{
27 public const TABLE_ID = 'iaqsutg';
28
29 public const CMD_SHOW = 'show';
30
34 private $myCtrl;
35
39 private $myTpl;
40
44 private $myLng;
45
49 private $myDb;
50 private int $poolId;
51
60 {
61 $this->myCtrl = $myCtrl;
62 $this->myTpl = $myTpl;
63 $this->myLng = $myLng;
64 $this->myDb = $myDb;
65
66 $this->poolId = $poolId;
67
68 $this->setId(self::TABLE_ID . $this->poolId);
69 $this->setPrefix(self::TABLE_ID . $this->poolId);
70 parent::__construct($this, self::CMD_SHOW);
71
72 $this->setRowTemplate("tpl.il_as_qpl_skl_assign_stat_row.html", "components/ILIAS/TestQuestionPool");#
73
74 $this->setDefaultOrderField("qpl_qst_skl_usg_skill_col");
75 $this->setDefaultOrderDirection("asc");
76 }
77
78 public function executeCommand(): bool
79 {
80 switch ($this->myCtrl->getNextClass()) {
81 case strtolower(__CLASS__):
82 case '':
83
84 $command = $this->myCtrl->getCmd(self::CMD_SHOW) . 'Cmd';
85 return (bool) $this->$command();
86 break;
87
88 default:
89
90 throw new ilTestQuestionPoolException('unsupported next class');
91 }
92 return false;
93 }
94
95 private function showCmd(): void
96 {
97 $this->initColumns();
98
99
100 $this->setData($this->buildTableRowsArray(
102 ));
103
104 $this->myTpl->setContent($this->myCtrl->getHTML($this));
105 }
106
107 protected function initColumns(): void
108 {
109 $this->addColumn($this->myLng->txt('qpl_qst_skl_usg_skill_col'), 'skill_title', '50%');
110 $this->addColumn($this->myLng->txt('qpl_qst_skl_usg_numq_col'), 'num_questions', '');
111 $this->addColumn($this->myLng->txt('qpl_qst_skl_usg_sklpnt_col'), 'max_skill_points', '');
112 }
113
114 public function fillRow(array $a_set): void
115 {
116 $this->tpl->setVariable('SKILL_TITLE', $a_set['skill_title']);
117 $this->tpl->setVariable('SKILL_PATH', $a_set['skill_path']);
118 $this->tpl->setVariable('NUM_QUESTIONS', $a_set['num_questions']);
119 $this->tpl->setVariable('MAX_SKILL_POINTS', $a_set['max_skill_points']);
120 }
121
122 public function numericOrdering(string $a_field): bool
123 {
124 switch ($a_field) {
125 case 'num_questions':
126 case 'max_skill_points':
127 return true;
128 }
129
130 return false;
131 }
132
133 private function getUniqueAssignedSkillsStats(): array
134 {
135 $assignmentList = new ilAssQuestionSkillAssignmentList($this->myDb);
136
137 $assignmentList->setParentObjId($this->poolId);
138 $assignmentList->loadFromDb();
139 $assignmentList->loadAdditionalSkillData();
140
141 return $assignmentList->getUniqueAssignedSkills();
142 }
143
144 private function buildTableRowsArray($assignedSkills): array
145 {
146 $rows = [];
147
148 foreach ($assignedSkills as $assignedSkill) {
149 $rows[] = [
150 'skill_title' => $assignedSkill['skill_title'],
151 'skill_path' => $assignedSkill['skill_path'],
152 'num_questions' => $assignedSkill['num_assigns'],
153 'max_skill_points' => $assignedSkill['max_points'],
154 ];
155 }
156
157 return $rows;
158 }
159}
__construct(ilCtrl $myCtrl, ilGlobalTemplateInterface $myTpl, ilLanguage $myLng, ilDBInterface $myDb, $poolId)
fillRow(array $a_set)
Standard Version of Fill Row.
numericOrdering(string $a_field)
Should this field be sorted numeric?
Class ilCtrl provides processing control methods.
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
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.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
Interface ilDBInterface.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc