ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilAddAnswerFormBuilder Class Reference
+ Collaboration diagram for ilAddAnswerFormBuilder:

Public Member Functions

 __construct (ilTestCorrectionsGUI $parent_object, UIFactory $ui_factory, RefineryFactory $refinery, ilLanguage $language, ilCtrl $ctrl)
 
 buildAddAnswerForm (array $data=[])
 

Protected Member Functions

 buildInputs (array $data)
 

Protected Attributes

UIFactory $ui_factory
 
RefineryFactory $refinery
 
ilLanguage $language
 
string $form_action
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAddAnswerFormBuilder::__construct ( ilTestCorrectionsGUI  $parent_object,
UIFactory  $ui_factory,
RefineryFactory  $refinery,
ilLanguage  $language,
ilCtrl  $ctrl 
)

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

References $language, $refinery, $ui_factory, ilCtrl\getFormAction(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\refinery().

41  {
42  $this->ui_factory = $ui_factory;
43  $this->refinery = $refinery;
44  $this->language = $language;
45 
46  $this->form_action = $ctrl->getFormAction(
47  $parent_object,
48  'addAnswer'
49  );
50  }
getFormAction(object $a_gui_obj, string $a_fallback_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
+ Here is the call graph for this function:

Member Function Documentation

◆ buildAddAnswerForm()

ilAddAnswerFormBuilder::buildAddAnswerForm ( array  $data = [])

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

References $data, ILIAS\UI\Implementation\Component\Input\$inputs, and buildInputs().

Referenced by ilTestCorrectionsGUI\addAnswer().

52  : StandardForm
53  {
54  $inputs = $this->buildInputs($data);
55 
56  return $this->ui_factory->input()->container()->form()->standard($this->form_action, $inputs);
57  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildInputs()

ilAddAnswerFormBuilder::buildInputs ( array  $data)
protected

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

References 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 buildAddAnswerForm().

59  : array
60  {
61  $to_int_trafo = $this->refinery->kindlyTo()->int();
62  $fix_points_trafo = $this->refinery->custom()->transformation(
63  function ($v) {
64  $v = str_replace(',', '.', $v);
65 
66  if (is_numeric($v)) {
67  return (float) $v;
68  }
69 
70  return false;
71  }
72  );
73 
74  $inputs = [];
75  $inputs['question_id'] = $this->ui_factory->input()->field()->hidden()
76  ->withAdditionalTransformation($to_int_trafo)
77  ->withValue((string) ($data['question_id'] ?? ''));
78  $inputs['question_index'] = $this->ui_factory->input()->field()->hidden()
79  ->withAdditionalTransformation($to_int_trafo)
80  ->withValue((string) ($data['question_index'] ?? ''));
81  $inputs['answer_value'] = $this->ui_factory->input()->field()->hidden($this->language->txt('answer'))
82  ->withValue(($data['answer'] ?? ''));
83  $inputs['answer'] = $this->ui_factory->input()->field()->text($this->language->txt('answer'))
84  ->withValue(($data['answer'] ?? ''))
85  ->withDisabled(true);
86  $inputs['points'] = $this->ui_factory->input()->field()->text($this->language->txt('points'))
87  ->withAdditionalTransformation($fix_points_trafo);
88  return $inputs;
89  }
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:59
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $form_action

string ilAddAnswerFormBuilder::$form_action
protected

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

◆ $language

ilLanguage ilAddAnswerFormBuilder::$language
protected

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

Referenced by __construct().

◆ $refinery

RefineryFactory ilAddAnswerFormBuilder::$refinery
protected

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

Referenced by __construct().

◆ $ui_factory

UIFactory ilAddAnswerFormBuilder::$ui_factory
protected

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

Referenced by __construct().


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