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

Public Member Functions

 __construct (int $test_id, 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 ()
 
 getQuestionSetType ()
 
 withQuestionSetType (string $question_set_type)
 
 getAnonymity ()
 
 withAnonymity (bool $anonymous_test)
 
- 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 ()
 

Additional Inherited Members

- Protected Attributes inherited from TestSettings
int $test_id
 

Detailed Description

Definition at line 25 of file ilObjTestSettingsGeneral.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjTestSettingsGeneral::__construct ( int  $test_id,
protected string  $question_set_type = ilObjTest::QUESTION_SET_TYPE_FIXED,
protected bool  $anonymous_test = false 
)

Definition at line 27 of file ilObjTestSettingsGeneral.php.

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

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

Member Function Documentation

◆ getAnonymity()

ilObjTestSettingsGeneral::getAnonymity ( )

Definition at line 106 of file ilObjTestSettingsGeneral.php.

Referenced by toForm(), and toStorage().

106  : bool
107  {
108  return $this->anonymous_test;
109  }
+ Here is the caller graph for this function:

◆ getQuestionSetType()

ilObjTestSettingsGeneral::getQuestionSetType ( )

Definition at line 94 of file ilObjTestSettingsGeneral.php.

Referenced by toForm(), and toStorage().

94  : string
95  {
96  return $this->question_set_type;
97  }
+ Here is the caller graph for this function:

◆ toForm()

ilObjTestSettingsGeneral::toForm ( \ilLanguage  $lng,
FieldFactory  $f,
Refinery  $refinery,
array  $environment = null 
)
Returns
array<ILIAS>

Definition at line 39 of file ilObjTestSettingsGeneral.php.

References ILIAS\UI\Implementation\Component\Input\$inputs, getAnonymity(), getQuestionSetType(), ilObjTest\QUESTION_SET_TYPE_FIXED, ilObjTest\QUESTION_SET_TYPE_RANDOM, ilLanguage\txt(), ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\withValue().

44  : FormInput | array {
45  $inputs['question_set_type'] = $f->radio(
46  $lng->txt('test_question_set_type')
47  )->withOption(
49  $lng->txt('test_question_set_type_fixed'),
50  $lng->txt('test_question_set_type_fixed_info')
51  )->withOption(
53  $lng->txt('test_question_set_type_random'),
54  $lng->txt('test_question_set_type_random_info')
55  )->withValue($this->getQuestionSetType());
56 
57  $trafo = $refinery->custom()->transformation(
58  static function (string $v): bool {
59  if ($v === '1') {
60  return true;
61  }
62 
63  return false;
64  }
65  );
66 
67  $inputs['anonymity'] = $f->radio(
68  $lng->txt('tst_anonymity')
69  )->withOption(
70  '0',
71  $lng->txt('tst_anonymity_no_anonymization')
72  )->withOption(
73  '1',
74  $lng->txt('tst_anonymity_anonymous_test')
75  )->withValue($this->getAnonymity() ? '1' : '0')
77 
78  if ($environment['participant_data_exists']) {
79  $inputs['question_set_type'] = $inputs['question_set_type']->withDisabled(true);
80  $inputs['anonymity'] = $inputs['anonymity']->withDisabled(true);
81  }
82 
83  return $inputs;
84  }
const QUESTION_SET_TYPE_RANDOM
$lng
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:58
const QUESTION_SET_TYPE_FIXED
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()

ilObjTestSettingsGeneral::toStorage ( )

Definition at line 86 of file ilObjTestSettingsGeneral.php.

References getAnonymity(), getQuestionSetType(), and ILIAS\Repository\int().

86  : array
87  {
88  return [
89  'question_set_type' => ['text', $this->getQuestionSetType()],
90  'anonymity' => ['integer', (int) $this->getAnonymity()]
91  ];
92  }
+ Here is the call graph for this function:

◆ withAnonymity()

ilObjTestSettingsGeneral::withAnonymity ( bool  $anonymous_test)

Definition at line 111 of file ilObjTestSettingsGeneral.php.

111  : self
112  {
113  $clone = clone $this;
114  $clone->anonymous_test = $anonymous_test;
115  return $clone;
116  }

◆ withQuestionSetType()

ilObjTestSettingsGeneral::withQuestionSetType ( string  $question_set_type)

Definition at line 99 of file ilObjTestSettingsGeneral.php.

Referenced by ilObjTestSettingsMainGUI\getGeneralSettingsForStorage().

99  : self
100  {
101  $clone = clone $this;
102  $clone->question_set_type = $question_set_type;
103  return $clone;
104  }
+ Here is the caller graph for this function:

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