ILIAS  trunk Revision v5.2.0beta1-34132-g2d4d73d4a0
ilAssQuestionHintGUI Class Reference
+ Inheritance diagram for ilAssQuestionHintGUI:
+ Collaboration diagram for ilAssQuestionHintGUI:

Public Member Functions

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

Data Fields

const CMD_SHOW_FORM = 'showForm'
 command constants More...
 
const CMD_SAVE_FORM = 'saveForm'
 
const CMD_CANCEL_FORM = 'cancelForm'
 

Private Member Functions

 showFormCmd (ilPropertyFormGUI $form=null)
 shows the form for managing a new/existing hint More...
 
 saveFormCmd ()
 saves the form on successfull validation and redirects to showForm command More...
 
 cancelFormCmd ()
 gateway command method to jump back to question hints overview More...
 
 buildForm (ilAssQuestionHint $questionHint=null)
 builds the questions hints form More...
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 
ILIAS TestQuestionPool QuestionInfoService $questioninfo
 

Additional Inherited Members

- Protected Attributes inherited from ilAssQuestionHintAbstractGUI
ILIAS TestQuestionPool InternalRequestService $request
 
assQuestionGUI $questionGUI = null
 
assQuestion $questionOBJ = null
 
ilTabsGUI $tabs
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionHintGUI::__construct ( assQuestionGUI  $questionGUI)

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

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

42  {
43  parent::__construct($questionGUI);
44  global $DIC;
45  $this->main_tpl = $DIC->ui()->mainTemplate();
46  $this->questioninfo = $DIC->testQuestionPool()->questionInfo();
47  }
$DIC
Definition: xapitoken.php:62
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ buildForm()

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

builds the questions hints form

private ilCtrl $ilCtrl ilLanguage $lng

Returns
ilPropertyFormGUI $form

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

References $DIC, $lng, ilObjAdvancedEditing\_getUsedHTMLTags(), and ilFormPropertyGUI\setRequired().

Referenced by saveFormCmd(), and showFormCmd().

201  {
202  global $DIC;
203  $ilCtrl = $DIC['ilCtrl'];
204  $lng = $DIC['lng'];
205 
206  $form = new ilPropertyFormGUI();
207  $form->setTableWidth('100%');
208 
209  if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
210  // form input: hint text
211 
212  $areaInp = new ilTextAreaInputGUI($lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text');
213  $areaInp->setRequired(true);
214  $areaInp->setRows(10);
215  $areaInp->setCols(80);
216 
217  if (!$this->questionOBJ->getPreventRteUsage()) {
218  $areaInp->setUseRte(true);
219  }
220 
221  $areaInp->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
222 
223  $areaInp->setRTESupport($this->questionOBJ->getId(), 'qpl', 'assessment');
224 
225  $areaInp->addPlugin("latex");
226  $areaInp->addButton("latex");
227  $areaInp->addButton("pastelatex");
228 
229  $form->addItem($areaInp);
230  }
231 
232  // form input: hint points
233 
234  $numInp = new ilNumberInputGUI($lng->txt('tst_question_hints_form_label_hint_points'), 'hint_points');
235  $numInp->allowDecimals(true);
236  $numInp->setRequired(true);
237  $numInp->setSize(3);
238 
239  $form->addItem($numInp);
240 
241  if ($questionHint instanceof ilAssQuestionHint) {
242  // build form title for an existing hint
243 
244  $form->setTitle(sprintf(
245  $lng->txt('tst_question_hints_form_header_edit'),
246  $questionHint->getIndex(),
247  $this->questionOBJ->getTitle()
248  ));
249 
250  $hiddenInp = new ilHiddenInputGUI('hint_id');
251  $form->addItem($hiddenInp);
252 
253  if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
254  $areaInp->setValue($questionHint->getText());
255  }
256 
257  $numInp->setValue($questionHint->getPoints());
258 
259  $hiddenInp->setValue($questionHint->getId());
260  } else {
261  // build form title for a new hint
262  $form->setTitle(sprintf(
263  $lng->txt('tst_question_hints_form_header_create'),
264  $this->questionOBJ->getTitle()
265  ));
266  }
267 
268  if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
269  if ($questionHint instanceof ilAssQuestionHint) {
270  $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save_points');
271  } else {
272  $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save_points_and_edit_page');
273  }
274  } else {
275  $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save');
276  }
277 
278  $form->setFormAction($ilCtrl->getFormAction($this));
279 
280  $form->addCommandButton(self::CMD_SAVE_FORM, $saveCmdLabel);
281  $form->addCommandButton(self::CMD_CANCEL_FORM, $lng->txt('cancel'));
282 
283  return $form;
284  }
getIndex()
returns the ordering index of hint
getId()
returns the hint id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$lng
$DIC
Definition: xapitoken.php:62
setRequired(bool $a_required)
getPoints()
returns the points to ground-off for this hint
This class represents a text area property in a property form.
getText()
returns the hint text
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

gateway command method to jump back to question hints overview

private ilCtrl $ilCtrl

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

References $DIC.

184  : void
185  {
186  global $DIC;
187  $ilCtrl = $DIC['ilCtrl'];
188 
189  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI');
190  }
$DIC
Definition: xapitoken.php:62

◆ executeCommand()

ilAssQuestionHintGUI::executeCommand ( )

Execute Command.

public ilCtrl $ilCtrl

Returns
mixed

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

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

