ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
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 185 of file class.ilAssQuestionHintGUI.php.

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

Referenced by saveFormCmd(), and showFormCmd().

186  {
187  global $ilCtrl, $lng;
188 
189  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
190  require_once 'Services/Form/classes/class.ilTextAreaInputGUI.php';
191  require_once 'Services/Form/classes/class.ilNumberInputGUI.php';
192  require_once 'Services/Form/classes/class.ilHiddenInputGUI.php';
193 
194  $form = new ilPropertyFormGUI();
195  $form->setTableWidth('100%');
196 
197  if( !$this->questionOBJ->isAdditionalContentEditingModePageObject() )
198  {
199  // form input: hint text
200 
201  $areaInp = new ilTextAreaInputGUI($lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text');
202  $areaInp->setRequired(true);
203  $areaInp->setRows(10);
204  $areaInp->setCols(80);
205 
206  if( !$this->questionOBJ->getPreventRteUsage() ) $areaInp->setUseRte(true);
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  {
231  // build form title for an existing hint
232 
233  $form->setTitle(sprintf(
234  $lng->txt('tst_question_hints_form_header_edit'),
235  $questionHint->getIndex(),
236  $this->questionOBJ->getTitle()
237  ));
238 
239  // hidden input: hint id
240 
241  $hiddenInp = new ilHiddenInputGUI('hint_id');
242  $form->addItem($hiddenInp);
243 
244  // init values
245 
246  require_once 'Services/Utilities/classes/class.ilUtil.php';
247 
248  if( !$this->questionOBJ->isAdditionalContentEditingModePageObject() )
249  {
250  $areaInp->setValue( ilUtil::prepareTextareaOutput($questionHint->getText(), true) );
251  }
252 
253  $numInp->setValue($questionHint->getPoints());
254 
255  $hiddenInp->setValue($questionHint->getId());
256  }
257  else
258  {
259  // build form title for a new hint
260  $form->setTitle(sprintf(
261  $lng->txt('tst_question_hints_form_header_create'),
262  $this->questionOBJ->getTitle()
263  ));
264  }
265 
266  if( $this->questionOBJ->isAdditionalContentEditingModePageObject() )
267  {
268  if( $questionHint instanceof ilAssQuestionHint )
269  {
270  $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save_points');
271  }
272  else
273  {
274  $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save_points_and_edit_page');
275  }
276  }
277  else
278  {
279  $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save');
280  }
281 
282  $form->setFormAction($ilCtrl->getFormAction($this));
283 
284  $form->addCommandButton(self::CMD_SAVE_FORM, $saveCmdLabel);
285  $form->addCommandButton(self::CMD_CANCEL_FORM, $lng->txt('cancel'));
286 
287  return $form;
288  }
static prepareTextareaOutput($txt_output, $prepare_for_latex_output=FALSE, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
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.
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 170 of file class.ilAssQuestionHintGUI.php.

References $ilCtrl.

171  {
172  global $ilCtrl;
173 
174  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI');
175  }
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 $cmd, $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  {
43  case 'ilasshintpagegui':
44 
45  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintPageObjectCommandForwarder.php';
46  $forwarder = new ilAssQuestionHintPageObjectCommandForwarder($this->questionOBJ, $ilCtrl, $ilTabs, $lng);
48  $forwarder->forward();
49  break;
50 
51  default:
52 
53  $cmd .= 'Cmd';
54  $this->$cmd();
55  break;
56  }
57 
58  return true;
59  }
$cmd
Definition: sahs_server.php:35
global $tpl
Definition: ilias.php:8
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 103 of file class.ilAssQuestionHintGUI.php.

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

104  {
105  global $ilCtrl, $lng, $ilUser;
106 
107  $form = $this->buildForm();
108 
109  if( $form->checkInput() )
110  {
111  $questionHint = new ilAssQuestionHint();
112 
113  if( (int)$form->getInput('hint_id') )
114  {
115  $questionHint->load( (int)$form->getInput('hint_id') );
116 
117  $hintJustCreated = false;
118  }
119  else
120  {
121  $questionHint->setQuestionId( $this->questionOBJ->getId() );
122 
123  $questionHint->setIndex(
124  ilAssQuestionHintList::getNextIndexByQuestionId($this->questionOBJ->getId())
125  );
126 
127  $hintJustCreated = true;
128  }
129 
130  $questionHint->setText( $form->getInput('hint_text') );
131  $questionHint->setPoints( $form->getInput('hint_points') );
132 
133  $questionHint->save();
134  ilUtil::sendSuccess($lng->txt('tst_question_hints_form_saved_msg'), true);
135 
136  if(!$this->questionOBJ->isAdditionalContentEditingModePageObject())
137  {
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  {
145  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
146  }
147 
148 
149  if( $hintJustCreated && $this->questionOBJ->isAdditionalContentEditingModePageObject() )
150  {
151  $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $questionHint->getId());
152  $ilCtrl->redirectByClass('ilasshintpagegui', 'edit');
153  }
154  else
155  {
156  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
157  }
158  }
159 
160  ilUtil::sendFailure($lng->txt('tst_question_hints_form_invalid_msg'));
161  $this->showFormCmd($form);
162  }
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...
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 68 of file class.ilAssQuestionHintGUI.php.

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

Referenced by saveFormCmd().

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