ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\Test\Settings\MainSettings\SettingsGeneral Class Reference
+ Inheritance diagram for ILIAS\Test\Settings\MainSettings\SettingsGeneral:
+ Collaboration diagram for ILIAS\Test\Settings\MainSettings\SettingsGeneral:

Public Member Functions

 __construct (protected string $question_set_type=\ilObjTest::QUESTION_SET_TYPE_FIXED, protected bool $anonymous_test=false)
 
 toForm (\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
 
 toStorage ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 getQuestionSetType ()
 
 withQuestionSetType (string $question_set_type)
 
 getAnonymity ()
 
 withAnonymity (bool $anonymous_test)
 
 toExport ()
 Transform the object into a simple, associative array. More...
 
- Public Member Functions inherited from ILIAS\Test\Settings\TestSettings
 __construct ()
 
 toForm (\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
 
 toStorage ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 toExport ()
 Transform the object into a simple, associative array. More...
 

Static Public Member Functions

static fromExport (array $data)
 Creates an instance of the object from an array. More...
 
static fromExport (array $data)
 Creates an instance of the object from an array. More...
 

Detailed Description

Definition at line 30 of file SettingsGeneral.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Settings\MainSettings\SettingsGeneral::__construct ( protected string  $question_set_type = \ilObjTest::QUESTION_SET_TYPE_FIXED,
protected bool  $anonymous_test = false 
)

Definition at line 32 of file SettingsGeneral.php.

35 {
37 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ fromExport()

static ILIAS\Test\Settings\MainSettings\SettingsGeneral::fromExport ( array  $data)
static

Creates an instance of the object from an array.

This static factory method is responsible for constructing a new object instance from the provided array data. It should validate the input and may throw an exception if the data is incomplete or malformed.

Parameters
ExportableArray$dataThe data to restore the object from
Returns
static A new instance of the class

Implements ILIAS\Test\ExportImport\Exportable.

Definition at line 148 of file SettingsGeneral.php.

148 : static
149 {
150 return new self(
151 (string) $data['question_set_type'],
152 (bool) $data['anonymity']
153 );
154 }

References $data.

Referenced by ILIAS\Test\Settings\MainSettings\MainSettings\fromExport().

+ Here is the caller graph for this function:

◆ getAnonymity()

ILIAS\Test\Settings\MainSettings\SettingsGeneral::getAnonymity ( )

Definition at line 128 of file SettingsGeneral.php.

128 : bool
129 {
130 return $this->anonymous_test;
131 }

◆ getQuestionSetType()

ILIAS\Test\Settings\MainSettings\SettingsGeneral::getQuestionSetType ( )

Definition at line 116 of file SettingsGeneral.php.

116 : string
117 {
118 return $this->question_set_type;
119 }

◆ toExport()

ILIAS\Test\Settings\MainSettings\SettingsGeneral::toExport ( )

Transform the object into a simple, associative array.

The resulting array represents the object's state and should contain only scalar values, arrays, or other Exportable objects.

Returns
ExportableArray The exportable array representation of the object

Implements ILIAS\Test\ExportImport\Exportable.

Definition at line 140 of file SettingsGeneral.php.

140 : array
141 {
142 return [
143 'question_set_type' => $this->getQuestionSetType(),
144 'anonymity' => $this->getAnonymity()
145 ];
146 }

◆ toForm()

ILIAS\Test\Settings\MainSettings\SettingsGeneral::toForm ( \ilLanguage  $lng,
FieldFactory  $f,
Refinery  $refinery,
?array  $environment = null 
)
Returns
array<ILIAS\UI\Component\Input\Field\Input>

Reimplemented from ILIAS\Test\Settings\TestSettings.

Definition at line 43 of file SettingsGeneral.php.

48 : FormInput | array {
49 $inputs['question_set_type'] = $f->radio(
50 $lng->txt('test_question_set_type')
51 )->withOption(
53 $lng->txt('test_question_set_type_fixed'),
54 $lng->txt('test_question_set_type_fixed_info')
55 )->withOption(
57 $lng->txt('test_question_set_type_random'),
58 $lng->txt('test_question_set_type_random_info')
59 )->withValue($this->getQuestionSetType());
60
61 $trafo = $refinery->custom()->transformation(
62 static function (string $v): bool {
63 if ($v === '1') {
64 return true;
65 }
66
67 return false;
68 }
69 );
70
71 $inputs['anonymity'] = $f->radio(
72 $lng->txt('tst_anonymity')
73 )->withOption(
74 '0',
75 $lng->txt('tst_anonymity_no_anonymization')
76 )->withOption(
77 '1',
78 $lng->txt('tst_anonymity_anonymous_test')
79 )->withValue($this->getAnonymity() ? '1' : '0')
80 ->withAdditionalTransformation($trafo);
81
82 if ($environment['participant_data_exists']) {
83 $inputs['question_set_type'] = $inputs['question_set_type']->withDisabled(true);
84 $inputs['anonymity'] = $inputs['anonymity']->withDisabled(true);
85 }
86
87 return $inputs;
88 }
const QUESTION_SET_TYPE_RANDOM
const QUESTION_SET_TYPE_FIXED
global $lng
Definition: privfeed.php:31

◆ toLog()

ILIAS\Test\Settings\MainSettings\SettingsGeneral::toLog ( AdditionalInformationGenerator  $additional_info)

Reimplemented from ILIAS\Test\Settings\TestSettings.

Definition at line 98 of file SettingsGeneral.php.

98 : array
99 {
100 switch ($this->getQuestionSetType()) {
101 case \ilObjTest::QUESTION_SET_TYPE_FIXED:
103 ->getTagForLangVar('test_question_set_type_fixed');
104 break;
105 case \ilObjTest::QUESTION_SET_TYPE_RANDOM:
107 ->getTagForLangVar('test_question_set_type_random') ;
108 break;
109 }
110
111 $log_array[AdditionalInformationGenerator::KEY_TEST_ANONYMITY] = $additional_info
113 return $log_array;
114 }

References ILIAS\Test\Logging\AdditionalInformationGenerator\getEnabledDisabledTagForBool(), ILIAS\Test\Logging\AdditionalInformationGenerator\getTagForLangVar(), ILIAS\Test\Logging\AdditionalInformationGenerator\KEY_TEST_ANONYMITY, and ILIAS\Test\Logging\AdditionalInformationGenerator\KEY_TEST_QUESTION_SET_TYPE.

+ Here is the call graph for this function:

◆ toStorage()

ILIAS\Test\Settings\MainSettings\SettingsGeneral::toStorage ( )

Reimplemented from ILIAS\Test\Settings\TestSettings.

Definition at line 90 of file SettingsGeneral.php.

90 : array
91 {
92 return [
93 'question_set_type' => ['text', $this->getQuestionSetType()],
94 'anonymity' => ['integer', (int) $this->getAnonymity()]
95 ];
96 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ withAnonymity()

ILIAS\Test\Settings\MainSettings\SettingsGeneral::withAnonymity ( bool  $anonymous_test)

Definition at line 133 of file SettingsGeneral.php.

133 : self
134 {
135 $clone = clone $this;
136 $clone->anonymous_test = $anonymous_test;
137 return $clone;
138 }

◆ withQuestionSetType()

ILIAS\Test\Settings\MainSettings\SettingsGeneral::withQuestionSetType ( string  $question_set_type)

Definition at line 121 of file SettingsGeneral.php.

121 : self
122 {
123 $clone = clone $this;
124 $clone->question_set_type = $question_set_type;
125 return $clone;
126 }

Referenced by ILIAS\Test\Settings\MainSettings\SettingsMainGUI\getGeneralSettingsForStorage().

+ Here is the caller graph for this function:

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