ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAssQuestionSkillAssignmentPropertyFormGUI.php
Go to the documentation of this file.
1 <?php
2 
28 {
30  private $pageTemplate;
32  private $parentGUI;
34  private $question = null;
36  private $assignment = null;
38  private $manipulationEnabled = false;
40  private $uiFactory;
42  private $uiRenderer;
43 
44  public function __construct(
46  ilCtrl $ctrl,
49  ) {
50  global $DIC;
51 
52  $this->pageTemplate = $pageTemplate;
53  $this->ctrl = $ctrl;
54  $this->lng = $lng;
55  $this->parentGUI = $parentGUI;
56  $this->uiFactory = $DIC->ui()->factory();
57  $this->uiRenderer = $DIC->ui()->renderer();
58 
60  }
61 
65  public function getQuestion(): ?assQuestion
66  {
67  return $this->question;
68  }
69 
73  public function setQuestion($question): void
74  {
75  $this->question = $question;
76  }
77 
82  {
83  return $this->assignment;
84  }
85 
89  public function setAssignment($assignment): void
90  {
91  $this->assignment = $assignment;
92  }
93 
97  public function isManipulationEnabled(): bool
98  {
100  }
101 
106  {
107  $this->manipulationEnabled = $manipulationEnabled;
108  }
109 
110  public function build(): void
111  {
112  $this->setFormAction($this->ctrl->getFormAction($this->parentGUI));
113 
114  if ($this->isManipulationEnabled()) {
115  $this->addCommandButton(
117  $this->lng->txt('save')
118  );
119 
120  $this->addCommandButton(
122  $this->lng->txt('cancel')
123  );
124  } else {
125  $this->addCommandButton(
127  $this->lng->txt('back')
128  );
129  }
130 
131  $this->setTitle($this->assignment->getSkillTitle());
132 
133  $questionTitle = new ilNonEditableValueGUI($this->lng->txt('question'));
134  $questionTitle->setValue($this->question->getTitle());
135  $this->addItem($questionTitle);
136 
137  $questionDesc = new ilNonEditableValueGUI($this->lng->txt('description'));
138  $questionDesc->setValue($this->question->getComment());
139  $this->addItem($questionDesc);
140 
141  if ($this->questionSupportsSolutionCompare()) {
142  $this->populateFullProperties();
143  } else {
144  $this->populateLimitedProperties();
145  }
146  }
147 
148  private function populateFullProperties(): void
149  {
150  $evaluationMode = new ilRadioGroupInputGUI($this->lng->txt('condition'), 'eval_mode');
151  $evalOptionReachedQuestionPoints = new ilRadioOption(
152  $this->lng->txt('qpl_skill_point_eval_by_quest_result'),
153  'result'
154  );
155  $evaluationMode->addOption($evalOptionReachedQuestionPoints);
156  $evalOptionLogicalAnswerCompare = new ilRadioOption(
157  $this->lng->txt('qpl_skill_point_eval_by_solution_compare'),
158  'solution'
159  );
160  $evaluationMode->addOption($evalOptionLogicalAnswerCompare);
161  $evaluationMode->setRequired(true);
162  $evaluationMode->setValue($this->assignment->getEvalMode());
163  if (!$this->isManipulationEnabled()) {
164  $evaluationMode->setDisabled(true);
165  }
166  $this->addItem($evaluationMode);
167 
168  $questSolutionCompareExpressions = new ilLogicalAnswerComparisonExpressionInputGUI(
169  $this->lng->txt('tst_solution_compare_cfg'),
170  'solution_compare_expressions'
171  );
172  $questSolutionCompareExpressions->setRequired(true);
173  $questSolutionCompareExpressions->setAllowMove($this->isManipulationEnabled());
174  $questSolutionCompareExpressions->setAllowAddRemove($this->isManipulationEnabled());
175  $questSolutionCompareExpressions->setQuestionObject($this->question);
176  $questSolutionCompareExpressions->setValues($this->assignment->getSolutionComparisonExpressionList()->get());
177  $questSolutionCompareExpressions->setMinvalueShouldBeGreater(false);
178 
179  $questSolutionCompareExpressions->setMinValue(1);
180  if ($this->isManipulationEnabled()) {
181  if ($this->getQuestion() instanceof iQuestionCondition) {
182  // #19192
183  $legendGUI = new ilAssLacLegendGUI($this->pageTemplate, $this->lng, $this->uiFactory);
184  $legendGUI->setQuestionOBJ($this->getQuestion());
185  $legenModal = $legendGUI->get();
186 
187  $legendToggleButton = $this->uiFactory
188  ->button()
189  ->shy($this->lng->txt('ass_lac_show_legend_btn'), '#')
190  ->withOnClick($legenModal->getShowSignal());
191 
192  $questSolutionCompareExpressions->setInfo($this->uiRenderer->render([
193  $legendToggleButton,
194  $legenModal
195  ]));
196  }
197  } else {
198  $questSolutionCompareExpressions->setDisabled(true);
199  }
200  $evalOptionLogicalAnswerCompare->addSubItem($questSolutionCompareExpressions);
201 
202  $questResultSkillPoints = $this->buildResultSkillPointsInputField();
203  $evalOptionReachedQuestionPoints->addSubItem($questResultSkillPoints);
204  }
205 
206  private function populateLimitedProperties(): void
207  {
208  $evaluationMode = new ilNonEditableValueGUI($this->lng->txt('condition'));
209  $evaluationMode->setValue($this->lng->txt('qpl_skill_point_eval_by_quest_result'));
210  $this->addItem($evaluationMode);
211 
212  $questResultSkillPoints = $this->buildResultSkillPointsInputField();
213  $evaluationMode->addSubItem($questResultSkillPoints);
214  }
215 
217  {
218  $questResultSkillPoints = new ilNumberInputGUI($this->lng->txt('tst_comp_points'), 'q_res_skill_points');
219  $questResultSkillPoints->setRequired(true);
220  $questResultSkillPoints->setSize(4);
221  $questResultSkillPoints->setMinvalueShouldBeGreater(false);
222  $questResultSkillPoints->setMinValue(1);
223  $questResultSkillPoints->allowDecimals(false);
224  $questResultSkillPoints->setValue($this->assignment->getSkillPoints());
225  if (!$this->isManipulationEnabled()) {
226  $questResultSkillPoints->setDisabled(true);
227  }
228 
229  return $questResultSkillPoints;
230  }
231 
232  private function questionSupportsSolutionCompare(): bool
233  {
234  return (
235  $this->question instanceof iQuestionCondition
236  );
237  }
238 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Abstract basic class which is to be extended by the concrete assessment question type classes...
global $DIC
Definition: feed.php:28
This class represents a property in a property form.
setFormAction(string $a_formaction)
This class represents a number property in a property form.
setValue(string $a_value)
setRequired(bool $a_required)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
__construct(ilGlobalTemplateInterface $pageTemplate, ilCtrl $ctrl, ilLanguage $lng, ilAssQuestionSkillAssignmentsGUI $parentGUI)