ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAddAnswerFormBuilder Class Reference
+ Collaboration diagram for ilAddAnswerFormBuilder:

Public Member Functions

 __construct (private readonly UIFactory $ui_factory, private readonly RefineryFactory $refinery, private readonly ilLanguage $language, private readonly ilCtrl $ctrl)
 
 buildAddAnswerModal (string $title, array $data=[])
 

Protected Member Functions

 buildInputs (array $data)
 

Detailed Description

Definition at line 25 of file class.ilAddAnswerFormBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

ilAddAnswerFormBuilder::__construct ( private readonly UIFactory  $ui_factory,
private readonly RefineryFactory  $refinery,
private readonly ilLanguage  $language,
private readonly ilCtrl  $ctrl 
)

Definition at line 27 of file class.ilAddAnswerFormBuilder.php.

32 {
33 }

Member Function Documentation

◆ buildAddAnswerModal()

ilAddAnswerFormBuilder::buildAddAnswerModal ( string  $title,
array  $data = [] 
)

Definition at line 35 of file class.ilAddAnswerFormBuilder.php.

35 : RoundTripModal
36 {
37 return $this->ui_factory->modal()->roundtrip(
38 $title,
39 null,
40 $this->buildInputs($data),
41 $this->ctrl->getFormActionByClass([ilObjTestGUI::class, ilTestCorrectionsGUI::class], 'addAnswer')
42 );
43 }

References $data, buildInputs(), and ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ buildInputs()

ilAddAnswerFormBuilder::buildInputs ( array  $data)
protected

Definition at line 45 of file class.ilAddAnswerFormBuilder.php.

45 : array
46 {
47 $to_int_trafo = $this->refinery->kindlyTo()->int();
48 $fix_points_trafo = $this->refinery->custom()->transformation(
49 function ($v) {
50 $v = str_replace(',', '.', $v);
51
52 if (is_numeric($v)) {
53 return (float) $v;
54 }
55
56 return false;
57 }
58 );
59
60 $inputs = [];
61 $inputs['question_id'] = $this->ui_factory->input()->field()->hidden()
62 ->withAdditionalTransformation($to_int_trafo)
63 ->withValue((string) ($data['question_id'] ?? ''));
64 $inputs['question_index'] = $this->ui_factory->input()->field()->hidden()
65 ->withAdditionalTransformation($to_int_trafo)
66 ->withValue((string) ($data['question_index'] ?? ''));
67 $inputs['answer_value'] = $this->ui_factory->input()->field()->hidden($this->language->txt('answer'))
68 ->withValue(($data['answer'] ?? ''));
69 $inputs['answer'] = $this->ui_factory->input()->field()->text($this->language->txt('answer'))
70 ->withValue(($data['answer'] ?? ''))
71 ->withDisabled(true);
72 $inputs['points'] = $this->ui_factory->input()->field()->text($this->language->txt('points'))
73 ->withAdditionalTransformation($fix_points_trafo);
74 return $inputs;
75 }
withAdditionalTransformation(Transformation $trafo)
@inheritDoc
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61

References $data, ILIAS\UI\Implementation\Component\Input\$inputs, ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\refinery(), ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by buildAddAnswerModal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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