57  {
58  global $DIC;
59  $ilCtrl = $DIC['ilCtrl'];
60  $ilTabs = $DIC['ilTabs'];
61  $lng = $DIC['lng'];
62  $tpl = $DIC['tpl'];
63 
64  $cmd = $ilCtrl->getCmd(self::CMD_SHOW_FORM);
65  $nextClass = $ilCtrl->getNextClass($this);
66 
67  switch ($nextClass) {
68  case 'ilasshintpagegui':
69  $forwarder = new ilAssQuestionHintPageObjectCommandForwarder($this->questionOBJ, $ilCtrl, $ilTabs, $lng);
71  $forwarder->forward();
72  break;
73 
74  default:
75  $this->tabs->setTabActive('tst_question_hints_tab');
76  $cmd .= 'Cmd';
77  $this->$cmd();
78  break;
79  }
80 
81  return true;
82  }
$lng
$DIC
Definition: xapitoken.php:62
+ Here is the call graph for this function:

◆ saveFormCmd()

ilAssQuestionHintGUI::saveFormCmd ( )
private

saves the form on successfull validation and redirects to showForm command

private ilCtrl $ilCtrl ilLanguage $lng

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

References $DIC, $lng, assQuestion\_isWriteable(), buildForm(), ilAssQuestionHintsGUI\CMD_CONFIRM_SYNC, ilAssQuestionHintsGUI\CMD_SHOW_LIST, ilAssQuestionHintList\getNextIndexByQuestionId(), and showFormCmd().

125  : void
126  {
127  global $DIC;
128  $ilCtrl = $DIC['ilCtrl'];
129  $lng = $DIC['lng'];
130  $ilUser = $DIC['ilUser'];
131 
132  $questionHint = new ilAssQuestionHint();
133  if ($this->request->isset('hint_id')) {
134  $questionHint->load((int) $this->request->int('hint_id'));
135 
136  $hintJustCreated = false;
137  $form = $this->buildForm($questionHint);
138  } else {
139  $questionHint->setQuestionId($this->questionOBJ->getId());
140 
141  $questionHint->setIndex(
142  ilAssQuestionHintList::getNextIndexByQuestionId($this->questionOBJ->getId())
143  );
144 
145  $hintJustCreated = true;
146  $form = $this->buildForm();
147  }
148 
149  if ($form->checkInput()) {
150  $questionHint->setText($form->getInput('hint_text'));
151  $questionHint->setPoints($form->getInput('hint_points'));
152 
153  $questionHint->save();
154  $this->main_tpl->setOnScreenMessage('success', $lng->txt('tst_question_hints_form_saved_msg'), true);
155 
156  if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
157  $this->questionOBJ->updateTimestamp();
158  }
159 
160  $originalexists = $this->questioninfo->questionExistsInPool((int) $this->questionOBJ->getOriginalId());
161  if ($this->request->raw('calling_test') && $originalexists && assQuestion::_isWriteable($this->questionOBJ->getOriginalId(), $ilUser->getId())) {
162  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
163  }
164 
165 
166  if ($hintJustCreated && $this->questionOBJ->isAdditionalContentEditingModePageObject()) {
167  $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $questionHint->getId());
168  $ilCtrl->redirectByClass('ilasshintpagegui', 'edit');
169  } else {
170  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
171  }
172  }
173 
174  $this->main_tpl->setOnScreenMessage('failure', $lng->txt('tst_question_hints_form_invalid_msg'));
175  $this->showFormCmd($form);
176  }
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...
$lng
buildForm(ilAssQuestionHint $questionHint=null)
builds the questions hints form
$DIC
Definition: xapitoken.php:62
static _isWriteable(int $question_id, int $user_id)
showFormCmd(ilPropertyFormGUI $form=null)
shows the form for managing a new/existing hint
+ Here is the call graph for this function:

◆ showFormCmd()

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

shows the form for managing a new/existing hint

private ilCtrl $ilCtrl ilTemplate $tpl

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

References $DIC, $lng, buildForm(), ilAssQuestionHintsGUI\CMD_SHOW_LIST, and ILIAS\Repository\int().

Referenced by saveFormCmd().

91  : void
92  {
93  global $DIC;
94  $ilCtrl = $DIC['ilCtrl'];
95  $tpl = $DIC['tpl'];
96  $ilToolbar = $DIC['ilToolbar'];
97  $lng = $DIC['lng'];
98  $ilCtrl = $DIC['ilCtrl'];
99 
100  if ($form instanceof ilPropertyFormGUI) {
101  $form->setValuesByPost();
102  } elseif ($this->request->isset('hint_id') && (int) $this->request->raw('hint_id')) {
103  $questionHint = new ilAssQuestionHint();
104 
105  if (!$questionHint->load((int) $this->request->raw('hint_id'))) {
106  $this->main_tpl->setOnScreenMessage('failure', 'invalid hint id given: ' . (int) $this->request->raw('hint_id'), true);
107  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
108  }
109 
110  $form = $this->buildForm($questionHint);
111  } else {
112  $form = $this->buildForm();
113  }
114 
115  $tpl->setContent($form->getHTML());
116  }
const CMD_SHOW_LIST
command constants
$lng
buildForm(ilAssQuestionHint $questionHint=null)
builds the questions hints form
$DIC
Definition: xapitoken.php:62
+ 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 38 of file class.ilAssQuestionHintGUI.php.

◆ $questioninfo

ILIAS TestQuestionPool QuestionInfoService ilAssQuestionHintGUI::$questioninfo
private

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

◆ CMD_CANCEL_FORM

const ilAssQuestionHintGUI::CMD_CANCEL_FORM = 'cancelForm'

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

◆ CMD_SAVE_FORM

const ilAssQuestionHintGUI::CMD_SAVE_FORM = 'saveForm'

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

◆ CMD_SHOW_FORM

const ilAssQuestionHintGUI::CMD_SHOW_FORM = 'showForm'

command constants

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

Referenced by ilAssQuestionHintsTableGUI\fillRow(), and ilAssQuestionHintsGUI\showListCmd().


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