ILIAS  release_8 Revision v8.24
ilIndividualAssessmentUserGrading.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use ILIAS\Refinery\Factory as Refinery;
23use ILIAS\Data\Factory as DataFactory;
25
27{
28 protected string $name;
29 protected string $record;
30 protected string $internal_note;
31 protected ?string $file;
32 protected bool $is_file_visible;
33 protected int $learning_progress;
34 protected string $place;
35 protected ?DateTimeImmutable $event_time;
36 protected bool $notify;
37 protected bool $finalized;
38
39 public function __construct(
40 string $name,
41 string $record,
42 string $internal_note,
43 ?string $file,
46 string $place,
47 ?DateTimeImmutable $event_time,
48 bool $notify,
49 bool $finalized = false
50 ) {
51 $this->name = $name;
52 $this->record = $record;
53 $this->internal_note = $internal_note;
54 $this->file = $file;
55 $this->is_file_visible = $is_file_visible;
56 $this->learning_progress = $learning_progress;
57 $this->place = $place;
58 $this->event_time = $event_time;
59 $this->notify = $notify;
60 $this->finalized = $finalized;
61 }
62
63 public function getName(): string
64 {
65 return $this->name;
66 }
67
68 public function getRecord(): string
69 {
70 return $this->record;
71 }
72
73 public function getInternalNote(): string
74 {
76 }
77
78 public function getFile(): ?string
79 {
80 return $this->file;
81 }
82
83 public function hasFile(): bool
84 {
85 return !empty($this->file);
86 }
87
88 public function isFileVisible(): bool
89 {
91 }
92
93 public function getLearningProgress(): int
94 {
96 }
97
98 public function getPlace(): string
99 {
100 return $this->place;
101 }
102
103 public function getEventTime(): ?DateTimeImmutable
104 {
105 return $this->event_time;
106 }
107
108 public function isNotify(): bool
109 {
110 return $this->notify;
111 }
112
113 public function isFinalized(): bool
114 {
115 return $this->finalized;
116 }
117
118 public function withFinalized(bool $finalize): ilIndividualAssessmentUserGrading
119 {
120 $clone = clone $this;
121 $clone->finalized = $finalize;
122 return $clone;
123 }
124
126 {
127 $clone = clone $this;
128 $clone->file = $file;
129 return $clone;
130 }
131
132 public function toFormInput(
133 Field\Factory $input,
134 DataFactory $data_factory,
136 Refinery $refinery,
137 AbstractCtrlAwareUploadHandler $file_handler,
138 \ILIAS\Data\DateFormat\DateFormat $date_format,
139 array $grading_options,
140 bool $may_be_edited = true,
141 bool $place_required = false,
142 bool $amend = false
143 ): \ILIAS\UI\Component\Input\Container\Form\FormInput {
144 $name = $input
145 ->text($lng->txt('name'), '')
146 ->withDisabled(true)
147 ->withValue($this->getName())
148 ;
149
150 $record = $input
151 ->textarea($lng->txt('iass_record'), $lng->txt('iass_record_info'))
152 ->withValue($this->getRecord())
153 ->withDisabled(!$may_be_edited)
154 ;
155
156 $internal_note = $input
157 ->textarea($lng->txt('iass_internal_note'), $lng->txt('iass_internal_note_info'))
158 ->withValue($this->getInternalNote())
159 ->withDisabled(!$may_be_edited)
160 ;
161
162 $file = $input
163 ->file($file_handler, $lng->txt('iass_upload_file'), $lng->txt('iass_file_dropzone'))
164 ->withValue($this->hasFile() ? [$this->getFile()] : [])
165 ;
166
167 $file_visible = $input
168 ->checkbox($lng->txt('iass_file_visible_examinee'))
169 ->withValue($this->isFileVisible())
170 ->withDisabled(!$may_be_edited)
171 ;
172
173 $learning_progress = $input
174 ->select($lng->txt('grading'), $grading_options)
176 ->withDisabled(!$may_be_edited)
177 ->withRequired(true)
178 ;
179
180 $place = $input
181 ->text($lng->txt('iass_place'))
182 ->withValue($this->getPlace())
183 ->withRequired($place_required)
184 ->withDisabled(!$may_be_edited)
185 ;
186
187 $event_time = $input
188 ->dateTime($lng->txt('iass_event_time'))
189 ->withUseTime(true)
190 ->withFormat($date_format)
191 ->withRequired($place_required)
192 ->withDisabled(!$may_be_edited)
193 ;
194
195 if (!is_null($this->getEventTime())) {
196 $event_time = $event_time->withValue(
197 $this->getEventTime()->format($date_format->toString() . ' HH:mm')
198 );
199 }
200
201 $notify = $input
202 ->checkbox($lng->txt('iass_notify'), $lng->txt('iass_notify_explanation'))
203 ->withValue($this->isNotify())
204 ->withDisabled(!$may_be_edited)
205 ;
206
207 $fields = [
208 'name' => $name,
209 'record' => $record,
210 'internal_note' => $internal_note,
211 'file' => $file,
212 'file_visible' => $file_visible,
213 'learning_progress' => $learning_progress,
214 'place' => $place,
215 'event_time' => $event_time,
216 'notify' => $notify
217 ];
218
219 if (!$amend) {
220 $finalized = $input
221 ->checkbox($lng->txt('iass_finalize'), $lng->txt('iass_finalize_info'))
222 ->withValue($this->isFinalized())
223 ->withDisabled(!$may_be_edited)
224 ;
225
226 $fields['finalized'] = $finalized;
227 }
228
229 return $input->section(
230 $fields,
231 $lng->txt('iass_edit_record')
232 )->withAdditionalTransformation(
233 $refinery->custom()->transformation(function ($values) use ($amend) {
234 $finalized = $this->isFinalized();
235 if (!$amend) {
236 $finalized = $values['finalized'];
237 }
238
239 $file = null;
240 if (
241 isset($values['file'][0]) &&
242 trim($values['file'][0]) != ''
243 ) {
244 $file = $values['file'][0];
245 }
246
248 $values['name'],
249 $values['record'],
250 $values['internal_note'],
251 $file,
252 $values['file_visible'],
253 (int) $values['learning_progress'],
254 $values['place'],
255 $values['event_time'],
256 $values['notify'],
258 );
259 })
260 );
261 }
262}
static return function(ContainerConfigurator $containerConfigurator)
Definition: basic_rector.php:9
A Date Format provides a format definition akin to PHP's date formatting options, but stores the sing...
Definition: DateFormat.php:27
Builds data types.
Definition: Factory.php:21
return true
toFormInput(Field\Factory $input, DataFactory $data_factory, ilLanguage $lng, Refinery $refinery, AbstractCtrlAwareUploadHandler $file_handler, \ILIAS\Data\DateFormat\DateFormat $date_format, array $grading_options, bool $may_be_edited=true, bool $place_required=false, bool $amend=false)
__construct(string $name, string $record, string $internal_note, ?string $file, bool $is_file_visible, int $learning_progress, string $place, ?DateTimeImmutable $event_time, bool $notify, bool $finalized=false)
language handling
This describes inputs that can be used in forms.
Definition: FormInput.php:32
This is what a factory for input fields looks like.
Definition: Factory.php:29
This is a legacy support of Component\Input\Field\Input that has been moved to Component\Input\Contai...
Definition: Input.php:32
Refinery Factory $refinery
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Checkbox.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:59
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$lng