ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilAssQuestionSkillAssignmentsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
26 {
31 
35  private $loadSkillPointsFromRequest = false;
36 
41 
43  {
44  $this->skillQuestionAssignmentList = $assignmentList;
45  }
46 
50  public function areManipulationsEnabled(): bool
51  {
53  }
54 
59  {
60  $this->manipulationsEnabled = $manipulationsEnabled;
61  }
62 
63  public function __construct($parentOBJ, $parentCmd, ilCtrl $ctrl, ilLanguage $lng)
64  {
65  $this->lng = $lng;
66  $this->ctrl = $ctrl;
67 
68  $this->setId('assQstSkl');
69  $this->setPrefix('assQstSkl');
70 
71  parent::__construct($parentOBJ, $parentCmd);
72 
73  $this->setStyle('table', 'fullwidth');
74 
75  $this->setRowTemplate("tpl.tst_skl_qst_assignment_row.html", "Modules/Test");
76 
77  $this->enable('header');
78  $this->disable('sort');
79  $this->disable('select_all');
80  }
81 
82  public function init(): void
83  {
84  $this->initColumns();
85  }
86 
91  {
93  }
94 
95  private function initColumns(): void
96  {
97  $this->addColumn($this->lng->txt('tst_question'), 'question', '25%');
98  $this->addColumn($this->lng->txt('tst_competence'), 'competence', '');
99  $this->addColumn($this->lng->txt('tst_comp_eval_mode'), 'eval_mode', '13%');
100  $this->addColumn($this->lng->txt('tst_comp_points'), 'points', '12%');
101  $this->addColumn($this->lng->txt('actions'), 'actions', '20%');
102  }
103 
104  public function fillRow(array $a_set): void
105  {
106  $assignments = $this->skillQuestionAssignmentList->getAssignmentsByQuestionId($a_set['question_id']);
107 
108  $this->ctrl->setParameter($this->parent_obj, 'question_id', $a_set['question_id']);
109 
110  $this->tpl->setCurrentBlock('question_title');
111  $this->tpl->setVariable('ROWSPAN', $this->getRowspan($assignments));
112  $this->tpl->setVariable('QUESTION_TITLE', $a_set['title']);
113  $this->tpl->setVariable('QUESTION_DESCRIPTION', $a_set['description']);
114  $this->tpl->parseCurrentBlock();
115 
116  $this->tpl->setCurrentBlock('tbl_content');
117 
118  for ($i = 0, $numAssigns = count($assignments); $i < $numAssigns; $i++) {
119  /* @var ilAssQuestionSkillAssignment $assignment */
120  $assignment = $assignments[$i];
121 
122  $this->tpl->setCurrentBlock('actions_col');
123  $this->tpl->setVariable('ACTION', $this->getCompetenceAssignPropertiesFormLink($assignment));
124  $this->tpl->parseCurrentBlock();
125 
126  $this->tpl->setCurrentBlock('tbl_content');
127 
128  $this->tpl->setVariable('COMPETENCE', $assignment->getSkillTitle());
129  $this->tpl->setVariable('COMPETENCE_PATH', $assignment->getSkillPath());
130  $this->tpl->setVariable('EVAL_MODE', $this->getEvalModeLabel($assignment));
131  $this->tpl->setVariable('SKILL_POINTS', $assignment->getMaxSkillPoints());
132 
133  if ($this->areManipulationsEnabled() || ($i + 1) < $numAssigns) {
134  $this->tpl->parseCurrentBlock();
135 
136  $this->tpl->setCurrentBlock('tbl_content');
137  $this->tpl->setVariable("CSS_ROW", $this->css_row);
138  }
139  }
140 
141  if ($this->areManipulationsEnabled()) {
142  $this->tpl->setCurrentBlock('actions_col');
143  $this->tpl->setVariable('ACTION', $this->getManageCompetenceAssignsActionLink());
144  $this->tpl->parseCurrentBlock();
145 
146  $this->tpl->setCurrentBlock('tbl_content');
147  } elseif (!$numAssigns) {
148  $this->tpl->setCurrentBlock('actions_col');
149  $this->tpl->setVariable('ACTION', '&nbsp;');
150  $this->tpl->parseCurrentBlock();
151 
152  $this->tpl->setCurrentBlock('tbl_content');
153  }
154  }
155 
156  private function getRowspan($assignments): int
157  {
158  $cnt = count($assignments);
159 
160  if ($cnt == 0) {
161  return 1;
162  }
163 
164  if ($this->areManipulationsEnabled()) {
165  $cnt++;
166  }
167 
168  return $cnt;
169  }
170 
171  private function getManageCompetenceAssignsActionLink(): string
172  {
173  $href = $this->ctrl->getLinkTarget(
174  $this->parent_obj,
176  );
177 
178  $label = $this->lng->txt('tst_manage_competence_assigns');
179 
180  return $this->buildActionLink($href, $label);
181  }
182 
184  {
185  $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', $assignment->getSkillBaseId());
186  $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', $assignment->getSkillTrefId());
187 
188  $href = $this->ctrl->getLinkTarget(
189  $this->parent_obj,
191  );
192 
193  if ($this->areManipulationsEnabled()) {
194  $label = $this->lng->txt('tst_edit_competence_assign');
195  } else {
196  $label = $this->lng->txt('tst_view_competence_assign');
197  }
198 
199  $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', null);
200  $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', null);
201 
202  return $this->buildActionLink($href, $label);
203  }
204 
205  private function buildActionLink($href, $label): string
206  {
207  return "<a href=\"{$href}\" title=\"{$label}\">{$label}</a>";
208  }
209 
210  private function buildActionColumnHTML($assignments): string
211  {
212  $actions = array();
213 
214  /* PHP8: This appears to be an incomplete feature: Removal of skill assignment is nowhere found other than
215  here, ilAssQuestionSkillAssignmentsGUI::CMD_REMOVE_SKILL_QUEST_ASSIGN is undefined. Defusing for now.
216 
217  foreach ($assignments as $assignment) {
218  $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', $assignment->getSkillBaseId());
219  $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', $assignment->getSkillTrefId());
220 
221  $href = $this->ctrl->getLinkTarget(
222  $this->parent_obj,
223  ilAssQuestionSkillAssignmentsGUI::CMD_REMOVE_SKILL_QUEST_ASSIGN
224  );
225 
226  $label = $this->lng->txt('tst_remove_competence');
227 
228  $actions[] = $this->buildActionLink($href, $label);
229  }
230  */
231 
232  $href = $this->ctrl->getLinkTarget(
233  $this->parent_obj,
235  );
236 
237  $label = $this->lng->txt('tst_assign_competence');
238  $actions[] = $this->buildActionLink($href, $label);
239 
240  return implode('<br />', $actions);
241  }
242 
243  private function getEvalModeLabel(ilAssQuestionSkillAssignment $assignment): string
244  {
245  if ($assignment->hasEvalModeBySolution()) {
246  return $this->lng->txt('qpl_skill_point_eval_mode_solution_compare');
247  }
248 
249  return $this->lng->txt('qpl_skill_point_eval_mode_quest_result');
250  }
251 }
enable(string $a_module_name)
ilLanguage $lng
setId(string $a_val)
setStyle(string $a_element, string $a_style)
__construct(VocabulariesInterface $vocabularies)
setSkillQuestionAssignmentList(ilAssQuestionSkillAssignmentList $assignmentList)
__construct($parentOBJ, $parentCmd, ilCtrl $ctrl, ilLanguage $lng)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
getEvalModeLabel(ilAssQuestionSkillAssignment $assignment)
getCompetenceAssignPropertiesFormLink(ilAssQuestionSkillAssignment $assignment)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
disable(string $a_module_name)
setPrefix(string $a_prefix)