ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilAssQuestionHintGUI Class Reference
+ Inheritance diagram for ilAssQuestionHintGUI:
+ Collaboration diagram for ilAssQuestionHintGUI:

Public Member Functions

 __construct (assQuestionGUI $questionGUI)
 
 executeCommand ()
 
- Public Member Functions inherited from ilAssQuestionHintAbstractGUI
 __construct (assQuestionGUI $question_gui)
 Constructor. More...
 

Data Fields

const CMD_SHOW_FORM = 'showForm'
 
const CMD_SAVE_FORM = 'saveForm'
 
const CMD_CANCEL_FORM = 'cancelForm'
 

Private Member Functions

 showFormCmd (?ilPropertyFormGUI $form=null)
 
 saveFormCmd ()
 
 cancelFormCmd ()
 
 buildForm (?ilAssQuestionHint $questionHint=null)
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 
GeneralQuestionPropertiesRepository $questionrepository
 

Additional Inherited Members

- Protected Attributes inherited from ilAssQuestionHintAbstractGUI
RequestDataCollector $request_data_collector
 
assQuestionGUI $question_gui = null
 
assQuestion $question_obj = null
 
ilTabsGUI $tabs
 
ilLanguage $lng
 
ilCtrl $ctrl
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionHintGUI::__construct ( assQuestionGUI  $questionGUI)

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

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

