ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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'
 
const CMD_CONFIRM_FORM = 'confirmForm'
 

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
 

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 32 of file class.ilAssQuestionHintGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionHintGUI::__construct ( assQuestionGUI  $questionGUI)

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

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

43  {
44  parent::__construct($questionGUI);
45  global $DIC;
46  $this->main_tpl = $DIC->ui()->mainTemplate();
47  }
global $DIC
Definition: feed.php:28
__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 202 of file class.ilAssQuestionHintGUI.php.

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

Referenced by saveFormCmd(), and showFormCmd().

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

References $DIC.

186  : void
187  {
188  global $DIC;
189  $ilCtrl = $DIC['ilCtrl'];
190 
191  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI');
192  }
global $DIC
Definition: feed.php:28

◆ executeCommand()

ilAssQuestionHintGUI::executeCommand ( )

Execute Command.

public ilCtrl $ilCtrl

Returns
mixed

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

References $DIC, $lng, $tpl, 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  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintPageObjectCommandForwarder.php';
70  $forwarder = new ilAssQuestionHintPageObjectCommandForwarder($this->questionOBJ, $ilCtrl, $ilTabs, $lng);
72  $forwarder->forward();
73  break;
74 
75  default:
76  $this->tabs->setTabActive('tst_question_hints_tab');
77  $cmd .= 'Cmd';
78  $this->$cmd();
79  break;
80  }
81 
82  return true;
83  }
$lng
global $DIC
Definition: feed.php:28
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ 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 126 of file class.ilAssQuestionHintGUI.php.

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

126  : void
127  {
128  global $DIC;
129  $ilCtrl = $DIC['ilCtrl'];
130  $lng = $DIC['lng'];
131  $ilUser = $DIC['ilUser'];
132 
133  $questionHint = new ilAssQuestionHint();
134  if ($this->request->isset('hint_id')) {
135  $questionHint->load((int) $this->request->int('hint_id'));
136 
137  $hintJustCreated = false;
138  $form = $this->buildForm($questionHint);
139  } else {
140  $questionHint->setQuestionId($this->questionOBJ->getId());
141 
142  $questionHint->setIndex(
143  ilAssQuestionHintList::getNextIndexByQuestionId($this->questionOBJ->getId())
144  );
145 
146  $hintJustCreated = true;
147  $form = $this->buildForm();
148  }
149 
150  if ($form->checkInput()) {
151  $questionHint->setText($form->getInput('hint_text'));
152  $questionHint->setPoints($form->getInput('hint_points'));
153 
154  $questionHint->save();
155  $this->main_tpl->setOnScreenMessage('success', $lng->txt('tst_question_hints_form_saved_msg'), true);
156 
157  if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
158  $this->questionOBJ->updateTimestamp();
159  }
160 
161  $originalexists = $this->questionOBJ->_questionExistsInPool((int) $this->questionOBJ->getOriginalId());
162  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
163  if ($this->request->raw('calling_test') && $originalexists && assQuestion::_isWriteable($this->questionOBJ->getOriginalId(), $ilUser->getId())) {
164  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
165  }
166 
167 
168  if ($hintJustCreated && $this->questionOBJ->isAdditionalContentEditingModePageObject()) {
169  $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $questionHint->getId());
170  $ilCtrl->redirectByClass('ilasshintpagegui', 'edit');
171  } else {
172  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
173  }
174  }
175 
176  $this->main_tpl->setOnScreenMessage('failure', $lng->txt('tst_question_hints_form_invalid_msg'));
177  $this->showFormCmd($form);
178  }
$lng
const CMD_SHOW_LIST
command constants
global $DIC
Definition: feed.php:28
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...
buildForm(ilAssQuestionHint $questionHint=null)
builds the questions hints form
$ilUser
Definition: imgupload.php:34
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 92 of file class.ilAssQuestionHintGUI.php.

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

Referenced by saveFormCmd().

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

◆ CMD_CANCEL_FORM

const ilAssQuestionHintGUI::CMD_CANCEL_FORM = 'cancelForm'

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

◆ CMD_CONFIRM_FORM

const ilAssQuestionHintGUI::CMD_CONFIRM_FORM = 'confirmForm'

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

◆ CMD_SAVE_FORM

const ilAssQuestionHintGUI::CMD_SAVE_FORM = 'saveForm'

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

◆ CMD_SHOW_FORM

const ilAssQuestionHintGUI::CMD_SHOW_FORM = 'showForm'

command constants

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

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


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