ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
22  private $loadSkillPointsFromRequest = false;
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  {
75  $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
76 
77  $this->addCommandButton(
78  ilAssQuestionSkillAssignmentsGUI::CMD_SAVE_SKILL_POINTS, $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  {
116  /* @var ilAssQuestionSkillAssignment $assignment */
117  $assignment = $assignments[$i];
118 
119  $this->tpl->setCurrentBlock('actions_col');
120  $this->tpl->setVariable('ACTION', $this->getCompetenceAssignPropertiesFormLink($assignment));
121  $this->tpl->parseCurrentBlock();
122 
123  $this->tpl->setCurrentBlock('tbl_content');
124 
125  $this->tpl->setVariable('COMPETENCE', $assignment->getSkillTitle());
126  $this->tpl->setVariable('COMPETENCE_PATH', $assignment->getSkillPath());
127  $this->tpl->setVariable('EVAL_MODE', $this->getEvalModeLabel($assignment));
128 
129  if( $this->isSkillPointInputRequired($assignment) )
130  {
131  $this->tpl->setVariable('SKILL_POINTS', $this->buildSkillPointsInput($assignment));
132  }
133  else
134  {
135  $this->tpl->setVariable('SKILL_POINTS', $assignment->getMaxSkillPoints());
136  }
137 
138  if( $this->areManipulationsEnabled() || ($i + 1) < $numAssigns )
139  {
140  $this->tpl->parseCurrentBlock();
141 
142  $this->tpl->setCurrentBlock('tbl_content');
143  $this->tpl->setVariable("CSS_ROW", $this->css_row);
144  }
145  }
146 
147  if( $this->areManipulationsEnabled() )
148  {
149  $this->tpl->setCurrentBlock('actions_col');
150  $this->tpl->setVariable('ACTION', $this->getManageCompetenceAssignsActionLink());
151  $this->tpl->parseCurrentBlock();
152 
153  $this->tpl->setCurrentBlock('tbl_content');
154  }
155  elseif( !$numAssigns )
156  {
157  $this->tpl->setCurrentBlock('actions_col');
158  $this->tpl->setVariable('ACTION', '&nbsp;');
159  $this->tpl->parseCurrentBlock();
160 
161  $this->tpl->setCurrentBlock('tbl_content');
162  }
163  }
164 
165  private function getRowspan($assignments)
166  {
167  $cnt = count($assignments);
168 
169  if( $cnt == 0 )
170  {
171  return 1;
172  }
173 
174  if( $this->areManipulationsEnabled() )
175  {
176  $cnt++;
177  }
178 
179  return $cnt;
180  }
181 
183  {
184  $href = $this->ctrl->getLinkTarget(
186  );
187 
188  $label = $this->lng->txt('tst_manage_competence_assigns');
189 
190  return $this->buildActionLink($href, $label);
191  }
192 
194  {
195  $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', $assignment->getSkillBaseId());
196  $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', $assignment->getSkillTrefId());
197 
198  $href = $this->ctrl->getLinkTarget(
200  );
201 
202  if( $this->areManipulationsEnabled() )
203  {
204  $label = $this->lng->txt('tst_edit_competence_assign');
205  }
206  else
207  {
208  $label = $this->lng->txt('tst_view_competence_assign');
209  }
210 
211  $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', null);
212  $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', null);
213 
214  return $this->buildActionLink($href, $label);
215  }
216 
217  private function buildActionLink($href, $label)
218  {
219  return "<a href=\"{$href}\" title=\"{$label}\">{$label}</a>";
220  }
221 
222  private function buildActionColumnHTML($assignments)
223  {
224  $actions = array();
225 
226  foreach($assignments as $assignment)
227  {
228  $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', $assignment->getSkillBaseId());
229  $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', $assignment->getSkillTrefId());
230 
231  $href = $this->ctrl->getLinkTarget(
232  $this->parent_obj, ilAssQuestionSkillAssignmentsGUI::CMD_REMOVE_SKILL_QUEST_ASSIGN
233  );
234 
235  $label = $this->lng->txt('tst_remove_competence');
236 
237  $actions[] = $this->buildActionLink($href, $label);
238  }
239 
240  $href = $this->ctrl->getLinkTarget(
242  );
243 
244  $label = $this->lng->txt('tst_assign_competence');
245  $actions[] = $this->buildActionLink($href, $label);
246 
247  return implode('<br />', $actions);
248  }
249 
250  private function getEvalModeLabel(ilAssQuestionSkillAssignment $assignment)
251  {
252  if( $assignment->hasEvalModeBySolution() )
253  {
254  return $this->lng->txt('qpl_skill_point_eval_mode_solution_compare');
255  }
256 
257  return $this->lng->txt('qpl_skill_point_eval_mode_quest_result');
258  }
259 
261  {
262  $assignmentKey = implode(':', array(
263  $assignment->getSkillBaseId(), $assignment->getSkillTrefId(), $assignment->getQuestionId()
264  ));
265 
266  if($this->loadSkillPointsFromRequest)
267  {
268  $points = isset($_POST['skill_points'][$assignmentKey]) ? ilUtil::stripSlashes($_POST['skill_points'][$assignmentKey]) : '';
269  }
270  else
271  {
272  $points = $assignment->getSkillPoints();
273  }
274 
275  return "<input type\"text\" size=\"2\" name=\"skill_points[{$assignmentKey}]\" value=\"{$points}\" />";
276  }
277 
279  {
280  if( !$this->areManipulationsEnabled() )
281  {
282  return false;
283  }
284 
285  if( $assignment->hasEvalModeBySolution() )
286  {
287  return false;
288  }
289 
290  return true;
291  }
292 }
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)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
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:17
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.
$_POST["username"]
isSkillPointInputRequired(ilAssQuestionSkillAssignment $assignment)