19 declare(strict_types=1);
37 protected bool $start_time_enabled =
false,
39 protected bool $end_time_enabled =
false,
41 protected bool $password_enabled =
false,
42 protected ?
string $password =
null,
43 protected ?
string $ip_range_from =
null,
44 protected ?
string $ip_range_to =
null,
45 protected bool $fixed_participants =
false 54 ?array $environment =
null 60 $inputs[
'fixed_participants_enabled'] = $f->checkbox(
61 $lng->
txt(
'participants_invitation'),
62 $lng->
txt(
'participants_invitation_description')
64 if ($environment[
'participant_data_exists']) {
65 $inputs[
'fixed_participants_enabled'] =
$inputs[
'fixed_participants_enabled']
69 return $f->section(
$inputs, $lng->
txt(
'tst_settings_header_execution'));
76 ?array $environment =
null 78 $constraint = $refinery->custom()->constraint(
79 static fn(array $vs) =>
80 $vs[
'start_time'] ===
null || $vs[
'end_time'] ===
null || $vs[
'start_time'] < $vs[
'end_time'],
81 $lng->
txt(
'duration_end_must_not_be_earlier_than_start')
84 $trafo = $refinery->custom()->transformation(
85 static function (array $vs): array {
86 $vs[
'start_time_enabled'] = $vs[
'start_time'] !==
null;
87 $vs[
'end_time_enabled'] = $vs[
'end_time'] !==
null;
93 ->withAdditionalTransformation($constraint)
94 ->withAdditionalTransformation($trafo);
102 $sub_inputs_access_window[
'start_time'] = $f->dateTime(
103 $lng->
txt(
'tst_starting_time'),
104 $lng->
txt(
'tst_starting_time_desc')
105 )->withTimezone($environment[
'user_time_zone'])
106 ->withFormat($environment[
'user_date_format'])
109 $sub_inputs_access_window[
'start_time'] = $sub_inputs_access_window[
'start_time']
112 if ($environment[
'participant_data_exists']) {
113 $sub_inputs_access_window[
'start_time'] = $sub_inputs_access_window[
'start_time']->withDisabled(
true);
116 $sub_inputs_access_window[
'end_time'] = $f->dateTime(
117 $lng->
txt(
'tst_ending_time'),
118 $lng->
txt(
'tst_ending_time_desc')
119 )->withTimezone($environment[
'user_time_zone'])
120 ->withFormat($environment[
'user_date_format'])
123 $sub_inputs_access_window[
'end_time'] = $sub_inputs_access_window[
'end_time']
127 return $sub_inputs_access_window;
135 $trafo = $refinery->custom()->transformation(
136 static function (?array $vs): array {
139 'password_enabled' =>
false,
140 'password_value' =>
null 144 $vs[
'password_enabled'] =
true;
149 $sub_inputs_password[
'password_value'] = $f->text($lng->
txt(
'tst_password_enter'))
150 ->withRequired(
true)->withMaxLength(self::MAX_PASSWORD_LENGTH);
152 $password_input = $f->optionalGroup(
153 $sub_inputs_password,
154 $lng->
txt(
'tst_password'),
155 $lng->
txt(
'tst_password_details')
157 ->withAdditionalTransformation($trafo);
160 return $password_input;
163 return $password_input->withValue(
173 $validate_ip = $refinery->custom()->constraint(
174 static function (?
string $v):
bool {
178 return filter_var($v, FILTER_VALIDATE_IP) !==
false;
180 $lng->
txt(
'invalid_ip')
183 $validate_order = $refinery->custom()->constraint(
184 function (?array $vs):
bool {
189 $vs[
'ip_range_from'],
193 sprintf($lng->
txt(
'not_greater_than'), $lng->
txt(
'max_ip_label'), $lng->
txt(
'min_ip_label'))
195 $trafo = $refinery->custom()->transformation(
196 static function (?array $vs): array {
199 'ip_range_from' =>
null,
200 'ip_range_to' =>
null 207 $get_ip_range = $f->optionalGroup(
209 'ip_range_from' => $f->text($lng->
txt(
'min_ip_label'))
211 'ip_range_to' => $f->text($lng->
txt(
'max_ip_label'))
214 $lng->
txt(
'ip_range_label'),
215 $lng->
txt(
'ip_range_info')
219 $get_ip_range = $get_ip_range->withValue(
227 return $get_ip_range->withAdditionalTransformation($validate_order)
228 ->withAdditionalTransformation($trafo);
233 if (filter_var($start, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !==
false 234 && filter_var($end, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !==
false) {
235 return ip2long($start) <= ip2long($end);
238 if (filter_var($start, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !==
false 239 && filter_var($end, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !==
false) {
240 return bin2hex(inet_pton($start)) <= bin2hex(inet_pton($end));
262 $starting_time = $additional_info->
getNoneTag();
268 if (($et_immutable = $this->
getEndTime()) instanceof \DateTimeImmutable) {
286 return $this->start_time_enabled;
290 $clone = clone $this;
291 $clone->start_time_enabled = $start_time_enabled;
297 return $this->start_time;
301 $clone = clone $this;
302 $clone->start_time = $start_time;
308 return $this->end_time_enabled;
312 $clone = clone $this;
313 $clone->end_time_enabled = $end_time_enabled;
319 return $this->end_time;
323 $clone = clone $this;
324 $clone->end_time = $end_time;
330 return $this->password_enabled;
334 $clone = clone $this;
335 $clone->password_enabled = $password_enabled;
341 return $this->password;
345 $clone = clone $this;
346 $clone->password = $password;
352 return $this->ip_range_from;
356 $clone = clone $this;
357 $clone->ip_range_from = $ip_range_from;
363 return $this->ip_range_to;
367 $clone = clone $this;
368 $clone->ip_range_to = $ip_range_to;
374 return $this->ip_range_from !==
null && $this->ip_range_to !==
null;
379 return $this->fixed_participants;
383 $clone = clone $this;
384 $clone->fixed_participants = $fixed_participants;
withPassword(?string $password)
getInputAccessWindow(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
withFixedParticipants(bool $fixed_participants)
withIpRangeTo(?string $ip_range_to)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
toLog(AdditionalInformationGenerator $additional_info)
withPasswordEnabled(bool $password_enabled)
checkIpRangeValidity(string $start, string $end)
const MAX_PASSWORD_LENGTH
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
withIpRangeFrom(?string $ip_range_from)
withStartTimeEnabled(bool $start_time_enabled)
getInputPassword(\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
withEndTime(?\DateTimeImmutable $end_time)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getSubInputsAccessWindow(\ilLanguage $lng, FieldFactory $f, array $environment)
__construct(Container $dic, ilPlugin $plugin)
__construct(int $test_id, protected bool $start_time_enabled=false, protected ?\DateTimeImmutable $start_time=null, protected bool $end_time_enabled=false, protected ?\DateTimeImmutable $end_time=null, protected bool $password_enabled=false, protected ?string $password=null, protected ?string $ip_range_from=null, protected ?string $ip_range_to=null, protected bool $fixed_participants=false)
withStartTime(?\DateTimeImmutable $start_time)
getInputIpRange(\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
withEndTimeEnabled(bool $end_time_enabled)