ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssQuestionSkillAssignmentsTableGUI.php
Go to the documentation of this file.
1<?php
2
21
29{
32
33 private bool $load_skill_points_from_request = false;
35
37 {
38 $this->skill_question_assignment_list = $assignmentList;
39 }
40
41 public function areManipulationsEnabled(): bool
42 {
44 }
45
46 public function setManipulationsEnabled(bool $manipulationsEnabled): void
47 {
48 $this->manipulations_enabled = $manipulationsEnabled;
49 }
50
51 public function __construct(
56 ) {
57 $this->lng = $lng;
58 $this->ctrl = $ctrl;
59
60 $local_dic = QuestionPoolDIC::dic();
61 $this->request_data_collector = $local_dic['request_data_collector'];
62
63 $this->setId('assQstSkl');
64 $this->setPrefix('assQstSkl');
65
67
68 $this->setStyle('table', 'fullwidth');
69
70 $this->setRowTemplate('tpl.tst_skl_qst_assignment_row.html', 'components/ILIAS/Test');
71
72 $this->enable('header');
73 $this->disable('sort');
74 $this->disable('select_all');
75 }
76
77 public function init(): void
78 {
79 $this->initColumns();
80 }
81
82 public function loadSkillPointsFromRequest(bool $loadSkillPointsFromRequest): void
83 {
84 $this->load_skill_points_from_request = $loadSkillPointsFromRequest;
85 }
86
87 private function initColumns(): void
88 {
89 $this->addColumn($this->lng->txt('tst_question'), 'question', '25%');
90 $this->addColumn($this->lng->txt('tst_competence'), 'competence', '');
91 $this->addColumn($this->lng->txt('tst_comp_eval_mode'), 'eval_mode', '13%');
92 $this->addColumn($this->lng->txt('tst_comp_points'), 'points', '12%');
93 $this->addColumn($this->lng->txt('actions'), 'actions', '20%');
94 }
95
96 public function fillRow(array $a_set): void
97 {
98 $assignments = $this->skill_question_assignment_list->getAssignmentsByQuestionId($a_set['question_id']);
99
100 $this->ctrl->setParameter($this->parent_obj, 'q_id', $a_set['question_id']);
101
102 $this->tpl->setCurrentBlock('question_title');
103 $this->tpl->setVariable('ROWSPAN', $this->getRowspan($assignments));
104 $this->tpl->setVariable('QUESTION_TITLE', $a_set['title']);
105 $this->tpl->setVariable('QUESTION_DESCRIPTION', $a_set['description']);
106 $this->tpl->parseCurrentBlock();
107
108 $this->tpl->setCurrentBlock('tbl_content');
109
110 $num_assigns = count($assignments);
111 /* @var ilAssQuestionSkillAssignment $assignment */
112 foreach ($assignments as $key => $assignment) {
113 $this->tpl->setCurrentBlock('actions_col');
114 $this->tpl->setVariable('ACTION', $this->getCompetenceAssignPropertiesFormLink($assignment));
115 $this->tpl->parseCurrentBlock();
116
117 $this->tpl->setCurrentBlock('tbl_content');
118
119 $this->tpl->setVariable('COMPETENCE', $assignment->getSkillTitle());
120 $this->tpl->setVariable('COMPETENCE_PATH', $assignment->getSkillPath());
121 $this->tpl->setVariable('EVAL_MODE', $this->getEvalModeLabel($assignment));
122 $this->tpl->setVariable('SKILL_POINTS', $assignment->getMaxSkillPoints());
123
124 if (($key + 1) < $num_assigns || $this->areManipulationsEnabled()) {
125 $this->tpl->parseCurrentBlock();
126
127 $this->tpl->setCurrentBlock('tbl_content');
128 $this->tpl->setVariable('CSS_ROW', $this->css_row);
129 }
130 }
131
132 if ($this->areManipulationsEnabled()) {
133 $this->tpl->setCurrentBlock('actions_col');
134 $this->tpl->setVariable('ACTION', $this->getManageCompetenceAssignsActionLink());
135 $this->tpl->parseCurrentBlock();
136
137 $this->tpl->setCurrentBlock('tbl_content');
138 return;
139 }
140
141 if (!$num_assigns) {
142 $this->tpl->setCurrentBlock('actions_col');
143 $this->tpl->setVariable('ACTION', '&nbsp;');
144 $this->tpl->parseCurrentBlock();
145
146 $this->tpl->setCurrentBlock('tbl_content');
147 }
148 }
149
150 private function getRowspan(array $assignments): int
151 {
152 $cnt = count($assignments);
153
154 if ($cnt === 0) {
155 return 1;
156 }
157
158 return $this->areManipulationsEnabled() ? $cnt + 1 : $cnt;
159 }
160
161 private function getManageCompetenceAssignsActionLink(): string
162 {
163 $href = $this->ctrl->getLinkTarget(
164 $this->parent_obj,
166 );
167
168 return $this->buildActionLink($href, $this->lng->txt('tst_manage_competence_assigns'));
169 }
170
172 {
173 $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', $assignment->getSkillBaseId());
174 $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', $assignment->getSkillTrefId());
175
176 $href = $this->ctrl->getLinkTarget(
177 $this->parent_obj,
179 );
180
181 $this->ctrl->setParameter($this->parent_obj, 'skill_base_id', null);
182 $this->ctrl->setParameter($this->parent_obj, 'skill_tref_id', null);
183
184 return $this->buildActionLink($href, $this->lng->txt(
185 $this->areManipulationsEnabled()
186 ? 'tst_edit_competence_assign'
187 : 'tst_view_competence_assign'
188 ));
189 }
190
191 private function buildActionLink(string $href, string $label): string
192 {
193 return "<a href=\"{$href}\" title=\"{$label}\">{$label}</a>";
194 }
195
196 private function getEvalModeLabel(ilAssQuestionSkillAssignment $assignment): string
197 {
198 return $this->lng->txt(
199 $assignment->hasEvalModeBySolution()
200 ? 'qpl_skill_point_eval_mode_solution_compare'
201 : 'qpl_skill_point_eval_mode_quest_result'
202 );
203 }
204}
getCompetenceAssignPropertiesFormLink(ilAssQuestionSkillAssignment $assignment)
setSkillQuestionAssignmentList(ilAssQuestionSkillAssignmentList $assignmentList)
__construct( $parent_obj, $parent_cmd, ilCtrl $ctrl, ilLanguage $lng)
getEvalModeLabel(ilAssQuestionSkillAssignment $assignment)
Class ilCtrl provides processing control methods.
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
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)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
ilLanguage $lng
enable(string $a_module_name)
setStyle(string $a_element, string $a_style)
disable(string $a_module_name)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc