ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAssQuestionSkillAssignmentsTableGUI.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';
5
13{
18
23
28
30 {
31 $this->skillQuestionAssignmentList = $assignmentList;
32 }
33
37 public function areManipulationsEnabled()
38 {
40 }
41
46 {
47 $this->manipulationsEnabled = $manipulationsEnabled;
48 }
49
50 public function __construct($parentOBJ, $parentCmd, ilCtrl $ctrl, ilLanguage $lng)
51 {
52 parent::__construct($parentOBJ, $parentCmd);
53
54 $this->lng = $lng;
55 $this->ctrl = $ctrl;
56
57 $this->setId('assQstSkl');
58 $this->getPrefix('assQstSkl');
59
60 $this->setStyle('table', 'fullwidth');
61
62 $this->setRowTemplate("tpl.tst_skl_qst_assignment_row.html", "Modules/Test");
63
64 $this->enable('header');
65 $this->disable('sort');
66 $this->disable('select_all');
67 }
68
69 public function init()
70 {
71 $this->initColumns();
72
73 if ($this->areManipulationsEnabled()) {
74 $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
75
76 $this->addCommandButton(
78 $this->lng->txt('tst_save_comp_points')
79 );
80 }
81 }
82
87 {
89 }
90
91 private function initColumns()
92 {
93 $this->addColumn($this->lng->txt('tst_question'), 'question', '25%');
94 $this->addColumn($this->lng->txt('tst_competence'), 'competence', '');
95 $this->addColumn($this->lng->txt('tst_comp_eval_mode'), 'eval_mode', '13%');
96 $this->addColumn($this->lng->txt('tst_comp_points'), 'points', '12%');
97 $this->addColumn($this->lng->txt('actions'), 'actions', '20%');
98 }
99
100 public function fillRow($question)
101 {
102 $assignments = $this->skillQuestionAssignmentList->getAssignmentsByQuestionId($question['question_id']);
103
104 $this->ctrl->setParameter($this->parent_obj, 'question_id', $question['question_id']);
105
106 $this->tpl->setCurrentBlock('question_title');
107 $this->tpl->setVariable('ROWSPAN', $this->getRowspan($assignments));
108 $this->tpl->setVariable('QUESTION_TITLE', $question['title']);
109 $this->tpl->setVariable('QUESTION_DESCRIPTION', $question['description']);
110 $this->tpl->parseCurrentBlock();
111
112 $this->tpl->setCurrentBlock('tbl_content');
113
114 for ($i = 0, $numAssigns = count($assignments); $i < $numAssigns; $i++) {
115 /* @var ilAssQuestionSkillAssignment $assignment */
116 $assignment = $assignments[$i];
117
118 $this->tpl->setCurrentBlock('actions_col');
119 $this->tpl->setVariable('ACTION', $this->getCompetenceAssignPropertiesFormLink($assignment));
120 $this->tpl->parseCurrentBlock();
121
122 $this->tpl->setCurrentBlock('tbl_content');
123
124 $this->tpl->setVariable('COMPETENCE', $assignment->getSkillTitle());
125 $this->tpl->setVariable('COMPETENCE_PATH', $assignment->getSkillPath());
126 $this->tpl->setVariable('EVAL_MODE', $this->getEvalModeLabel($assignment));
127
128 if ($this->isSkillPointInputRequired($assignment)) {
129 $this->tpl->setVariable('SKILL_POINTS', $this->buildSkillPointsInput($assignment));
130 } else {
131 $this->tpl->setVariable('SKILL_POINTS', $assignment->getMaxSkillPoints());
132 }
133
134 if ($this->areManipulationsEnabled() || ($i + 1) < $numAssigns) {
135 $this->tpl->parseCurrentBlock();
136
137 $this->tpl->setCurrentBlock('tbl_content');
138 $this->tpl->setVariable("CSS_ROW", $this->css_row);
139 }
140 }
141
142 if ($this->areManipulationsEnabled()) {
143 $this->tpl->setCurrentBlock('actions_col');
144 $this->tpl->setVariable('ACTION', $this->getManageCompetenceAssignsActionLink());
145 $this->tpl->parseCurrentBlock();
146
147 $this->tpl->setCurrentBlock('tbl_content');
148 } elseif (!$numAssigns) {
149 $this->tpl->setCurrentBlock('actions_col');
150 $this->tpl->setVariable('ACTION', '&nbsp;');
151 $this->tpl->parseCurrentBlock();
152
153 $this->tpl->setCurrentBlock('tbl_content');
154 }
155 }
156
157 private function getRowspan($assignments)
158 {
159 $cnt = count($assignments);
160
161 if ($cnt == 0) {
162 return 1;
163 }
164
165 if ($this->areManipulationsEnabled()) {
166 $cnt++;
167 }
168
169 return $cnt;
170 }
171
173 {
174 $href = $this->ctrl->getLinkTarget(
175 $this->parent_obj,
177 );
178
179 $label = $this->lng->txt('tst_manage_competence_assigns');
180
181 return $this->buildActionLink($href, $label);
182 }
183
185 {
186 $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', $assignment->getSkillBaseId());
187 $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', $assignment->getSkillTrefId());
188
189 $href = $this->ctrl->getLinkTarget(
190 $this->parent_obj,
192 );
193
194 if ($this->areManipulationsEnabled()) {
195 $label = $this->lng->txt('tst_edit_competence_assign');
196 } else {
197 $label = $this->lng->txt('tst_view_competence_assign');
198 }
199
200 $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', null);
201 $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', null);
202
203 return $this->buildActionLink($href, $label);
204 }
205
206 private function buildActionLink($href, $label)
207 {
208 return "<a href=\"{$href}\" title=\"{$label}\">{$label}</a>";
209 }
210
211 private function buildActionColumnHTML($assignments)
212 {
213 $actions = array();
214
215 foreach ($assignments as $assignment) {
216 $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', $assignment->getSkillBaseId());
217 $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', $assignment->getSkillTrefId());
218
219 $href = $this->ctrl->getLinkTarget(
220 $this->parent_obj,
221 ilAssQuestionSkillAssignmentsGUI::CMD_REMOVE_SKILL_QUEST_ASSIGN
222 );
223
224 $label = $this->lng->txt('tst_remove_competence');
225
226 $actions[] = $this->buildActionLink($href, $label);
227 }
228
229 $href = $this->ctrl->getLinkTarget(
230 $this->parent_obj,
232 );
233
234 $label = $this->lng->txt('tst_assign_competence');
235 $actions[] = $this->buildActionLink($href, $label);
236
237 return implode('<br />', $actions);
238 }
239
240 private function getEvalModeLabel(ilAssQuestionSkillAssignment $assignment)
241 {
242 if ($assignment->hasEvalModeBySolution()) {
243 return $this->lng->txt('qpl_skill_point_eval_mode_solution_compare');
244 }
245
246 return $this->lng->txt('qpl_skill_point_eval_mode_quest_result');
247 }
248
250 {
251 $assignmentKey = implode(':', array(
252 $assignment->getSkillBaseId(), $assignment->getSkillTrefId(), $assignment->getQuestionId()
253 ));
254
255 if ($this->loadSkillPointsFromRequest) {
256 $points = isset($_POST['skill_points'][$assignmentKey]) ? ilUtil::stripSlashes($_POST['skill_points'][$assignmentKey]) : '';
257 } else {
258 $points = $assignment->getSkillPoints();
259 }
260
261 return "<input type\"text\" size=\"2\" name=\"skill_points[{$assignmentKey}]\" value=\"{$points}\" />";
262 }
263
265 {
266 if (!$this->areManipulationsEnabled()) {
267 return false;
268 }
269
270 if ($assignment->hasEvalModeBySolution()) {
271 return false;
272 }
273
274 return true;
275 }
276}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
getCompetenceAssignPropertiesFormLink(ilAssQuestionSkillAssignment $assignment)
setSkillQuestionAssignmentList(ilAssQuestionSkillAssignmentList $assignmentList)
buildSkillPointsInput(ilAssQuestionSkillAssignment $assignment)
getEvalModeLabel(ilAssQuestionSkillAssignment $assignment)
isSkillPointInputRequired(ilAssQuestionSkillAssignment $assignment)
__construct($parentOBJ, $parentCmd, ilCtrl $ctrl, ilLanguage $lng)
This class provides processing control methods.
language handling
Class ilTable2GUI.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
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.
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
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc