19 declare(strict_types=1);
31 protected int $number_of_tries = 0,
32 protected bool $block_after_passed_enabled =
false,
33 protected ?
string $pass_waiting = null,
34 protected bool $processing_time_enabled =
false,
35 protected ?
string $processing_time = null,
36 protected bool $reset_processing_time =
false,
37 protected int $kiosk_mode = 0,
38 protected bool $examid_in_test_pass_enabled =
false 48 array $environment = null
70 $inputs[
'show_exam_id'] = $f->checkbox(
71 $lng->
txt(
'examid_in_test_pass'),
72 $lng->
txt(
'examid_in_test_pass_desc')
75 return $f->section(
$inputs, $lng->
txt(
'tst_settings_header_test_run'));
84 $trafo = $refinery->custom()->transformation(
85 static function (?array $vs): array {
88 'number_of_available_attempts' => 0,
89 'block_after_passed' => false
97 $sub_inputs[
'number_of_available_attempts'] = $f->numeric($lng->
txt(
'tst_nr_of_tries'));
98 $sub_inputs[
'block_after_passed'] = $f->checkbox(
99 $lng->
txt(
'tst_block_passes_after_passed'),
100 $lng->
txt(
'tst_block_passes_after_passed_info')
103 if (!$environment[
'participant_data_exists']) {
104 $sub_inputs[
'number_of_available_attempts'] =
105 $sub_inputs[
'number_of_available_attempts']->
withRequired(
true)
106 ->withAdditionalTransformation($refinery->int()->isGreaterThan(0));
109 $limit_attempts = $f->optionalGroup(
111 $lng->
txt(
'tst_limit_nr_of_tries'),
112 $lng->
txt(
'tst_nr_of_tries_desc')
114 ->withAdditionalTransformation($trafo);
117 $limit_attempts = $limit_attempts->withValue(
125 if (!$environment[
'participant_data_exists']) {
126 return $limit_attempts;
129 return $limit_attempts->withDisabled(
true);
138 $constraint = $refinery->custom()->constraint(
139 static function (?
string $vs):
bool {
140 if ($vs !== null && $vs ===
'0:0:0') {
146 sprintf($lng->
txt(
'not_greater_than'), $lng->
txt(
'tst_pass_waiting_time'), 0)
149 $trafo = $refinery->custom()->transformation(
150 static function (?array $vs): ?
string {
155 return implode(
':', $vs);
159 $force_waiting_between_attempts = $f->optionalGroup(
161 $lng->
txt(
'tst_pass_waiting_enabled'),
162 $lng->
txt(
'tst_pass_waiting_info')
164 ->withAdditionalTransformation($trafo);
167 list($days, $hours, $minutes) = explode(
':', $this->
getPassWaiting());
168 $force_waiting_between_attempts = $force_waiting_between_attempts->withValue(
172 'minutes' => $minutes
177 if (!$environment[
'participant_data_exists']) {
178 return $force_waiting_between_attempts->withAdditionalTransformation($constraint);
181 return $force_waiting_between_attempts->withDisabled(
true);
189 $sub_inputs_force_waiting_between_attempts[
'days'] = $f->numeric($lng->
txt(
'days'))
193 $sub_inputs_force_waiting_between_attempts[
'hours'] = $f->numeric($lng->
txt(
'hours'))
198 $sub_inputs_force_waiting_between_attempts[
'minutes'] = $f->numeric($lng->
txt(
'minutes'))
204 return $sub_inputs_force_waiting_between_attempts;
209 if ($pass_waiting === null || $pass_waiting ===
'') {
213 $pass_waiting_array = array_map(
214 fn(
string $v) => strval((
int) $v),
215 explode(
':', $pass_waiting)
217 if (count($pass_waiting_array) === 3) {
218 return implode(
':', $pass_waiting_array);
221 $month = array_shift($pass_waiting_array);
222 $pass_waiting_array[0] = strval((
int) $pass_waiting_array[0] + (
int) $month * 31);
223 return implode(
':', $pass_waiting_array);
232 $trafo = $refinery->custom()->transformation(
233 static function (?array $vs): array {
236 'processing_time_limit' =>
false,
237 'time_limit_for_completion_value' => null,
238 'reset_time_limit_for_completion_by_attempt' => false
242 $vs[
'processing_time_limit'] =
true;
243 $vs[
'time_limit_for_completion_value'] = sprintf(
246 $vs[
'time_limit_for_completion_value'] / 60
248 $vs[
'time_limit_for_completion_value'] % 60
254 $sub_inputs_time_limit_for_completion[
'time_limit_for_completion_value'] = $f
256 $lng->
txt(
'tst_processing_time_duration'),
257 $lng->
txt(
'tst_processing_time_desc')
261 ->
withValue(self::DEFAULT_PROCESSING_TIME_MINUTES);
262 $sub_inputs_time_limit_for_completion[
'reset_time_limit_for_completion_by_attempt'] = $f->checkbox(
263 $lng->
txt(
'tst_reset_processing_time'),
264 $lng->
txt(
'tst_reset_processing_time_desc')
267 $time_limit_for_completion = $f->optionalGroup(
268 $sub_inputs_time_limit_for_completion,
269 $lng->
txt(
'tst_processing_time'),
270 $lng->
txt(
'tst_processing_time_desc')
272 ->withAdditionalTransformation($trafo);
275 $time_limit_for_completion = $time_limit_for_completion->withValue(
283 if (!$environment[
'participant_data_exists']) {
284 return $time_limit_for_completion;
287 return $time_limit_for_completion->withDisabled(
true);
295 $trafo = $refinery->custom()->transformation(
296 static function (?array $vs): ?
int {
298 return $kiosk_mode = 0;
303 if ($vs[
'show_title'] ===
true) {
307 if ($vs[
'show_participant_name'] ===
true) {
315 $sub_inputs_kiosk_mode[
'show_title'] = $f->checkbox(
316 $lng->
txt(
'kiosk_show_title')
319 $sub_inputs_kiosk_mode[
'show_participant_name'] = $f->checkbox(
320 $lng->
txt(
'kiosk_show_participant')
323 $kiosk_mode = $f->optionalGroup(
324 $sub_inputs_kiosk_mode,
326 $lng->
txt(
'kiosk_description')
328 ->withAdditionalTransformation($trafo);
334 return $kiosk_mode->withValue(
358 return $this->number_of_tries;
362 $clone = clone $this;
363 $clone->number_of_tries = $number_of_tries;
369 return $this->block_after_passed_enabled;
373 $clone = clone $this;
374 $clone->block_after_passed_enabled = $block_after_passed_enabled;
380 return $this->pass_waiting;
384 if ($this->pass_waiting === null) {
387 if (array_sum(explode(
':', $this->pass_waiting)) > 0) {
394 $clone = clone $this;
401 return $this->processing_time_enabled;
405 $clone = clone $this;
406 $clone->processing_time_enabled = $processing_time_enabled;
412 return $this->processing_time;
416 if ($this->processing_time !== null) {
417 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/is", $this->processing_time, $matches)) {
418 return ((
int) $matches[1] * 60) + (
int) $matches[2];
422 return self::DEFAULT_PROCESSING_TIME_MINUTES;
426 $clone = clone $this;
427 $clone->processing_time = $processing_time;
433 return $this->reset_processing_time;
437 $clone = clone $this;
438 $clone->reset_processing_time = $reset_processing_time;
444 return $this->kiosk_mode;
448 if (($this->kiosk_mode & 1) > 0) {
456 if (($this->kiosk_mode & 2) > 0) {
464 if (($this->kiosk_mode & 4) > 0) {
472 $clone = clone $this;
473 $clone->kiosk_mode = $kiosk_mode;
479 return $this->examid_in_test_pass_enabled;
483 $clone = clone $this;
484 $clone->examid_in_test_pass_enabled = $exam_id_in_test_pass_enabled;
getSubInputsForceWaitingBetweenAttempts(\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
withNumberOfTries(int $number_of_tries)
cleanupPassWaiting(?string $pass_waiting)
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...
getShowParticipantNameInKioskMode()
getInputTimeLimitForCompletion(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment)
getExamIdInTestPassEnabled()
withBlockAfterPassedEnabled(bool $block_after_passed_enabled)
getShowTitleInKioskMode()
getBlockAfterPassedEnabled()
getProcessingTimeEnabled()
withResetProcessingTime(bool $reset_processing_time)
withProcessingTime(?string $processing_time)
getProcessingTimeAsMinutes()
withProcessingTimeEnabled(bool $processing_time_enabled)
__construct(int $test_id, protected int $number_of_tries=0, protected bool $block_after_passed_enabled=false, protected ?string $pass_waiting=null, protected bool $processing_time_enabled=false, protected ?string $processing_time=null, protected bool $reset_processing_time=false, protected int $kiosk_mode=0, protected bool $examid_in_test_pass_enabled=false)
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment=null)
withKioskMode(int $kiosk_mode)
getInputLimitAttempts(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment)
getInputKioskMode(\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
const DEFAULT_PROCESSING_TIME_MINUTES
withPassWaiting(?string $pass_waiting)
withExamIdInTestPassEnabled(bool $exam_id_in_test_pass_enabled)
getInputForceWaitingBetweenAttempts(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment)
Refinery Factory $refinery