ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
GlobalTestSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\UI\Factory as UIFactory;
28
30{
31 public function __construct(
32 private ProcessLockModes $process_lock_mode = ProcessLockModes::ASS_PROC_LOCK_MODE_NONE,
33 private string $image_map_line_color = 'FF0000',
34 private UserIdentifiers $user_identifier = UserIdentifiers::USER_ID,
35 private int $skill_triggering_number_of_answers = 1,
36 private bool $export_essay_questions_as_html = false,
37 private array $disabled_question_types = [],
38 private bool $manual_scoring_enabled = false,
39 private bool $adjusting_questions_with_results_allowed = false,
40 private bool $page_editor_enabled = false
41 ) {
42 }
43
48 public function toForm(
49 UIFactory $ui_factory,
52 ): array {
53 $ff = $ui_factory->input()->field();
54 $all_question_types = \ilObjQuestionPool::_getQuestionTypes(true);
55 $enabled_question_types = array_map(
56 static fn(array $v): int => $v['question_type_id'],
57 array_filter(
58 $all_question_types,
59 fn(array $v): bool => !in_array($v['question_type_id'], $this->disabled_question_types)
60 )
61 );
62 $trafo = $this->buildGlobalSettingsBuilderTrafo($refinery, $all_question_types);
63
64 return [
65 'global_settings' => $ff->group([
66 'general_settings' => $this->buildGeneralSettingsInputs($ff, $refinery, $lng),
67 'question_settings' => $this->buildQuestionSettingsInputs(
68 $ff,
69 $lng,
70 $all_question_types,
71 $enabled_question_types
72 )
73 ])->withAdditionalTransformation($trafo)
74 ];
75 }
76
78 {
79 return $this->process_lock_mode;
80 }
81
82 public function withProcessLockMode(ProcessLockModes $process_lock_mode): self
83 {
84 $clone = clone $this;
85 $clone->process_lock_mode = $process_lock_mode;
86 return $clone;
87 }
88
89 public function getImageMapLineColor(): string
90 {
91 return $this->image_map_line_color;
92 }
93
94 public function withImageMapLineColor(string $image_map_line_color): self
95 {
96 $clone = clone $this;
97 $clone->image_map_line_color = $image_map_line_color;
98 return $clone;
99 }
100
102 {
103 return $this->user_identifier;
104 }
105
106 public function withUserIdentifier(UserIdentifiers $user_identifier): self
107 {
108 $clone = clone $this;
109 $clone->user_identifier = $user_identifier;
110 return $clone;
111 }
112
114 {
115 return $this->skill_triggering_number_of_answers;
116 }
117
118 public function withSkillTriggeringNumberOfAnswers(int $skill_triggering_number_of_answers): self
119 {
120 $clone = clone $this;
121 $clone->skill_triggering_number_of_answers = $skill_triggering_number_of_answers;
122 return $clone;
123 }
124
125 public function getExportEssayQuestionsAsHtml(): bool
126 {
127 return $this->export_essay_questions_as_html;
128 }
129
130 public function withExportEssayQuestionsAsHtml(bool $export_essay_questions_as_html): self
131 {
132 $clone = clone $this;
133 $clone->export_essay_questions_as_html = $export_essay_questions_as_html;
134 return $clone;
135 }
136
140 public function getDisabledQuestionTypes(): array
141 {
142 return $this->disabled_question_types;
143 }
144
148 public function withDisabledQuestionTypes(array $disabled_question_types): self
149 {
150 $clone = clone $this;
151 $clone->disabled_question_types = $disabled_question_types;
152 return $clone;
153 }
154
155 public function isManualScoringEnabled(): bool
156 {
157 return $this->manual_scoring_enabled;
158 }
159
160 public function withManualScoringEnabled(bool $manual_scoring_enabled): self
161 {
162 $clone = clone $this;
163 $clone->manual_scoring_enabled = $manual_scoring_enabled;
164 return $clone;
165 }
166
168 {
169 return $this->adjusting_questions_with_results_allowed;
170 }
171
172 public function withAdjustingQuestionsWithResultsAllowed(bool $adjusting_questions_with_results_allowed): self
173 {
174 $clone = clone $this;
175 $clone->adjusting_questions_with_results_allowed = $adjusting_questions_with_results_allowed;
176 return $clone;
177 }
178
179 public function isPageEditorEnabled(): bool
180 {
181 return $this->page_editor_enabled;
182 }
183
184 public function withPageEditorEnabled(bool $page_editor_enabled): self
185 {
186 $clone = clone $this;
187 $clone->page_editor_enabled = $page_editor_enabled;
188 return $clone;
189 }
190
193 array $all_question_types
194 ): Transformation {
195 return $refinery->custom()->transformation(
196 static function ($vs) use ($all_question_types): self {
197 $process_lock_mode = ProcessLockModes::ASS_PROC_LOCK_MODE_NONE;
198 if ($vs['general_settings']['process_lock_mode'] !== null) {
199 $process_lock_mode = ProcessLockModes::from($vs['general_settings']['process_lock_mode'][0]);
200 }
201 return new self(
202 $process_lock_mode,
203 substr($vs['general_settings']['image_map_line_color']->asHex(), 1),
204 UserIdentifiers::from($vs['general_settings']['user_identifier']),
205 $vs['general_settings']['skill_triggering_number_of_answers'],
206 $vs['general_settings']['export_essay_questions_as_html'],
207 array_reduce(
208 $all_question_types,
209 static function (array $c, array $v) use ($vs): array {
210 if (!in_array($v['question_type_id'], $vs['question_settings']['enabled_question_types'])) {
211 $c[] = $v['question_type_id'];
212 }
213 return $c;
214 },
215 []
216 ),
217 $vs['question_settings']['manual_scoring_enabled'],
218 $vs['question_settings']['adjusting_questions_with_results_allowed']
219 );
220 }
221 );
222 }
223
225 FieldFactory $ff,
228 ): Section {
229 return $ff->section(
230 [
231 'process_lock_mode' => $ff->optionalGroup(
232 [
233 $ff->radio($lng->txt('ass_process_lock_mode'))
234 ->withOption(
235 ProcessLockModes::ASS_PROC_LOCK_MODE_FILE->value,
236 $lng->txt('ass_process_lock_mode_file'),
237 $lng->txt('ass_process_lock_mode_file_desc')
238 )->withOption(
240 $lng->txt('ass_process_lock_mode_db'),
241 $lng->txt('ass_process_lock_mode_db_desc')
242 )
243 ],
244 $lng->txt('ass_process_lock')
245 )->withByline($lng->txt('ass_process_lock_desc'))
246 ->withValue($this->process_lock_mode === ProcessLockModes::ASS_PROC_LOCK_MODE_NONE ? null : [$this->process_lock_mode->value]),
247 'image_map_line_color' => $ff->colorSelect($lng->txt('imap_line_color'))
248 ->withValue('#' . $this->image_map_line_color),
249 'user_identifier' => $ff->select(
250 $lng->txt('user_criteria'),
251 array_reduce(
252 UserIdentifiers::cases(),
253 function (array $c, UserIdentifiers $v): array {
254 $c[$v->value] = $v->value;
255 return $c;
256 },
257 []
258 )
259 )->withRequired(true)
260 ->withByline($lng->txt('user_criteria_desc'))
261 ->withValue($this->user_identifier->value),
262 'skill_triggering_number_of_answers' => $ff->numeric($lng->txt('tst_skill_triggerings_num_req_answers'))
263 ->withAdditionalTransformation($refinery->int()->isGreaterThan(0))
264 ->withByline($lng->txt('tst_skill_triggerings_num_req_answers_desc'))
265 ->withValue($this->skill_triggering_number_of_answers),
266 'export_essay_questions_as_html' => $ff->checkbox($lng->txt('export_essay_qst_with_html'))
267 ->withByline($lng->txt('export_essay_qst_with_html_desc'))
268 ->withValue($this->export_essay_questions_as_html)
269 ],
270 $lng->txt('settings')
271 );
272 }
273
275 FieldFactory $ff,
277 array $all_question_types,
278 array $enabled_question_types
279 ): Section {
280 return $ff->section(
281 [
282 'enabled_question_types' => $ff->multiSelect(
283 $lng->txt('assf_allowed_questiontypes'),
284 array_reduce(
285 array_keys($all_question_types),
286 function (array $c, string $v) use ($all_question_types): array {
287 $c[$all_question_types[$v]['question_type_id']] = $v;
288 return $c;
289 },
290 []
291 )
292 )->withByline($lng->txt('assf_allowed_questiontypes_desc'))
293 ->withValue($enabled_question_types),
294 'manual_scoring_enabled' => $ff->checkbox($lng->txt('activate_manual_scoring'))
295 ->withByline($lng->txt('activate_manual_scoring_desc'))
296 ->withValue($this->isManualScoringEnabled()),
297 'adjusting_questions_with_results_allowed' => $ff->checkbox($lng->txt('assessment_scoring_adjust'))
298 ->withByline($lng->txt('assessment_scoring_adjust_desc'))
299 ->withValue($this->isAdjustingQuestionsWithResultsAllowed())
300 ],
301 $lng->txt('assf_questiontypes')
302 );
303 }
304}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
buildQuestionSettingsInputs(FieldFactory $ff, \ilLanguage $lng, array $all_question_types, array $enabled_question_types)
withProcessLockMode(ProcessLockModes $process_lock_mode)
toForm(UIFactory $ui_factory, Refinery $refinery, \ilLanguage $lng)
buildGlobalSettingsBuilderTrafo(Refinery $refinery, array $all_question_types)
withExportEssayQuestionsAsHtml(bool $export_essay_questions_as_html)
__construct(private ProcessLockModes $process_lock_mode=ProcessLockModes::ASS_PROC_LOCK_MODE_NONE, private string $image_map_line_color='FF0000', private UserIdentifiers $user_identifier=UserIdentifiers::USER_ID, private int $skill_triggering_number_of_answers=1, private bool $export_essay_questions_as_html=false, private array $disabled_question_types=[], private bool $manual_scoring_enabled=false, private bool $adjusting_questions_with_results_allowed=false, private bool $page_editor_enabled=false)
withAdjustingQuestionsWithResultsAllowed(bool $adjusting_questions_with_results_allowed)
withSkillTriggeringNumberOfAnswers(int $skill_triggering_number_of_answers)
buildGeneralSettingsInputs(FieldFactory $ff, Refinery $refinery, \ilLanguage $lng)
language handling
static _getQuestionTypes($all_tags=false, $fixOrder=false, $withDeprecatedTypes=true)
$c
Definition: deliver.php:25
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A transformation is a function from one datatype to another.
This is what a factory for input fields looks like.
Definition: Factory.php:31
This describes section inputs.
Definition: Section.php:29
withAdditionalTransformation(Transformation $trafo)
@inheritDoc
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
global $lng
Definition: privfeed.php:31