ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SettingsResultDetails.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
28use ILIAS\Refinery\Factory as Refinery;
29
31{
41
42 protected bool $examid_in_test_res = true;
43 protected int $exportsettings = 0;
44 protected int $results_presentation = 0;
45
46
47 public function __construct(int $test_id)
48 {
50 }
51
52 public function toForm(
54 FieldFactory $f,
56 ?array $environment = null
57 ): FormInput {
58 $fields = [
59 'solution_best_solution' =>
60 $f->checkbox(
61 $lng->txt('tst_results_print_best_solution'),
62 $lng->txt('tst_results_print_best_solution_info')
64 'solution_feedback' => $f->checkbox(
65 $lng->txt('tst_show_solution_feedback'),
66 $lng->txt('tst_show_solution_feedback_desc')
68 'solution_suggested' => $f->checkbox(
69 $lng->txt('tst_show_solution_suggested'),
70 $lng->txt('tst_show_solution_suggested_desc')
72 'solution_printview' => $f->checkbox(
73 $lng->txt('tst_show_solution_printview'),
74 $lng->txt('tst_show_solution_printview_desc')
76 'solution_hide_page' => $f->checkbox(
77 $lng->txt('tst_hide_pagecontents'),
78 $lng->txt('tst_hide_pagecontents_desc')
80
81 'solution_signature' => $f->checkbox(
82 $lng->txt('tst_show_solution_signature'),
83 $lng->txt('tst_show_solution_signature_desc')
84 )
86 //TODO ?->withDisabled($anonymity)
87 ,
88 'examid_in_test_res' => $f->checkbox(
89 $lng->txt('examid_in_test_res'),
90 $lng->txt('examid_in_test_res_desc')
92 ];
93
94 return $f->section($fields, $lng->txt('tst_results_details_options'))
95 ->withAdditionalTransformation(
96 $refinery->custom()->transformation(
97 function ($v) {
98 return (clone $this)
99 ->withShowSolutionListComparison($v['solution_best_solution'])
100 ->withShowSolutionFeedback($v['solution_feedback'])
101 ->withShowSolutionSuggested($v['solution_suggested'])
102 ->withShowSolutionPrintview($v['solution_printview'])
103 ->withShowSolutionAnswersOnly($v['solution_hide_page'])
104 ->withShowSolutionSignature($v['solution_signature'])
105 ->withShowExamIdInTestResults($v["examid_in_test_res"]);
106 }
107 )
108 );
109 }
110
111 public function toStorage(): array
112 {
113 return [
114 'results_presentation' => ['integer', $this->getResultsPresentation()],
115 'examid_in_test_res' => ['integer', (int) $this->getShowExamIdInTestResults()],
116 'exportsettings' => ['integer', $this->getExportSettings()]
117 ];
118 }
119
120 public function toLog(AdditionalInformationGenerator $additional_info): array
121 {
122 return [
124 ->getEnabledDisabledTagForBool($this->getShowSolutionListComparison()),
126 ->getEnabledDisabledTagForBool($this->getShowSolutionFeedback()),
128 ->getEnabledDisabledTagForBool($this->getShowSolutionSuggested()),
130 ->getEnabledDisabledTagForBool($this->getShowSolutionPrintview()),
132 ->getEnabledDisabledTagForBool($this->getShowSolutionAnswersOnly()),
134 ->getEnabledDisabledTagForBool($this->getShowSolutionSignature()),
136 ->getEnabledDisabledTagForBool($this->getShowExamIdInTestResults())
137 ];
138 }
139
140 public function getResultsPresentation(): int
141 {
142 return $this->results_presentation;
143 }
144 public function withResultsPresentation(int $results_presentation): self
145 {
146 $clone = clone $this;
147 $clone->results_presentation = $results_presentation;
148 return $clone;
149 }
150
151 public function getShowExamIdInTestResults(): bool
152 {
153 return $this->examid_in_test_res;
154 }
155 public function withShowExamIdInTestResults(bool $examid_in_test_res): self
156 {
157 $clone = clone $this;
158 $clone->examid_in_test_res = $examid_in_test_res;
159 return $clone;
160 }
161
162 protected function compareResultPresentation(int $bit): bool
163 {
164 return ($this->results_presentation & $bit) > 0;
165 }
166 protected function modifyResultPresentation(int $bit, bool $flag): self
167 {
168 $clone = clone $this;
169 $v = $clone->results_presentation;
170
171 if ($flag) {
172 $v = $v | $bit;
173 } else {
174 if ($this->compareResultPresentation($bit)) {
175 $v = $v ^ $bit;
176 }
177 }
178 $clone->results_presentation = $v;
179 return $clone;
180 }
181
182 public function getShowPassDetails(): bool
183 {
184 return $this->compareResultPresentation(self::RESULTPRES_BIT_PASS_DETAILS);
185 }
186 public function withShowPassDetails(bool $flag): self
187 {
188 return $this->modifyResultPresentation(self::RESULTPRES_BIT_PASS_DETAILS, $flag);
189 }
190
191 public function getShowSolutionPrintview(): bool
192 {
193 return $this->compareResultPresentation(self::RESULTPRES_BIT_SOLUTION_PRINTVIEW);
194 }
195 public function withShowSolutionPrintview(bool $flag): self
196 {
197 return $this->modifyResultPresentation(self::RESULTPRES_BIT_SOLUTION_PRINTVIEW, $flag);
198 }
199
200 public function getShowSolutionFeedback(): bool
201 {
202 return $this->compareResultPresentation(self::RESULTPRES_BIT_SOLUTION_FEEDBACK);
203 }
204 public function withShowSolutionFeedback(bool $flag): self
205 {
206 return $this->modifyResultPresentation(self::RESULTPRES_BIT_SOLUTION_FEEDBACK, $flag);
207 }
208
209 public function getShowSolutionAnswersOnly(): bool
210 {
211 return $this->compareResultPresentation(self::RESULTPRES_BIT_SOLUTION_ANSWERS_ONLY);
212 }
213 public function withShowSolutionAnswersOnly(bool $flag): self
214 {
215 return $this->modifyResultPresentation(self::RESULTPRES_BIT_SOLUTION_ANSWERS_ONLY, $flag);
216 }
217
218 public function getShowSolutionSignature(): bool
219 {
220 return $this->compareResultPresentation(self::RESULTPRES_BIT_SOLUTION_SIGNATURE);
221 }
222 public function withShowSolutionSignature(bool $flag): self
223 {
224 return $this->modifyResultPresentation(self::RESULTPRES_BIT_SOLUTION_SIGNATURE, $flag);
225 }
226
227 public function getShowSolutionSuggested(): bool
228 {
229 return $this->compareResultPresentation(self::RESULTPRES_BIT_SOLUTION_SUGGESTED);
230 }
231 public function withShowSolutionSuggested(bool $flag): self
232 {
233 return $this->modifyResultPresentation(self::RESULTPRES_BIT_SOLUTION_SUGGESTED, $flag);
234 }
235
236 public function getShowSolutionListComparison(): bool
237 {
238 return $this->compareResultPresentation(self::RESULTPRES_BIT_SOLUTION_LISTCOMPARE);
239 }
240 public function withShowSolutionListComparison(bool $flag): self
241 {
242 return $this->modifyResultPresentation(self::RESULTPRES_BIT_SOLUTION_LISTCOMPARE, $flag);
243 }
244
245 public function getExportSettings(): int
246 {
247 return $this->exportsettings;
248 }
249 public function withExportSettings(int $exportsettings): self
250 {
251 $clone = clone $this;
252 $clone->exportsettings = $exportsettings;
253 return $clone;
254 }
255 protected function compareExportSetting(int $bit): bool
256 {
257 return ($this->exportsettings & $bit) > 0;
258 }
259 protected function modifyExportSetting(int $bit, bool $flag): self
260 {
261 $clone = clone $this;
262 $v = $clone->exportsettings;
263
264 if ($flag) {
265 $v = $v | $bit;
266 } else {
267 if ($this->compareExportSetting($bit)) {
268 $v = $v ^ $bit;
269 }
270 }
271 $clone->exportsettings = $v;
272 return $clone;
273 }
274}
Builds data types.
Definition: Factory.php:36
toLog(AdditionalInformationGenerator $additional_info)
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
language handling
This describes inputs that can be used in forms.
Definition: FormInput.php:33
This is what a factory for input fields looks like.
Definition: Factory.php:31
__construct(Container $dic, ilPlugin $plugin)
@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