ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilObjTestSettingsAccess Class Reference
+ Inheritance diagram for ilObjTestSettingsAccess:
+ Collaboration diagram for ilObjTestSettingsAccess:

Public Member Functions

 __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 bool $fixed_participants=false,)
 
 toForm (\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment=null)
 
 toStorage ()
 
 getStartTimeEnabled ()
 
 withStartTimeEnabled (bool $start_time_enabled)
 
 getStartTime ()
 
 withStartTime (?DateTimeImmutable $start_time)
 
 getEndTimeEnabled ()
 
 withEndTimeEnabled (bool $end_time_enabled)
 
 getEndTime ()
 
 withEndTime (?DateTimeImmutable $end_time)
 
 getPasswordEnabled ()
 
 withPasswordEnabled (bool $password_enabled)
 
 getPassword ()
 
 withPassword (?string $password)
 
 getFixedParticipants ()
 
 withFixedParticipants (bool $fixed_participants)
 
- Public Member Functions inherited from TestSettings
 __construct (int $test_id)
 
 getTestId ()
 
 withTestId (int $test_id)
 
 toForm (\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment=null)
 
 toStorage ()
 

Private Member Functions

 getInputAccessWindow (\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment=null)
 
 getSubInputsAccessWindow (\ilLanguage $lng, FieldFactory $f, array $environment)
 
 getInputPassword (\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
 

Private Attributes

const MAX_PASSWORD_LENGTH = 20
 

Additional Inherited Members

- Protected Attributes inherited from TestSettings
int $test_id
 

Detailed Description

Definition at line 28 of file ilObjTestSettingsAccess.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjTestSettingsAccess::__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 bool  $fixed_participants = false 
)

Definition at line 32 of file ilObjTestSettingsAccess.php.

References ILIAS\MetaData\Repository\Validation\Data\__construct().

41  {
43  }
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ getEndTime()

ilObjTestSettingsAccess::getEndTime ( )

Definition at line 208 of file ilObjTestSettingsAccess.php.

Referenced by getSubInputsAccessWindow(), and toStorage().

209  {
210  return $this->end_time;
211  }
+ Here is the caller graph for this function:

◆ getEndTimeEnabled()

ilObjTestSettingsAccess::getEndTimeEnabled ( )

Definition at line 197 of file ilObjTestSettingsAccess.php.

Referenced by toStorage().

197  : bool
198  {
199  return $this->end_time_enabled;
200  }
+ Here is the caller graph for this function:

◆ getFixedParticipants()

ilObjTestSettingsAccess::getFixedParticipants ( )

Definition at line 241 of file ilObjTestSettingsAccess.php.

Referenced by toForm(), and toStorage().

241  : bool
242  {
243  return $this->fixed_participants;
244  }
+ Here is the caller graph for this function:

◆ getInputAccessWindow()

ilObjTestSettingsAccess::getInputAccessWindow ( \ilLanguage  $lng,
FieldFactory  $f,
Refinery  $refinery,
array  $environment = null 
)
private

Definition at line 66 of file ilObjTestSettingsAccess.php.

References getSubInputsAccessWindow(), and ilLanguage\txt().

Referenced by toForm().

71  : Group {
72  $constraint = $refinery->custom()->constraint(
73  static fn (array $vs) =>
74  $vs['start_time'] === null || $vs['end_time'] === null || $vs['start_time'] < $vs['end_time'],
75  $lng->txt('duration_end_must_not_be_earlier_than_start')
76  );
77 
78  $trafo = $refinery->custom()->transformation(
79  static function (array $vs): array {
80  $vs['start_time_enabled'] = $vs['start_time'] !== null;
81  $vs['end_time_enabled'] = $vs['end_time'] !== null;
82  return $vs;
83  }
84  );
85 
86  return $f->group($this->getSubInputsAccessWindow($lng, $f, $environment))
87  ->withAdditionalTransformation($constraint)
88  ->withAdditionalTransformation($trafo);
89  }
$lng
getSubInputsAccessWindow(\ilLanguage $lng, FieldFactory $f, array $environment)
Refinery Factory $refinery
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInputPassword()

ilObjTestSettingsAccess::getInputPassword ( \ilLanguage  $lng,
FieldFactory  $f,
Refinery  $refinery 
)
private

Definition at line 124 of file ilObjTestSettingsAccess.php.

References getPassword(), getPasswordEnabled(), ilLanguage\txt(), and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by toForm().