41  {
42  parent::__construct($questionGUI);
43  global $DIC;
44  $this->main_tpl = $DIC->ui()->mainTemplate();
45 
46  $local_dic = QuestionPoolDIC::dic();
47  $this->questionrepository = $local_dic['question.general_properties.repository'];
48  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ buildForm()

ilAssQuestionHintGUI::buildForm ( ?ilAssQuestionHint  $questionHint = null)
private

Definition at line 156 of file class.ilAssQuestionHintGUI.php.

References ilObjAdvancedEditing\_getUsedHTMLTags(), ilNumberInputGUI\allowDecimals(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setRequired().

Referenced by saveFormCmd(), and showFormCmd().

157  {
158  $form = new ilPropertyFormGUI();
159  $form->setTableWidth('100%');
160 
161  if (!$this->question_obj->isAdditionalContentEditingModePageObject()) {
162  // form input: hint text
163 
164  $areaInp = new ilTextAreaInputGUI($this->lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text');
165  $areaInp->setRequired(true);
166  $areaInp->setRows(10);
167  $areaInp->setCols(80);
168 
169  if (!$this->question_obj->getPreventRteUsage()) {
170  $areaInp->setUseRte(true);
171  }
172 
173  $areaInp->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
174 
175  $areaInp->setRTESupport($this->question_obj->getId(), 'qpl', 'assessment');
176 
177  $form->addItem($areaInp);
178  }
179 
180  // form input: hint points
181 
182  $numInp = new ilNumberInputGUI($this->lng->txt('tst_question_hints_form_label_hint_points'), 'hint_points');
183  $numInp->allowDecimals(true);
184  $numInp->setRequired(true);
185  $numInp->setSize(3);
186 
187  $form->addItem($numInp);
188 
189  if ($questionHint instanceof ilAssQuestionHint) {
190  // build form title for an existing hint
191 
192  $form->setTitle(sprintf(
193  $this->lng->txt('tst_question_hints_form_header_edit'),
194  $questionHint->getIndex(),
195  $this->question_obj->getTitleForHTMLOutput()
196  ));
197 
198  $hiddenInp = new ilHiddenInputGUI('hint_id');
199  $form->addItem($hiddenInp);
200 
201  if (!$this->question_obj->isAdditionalContentEditingModePageObject()) {
202  $areaInp->setValue($questionHint->getText());
203  }
204 
205  $numInp->setValue((string) $questionHint->getPoints());
206 
207  $hiddenInp->setValue((string) $questionHint->getId());
208  } else {
209  // build form title for a new hint
210  $form->setTitle(sprintf(
211  $this->lng->txt('tst_question_hints_form_header_create'),
212  $this->question_obj->getTitleForHTMLOutput()
213  ));
214  }
215 
216  if ($this->question_obj->isAdditionalContentEditingModePageObject()) {
217  if ($questionHint instanceof ilAssQuestionHint) {
218  $saveCmdLabel = $this->lng->txt('tst_question_hints_form_cmd_save_points');
219  } else {
220  $saveCmdLabel = $this->lng->txt('tst_question_hints_form_cmd_save_points_and_edit_page');
221  }
222  } else {
223  $saveCmdLabel = $this->lng->txt('tst_question_hints_form_cmd_save');
224  }
225 
226  $form->setFormAction($this->ctrl->getFormAction($this));
227 
228  $form->addCommandButton(self::CMD_SAVE_FORM, $saveCmdLabel);
229  $form->addCommandButton(self::CMD_CANCEL_FORM, $this->lng->txt('cancel'));
230 
231  return $form;
232  }
allowDecimals(bool $a_value)
This class represents a hidden form property in a property form.
This class represents a number property in a property form.
setRequired(bool $a_required)
This class represents a text area property in a property form.
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancelFormCmd()

ilAssQuestionHintGUI::cancelFormCmd ( )
private

Definition at line 150 of file class.ilAssQuestionHintGUI.php.

References ILIAS\Repository\ctrl().

150  : void
151  {
152 
153  $this->ctrl->redirectByClass(ilAssQuestionHintsGUI::class);
154  }
+ Here is the call graph for this function:

◆ executeCommand()

ilAssQuestionHintGUI::executeCommand ( )

Definition at line 50 of file class.ilAssQuestionHintGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilAssQuestionHintPageObjectCommandForwarder\PRESENTATION_MODE_AUTHOR, and ILIAS\Repository\tabs().

51  {
52  $cmd = $this->ctrl->getCmd(self::CMD_SHOW_FORM);
53  $nextClass = $this->ctrl->getNextClass($this);
54 
55  switch ($nextClass) {
56  case 'ilasshintpagegui':
58  $this->question_obj,
59  $this->ctrl,
60  $this->tabs,
61  $this->lng
62  );
64  $forwarder->forward();
65  break;
66 
67  default:
68  $this->tabs->setTabActive('tst_question_hints_tab');
69  $cmd .= 'Cmd';
70  $this->$cmd();
71  break;
72  }
73 
74  return true;
75  }
+ Here is the call graph for this function:

◆ saveFormCmd()

ilAssQuestionHintGUI::saveFormCmd ( )
private

Definition at line 101 of file class.ilAssQuestionHintGUI.php.

References buildForm(), ilAssQuestionHintsGUI\CMD_CONFIRM_SYNC, ilAssQuestionHintsGUI\CMD_SHOW_LIST, ILIAS\Repository\ctrl(), ilAssQuestionHintList\getNextIndexByQuestionId(), ILIAS\Repository\lng(), and showFormCmd().

101  : void
102  {
103  $questionHint = new ilAssQuestionHint();
104  if ($this->request_data_collector->isset('hint_id')) {
105  $questionHint->load((int) $this->request_data_collector->int('hint_id'));
106 
107  $hintJustCreated = false;
108  $form = $this->buildForm($questionHint);
109  } else {
110  $questionHint->setQuestionId($this->question_obj->getId());
111 
112  $questionHint->setIndex(
113  ilAssQuestionHintList::getNextIndexByQuestionId($this->question_obj->getId())
114  );
115 
116  $hintJustCreated = true;
117  $form = $this->buildForm();
118  }
119 
120  if ($form->checkInput()) {
121  $questionHint->setText($form->getInput('hint_text'));
122  $questionHint->setPoints($form->getInput('hint_points'));
123 
124  $questionHint->save();
125  $this->main_tpl->setOnScreenMessage('success', $this->lng->txt('tst_question_hints_form_saved_msg'), true);
126 
127  if (!$this->question_obj->isAdditionalContentEditingModePageObject()) {
128  $this->question_obj->updateTimestamp();
129  }
130 
131  if ($this->question_gui->needsSyncQuery()) {
132  $this->ctrl->redirectByClass(
133  ilAssQuestionHintsGUI::class,
135  );
136  }
137 
138  if ($hintJustCreated && $this->question_obj->isAdditionalContentEditingModePageObject()) {
139  $this->ctrl->setParameterByClass(ilAssHintPageGUI::class, 'hint_id', $questionHint->getId());
140  $this->ctrl->redirectByClass(ilAssHintPageGUI::class, 'edit');
141  } else {
142  $this->ctrl->redirectByClass(ilAssQuestionHintsGUI::class, ilAssQuestionHintsGUI::CMD_SHOW_LIST);
143  }
144  }
145 
146  $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt('tst_question_hints_form_invalid_msg'));
147  $this->showFormCmd($form);
148  }
buildForm(?ilAssQuestionHint $questionHint=null)
showFormCmd(?ilPropertyFormGUI $form=null)
const CMD_SHOW_LIST
command constants
static getNextIndexByQuestionId($questionId)
determines the next index to be used for a new hint that is to be added to the list of existing hints...
+ Here is the call graph for this function:

◆ showFormCmd()

ilAssQuestionHintGUI::showFormCmd ( ?ilPropertyFormGUI  $form = null)
private

Definition at line 77 of file class.ilAssQuestionHintGUI.php.

References buildForm(), ilAssQuestionHintsGUI\CMD_SHOW_LIST, ILIAS\Repository\ctrl(), and ILIAS\Repository\int().

Referenced by saveFormCmd().

77  : void
78  {
79  if ($form instanceof ilPropertyFormGUI) {
80  $form->setValuesByPost();
81  } elseif ($this->request_data_collector->isset('hint_id') && (int) $this->request_data_collector->raw('hint_id')) {
82  $questionHint = new ilAssQuestionHint();
83 
84  if (!$questionHint->load((int) $this->request_data_collector->raw('hint_id'))) {
85  $this->main_tpl->setOnScreenMessage(
86  'failure',
87  'invalid hint id given: ' . $this->request_data_collector->string('hint_id'),
88  true
89  );
90  $this->ctrl->redirectByClass(ilAssQuestionHintsGUI::class, ilAssQuestionHintsGUI::CMD_SHOW_LIST);
91  }
92 
93  $form = $this->buildForm($questionHint);
94  } else {
95  $form = $this->buildForm();
96  }
97 
98  $this->main_tpl->setContent($form->getHTML());
99  }
buildForm(?ilAssQuestionHint $questionHint=null)
const CMD_SHOW_LIST
command constants
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $main_tpl

ilGlobalTemplateInterface ilAssQuestionHintGUI::$main_tpl
private

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

◆ $questionrepository

GeneralQuestionPropertiesRepository ilAssQuestionHintGUI::$questionrepository
private

Definition at line 38 of file class.ilAssQuestionHintGUI.php.

◆ CMD_CANCEL_FORM

const ilAssQuestionHintGUI::CMD_CANCEL_FORM = 'cancelForm'

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

◆ CMD_SAVE_FORM

const ilAssQuestionHintGUI::CMD_SAVE_FORM = 'saveForm'

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

◆ CMD_SHOW_FORM

const ilAssQuestionHintGUI::CMD_SHOW_FORM = 'showForm'

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