ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilIndividualAssessmentUserGrading.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 2020 Daniel Weise <daniel.weise@concepts-and-training.de> Extended GPL, see docs/LICENSE */
3
4declare(strict_types=1);
5
6use \ILIAS\UI\Component\Input\Field;
7use \ILIAS\Refinery\Factory as Refinery;
8
10{
14 protected $name;
15
19 protected $record;
20
24 protected $internal_note;
25
29 protected $file;
30
35
40
44 protected $place;
45
49 protected $event_time;
50
54 protected $notify;
55
59 protected $finalized;
60
61 public function __construct(
62 string $name,
63 string $record,
64 string $internal_note,
65 ?string $file,
68 string $place,
69 ?DateTimeImmutable $event_time,
70 bool $notify,
71 bool $finalized = false
72 ) {
73 $this->name = $name;
74 $this->record = $record;
75 $this->internal_note = $internal_note;
76 $this->file = $file;
77 $this->is_file_visible = $is_file_visible;
78 $this->learning_progress = $learning_progress;
79 $this->place = $place;
80 $this->event_time = $event_time;
81 $this->notify = $notify;
82 $this->finalized = $finalized;
83 }
84
85 public function getName() : string
86 {
87 return $this->name;
88 }
89
90 public function getRecord() : string
91 {
92 return $this->record;
93 }
94
95 public function getInternalNote() : string
96 {
98 }
99
100 public function getFile() : ?string
101 {
102 return $this->file;
103 }
104
105 public function hasFile(): bool
106 {
107 return !empty($this->file);
108 }
109
110 public function isFileVisible() : bool
111 {
113 }
114
115 public function getLearningProgress() : int
116 {
118 }
119
120 public function getPlace() : string
121 {
122 return $this->place;
123 }
124
125 public function getEventTime() : ?DateTimeImmutable
126 {
127 return $this->event_time;
128 }
129
130 public function isNotify() : bool
131 {
132 return $this->notify;
133 }
134
135 public function isFinalized() : bool
136 {
137 return $this->finalized;
138 }
139
140 public function withFinalized(bool $finalize) : ilIndividualAssessmentUserGrading
141 {
142 $clone = clone $this;
143 $clone->finalized = $finalize;
144 return $clone;
145 }
146
148 {
149 $clone = clone $this;
150 $clone->file = $file;
151 return $clone;
152 }
153
154 public function toFormInput(
155 Field\Factory $input,
157 Refinery $refinery,
158 array $grading_options,
159 bool $may_be_edited = true,
160 bool $place_required = false,
161 bool $amend = false,
163 ) : Field\Input {
164 $name = $input
165 ->text($lng->txt('name'), '')
166 ->withDisabled(true)
167 ->withValue($this->getName())
168 ;
169
170 $record = $input
171 ->textarea($lng->txt('iass_record'), $lng->txt('iass_record_info'))
172 ->withValue($this->getRecord())
173 ->withDisabled(!$may_be_edited)
174 ;
175
176 $internal_note = $input
177 ->textarea($lng->txt('iass_internal_note'), $lng->txt('iass_internal_note_info'))
178 ->withValue($this->getInternalNote())
179 ->withDisabled(!$may_be_edited)
180 ;
181
182 $file = $input
183 ->file($file_handler, $lng->txt('iass_upload_file'), $lng->txt('iass_file_dropzone'))
184 ->withValue($this->hasFile() ? [$this->getFile()] : null)
185 ;
186
187 $file_visible = $input
188 ->checkbox($lng->txt('iass_file_visible_examinee'))
189 ->withValue($this->isFileVisible())
190 ->withDisabled(!$may_be_edited)
191 ;
192
193 $learning_progress = $input
194 ->select($lng->txt('grading'), $grading_options)
196 ->withDisabled(!$may_be_edited)
197 ->withRequired(true)
198 ;
199
200 $place = $input
201 ->text($lng->txt('iass_place'))
202 ->withValue($this->getPlace())
203 ->withRequired($place_required)
204 ->withDisabled(!$may_be_edited)
205 ;
206
207 $event_time = $input
208 ->dateTime($lng->txt('iass_event_time'))
209 ->withRequired($place_required)
210 ->withDisabled(!$may_be_edited)
211 ;
212
213 if (!is_null($this->getEventTime())) {
214 $event_time = $event_time->withValue($this->getEventTime()->format('d-m-Y'));
215 }
216
217 $notify = $input
218 ->checkbox($lng->txt('iass_notify'), $lng->txt('iass_notify_explanation'))
219 ->withValue($this->isNotify())
220 ->withDisabled(!$may_be_edited)
221 ;
222
223 $fields = [
224 'name' => $name,
225 'record' => $record,
226 'internal_note' => $internal_note,
227 'file' => $file,
228 'file_visible' => $file_visible,
229 'learning_progress' => $learning_progress,
230 'place' => $place,
231 'event_time' => $event_time,
232 'notify' => $notify
233 ];
234
235 if (!$amend) {
236 $finalized = $input
237 ->checkbox($lng->txt('iass_finalize'), $lng->txt('iass_finalize_info'))
238 ->withValue($this->isFinalized())
239 ->withDisabled(!$may_be_edited)
240 ;
241
242 $fields['finalized'] = $finalized;
243 }
244
245 return $input->section(
246 $fields,
247 $lng->txt('iass_edit_record')
248 )->withAdditionalTransformation(
249 $refinery->custom()->transformation(function ($values) use ($amend) {
250 $finalized = $this->isFinalized();
251 if (!$amend) {
252 $finalized = $values['finalized'];
253 }
254
255 $file = $this->getFile();
256 if (
257 isset($values['file'][0]) &&
258 trim($values['file'][0]) != ''
259 ) {
260 $file = $values['file'][0];
261 }
262
264 $values['name'],
265 $values['record'],
266 $values['internal_note'],
267 $file,
268 $values['file_visible'],
269 (int) $values['learning_progress'],
270 $values['place'],
271 $values['event_time'],
272 $values['notify'],
274 );
275 })
276 );
277 }
278}
An exception for terminatinating execution or to throw for unit testing.
__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)
toFormInput(Field\Factory $input, \ilLanguage $lng, Refinery $refinery, array $grading_options, bool $may_be_edited=true, bool $place_required=false, bool $amend=false, ilIndividualAssessmentMemberGUI $file_handler)
language handling
This is what a factory for input fields looks like.
Definition: Factory.php:11
This describes commonalities between all inputs.
Definition: Input.php:32
$lng