128  : OptionalGroup {
129  $trafo = $refinery->custom()->transformation(
130  static function (?array $vs): array {
131  if ($vs === null) {
132  return [
133  'password_enabled' => false,
134  'password_value' => null
135  ];
136  }
137 
138  $vs['password_enabled'] = true;
139  return $vs;
140  }
141  );
142 
143  $sub_inputs_password['password_value'] = $f->text($lng->txt('tst_password_enter'))
144  ->withRequired(true)->withMaxLength(self::MAX_PASSWORD_LENGTH);
145 
146  $password_input = $f->optionalGroup(
147  $sub_inputs_password,
148  $lng->txt('tst_password'),
149  $lng->txt('tst_password_details')
150  )->withValue(null)
151  ->withAdditionalTransformation($trafo);
152 
153  if (!$this->getPasswordEnabled()) {
154  return $password_input;
155  }
156 
157  return $password_input->withValue(
158  ['password_value' => $this->getPassword()]
159  );
160  }
This describes optional group inputs.
$lng
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:58
Refinery Factory $refinery
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPassword()

ilObjTestSettingsAccess::getPassword ( )

Definition at line 230 of file ilObjTestSettingsAccess.php.

Referenced by getInputPassword(), and toStorage().

230  : ?string
231  {
232  return $this->password;
233  }
+ Here is the caller graph for this function:

◆ getPasswordEnabled()

ilObjTestSettingsAccess::getPasswordEnabled ( )

Definition at line 219 of file ilObjTestSettingsAccess.php.

Referenced by getInputPassword(), and toStorage().

219  : bool
220  {
221  return $this->password_enabled;
222  }
+ Here is the caller graph for this function:

◆ getStartTime()

ilObjTestSettingsAccess::getStartTime ( )

Definition at line 186 of file ilObjTestSettingsAccess.php.

Referenced by getSubInputsAccessWindow(), and toStorage().

187  {
188  return $this->start_time;
189  }
+ Here is the caller graph for this function:

◆ getStartTimeEnabled()

ilObjTestSettingsAccess::getStartTimeEnabled ( )

Definition at line 175 of file ilObjTestSettingsAccess.php.

Referenced by toStorage().

175  : bool
176  {
177  return $this->start_time_enabled;
178  }
+ Here is the caller graph for this function:

◆ getSubInputsAccessWindow()

ilObjTestSettingsAccess::getSubInputsAccessWindow ( \ilLanguage  $lng,
FieldFactory  $f,
array  $environment 
)
private

Definition at line 91 of file ilObjTestSettingsAccess.php.

References getEndTime(), getStartTime(), and ilLanguage\txt().

Referenced by getInputAccessWindow().

95  : array {
96  $sub_inputs_access_window['start_time'] = $f->dateTime(
97  $lng->txt('tst_starting_time'),
98  $lng->txt('tst_starting_time_desc')
99  )->withTimezone($environment['user_time_zone'])
100  ->withFormat($environment['user_date_format'])
101  ->withUseTime(true);
102  if ($this->getStartTime() !== null) {
103  $sub_inputs_access_window['start_time'] = $sub_inputs_access_window['start_time']
104  ->withValue($this->getStartTime()->setTimezone(new DateTimeZone($environment['user_time_zone'])));
105  }
106  if ($environment['participant_data_exists']) {
107  $sub_inputs_access_window['start_time'] = $sub_inputs_access_window['start_time']->withDisabled(true);
108  }
109 
110  $sub_inputs_access_window['end_time'] = $f->dateTime(
111  $lng->txt('tst_ending_time'),
112  $lng->txt('tst_ending_time_desc')
113  )->withTimezone($environment['user_time_zone'])
114  ->withFormat($environment['user_date_format'])
115  ->withUseTime(true);
116  if ($this->getEndTime() !== null) {
117  $sub_inputs_access_window['end_time'] = $sub_inputs_access_window['end_time']
118  ->withValue($this->getEndTime()->setTimezone(new DateTimeZone($environment['user_time_zone'])));
119  }
120 
121  return $sub_inputs_access_window;
122  }
$lng
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toForm()

ilObjTestSettingsAccess::toForm ( \ilLanguage  $lng,
FieldFactory  $f,
Refinery  $refinery,
array  $environment = null 
)

Definition at line 45 of file ilObjTestSettingsAccess.php.

References ILIAS\UI\Implementation\Component\Input\$inputs, getFixedParticipants(), getInputAccessWindow(), getInputPassword(), ilLanguage\txt(), and ILIAS\UI\Implementation\Component\Input\withValue().

