ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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, $parentCmd, ilCtrl $ctrl, ilLanguage $lng)
46 {
47 parent::__construct($parentOBJ, $parentCmd);
48
49 $this->lng = $lng;
50 $this->ctrl = $ctrl;
51
52 $this->lng->loadLanguageModule('form');
53
54 $this->setStyle('table', 'fullwidth');
55
56 $this->setRowTemplate("tpl.tst_skl_thresholds_row.html", "Modules/Test");
57
58 $this->enable('header');
59 #$this->disable('sort');
60 $this->disable('select_all');
61
62 $this->setDefaultOrderField('competence');
63 $this->setDefaultOrderDirection('asc');
64
65 $this->setFormAction($ctrl->getFormAction($parentOBJ));
66
67 $this->addCommandButton(
68 ilTestSkillLevelThresholdsGUI::CMD_SAVE_SKILL_THRESHOLDS, $this->lng->txt('tst_save_thresholds')
69 );
70 }
71
72 public function initColumns()
73 {
74 $this->addColumn($this->lng->txt('tst_competence'),'competence', '50%');
75
77 {
78 $this->addColumn($this->lng->txt('tst_num_questions'),'', '10%');
79 $this->addColumn($this->lng->txt('tst_max_comp_points'),'', '10%');
80 }
81
82 $this->addColumn($this->lng->txt('tst_level'),'', '10%');
83 $this->addColumn($this->lng->txt('tst_threshold'),'', '10%');
84 }
85
86 public function fillRow($data)
87 {
88 $skill = $data['skill'];
89 $levels = $skill->getLevelData();
90
92 {
93 $this->tpl->setCurrentBlock('quest_assign_info');
94 $this->tpl->setVariable('ROWSPAN', $this->getRowspan(count($levels)));
95 $this->tpl->setVariable('NUM_QUESTIONS', $data['num_assigns']);
96 $this->tpl->setVariable('MAX_COMP_POINTS', $data['max_points']);
97 $this->tpl->parseCurrentBlock();
98 }
99
100 $this->tpl->setCurrentBlock('competence');
101 $this->tpl->setVariable('ROWSPAN', $this->getRowspan(count($levels)));
102 $this->tpl->setVariable('COMPETENCE', $data['competence']);
103 $this->tpl->parseCurrentBlock();
104
105 $this->tpl->setCurrentBlock('tbl_content');
106
107 for($i = 0, $max = count($levels); $i < $max; $i++)
108 {
109 $level = $levels[$i];
110
111 $this->tpl->setVariable('LEVEL', $level['title']);
112
113 $this->tpl->setVariable('THRESHOLD', $this->buildThresholdInput(
114 $data['skill_base_id'], $data['skill_tref_id'], $level['id']
115 )->render());
116
117 if( $i < ($max - 1) )
118 {
119 $this->tpl->parseCurrentBlock();
120 $this->tpl->setVariable("CSS_ROW", $this->css_row);
121 $this->tpl->setVariable("CSS_NO_BORDER", 'ilBorderlessRow');
122 }
123 }
124 }
125
126 private function getRowspan($numLevels)
127 {
128 if($numLevels == 0)
129 {
130 return 1;
131 }
132
133 return $numLevels;
134 }
135
139 public function getInputElements()
140 {
141 $elements = array();
142
143 foreach($this->getData() as $data)
144 {
145 $skill = $data['skill'];
146 $levels = $skill->getLevelData();
147 for($i = 0, $max = count($levels); $i < $max; $i++)
148 {
149 $level = $levels[$i];
150
151 $elements[] = $this->buildThresholdInput(
152 $data['skill_base_id'], $data['skill_tref_id'], $level['id']
153 );
154 }
155 }
156
157 return $elements;
158 }
159
166 private function buildThresholdInput($skillBaseId, $skillTrefId, $skillLevelId)
167 {
168 $skillKey = $skillBaseId.':'.$skillTrefId;
169
170 if(isset($this->input_elements_by_id[$skillKey][$skillLevelId]))
171 {
172 return $this->input_elements_by_id[$skillKey][$skillLevelId];
173 }
174
175 $threshold = $this->skillLevelThresholdList->getThreshold($skillBaseId, $skillTrefId, $skillLevelId);
176 if( $threshold instanceof ilTestSkillLevelThreshold )
177 {
178 $thresholdValue = $threshold->getThreshold();
179 }
180 else
181 {
182 $thresholdValue = '';
183 }
184
185 $value = new ilNumberInputGUI('', 'threshold_'. $skillKey . '_' . $skillLevelId);
186 $value->setValue($thresholdValue);
187 $value->setSize(5);
188 $value->setMinValue(0);
189
190 if(!isset($this->input_elements_by_id[$skillKey]))
191 {
192 $this->input_elements_by_id[$skillKey] = array();
193 }
194
195 $this->input_elements_by_id[$skillKey][$skillLevelId] = $value;
196
197 return $value;
198 }
199
200 public function completeCompetenceTitles($rows)
201 {
202 foreach($rows as $key => $row)
203 {
204 $rows[$key]['competence'] = ilBasicSkill::_lookupTitle(
205 $row['skill']->getId(), $row['skill_tref_id']
206 );
207 }
208
209 return $rows;
210 }
211}
This class provides processing control methods.
getFormAction(&$a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
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.
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.
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.
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
__construct($parentOBJ, $parentCmd, ilCtrl $ctrl, ilLanguage $lng)
buildThresholdInput($skillBaseId, $skillTrefId, $skillLevelId)
setQuestionAssignmentColumnsEnabled($questionAssignmentColumnsEnabled)
setSkillLevelThresholdList(ilTestSkillLevelThresholdList $skillLevelThresholdList)
global $lng
Definition: privfeed.php:40