19declare(strict_types=1);
35 protected int $number_of_tries = 0,
36 protected bool $block_after_passed_enabled =
false,
37 protected ?
string $pass_waiting =
null,
38 protected bool $processing_time_enabled =
false,
39 protected ?
string $processing_time =
null,
40 protected bool $reset_processing_time =
false,
41 protected int $kiosk_mode = 0,
42 protected bool $examid_in_test_attempt_enabled =
false
52 ?array $environment =
null
75 $lng->txt(
'examid_in_test_pass'),
76 $lng->txt(
'examid_in_test_pass_desc')
79 return $f->section(
$inputs,
$lng->txt(
'tst_settings_header_test_run'));
89 static function (?array $vs): array {
92 'number_of_available_attempts' => 0,
93 'block_after_passed' => false
101 $sub_inputs[
'number_of_available_attempts'] =
$f->numeric(
$lng->txt(
'tst_nr_of_tries'));
102 $sub_inputs[
'block_after_passed'] =
$f->checkbox(
103 $lng->txt(
'tst_block_passes_after_passed'),
104 $lng->txt(
'tst_block_passes_after_passed_info')
107 if (!$environment[
'participant_data_exists']) {
108 $sub_inputs[
'number_of_available_attempts'] =
109 $sub_inputs[
'number_of_available_attempts']->withRequired(
true)
110 ->withAdditionalTransformation(
$refinery->int()->isGreaterThan(0));
113 $limit_attempts =
$f->optionalGroup(
115 $lng->txt(
'tst_limit_nr_of_tries'),
116 $lng->txt(
'tst_nr_of_tries_desc')
118 ->withAdditionalTransformation($trafo);
120 if ($this->getNumberOfTries() > 0) {
121 $limit_attempts = $limit_attempts->withValue(
123 'number_of_available_attempts' => $this->getNumberOfTries(),
124 'block_after_passed' => $this->getBlockAfterPassedEnabled()
129 if (!$environment[
'participant_data_exists']) {
130 return $limit_attempts;
133 return $limit_attempts->withDisabled(
true);
143 static function (?string $vs): bool {
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 {
151 return $vs ===
null ? null : implode(
':', $vs);
155 $force_waiting_between_attempts =
$f->optionalGroup(
157 $lng->txt(
'tst_pass_waiting_enabled'),
158 $lng->txt(
'tst_pass_waiting_info')
160 ->withAdditionalTransformation($trafo);
162 if ($this->getPassWaitingEnabled()) {
163 list($days, $hours, $minutes) = explode(
':', $this->getPassWaiting());
164 $force_waiting_between_attempts = $force_waiting_between_attempts->withValue(
168 'minutes' => $minutes
173 if (!$environment[
'participant_data_exists']) {
174 return $force_waiting_between_attempts->withAdditionalTransformation($constraint);
177 return $force_waiting_between_attempts->withDisabled(
true);
185 $sub_inputs_force_waiting_between_attempts[
'days'] =
$f->numeric(
$lng->txt(
'days'))
189 $sub_inputs_force_waiting_between_attempts[
'hours'] =
$f->numeric(
$lng->txt(
'hours'))
190 ->withAdditionalTransformation(
$refinery->int()->isGreaterThanOrEqual(0))
191 ->withAdditionalTransformation(
$refinery->int()->isLessThanOrEqual(24))
194 $sub_inputs_force_waiting_between_attempts[
'minutes'] =
$f->numeric(
$lng->txt(
'minutes'))
195 ->withAdditionalTransformation(
$refinery->int()->isGreaterThanOrEqual(0))
196 ->withAdditionalTransformation(
$refinery->int()->isLessThanOrEqual(60))
200 return $sub_inputs_force_waiting_between_attempts;
205 if ($pass_waiting ===
null || $pass_waiting ===
'') {
209 $pass_waiting_array = array_map(
210 fn(
string $v) => strval((
int) $v),
211 explode(
':', $pass_waiting)
213 if (count($pass_waiting_array) === 3) {
214 return implode(
':', $pass_waiting_array);
217 $month = array_shift($pass_waiting_array);
218 $pass_waiting_array[0] = strval((
int) $pass_waiting_array[0] + (
int) $month * 31);
219 return implode(
':', $pass_waiting_array);
229 static function (?array $vs): array {
232 'processing_time_limit' =>
false,
233 'time_limit_for_completion_value' =>
null,
234 'reset_time_limit_for_completion_by_attempt' => false
238 $vs[
'processing_time_limit'] =
true;
239 $vs[
'time_limit_for_completion_value'] = sprintf(
242 $vs[
'time_limit_for_completion_value'] / 60
244 $vs[
'time_limit_for_completion_value'] % 60
250 $sub_inputs_time_limit_for_completion[
'time_limit_for_completion_value'] =
$f
252 $lng->txt(
'tst_processing_time_duration')
255 ->withAdditionalTransformation(
$refinery->int()->isGreaterThan(0))
256 ->
withValue(self::DEFAULT_PROCESSING_TIME_MINUTES);
257 $sub_inputs_time_limit_for_completion[
'reset_time_limit_for_completion_by_attempt'] =
$f->checkbox(
258 $lng->txt(
'tst_reset_processing_time'),
259 $lng->txt(
'tst_reset_processing_time_desc')
262 $time_limit_for_completion =
$f->optionalGroup(
263 $sub_inputs_time_limit_for_completion,
264 $lng->txt(
'tst_processing_time'),
265 $lng->txt(
'tst_processing_time_desc')
267 ->withAdditionalTransformation($trafo);
269 if ($this->getProcessingTimeEnabled()) {
270 $time_limit_for_completion = $time_limit_for_completion->withValue(
272 'time_limit_for_completion_value' => (
int) $this->getProcessingTimeAsMinutes(),
273 'reset_time_limit_for_completion_by_attempt' => (bool) $this->getResetProcessingTime()
278 if (!$environment[
'participant_data_exists']) {
279 return $time_limit_for_completion;
282 return $time_limit_for_completion->withDisabled(
true);
291 static function (?array $vs): ?
int {
298 if ($vs[
'show_title'] ===
true) {
302 if ($vs[
'show_participant_name'] ===
true) {
310 $sub_inputs_kiosk_mode[
'show_title'] =
$f->checkbox(
$lng->txt(
'kiosk_show_title'));
312 $sub_inputs_kiosk_mode[
'show_participant_name'] =
$f->checkbox(
$lng->txt(
'kiosk_show_participant'));
314 $kiosk_mode =
$f->optionalGroup(
315 $sub_inputs_kiosk_mode,
317 $lng->txt(
'kiosk_description')
319 ->withAdditionalTransformation($trafo);
321 if (!$this->getKioskMode()) {
325 return $kiosk_mode->withValue([
326 'show_title' => $this->getShowTitleInKioskMode(),
327 'show_participant_name' => $this->getShowParticipantNameInKioskMode()
334 'nr_of_tries' => [
'integer', $this->getNumberOfTries()],
335 'block_after_passed' => [
'integer', (
int) $this->getBlockAfterPassedEnabled()],
336 'pass_waiting' => [
'string', $this->getPassWaiting()],
337 'enable_processing_time' => [
'integer', (
int) $this->getProcessingTimeEnabled()],
338 'processing_time' => [
'string', $this->getProcessingTime()],
339 'reset_processing_time' => [
'integer', (
int) $this->getResetProcessingTime()],
340 'kiosk' => [
'integer', $this->getKioskMode()],
341 'examid_in_test_pass' => [
'integer', (
int) $this->getExamIdInTestAttemptEnabled()]
347 $log_array[AdditionalInformationGenerator::KEY_TEST_LIMIT_NR_OF_TRIES] = $this->getNumberOfTries() > 0
349 if ($this->getNumberOfTries() > 0) {
350 $log_array[AdditionalInformationGenerator::KEY_TEST_BLOCK_AFTER_PASSED] = $additional_info
354 $log_array[AdditionalInformationGenerator::KEY_TEST_PASSWAITING_ENABLED] = $this->getPassWaitingEnabled()
357 $log_array[AdditionalInformationGenerator::KEY_TEST_PROCESSING_TIME_ENABLED] = $this->getProcessingTimeEnabled()
359 if ($this->getProcessingTimeEnabled()) {
360 $log_array[AdditionalInformationGenerator::KEY_TEST_RESET_PROCESSING_TIME] = $additional_info
364 $log_array[AdditionalInformationGenerator::KEY_TEST_KIOSK_ENABLED] = $additional_info
366 if ($this->getKioskModeEnabled()) {
367 $log_array[AdditionalInformationGenerator::KEY_TEST_KIOSK_SHOW_TITLE] = $additional_info
369 $log_array[AdditionalInformationGenerator::KEY_TEST_KIOSK_SHOW_PARTICIPANT_NAME] = $additional_info
373 $log_array[AdditionalInformationGenerator::KEY_TEST_SHOW_EXAM_ID] = $additional_info
380 return $this->number_of_tries;
385 $clone = clone $this;
386 $clone->number_of_tries = $number_of_tries;
392 return $this->block_after_passed_enabled;
397 $clone = clone $this;
398 $clone->block_after_passed_enabled = $block_after_passed_enabled;
404 return $this->pass_waiting;
409 $clone = clone $this;
410 $clone->pass_waiting = $this->cleanupPassWaiting($pass_waiting);
416 if ($this->pass_waiting ===
null) {
419 if (array_sum(explode(
':', $this->pass_waiting)) > 0) {
427 return $this->processing_time_enabled;
432 $clone = clone $this;
433 $clone->processing_time_enabled = $processing_time_enabled;
439 return $this->processing_time;
444 $clone = clone $this;
445 $clone->processing_time = $processing_time;
451 if ($this->processing_time !==
null && preg_match(
"/(\d{2}):(\d{2}):(\d{2})/is", $this->processing_time, $matches)) {
452 return ((
int) $matches[1] * 60) + (
int) $matches[2];
455 return self::DEFAULT_PROCESSING_TIME_MINUTES;
460 return $this->reset_processing_time;
465 $clone = clone $this;
466 $clone->reset_processing_time = $reset_processing_time;
472 return $this->kiosk_mode;
477 $clone = clone $this;
478 $clone->kiosk_mode = $kiosk_mode;
484 return ($this->kiosk_mode & 1) > 0;
489 return ($this->kiosk_mode & 2) > 0;
494 return ($this->kiosk_mode & 4) > 0;
499 return $this->examid_in_test_attempt_enabled;
504 $clone = clone $this;
505 $clone->examid_in_test_attempt_enabled = $exam_id_in_test_pass_enabled;
512 'nr_of_tries' => $this->getNumberOfTries(),
513 'block_after_passed' => $this->getBlockAfterPassedEnabled(),
514 'pass_waiting' => $this->getPassWaiting(),
515 'enable_processing_time' => $this->getProcessingTimeEnabled(),
516 'processing_time' => $this->getProcessingTime(),
517 'reset_processing_time' => $this->getResetProcessingTime(),
518 'kiosk_mode' => $this->getKioskMode(),
519 'examid_in_test_pass' => $this->getExamIdInTestAttemptEnabled()
527 (
bool)
$data[
'block_after_passed'],
528 $data[
'pass_waiting'],
529 (bool)
$data[
'enable_processing_time'],
530 $data[
'processing_time'],
531 (
bool)
$data[
'reset_processing_time'],
533 (
bool)
$data[
'examid_in_test_pass']
__construct(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_attempt_enabled=false)
getProcessingTimeAsMinutes()
getInputForceWaitingBetweenAttempts(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment)
const DEFAULT_PROCESSING_TIME_MINUTES
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
withBlockAfterPassedEnabled(bool $block_after_passed_enabled)
withNumberOfTries(int $number_of_tries)
toExport()
Transform the object into a simple, associative array.
withProcessingTimeEnabled(bool $processing_time_enabled)
getInputTimeLimitForCompletion(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment)
withExamIdInTestAttemptEnabled(bool $exam_id_in_test_pass_enabled)
getExamIdInTestAttemptEnabled()
getSubInputsForceWaitingBetweenAttempts(\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
withPassWaiting(?string $pass_waiting)
getShowParticipantNameInKioskMode()
getShowTitleInKioskMode()
cleanupPassWaiting(?string $pass_waiting)
static fromExport(array $data)
Creates an instance of the object from an array.
getInputLimitAttempts(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment)
withResetProcessingTime(bool $reset_processing_time)
withProcessingTime(?string $processing_time)
getBlockAfterPassedEnabled()
withKioskMode(int $kiosk_mode)
getInputKioskMode(\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
getProcessingTimeEnabled()
toLog(AdditionalInformationGenerator $additional_info)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This interface allows an object to define its own transformation into a language-neutral,...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))