ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 
4 require_once 'Services/Table/classes/class.ilTable2GUI.php';
5 
13 {
18 
23 
25  {
26  $this->skillQuestionAssignmentList = $assignmentList;
27  }
28 
32  public function areManipulationsEnabled()
33  {
35  }
36 
41  {
42  $this->manipulationsEnabled = $manipulationsEnabled;
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->setId('assQstSkl');
53  $this->getPrefix('assQstSkl');
54 
55  $this->setStyle('table', 'fullwidth');
56 
57  $this->setRowTemplate("tpl.tst_skl_qst_assignment_row.html", "Modules/Test");
58 
59  $this->enable('header');
60  $this->disable('sort');
61  $this->disable('select_all');
62  }
63 
64  public function init()
65  {
66  $this->initColumns();
67 
68  if( $this->areManipulationsEnabled() )
69  {
70  $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
71 
72  $this->addCommandButton(
73  ilAssQuestionSkillAssignmentsGUI::CMD_SAVE_SKILL_POINTS, $this->lng->txt('tst_save_comp_points')
74  );
75  }
76  }
77 
78  private function initColumns()
79  {
80  $this->addColumn($this->lng->txt('tst_question'),'question', '25%');
81  $this->addColumn($this->lng->txt('tst_competence'),'competence', '');
82  $this->addColumn($this->lng->txt('tst_comp_eval_mode'),'eval_mode', '13%');
83  $this->addColumn($this->lng->txt('tst_comp_points'),'points', '12%');
84  $this->addColumn($this->lng->txt('actions'), 'actions', '20%');
85  }
86 
87  public function fillRow($question)
88  {
89  $assignments = $this->skillQuestionAssignmentList->getAssignmentsByQuestionId($question['question_id']);
90 
91  $this->ctrl->setParameter($this->parent_obj, 'question_id', $question['question_id']);
92 
93  $this->tpl->setCurrentBlock('question_title');
94  $this->tpl->setVariable('ROWSPAN', $this->getRowspan($assignments));
95  $this->tpl->setVariable('QUESTION_TITLE', $question['title']);
96  $this->tpl->setVariable('QUESTION_DESCRIPTION', $question['description']);
97  $this->tpl->parseCurrentBlock();
98 
99  $this->tpl->setCurrentBlock('tbl_content');
100 
101  for($i = 0, $numAssigns = count($assignments); $i < $numAssigns; $i++)
102  {
103  /* @var ilAssQuestionSkillAssignment $assignment */
104  $assignment = $assignments[$i];
105 
106  $this->tpl->setCurrentBlock('actions_col');
107  $this->tpl->setVariable('ACTION', $this->getCompetenceAssignPropertiesFormLink($assignment));
108  $this->tpl->parseCurrentBlock();
109 
110  $this->tpl->setCurrentBlock('tbl_content');
111 
112  $this->tpl->setVariable('COMPETENCE', $assignment->getSkillTitle());
113  $this->tpl->setVariable('COMPETENCE_PATH', $assignment->getSkillPath());
114  $this->tpl->setVariable('EVAL_MODE', $this->getEvalModeLabel($assignment));
115 
116  if( $this->isSkillPointInputRequired($assignment) )
117  {
118  $this->tpl->setVariable('SKILL_POINTS', $this->buildSkillPointsInput($assignment));
119  }
120  else
121  {
122  $this->tpl->setVariable('SKILL_POINTS', $assignment->getMaxSkillPoints());
123  }
124 
125  if( $this->areManipulationsEnabled() || ($i + 1) < $numAssigns )
126  {
127  $this->tpl->parseCurrentBlock();
128 
129  $this->tpl->setCurrentBlock('tbl_content');
130  $this->tpl->setVariable("CSS_ROW", $this->css_row);
131  }
132  }
133 
134  if( $this->areManipulationsEnabled() )
135  {
136  $this->tpl->setCurrentBlock('actions_col');
137  $this->tpl->setVariable('ACTION', $this->getManageCompetenceAssignsActionLink());
138  $this->tpl->parseCurrentBlock();
139 
140  $this->tpl->setCurrentBlock('tbl_content');
141  }
142  elseif( !$numAssigns )
143  {
144  $this->tpl->setCurrentBlock('actions_col');
145  $this->tpl->setVariable('ACTION', '&nbsp;');
146  $this->tpl->parseCurrentBlock();
147 
148  $this->tpl->setCurrentBlock('tbl_content');
149  }
150  }
151 
152  private function getRowspan($assignments)
153  {
154  $cnt = count($assignments);
155 
156  if( $cnt == 0 )
157  {
158  return 1;
159  }
160 
161  if( $this->areManipulationsEnabled() )
162  {
163  $cnt++;
164  }
165 
166  return $cnt;
167  }
168 
170  {
171  $href = $this->ctrl->getLinkTarget(
173  );
174 
175  $label = $this->lng->txt('tst_manage_competence_assigns');
176 
177  return $this->buildActionLink($href, $label);
178  }
179 
181  {
182  $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', $assignment->getSkillBaseId());
183  $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', $assignment->getSkillTrefId());
184 
185  $href = $this->ctrl->getLinkTarget(
187  );
188 
189  if( $this->areManipulationsEnabled() )
190  {
191  $label = $this->lng->txt('tst_edit_competence_assign');
192  }
193  else
194  {
195  $label = $this->lng->txt('tst_view_competence_assign');
196  }
197 
198  $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', null);
199  $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', null);
200 
201  return $this->buildActionLink($href, $label);
202  }
203 
204  private function buildActionLink($href, $label)
205  {
206  return "<a href=\"{$href}\" title=\"{$label}\">{$label}</a>";
207  }
208 
209  private function buildActionColumnHTML($assignments)
210  {
211  $actions = array();
212 
213  foreach($assignments as $assignment)
214  {
215  $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', $assignment->getSkillBaseId());
216  $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', $assignment->getSkillTrefId());
217 
218  $href = $this->ctrl->getLinkTarget(
219  $this->parent_obj, ilAssQuestionSkillAssignmentsGUI::CMD_REMOVE_SKILL_QUEST_ASSIGN
220  );
221 
222  $label = $this->lng->txt('tst_remove_competence');
223 
224  $actions[] = $this->buildActionLink($href, $label);
225  }
226 
227  $href = $this->ctrl->getLinkTarget(
229  );
230 
231  $label = $this->lng->txt('tst_assign_competence');
232  $actions[] = $this->buildActionLink($href, $label);
233 
234  return implode('<br />', $actions);
235  }
236 
237  private function getEvalModeLabel(ilAssQuestionSkillAssignment $assignment)
238  {
239  if( $assignment->hasEvalModeBySolution() )
240  {
241  return $this->lng->txt('qpl_skill_point_eval_mode_solution_compare');
242  }
243 
244  return $this->lng->txt('qpl_skill_point_eval_mode_quest_result');
245  }
246 
248  {
249  $assignmentKey = implode(':', array(
250  $assignment->getSkillBaseId(), $assignment->getSkillTrefId(), $assignment->getQuestionId()
251  ));
252 
253  return "<input type\"text\" size=\"2\" name=\"skill_points[{$assignmentKey}]\" value=\"{$assignment->getSkillPoints()}\" />";
254  }
255 
257  {
258  if( !$this->areManipulationsEnabled() )
259  {
260  return false;
261  }
262 
263  if( $assignment->hasEvalModeBySolution() )
264  {
265  return false;
266  }
267 
268  return true;
269  }
270 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
This class provides processing control methods.
setStyle($a_element, $a_style)
buildSkillPointsInput(ilAssQuestionSkillAssignment $assignment)
setId($a_val)
Set id.
Class ilTable2GUI.
setSkillQuestionAssignmentList(ilAssQuestionSkillAssignmentList $assignmentList)
__construct($parentOBJ, $parentCmd, ilCtrl $ctrl, ilLanguage $lng)
enable($a_module_name)
enables particular modules of table
getEvalModeLabel(ilAssQuestionSkillAssignment $assignment)
setRowTemplate($a_template, $a_template_dir="")
Set row template.
getCompetenceAssignPropertiesFormLink(ilAssQuestionSkillAssignment $assignment)
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
disable($a_module_name)
diesables particular modules of table
global $lng
Definition: privfeed.php:40
language handling
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.
isSkillPointInputRequired(ilAssQuestionSkillAssignment $assignment)