ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssQuestionSkillAssignmentPropertyFormGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use ILIAS\UI\Factory as UIFactory;
23use ILIAS\UI\Renderer as UIRenderer;
24
34{
35 private ?assQuestion $question = null;
37 private bool $manipulation_enabled = false;
38 private UIFactory $ui_factory;
39 private UIRenderer $ui_renderer;
40 private ?Modal $legend_modal = null;
41
42 public function __construct(
43 private readonly ilAssQuestionSkillAssignmentsGUI $parent_gui
44 ) {
45 global $DIC;
46 $this->ui_factory = $DIC['ui.factory'];
47 $this->ui_renderer = $DIC['ui.renderer'];
49 }
50
51 public function getQuestion(): ?assQuestion
52 {
53 return $this->question;
54 }
55
56 public function setQuestion(assQuestion $question): void
57 {
58 $this->question = $question;
59 }
60
62 {
63 return $this->assignment;
64 }
65
67 {
68 $this->assignment = $assignment;
69 }
70
71 public function isManipulationEnabled(): bool
72 {
74 }
75
77 {
78 $this->manipulation_enabled = $manipulation_enabled;
79 }
80
81 public function build(): void
82 {
83 $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
84
85 if ($this->isManipulationEnabled()) {
86 $this->addCommandButton(
88 $this->lng->txt('save')
89 );
90
91 $this->addCommandButton(
93 $this->lng->txt('cancel')
94 );
95 } else {
96 $this->addCommandButton(
98 $this->lng->txt('back')
99 );
100 }
101
102 $this->setTitle($this->assignment->getSkillTitle());
103
104 $questionTitle = new ilNonEditableValueGUI($this->lng->txt('question'));
105 $questionTitle->setValue($this->question->getTitle());
106 $this->addItem($questionTitle);
107
108 $questionDesc = new ilNonEditableValueGUI($this->lng->txt('description'));
109 $questionDesc->setValue($this->question->getComment());
110 $this->addItem($questionDesc);
111
112 if ($this->questionSupportsSolutionCompare()) {
113 $this->populateFullProperties();
114 } else {
116 }
117 }
118
119 public function getHTML(): string
120 {
121 if ($this->legend_modal === null) {
122 return parent::getHTML();
123 }
124 return parent::getHTML() . $this->ui_renderer->render($this->legend_modal);
125 }
126
127 private function populateFullProperties(): void
128 {
129 $evaluation_mode = new ilRadioGroupInputGUI($this->lng->txt('condition'), 'eval_mode');
130 $eval_option_reached_pointsoints = new ilRadioOption(
131 $this->lng->txt('qpl_skill_point_eval_by_quest_result'),
132 'result'
133 );
134 $evaluation_mode->addOption($eval_option_reached_pointsoints);
135 $eval_option_logical_answer_compare = new ilRadioOption(
136 $this->lng->txt('qpl_skill_point_eval_by_solution_compare'),
137 'solution'
138 );
139 $evaluation_mode->addOption($eval_option_logical_answer_compare);
140 $evaluation_mode->setRequired(true);
141 $evaluation_mode->setValue($this->assignment->getEvalMode());
142 if (!$this->isManipulationEnabled()) {
143 $evaluation_mode->setDisabled(true);
144 }
145 $this->addItem($evaluation_mode);
146
147 $quest_solution_compare_expressions = new ilLogicalAnswerComparisonExpressionInputGUI(
148 $this->lng->txt('tst_solution_compare_cfg'),
149 'solution_compare_expressions'
150 );
151 $quest_solution_compare_expressions->setRequired(true);
152 $quest_solution_compare_expressions->setAllowMove($this->isManipulationEnabled());
153 $quest_solution_compare_expressions->setAllowAddRemove($this->isManipulationEnabled());
154 $quest_solution_compare_expressions->setQuestionObject($this->question);
155 $quest_solution_compare_expressions->setValues($this->assignment->getSolutionComparisonExpressionList()->get());
156 $quest_solution_compare_expressions->setMinvalueShouldBeGreater(false);
157 $quest_solution_compare_expressions->setMinValue(1);
158
159 if ($this->isManipulationEnabled()) {
160 if ($this->getQuestion() instanceof iQuestionCondition) {
161 // #19192
162 $legend_gui = new ilAssLacLegendGUI($this->global_tpl, $this->lng, $this->ui_factory);
163 $legend_gui->setQuestionOBJ($this->getQuestion());
164 $this->legend_modal = $legend_gui->get();
165
166 $legend_show_button = $this->ui_factory
167 ->button()
168 ->shy($this->lng->txt('ass_lac_show_legend_btn'), '#')
169 ->withOnClick($this->legend_modal->getShowSignal());
170
171 $quest_solution_compare_expressions->setInfo(
172 $this->ui_renderer->render($legend_show_button)
173 );
174 }
175 } else {
176 $quest_solution_compare_expressions->setDisabled(true);
177 }
178 $eval_option_logical_answer_compare->addSubItem($quest_solution_compare_expressions);
179
180 $eval_option_reached_pointsoints->addSubItem(
182 );
183 }
184
185 private function populateLimitedProperties(): void
186 {
187 $evaluationMode = new ilNonEditableValueGUI($this->lng->txt('condition'));
188 $evaluationMode->setValue($this->lng->txt('qpl_skill_point_eval_by_quest_result'));
189 $this->addItem($evaluationMode);
190
191 $questResultSkillPoints = $this->buildResultSkillPointsInputField();
192 $evaluationMode->addSubItem($questResultSkillPoints);
193 }
194
196 {
197 $questResultSkillPoints = new ilNumberInputGUI($this->lng->txt('tst_comp_points'), 'q_res_skill_points');
198 $questResultSkillPoints->setRequired(true);
199 $questResultSkillPoints->setSize(4);
200 $questResultSkillPoints->setMinvalueShouldBeGreater(false);
201 $questResultSkillPoints->setMinValue(1);
202 $questResultSkillPoints->allowDecimals(false);
203 $questResultSkillPoints->setValue((string) $this->assignment->getSkillPoints());
204 if (!$this->isManipulationEnabled()) {
205 $questResultSkillPoints->setDisabled(true);
206 }
207
208 return $questResultSkillPoints;
209 }
210
211 private function questionSupportsSolutionCompare(): bool
212 {
213 return (
214 $this->question instanceof iQuestionCondition
215 );
216 }
217}
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