50  : FormInput {
51  $inputs['access_window'] = $this->getInputAccessWindow($lng, $f, $refinery, $environment);
52  $inputs['test_password'] = $this->getInputPassword($lng, $f, $refinery);
53 
54  $inputs['fixed_participants_enabled'] = $f->checkbox(
55  $lng->txt('participants_invitation'),
56  $lng->txt('participants_invitation_description')
57  )->withValue($this->getFixedParticipants());
58  if ($environment['participant_data_exists']) {
59  $inputs['fixed_participants_enabled'] = $inputs['fixed_participants_enabled']
60  ->withDisabled(true);
61  }
62 
63  return $f->section($inputs, $lng->txt('tst_settings_header_execution'));
64  }
getInputPassword(\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
getInputAccessWindow(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment=null)
$lng
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:58
This describes inputs that can be used in forms.
Definition: FormInput.php:31
Refinery Factory $refinery
+ Here is the call graph for this function:

◆ toStorage()

ilObjTestSettingsAccess::toStorage ( )

Definition at line 162 of file ilObjTestSettingsAccess.php.

References getEndTime(), getEndTimeEnabled(), getFixedParticipants(), getPassword(), getPasswordEnabled(), getStartTime(), getStartTimeEnabled(), and ILIAS\Repository\int().

162  : array
163  {
164  return [
165  'starting_time_enabled' => ['integer', (int) $this->getStartTimeEnabled()],
166  'starting_time' => ['integer', $this->getStartTime() !== null ? $this->getStartTime()->getTimestamp() : 0],
167  'ending_time_enabled' => ['integer', (int) $this->getEndTimeEnabled()],
168  'ending_time' => ['integer', $this->getEndTime() !== null ? $this->getEndTime()->getTimestamp() : 0],
169  'password_enabled' => ['integer', (int) $this->getPasswordEnabled()],
170  'password' => ['text', $this->getPassword()],
171  'fixed_participants' => ['integer', (int) $this->getFixedParticipants()]
172  ];
173  }
+ Here is the call graph for this function:

◆ withEndTime()

ilObjTestSettingsAccess::withEndTime ( ?DateTimeImmutable  $end_time)

Definition at line 212 of file ilObjTestSettingsAccess.php.

212  : self
213  {
214  $clone = clone $this;
215  $clone->end_time = $end_time;
216  return $clone;
217  }

◆ withEndTimeEnabled()

ilObjTestSettingsAccess::withEndTimeEnabled ( bool  $end_time_enabled)

Definition at line 201 of file ilObjTestSettingsAccess.php.

201  : self
202  {
203  $clone = clone $this;
204  $clone->end_time_enabled = $end_time_enabled;
205  return $clone;
206  }

◆ withFixedParticipants()

ilObjTestSettingsAccess::withFixedParticipants ( bool  $fixed_participants)

Definition at line 245 of file ilObjTestSettingsAccess.php.

245  : self
246  {
247  $clone = clone $this;
248  $clone->fixed_participants = $fixed_participants;
249  return $clone;
250  }

◆ withPassword()

ilObjTestSettingsAccess::withPassword ( ?string  $password)

Definition at line 234 of file ilObjTestSettingsAccess.php.

234  : self
235  {
236  $clone = clone $this;
237  $clone->password = $password;
238  return $clone;
239  }

◆ withPasswordEnabled()

ilObjTestSettingsAccess::withPasswordEnabled ( bool  $password_enabled)

Definition at line 223 of file ilObjTestSettingsAccess.php.

223  : self
224  {
225  $clone = clone $this;
226  $clone->password_enabled = $password_enabled;
227  return $clone;
228  }

◆ withStartTime()

ilObjTestSettingsAccess::withStartTime ( ?DateTimeImmutable  $start_time)

Definition at line 190 of file ilObjTestSettingsAccess.php.

190  : self
191  {
192  $clone = clone $this;
193  $clone->start_time = $start_time;
194  return $clone;
195  }

◆ withStartTimeEnabled()

ilObjTestSettingsAccess::withStartTimeEnabled ( bool  $start_time_enabled)

Definition at line 179 of file ilObjTestSettingsAccess.php.

Referenced by ilObjTestSettingsMainGUI\getAccessSettingsForStorage().

179  : self
180  {
181  $clone = clone $this;
182  $clone->start_time_enabled = $start_time_enabled;
183  return $clone;
184  }
+ Here is the caller graph for this function:

Field Documentation

◆ MAX_PASSWORD_LENGTH

const ilObjTestSettingsAccess::MAX_PASSWORD_LENGTH = 20
private

Definition at line 30 of file ilObjTestSettingsAccess.php.


The documentation for this class was generated from the following file: