ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAssQuestionHintGUI Class Reference
+ Inheritance diagram for ilAssQuestionHintGUI:
+ Collaboration diagram for ilAssQuestionHintGUI:

Public Member Functions

 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...
 

Additional Inherited Members

- Protected Attributes inherited from ilAssQuestionHintAbstractGUI
 $questionGUI = null
 
 $questionOBJ = null
 

Detailed Description

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

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

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

Referenced by saveFormCmd(), and showFormCmd().

170  {
171  global $ilCtrl, $lng;
172 
173  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
174  require_once 'Services/Form/classes/class.ilTextAreaInputGUI.php';
175  require_once 'Services/Form/classes/class.ilNumberInputGUI.php';
176  require_once 'Services/Form/classes/class.ilHiddenInputGUI.php';
177 
178  $form = new ilPropertyFormGUI();
179  $form->setTableWidth('100%');
180 
181  if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
182  // form input: hint text
183 
184  $areaInp = new ilTextAreaInputGUI($lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text');
185  $areaInp->setRequired(true);
186  $areaInp->setRows(10);
187  $areaInp->setCols(80);
188 
189  if (!$this->questionOBJ->getPreventRteUsage()) {
190  $areaInp->setUseRte(true);
191  }
192 
193  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
194  $areaInp->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
195 
196  $areaInp->setRTESupport($this->questionOBJ->getId(), 'qpl', 'assessment');
197 
198  $areaInp->addPlugin("latex");
199  $areaInp->addButton("latex");
200  $areaInp->addButton("pastelatex");
201 
202  $form->addItem($areaInp);
203  }
204 
205  // form input: hint points
206 
207  $numInp = new ilNumberInputGUI($lng->txt('tst_question_hints_form_label_hint_points'), 'hint_points');
208  $numInp->allowDecimals(true);
209  $numInp->setRequired(true);
210  $numInp->setSize(3);
211 
212  $form->addItem($numInp);
213 
214  if ($questionHint instanceof ilAssQuestionHint) {
215  // build form title for an existing hint
216 
217  $form->setTitle(sprintf(
218  $lng->txt('tst_question_hints_form_header_edit'),
219  $questionHint->getIndex(),
220  $this->questionOBJ->getTitle()
221  ));
222 
223  // hidden input: hint id
224 
225  $hiddenInp = new ilHiddenInputGUI('hint_id');
226  $form->addItem($hiddenInp);
227 
228  // init values
229 
230  require_once 'Services/Utilities/classes/class.ilUtil.php';
231 
232  if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
233  $areaInp->setValue($questionHint->getText());
234  }
235 
236  $numInp->setValue($questionHint->getPoints());
237 
238  $hiddenInp->setValue($questionHint->getId());
239  } else {
240  // build form title for a new hint
241  $form->setTitle(sprintf(
242  $lng->txt('tst_question_hints_form_header_create'),
243  $this->questionOBJ->getTitle()
244  ));
245  }
246 
247  if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
248  if ($questionHint instanceof ilAssQuestionHint) {
249  $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save_points');
250  } else {
251  $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save_points_and_edit_page');
252  }
253  } else {
254  $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save');
255  }
256 
257  $form->setFormAction($ilCtrl->getFormAction($this));
258 
259  $form->addCommandButton(self::CMD_SAVE_FORM, $saveCmdLabel);
260  $form->addCommandButton(self::CMD_CANCEL_FORM, $lng->txt('cancel'));
261 
262  return $form;
263  }
This class represents a property form user interface.
getIndex()
returns the ordering index of hint
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
getId()
returns the hint id
global $ilCtrl
Definition: ilias.php:18
allowDecimals($a_value)
Toggle Decimals.
This class represents a hidden form property in a property form.
if(isset($_POST['submit'])) $form
This class represents a number property in a property form.
getPoints()
returns the points to ground-off for this hint
global $lng
Definition: privfeed.php:17
This class represents a text area property in a property form.
getText()
returns the hint text
setRequired($a_required)
Set Required.
+ 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 154 of file class.ilAssQuestionHintGUI.php.

References $ilCtrl.

155  {
156  global $ilCtrl;
157 
158  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI');
159  }
global $ilCtrl
Definition: ilias.php:18

◆ executeCommand()

ilAssQuestionHintGUI::executeCommand ( )

Execute Command.

public ilCtrl $ilCtrl

Returns
mixed

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

References $ilCtrl, $lng, $tpl, and ilAssQuestionHintPageObjectCommandForwarder\PRESENTATION_MODE_AUTHOR.

35  {
36  global $ilCtrl, $ilTabs, $lng, $tpl;
37 
38  $cmd = $ilCtrl->getCmd(self::CMD_SHOW_FORM);
39  $nextClass = $ilCtrl->getNextClass($this);
40 
41  switch ($nextClass) {
42  case 'ilasshintpagegui':
43 
44  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintPageObjectCommandForwarder.php';
45  $forwarder = new ilAssQuestionHintPageObjectCommandForwarder($this->questionOBJ, $ilCtrl, $ilTabs, $lng);
47  $forwarder->forward();
48  break;
49 
50  default:
51 
52  $cmd .= 'Cmd';
53  $this->$cmd();
54  break;
55  }
56 
57  return true;
58  }
$tpl
Definition: ilias.php:10
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17

◆ saveFormCmd()

ilAssQuestionHintGUI::saveFormCmd ( )
private

saves the form on successfull validation and redirects to showForm command

private ilCtrl $ilCtrl ilLanguage $lng

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

References $_GET, $form, $ilCtrl, $ilUser, $lng, assQuestion\_isWriteable(), buildForm(), ilAssQuestionHintsGUI\CMD_CONFIRM_SYNC, ilAssQuestionHintsGUI\CMD_SHOW_LIST, ilAssQuestionHintList\getNextIndexByQuestionId(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and showFormCmd().

97  {
98  global $ilCtrl, $lng, $ilUser;
99 
100  $form = $this->buildForm();
101 
102  if ($form->checkInput()) {
103  $questionHint = new ilAssQuestionHint();
104 
105  if ((int) $form->getInput('hint_id')) {
106  $questionHint->load((int) $form->getInput('hint_id'));
107 
108  $hintJustCreated = false;
109  } else {
110  $questionHint->setQuestionId($this->questionOBJ->getId());
111 
112  $questionHint->setIndex(
113  ilAssQuestionHintList::getNextIndexByQuestionId($this->questionOBJ->getId())
114  );
115 
116  $hintJustCreated = true;
117  }
118 
119  $questionHint->setText($form->getInput('hint_text'));
120  $questionHint->setPoints($form->getInput('hint_points'));
121 
122  $questionHint->save();
123  ilUtil::sendSuccess($lng->txt('tst_question_hints_form_saved_msg'), true);
124 
125  if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
126  $this->questionOBJ->updateTimestamp();
127  }
128 
129  $originalexists = $this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id);
130  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
131  if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId())) {
132  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
133  }
134 
135 
136  if ($hintJustCreated && $this->questionOBJ->isAdditionalContentEditingModePageObject()) {
137  $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $questionHint->getId());
138  $ilCtrl->redirectByClass('ilasshintpagegui', 'edit');
139  } else {
140  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
141  }
142  }
143 
144  ilUtil::sendFailure($lng->txt('tst_question_hints_form_invalid_msg'));
145  $this->showFormCmd($form);
146  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_GET["client_id"]
const CMD_SHOW_LIST
command constants
global $ilCtrl
Definition: ilias.php:18
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...
if(isset($_POST['submit'])) $form
buildForm(ilAssQuestionHint $questionHint=null)
builds the questions hints form
$ilUser
Definition: imgupload.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
showFormCmd(ilPropertyFormGUI $form=null)
shows the form for managing a new/existing hint
static _isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
+ 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 67 of file class.ilAssQuestionHintGUI.php.

References $_GET, $form, $ilCtrl, $lng, $tpl, buildForm(), ilAssQuestionHintsGUI\CMD_SHOW_LIST, and ilUtil\sendFailure().

Referenced by saveFormCmd().

68  {
69  global $ilCtrl, $tpl, $ilToolbar, $lng, $ilCtrl;
70 
71  if ($form instanceof ilPropertyFormGUI) {
72  $form->setValuesByPost();
73  } elseif (isset($_GET['hint_id']) && (int) $_GET['hint_id']) {
74  $questionHint = new ilAssQuestionHint();
75 
76  if (!$questionHint->load((int) $_GET['hint_id'])) {
77  ilUtil::sendFailure('invalid hint id given: ' . (int) $_GET['hint_id'], true);
78  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
79  }
80 
81  $form = $this->buildForm($questionHint);
82  } else {
83  $form = $this->buildForm();
84  }
85 
86  $tpl->setContent($form->getHTML());
87  }
This class represents a property form user interface.
$_GET["client_id"]
$tpl
Definition: ilias.php:10
const CMD_SHOW_LIST
command constants
global $ilCtrl
Definition: ilias.php:18
buildForm(ilAssQuestionHint $questionHint=null)
builds the questions hints form
setValuesByPost()
Set form values from POST values.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ CMD_CANCEL_FORM

const ilAssQuestionHintGUI::CMD_CANCEL_FORM = 'cancelForm'

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

◆ CMD_CONFIRM_FORM

const ilAssQuestionHintGUI::CMD_CONFIRM_FORM = 'confirmForm'

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

◆ CMD_SAVE_FORM

const ilAssQuestionHintGUI::CMD_SAVE_FORM = 'saveForm'

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

◆ CMD_SHOW_FORM

const ilAssQuestionHintGUI::CMD_SHOW_FORM = 'showForm'

command constants

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

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


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