ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilAssQuestionSkillAssignmentPropertyFormGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23use ILIAS\UI\Factory as UIFactory;
24use ILIAS\UI\Renderer as UIRenderer;
25
35{
36 private ?assQuestion $question = null;
38 private bool $manipulation_enabled = false;
39 private UIFactory $ui_factory;
40 private UIRenderer $ui_renderer;
41 private ?Modal $legend_modal = null;
42
43 public function __construct(
44 private readonly ilAssQuestionSkillAssignmentsGUI $parent_gui
45 ) {
46 global $DIC;
47 $this->ui_factory = $DIC['ui.factory'];
48 $this->ui_renderer = $DIC['ui.renderer'];
50 }
51
52 public function getQuestion(): ?assQuestion
53 {
54 return $this->question;
55 }
56
57 public function setQuestion(assQuestion $question): void
58 {
59 $this->question = $question;
60 }
61
63 {
64 return $this->assignment;
65 }
66
68 {
69 $this->assignment = $assignment;
70 }
71
72 public function isManipulationEnabled(): bool
73 {
75 }
76
78 {
79 $this->manipulation_enabled = $manipulation_enabled;
80 }
81
82 public function build(): void
83 {
84 $assignment = $this->getAssignment();
85 $this->ctrl->setParameter(
86 $this->parent_gui,
87 EditSkillsOfQuestionTableActions::FULL_ROW_ID_PARAMETER,
88 "{$assignment?->getQuestionId()}_{$assignment?->getSkillBaseId()}_{$assignment?->getSkillTrefId()}"
89 );
90 $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
91
92 if ($this->isManipulationEnabled()) {
93 $this->addCommandButton(
95 $this->lng->txt('save')
96 );
97
98 $this->addCommandButton(
100 $this->lng->txt('cancel')
101 );
102 } else {
103 $this->addCommandButton(
105 $this->lng->txt('back')
106 );
107 }
108
109 $this->setTitle($this->assignment->getSkillTitle());
110
111 $questionTitle = new ilNonEditableValueGUI($this->lng->txt('question'));
112 $questionTitle->setValue($this->question->getTitle());
113 $this->addItem($questionTitle);
114
115 $questionDesc = new ilNonEditableValueGUI($this->lng->txt('description'));
116 $questionDesc->setValue($this->question->getComment());
117 $this->addItem($questionDesc);
118
119 if ($this->questionSupportsSolutionCompare()) {
120 $this->populateFullProperties();
121 } else {
123 }
124 }
125
126 public function getHTML(): string
127 {
128 if ($this->legend_modal === null) {
129 return parent::getHTML();
130 }
131 return parent::getHTML() . $this->ui_renderer->render($this->legend_modal);
132 }
133
134 private function populateFullProperties(): void
135 {
136 $evaluation_mode = new ilRadioGroupInputGUI($this->lng->txt('condition'), 'eval_mode');
137 $eval_option_reached_pointsoints = new ilRadioOption(
138 $this->lng->txt('qpl_skill_point_eval_by_quest_result'),
139 'result'
140 );
141 $evaluation_mode->addOption($eval_option_reached_pointsoints);
142 $eval_option_logical_answer_compare = new ilRadioOption(
143 $this->lng->txt('qpl_skill_point_eval_by_solution_compare'),
144 'solution'
145 );
146 $evaluation_mode->addOption($eval_option_logical_answer_compare);
147 $evaluation_mode->setRequired(true);
148 $evaluation_mode->setValue($this->assignment->getEvalMode());
149 if (!$this->isManipulationEnabled()) {
150 $evaluation_mode->setDisabled(true);
151 }
152 $this->addItem($evaluation_mode);
153
154 $quest_solution_compare_expressions = new ilLogicalAnswerComparisonExpressionInputGUI(
155 $this->lng->txt('tst_solution_compare_cfg'),
156 'solution_compare_expressions'
157 );
158 $quest_solution_compare_expressions->setRequired(true);
159 $quest_solution_compare_expressions->setAllowMove($this->isManipulationEnabled());
160 $quest_solution_compare_expressions->setAllowAddRemove($this->isManipulationEnabled());
161 $quest_solution_compare_expressions->setQuestionObject($this->question);
162 $quest_solution_compare_expressions->setValues($this->assignment->getSolutionComparisonExpressionList()->get());
163 $quest_solution_compare_expressions->setMinvalueShouldBeGreater(false);
164 $quest_solution_compare_expressions->setMinValue(1);
165
166 if ($this->isManipulationEnabled()) {
167 if ($this->getQuestion() instanceof iQuestionCondition) {
168 // #19192
169 $legend_gui = new ilAssLacLegendGUI($this->global_tpl, $this->lng, $this->ui_factory);
170 $legend_gui->setQuestionOBJ($this->getQuestion());
171 $this->legend_modal = $legend_gui->get();
172
173 $legend_show_button = $this->ui_factory
174 ->button()
175 ->shy($this->lng->txt('ass_lac_show_legend_btn'), '#')
176 ->withOnClick($this->legend_modal->getShowSignal());
177
178 $quest_solution_compare_expressions->setInfo(
179 $this->ui_renderer->render($legend_show_button)
180 );
181 }
182 } else {
183 $quest_solution_compare_expressions->setDisabled(true);
184 }
185 $eval_option_logical_answer_compare->addSubItem($quest_solution_compare_expressions);
186
187 $eval_option_reached_pointsoints->addSubItem(
189 );
190 }
191
192 private function populateLimitedProperties(): void
193 {
194 $evaluationMode = new ilNonEditableValueGUI($this->lng->txt('condition'));
195 $evaluationMode->setValue($this->lng->txt('qpl_skill_point_eval_by_quest_result'));
196 $this->addItem($evaluationMode);
197
198 $questResultSkillPoints = $this->buildResultSkillPointsInputField();
199 $evaluationMode->addSubItem($questResultSkillPoints);
200 }
201
203 {
204 $questResultSkillPoints = new ilNumberInputGUI($this->lng->txt('tst_comp_points'), 'q_res_skill_points');
205 $questResultSkillPoints->setRequired(true);
206 $questResultSkillPoints->setSize(4);
207 $questResultSkillPoints->setMinvalueShouldBeGreater(false);
208 $questResultSkillPoints->setMinValue(1);
209 $questResultSkillPoints->allowDecimals(false);
210 $questResultSkillPoints->setValue((string) $this->assignment->getSkillPoints());
211
212 if (!$this->isManipulationEnabled()) {
213 $questResultSkillPoints->setDisabled(true);
214 }
215
216 return $questResultSkillPoints;
217 }
218
219 private function questionSupportsSolutionCompare(): bool
220 {
221 return (
222 $this->question instanceof iQuestionCondition
223 );
224 }
225}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
__construct(private readonly ilAssQuestionSkillAssignmentsGUI $parent_gui)
setFormAction(string $a_formaction)
This class represents a non editable value in a property form.
This class represents a number property in a property form.
This class represents a property form user interface.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
This class represents a property in a property form.
This class represents an option in a radio group.
This describes commonalities between the different modals.
Definition: Modal.php:35
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26