ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAddAnswerModalFormGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
14 {
18  protected $DIC;
19 
23  protected $questionId = 0;
24 
28  protected $questionIndex = 0;
29 
33  protected $answerValue = '';
34 
35  public function __construct()
36  {
37  global $DIC; /* @var ILIAS\DI\Container $DIC */
38  $this->DIC = $DIC;
39 
40  parent::__construct();
41  }
42 
43  public function setValuesByArray($a_values, $a_restrict_to_value_keys = false)
44  {
45  $this->getItemByPostVar('answer_presentation')->setValue($a_values['answer']);
46  parent::setValuesByArray($a_values, $a_restrict_to_value_keys);
47  }
48 
52  public function getQuestionId() : int
53  {
54  return $this->questionId;
55  }
56 
60  public function setQuestionId(int $questionId)
61  {
62  $this->questionId = $questionId;
63  }
64 
68  public function getQuestionIndex() : int
69  {
70  return $this->questionIndex;
71  }
72 
76  public function setQuestionIndex(int $questionIndex)
77  {
78  $this->questionIndex = $questionIndex;
79  }
80 
84  public function getAnswerValue() : string
85  {
86  return $this->answerValue;
87  }
88 
92  public function setAnswerValue(string $answerValue)
93  {
94  $this->answerValue = $answerValue;
95  }
96 
97  public function build()
98  {
99  $answer = new ilNonEditableValueGUI($this->DIC->language()->txt('answer'));
100  $answer->setPostVar('answer_presentation');
101  $answer->setValue($this->getAnswerValue());
102  $this->addItem($answer);
103 
104  $points = new ilNumberInputGUI($this->DIC->language()->txt('points'), 'points');
105  $points->setRequired(true);
106  $points->setSize(6);
107  $points->allowDecimals(true);
108  $points->setMinvalueShouldBeGreater(true);
109  $points->setMinValue(0);
110  $this->addItem($points);
111 
112  $hiddenAnswerValue = new ilHiddenInputGUI('answer');
113  $hiddenAnswerValue->setValue($this->getAnswerValue());
114  $this->addItem($hiddenAnswerValue);
115 
116  $hiddenQuestionId = new ilHiddenInputGUI('qid');
117  $hiddenQuestionId->setValue($this->getQuestionId());
118  $this->addItem($hiddenQuestionId);
119 
120  $hiddenQuestionIndex = new ilHiddenInputGUI('qindex');
121  $hiddenQuestionIndex->setValue($this->getQuestionIndex());
122  $this->addItem($hiddenQuestionIndex);
123 
124  $this->addCommandButton('addAnswerAsynch', $this->DIC->language()->txt('save'));
125  $this->addCommandButton('cancel', $this->DIC->language()->txt('cancel'));
126  }
127 }
getItemByPostVar($a_post_var)
Get Item by POST variable.
This class represents a property form user interface.
setPostVar($a_postvar)
Set Post Variable.
addItem($a_item)
Add Item (Property, SectionHeader).
This class represents a hidden form property in a property form.
This class represents a number property in a property form.
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
This class represents a non editable value in a property form.
setRequired($a_required)
Set Required.