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'),
253 $lng->txt(
'tst_processing_time_desc')
256 ->withAdditionalTransformation(
$refinery->int()->isGreaterThan(0))
257 ->
withValue(self::DEFAULT_PROCESSING_TIME_MINUTES);
258 $sub_inputs_time_limit_for_completion[
'reset_time_limit_for_completion_by_attempt'] =
$f->checkbox(
259 $lng->txt(
'tst_reset_processing_time'),
260 $lng->txt(
'tst_reset_processing_time_desc')
263 $time_limit_for_completion =
$f->optionalGroup(
264 $sub_inputs_time_limit_for_completion,
265 $lng->txt(
'tst_processing_time'),
266 $lng->txt(
'tst_processing_time_desc')
268 ->withAdditionalTransformation($trafo);
270 if ($this->getProcessingTimeEnabled()) {
271 $time_limit_for_completion = $time_limit_for_completion->withValue(
273 'time_limit_for_completion_value' => (
int) $this->getProcessingTimeAsMinutes(),
274 'reset_time_limit_for_completion_by_attempt' => (bool) $this->getResetProcessingTime()
279 if (!$environment[
'participant_data_exists']) {
280 return $time_limit_for_completion;
283 return $time_limit_for_completion->withDisabled(
true);
292 static function (?array $vs): ?
int {
299 if ($vs[
'show_title'] ===
true) {
303 if ($vs[
'show_participant_name'] ===
true) {
311 $sub_inputs_kiosk_mode[
'show_title'] =
$f->checkbox(
$lng->txt(
'kiosk_show_title'));
313 $sub_inputs_kiosk_mode[
'show_participant_name'] =
$f->checkbox(
$lng->txt(
'kiosk_show_participant'));
315 $kiosk_mode =
$f->optionalGroup(
316 $sub_inputs_kiosk_mode,
318 $lng->txt(
'kiosk_description')
320 ->withAdditionalTransformation($trafo);
322 if (!$this->getKioskMode()) {
326 return $kiosk_mode->withValue([
327 'show_title' => $this->getShowTitleInKioskMode(),
328 'show_participant_name' => $this->getShowParticipantNameInKioskMode()
335 'nr_of_tries' => [
'integer', $this->getNumberOfTries()],
336 'block_after_passed' => [
'integer', (
int) $this->getBlockAfterPassedEnabled()],
337 'pass_waiting' => [
'string', $this->getPassWaiting()],
338 'enable_processing_time' => [
'integer', (
int) $this->getProcessingTimeEnabled()],
339 'processing_time' => [
'string', $this->getProcessingTime()],
340 'reset_processing_time' => [
'integer', (
int) $this->getResetProcessingTime()],
341 'kiosk' => [
'integer', $this->getKioskMode()],
342 'examid_in_test_pass' => [
'integer', (
int) $this->getExamIdInTestAttemptEnabled()]
348 $log_array[AdditionalInformationGenerator::KEY_TEST_LIMIT_NR_OF_TRIES] = $this->getNumberOfTries() > 0
350 if ($this->getNumberOfTries() > 0) {
351 $log_array[AdditionalInformationGenerator::KEY_TEST_BLOCK_AFTER_PASSED] = $additional_info
355 $log_array[AdditionalInformationGenerator::KEY_TEST_PASSWAITING_ENABLED] = $this->getPassWaitingEnabled()
358 $log_array[AdditionalInformationGenerator::KEY_TEST_PROCESSING_TIME_ENABLED] = $this->getProcessingTimeEnabled()
360 if ($this->getProcessingTimeEnabled()) {
361 $log_array[AdditionalInformationGenerator::KEY_TEST_RESET_PROCESSING_TIME] = $additional_info
365 $log_array[AdditionalInformationGenerator::KEY_TEST_KIOSK_ENABLED] = $additional_info
367 if ($this->getKioskModeEnabled()) {
368 $log_array[AdditionalInformationGenerator::KEY_TEST_KIOSK_SHOW_TITLE] = $additional_info
370 $log_array[AdditionalInformationGenerator::KEY_TEST_KIOSK_SHOW_PARTICIPANT_NAME] = $additional_info
374 $log_array[AdditionalInformationGenerator::KEY_TEST_SHOW_EXAM_ID] = $additional_info
381 return $this->number_of_tries;
386 $clone = clone $this;
387 $clone->number_of_tries = $number_of_tries;
393 return $this->block_after_passed_enabled;
398 $clone = clone $this;
399 $clone->block_after_passed_enabled = $block_after_passed_enabled;
405 return $this->pass_waiting;
410 $clone = clone $this;
411 $clone->pass_waiting = $this->cleanupPassWaiting($pass_waiting);
417 if ($this->pass_waiting ===
null) {
420 if (array_sum(explode(
':', $this->pass_waiting)) > 0) {
428 return $this->processing_time_enabled;
433 $clone = clone $this;
434 $clone->processing_time_enabled = $processing_time_enabled;
440 return $this->processing_time;
445 $clone = clone $this;
446 $clone->processing_time = $processing_time;
452 if ($this->processing_time !==
null && preg_match(
"/(\d{2}):(\d{2}):(\d{2})/is", $this->processing_time, $matches)) {
453 return ((
int) $matches[1] * 60) + (
int) $matches[2];
456 return self::DEFAULT_PROCESSING_TIME_MINUTES;
461 return $this->reset_processing_time;
466 $clone = clone $this;
467 $clone->reset_processing_time = $reset_processing_time;
473 return $this->kiosk_mode;
478 $clone = clone $this;
479 $clone->kiosk_mode = $kiosk_mode;
485 return ($this->kiosk_mode & 1) > 0;
490 return ($this->kiosk_mode & 2) > 0;
495 return ($this->kiosk_mode & 4) > 0;
500 return $this->examid_in_test_attempt_enabled;
505 $clone = clone $this;
506 $clone->examid_in_test_attempt_enabled = $exam_id_in_test_pass_enabled;
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)
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)
__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_attempt_enabled=false)
getShowParticipantNameInKioskMode()
getShowTitleInKioskMode()
cleanupPassWaiting(?string $pass_waiting)
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...
__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'))