ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 182 of file class.ilAssQuestionHintGUI.php.

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

Referenced by saveFormCmd(), and showFormCmd().

183  {
184  global $DIC;
185  $ilCtrl = $DIC['ilCtrl'];
186  $lng = $DIC['lng'];
187 
188  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
189  require_once 'Services/Form/classes/class.ilTextAreaInputGUI.php';
190  require_once 'Services/Form/classes/class.ilNumberInputGUI.php';
191  require_once 'Services/Form/classes/class.ilHiddenInputGUI.php';
192 
193  $form = new ilPropertyFormGUI();
194  $form->setTableWidth('100%');
195 
196  if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
197  // form input: hint text
198 
199  $areaInp = new ilTextAreaInputGUI($lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text');
200  $areaInp->setRequired(true);
201  $areaInp->setRows(10);
202  $areaInp->setCols(80);
203 
204  if (!$this->questionOBJ->getPreventRteUsage()) {
205  $areaInp->setUseRte(true);
206  }
207 
208  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
209  $areaInp->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
210 
211  $areaInp->setRTESupport($this->questionOBJ->getId(), 'qpl', 'assessment');
212 
213  $areaInp->addPlugin("latex");
214  $areaInp->addButton("latex");
215  $areaInp->addButton("pastelatex");
216 
217  $form->addItem($areaInp);
218  }
219 
220  // form input: hint points
221 
222  $numInp = new ilNumberInputGUI($lng->txt('tst_question_hints_form_label_hint_points'), 'hint_points');
223  $numInp->allowDecimals(true);
224  $numInp->setRequired(true);
225  $numInp->setSize(3);
226 
227  $form->addItem($numInp);
228 
229  if ($questionHint instanceof ilAssQuestionHint) {
230  // build form title for an existing hint
231 
232  $form->setTitle(sprintf(
233  $lng->txt('tst_question_hints_form_header_edit'),
234  $questionHint->getIndex(),
235  $this->questionOBJ->getTitle()
236  ));
237 
238  // hidden input: hint id
239 
240  $hiddenInp = new ilHiddenInputGUI('hint_id');
241  $form->addItem($hiddenInp);
242 
243  // init values
244 
245  require_once 'Services/Utilities/classes/class.ilUtil.php';
246 
247  if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
248  $areaInp->setValue($questionHint->getText());
249  }
250 
251  $numInp->setValue($questionHint->getPoints());
252 
253  $hiddenInp->setValue($questionHint->getId());
254  } else {
255  // build form title for a new hint
256  $form->setTitle(sprintf(
257  $lng->txt('tst_question_hints_form_header_create'),
258  $this->questionOBJ->getTitle()
259  ));
260  }
261 
262  if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
263  if ($questionHint instanceof ilAssQuestionHint) {
264  $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save_points');
265  } else {
266  $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save_points_and_edit_page');
267  }
268  } else {
269  $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save');
270  }
271 
272  $form->setFormAction($ilCtrl->getFormAction($this));
273 
274  $form->addCommandButton(self::CMD_SAVE_FORM, $saveCmdLabel);
275  $form->addCommandButton(self::CMD_CANCEL_FORM, $lng->txt('cancel'));
276 
277  return $form;
278  }
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
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
$lng
This class represents a number property in a property form.
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
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 166 of file class.ilAssQuestionHintGUI.php.

References $DIC, and $ilCtrl.

167  {
168  global $DIC;
169  $ilCtrl = $DIC['ilCtrl'];
170 
171  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI');
172  }
global $DIC
Definition: saml.php:7
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 $DIC, $ilCtrl, $lng, $tpl, and ilAssQuestionHintPageObjectCommandForwarder\PRESENTATION_MODE_AUTHOR.

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

◆ saveFormCmd()

ilAssQuestionHintGUI::saveFormCmd ( )
private

saves the form on successfull validation and redirects to showForm command

private ilCtrl $ilCtrl ilLanguage $lng

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

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

106  {
107  global $DIC;
108  $ilCtrl = $DIC['ilCtrl'];
109  $lng = $DIC['lng'];
110  $ilUser = $DIC['ilUser'];
111 
112  $form = $this->buildForm();
113 
114  if ($form->checkInput()) {
115  $questionHint = new ilAssQuestionHint();
116 
117  if ((int) $form->getInput('hint_id')) {
118  $questionHint->load((int) $form->getInput('hint_id'));
119 
120  $hintJustCreated = false;
121  } else {
122  $questionHint->setQuestionId($this->questionOBJ->getId());
123 
124  $questionHint->setIndex(
125  ilAssQuestionHintList::getNextIndexByQuestionId($this->questionOBJ->getId())
126  );
127 
128  $hintJustCreated = true;
129  }
130 
131  $questionHint->setText($form->getInput('hint_text'));
132  $questionHint->setPoints($form->getInput('hint_points'));
133 
134  $questionHint->save();
135  ilUtil::sendSuccess($lng->txt('tst_question_hints_form_saved_msg'), true);
136 
137  if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
138  $this->questionOBJ->updateTimestamp();
139  }
140 
141  $originalexists = $this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id);
142  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
143  if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId())) {
144  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
145  }
146 
147 
148  if ($hintJustCreated && $this->questionOBJ->isAdditionalContentEditingModePageObject()) {
149  $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $questionHint->getId());
150  $ilCtrl->redirectByClass('ilasshintpagegui', 'edit');
151  } else {
152  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
153  }
154  }
155 
156  ilUtil::sendFailure($lng->txt('tst_question_hints_form_invalid_msg'));
157  $this->showFormCmd($form);
158  }
global $DIC
Definition: saml.php:7
$_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
$lng
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.
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 71 of file class.ilAssQuestionHintGUI.php.

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

Referenced by saveFormCmd().

72  {
73  global $DIC;
74  $ilCtrl = $DIC['ilCtrl'];
75  $tpl = $DIC['tpl'];
76  $ilToolbar = $DIC['ilToolbar'];
77  $lng = $DIC['lng'];
78  $ilCtrl = $DIC['ilCtrl'];
79 
80  if ($form instanceof ilPropertyFormGUI) {
81  $form->setValuesByPost();
82  } elseif (isset($_GET['hint_id']) && (int) $_GET['hint_id']) {
83  $questionHint = new ilAssQuestionHint();
84 
85  if (!$questionHint->load((int) $_GET['hint_id'])) {
86  ilUtil::sendFailure('invalid hint id given: ' . (int) $_GET['hint_id'], true);
87  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
88  }
89 
90  $form = $this->buildForm($questionHint);
91  } else {
92  $form = $this->buildForm();
93  }
94 
95  $tpl->setContent($form->getHTML());
96  }
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$tpl
Definition: ilias.php:10
const CMD_SHOW_LIST
command constants
global $ilCtrl
Definition: ilias.php:18
$lng
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.
+ 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: