ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilTestSkillLevelThresholdsTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Table/classes/class.ilTable2GUI.php';
5require_once 'Services/Skill/classes/class.ilBasicSkill.php';
6require_once 'Services/Form/classes/class.ilNumberInputGUI.php';
7
15{
17
19
23 protected $input_elements_by_id = array();
24
26 {
27 $this->skillLevelThresholdList = $skillLevelThresholdList;
28 }
29
31 {
33 }
34
36 {
38 }
39
41 {
42 $this->questionAssignmentColumnsEnabled = $questionAssignmentColumnsEnabled;
43 }
44
45 public function __construct($parentOBJ, $testId, $parentCmd, ilCtrl $ctrl, ilLanguage $lng)
46 {
47 $this->setId('tst_skl_lev_thr_' . $testId);
48 parent::__construct($parentOBJ, $parentCmd);
49
50 $this->lng = $lng;
51 $this->ctrl = $ctrl;
52
53 $this->lng->loadLanguageModule('form');
54
55 $this->setStyle('table', 'fullwidth');
56
57 $this->setRowTemplate("tpl.tst_skl_thresholds_row.html", "Modules/Test");
58
59 $this->enable('header');
60 #$this->disable('sort');
61 $this->disable('select_all');
62
63 $this->setDefaultOrderField('competence');
64 $this->setDefaultOrderDirection('asc');
65 $this->setShowRowsSelector(true);
66
67 $this->setFormAction($ctrl->getFormAction($parentOBJ));
68
69 $this->addCommandButton(
71 $this->lng->txt('tst_save_thresholds')
72 );
73 }
74
75 public function initColumns()
76 {
77 $this->addColumn($this->lng->txt('tst_competence'), 'competence', '50%');
78
80 $this->addColumn($this->lng->txt('tst_num_questions'), '', '10%');
81 $this->addColumn($this->lng->txt('tst_max_comp_points'), '', '10%');
82 }
83
84 $this->addColumn($this->lng->txt('tst_level'), '', '10%');
85 $this->addColumn($this->lng->txt('tst_threshold'), '', '10%');
86 }
87
88 public function fillRow($data)
89 {
90 $skill = $data['skill'];
91 $levels = $skill->getLevelData();
92
94 $this->tpl->setCurrentBlock('quest_assign_info');
95 $this->tpl->setVariable('ROWSPAN', $this->getRowspan(count($levels)));
96 $this->tpl->setVariable('NUM_QUESTIONS', $data['num_assigns']);
97 $this->tpl->setVariable('MAX_COMP_POINTS', $data['max_points']);
98 $this->tpl->parseCurrentBlock();
99 }
100
101 $this->tpl->setCurrentBlock('competence');
102 $this->tpl->setVariable('ROWSPAN', $this->getRowspan(count($levels)));
103 $this->tpl->setVariable('COMPETENCE', $data['competence']);
104 $this->tpl->parseCurrentBlock();
105
106 $this->addHiddenInput('rendered[]', $this->buildUniqueRecordIdentifier($data));
107
108 $this->tpl->setCurrentBlock('tbl_content');
109
110 for ($i = 0, $max = count($levels); $i < $max; $i++) {
111 $level = $levels[$i];
112
113 $this->tpl->setVariable('LEVEL', $level['title']);
114
115 $this->tpl->setVariable('THRESHOLD', $this->buildThresholdInput(
116 $data['skill_base_id'],
117 $data['skill_tref_id'],
118 $level['id']
119 )->render());
120
121 if ($i < ($max - 1)) {
122 $this->tpl->parseCurrentBlock();
123 $this->tpl->setVariable("CSS_ROW", $this->css_row);
124 $this->tpl->setVariable("CSS_NO_BORDER", 'ilBorderlessRow');
125 }
126 }
127 }
128
133 private function buildUniqueRecordIdentifier(array $row) : string
134 {
135 return 'threshold_' . $row['skill_base_id'] . ':' . $row['skill_tref_id'];
136 }
137
138 private function getRowspan($numLevels)
139 {
140 if ($numLevels == 0) {
141 return 1;
142 }
143
144 return $numLevels;
145 }
146
151 public function getInputElements(array $idFilter) : array
152 {
153 $elements = array();
154
155 foreach ($this->getData() as $data) {
156 $id = $this->buildUniqueRecordIdentifier($data);
157 if (!in_array($id, $idFilter)) {
158 continue;
159 }
160
161 $skill = $data['skill'];
162 $levels = $skill->getLevelData();
163 for ($i = 0, $max = count($levels); $i < $max; $i++) {
164 $level = $levels[$i];
165
166 $elements[] = $this->buildThresholdInput(
167 $data['skill_base_id'],
168 $data['skill_tref_id'],
169 $level['id']
170 );
171 }
172 }
173
174 return $elements;
175 }
176
183 private function buildThresholdInput($skillBaseId, $skillTrefId, $skillLevelId)
184 {
185 $skillKey = $skillBaseId . ':' . $skillTrefId;
186
187 if (isset($this->input_elements_by_id[$skillKey][$skillLevelId])) {
188 return $this->input_elements_by_id[$skillKey][$skillLevelId];
189 }
190
191 $threshold = $this->skillLevelThresholdList->getThreshold($skillBaseId, $skillTrefId, $skillLevelId);
192 if ($threshold instanceof ilTestSkillLevelThreshold) {
193 $thresholdValue = $threshold->getThreshold();
194 } else {
195 $thresholdValue = '';
196 }
197
198 $value = new ilNumberInputGUI('', 'threshold_' . $skillKey . '_' . $skillLevelId);
199 $value->setValue($thresholdValue);
200 $value->setSize(5);
201 $value->setMinValue(0);
202 $value->setMaxValue(100);
203
204 if (!isset($this->input_elements_by_id[$skillKey])) {
205 $this->input_elements_by_id[$skillKey] = array();
206 }
207
208 $this->input_elements_by_id[$skillKey][$skillLevelId] = $value;
209
210 return $value;
211 }
212
214 {
215 foreach ($rows as $key => $row) {
216 $rows[$key]['competence'] = ilBasicSkill::_lookupTitle(
217 $row['skill']->getId(),
218 $row['skill_tref_id']
219 );
220 }
221
222 return $rows;
223 }
224}
An exception for terminatinating execution or to throw for unit testing.
This class provides processing control methods.
getFormAction( $a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=false)
Get form action url for gui class object.
language handling
This class represents a number property in a property form.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
Class ilTable2GUI.
addHiddenInput($a_name, $a_value)
Add Hidden Input field.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
render()
render table @access public
getId()
Get element id.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
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.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
setStyle($a_element, $a_style)
enable($a_module_name)
enables particular modules of table
buildThresholdInput($skillBaseId, $skillTrefId, $skillLevelId)
setQuestionAssignmentColumnsEnabled($questionAssignmentColumnsEnabled)
setSkillLevelThresholdList(ilTestSkillLevelThresholdList $skillLevelThresholdList)
__construct($parentOBJ, $testId, $parentCmd, ilCtrl $ctrl, ilLanguage $lng)
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$rows
Definition: xhr_table.php:10