ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilObjTestSettingsAdditional.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 
26 {
27  public function __construct(
28  int $test_id,
29  protected bool $skills_service_enabled = false,
30  protected bool $hide_info_tab = false,
31  ) {
32  parent::__construct($test_id);
33  }
34 
39  public function toForm(
43  array $environment = null
44  ): array {
45  $inputs = [];
46  if ((new ilSkillManagementSettings())->isActivated()) {
47  $inputs['skills_service_activation'] = $this->getInputSkillsServiceActivation(
48  $lng,
49  $f,
50  $environment['participant_data_exists']
51  );
52  }
53 
54  $inputs['hide_info_tab'] = $f->checkbox(
55  $lng->txt('tst_hide_info_tab'),
56  $lng->txt('tst_hide_info_tab_desc')
57  )->withValue($this->getHideInfoTab());
58 
59  return $inputs;
60  }
61 
65  bool $participant_data_exists
66  ): Checkbox {
67  $skills_service_activation = $f->checkbox(
68  $lng->txt('tst_activate_skill_service'),
69  $lng->txt('tst_activate_skill_service_desc')
71 
72  if ($participant_data_exists) {
73  return $skills_service_activation->withDisabled(true);
74  }
75 
76  return $skills_service_activation;
77  }
78 
79  public function toStorage(): array
80  {
81  return [
82  'skill_service' => ['integer', (int) $this->getSkillsServiceEnabled()],
83  'hide_info_tab' => ['integer', (int) $this->getHideInfoTab()],
84  ];
85  }
86 
87  public function getSkillsServiceEnabled(): bool
88  {
89  return $this->skills_service_enabled;
90  }
91 
92  public function withSkillsServiceEnabled(bool $skills_service_enabled): self
93  {
94  $clone = clone $this;
95  $clone->skills_service_enabled = $skills_service_enabled;
96  return $clone;
97  }
98 
99  public function getHideInfoTab(): bool
100  {
101  return $this->hide_info_tab;
102  }
103  public function withHideInfoTab(bool $hide_info_tab): self
104  {
105  $clone = clone $this;
106  $clone->hide_info_tab = $hide_info_tab;
107  return $clone;
108  }
109 }
This is what a factory for input fields looks like.
Definition: Factory.php:28
getInputSkillsServiceActivation(\ilLanguage $lng, FieldFactory $f, bool $participant_data_exists)
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes checkbox inputs.
Definition: Checkbox.php:28
__construct(VocabulariesInterface $vocabularies)
$lng
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment=null)
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:58
__construct(int $test_id, protected bool $skills_service_enabled=false, protected bool $hide_info_tab=false,)
withSkillsServiceEnabled(bool $skills_service_enabled)
Refinery Factory $refinery