ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
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 180 of file class.ilAssQuestionHintGUI.php.

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

Referenced by saveFormCmd(), and showFormCmd().

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

References $ilCtrl.

166  {
167  global $ilCtrl;
168 
169  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI');
170  }
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:40

◆ 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  $originalexists = $this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id);
137  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
138  if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId()))
139  {
140  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
141  }
142 
143 
144  if( $hintJustCreated && $this->questionOBJ->isAdditionalContentEditingModePageObject() )
145  {
146  $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $questionHint->getId());
147  $ilCtrl->redirectByClass('ilasshintpagegui', 'edit');
148  }
149  else
150  {
151  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
152  }
153  }
154 
155  ilUtil::sendFailure($lng->txt('tst_question_hints_form_invalid_msg'));
156  $this->showFormCmd($form);
157  }
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
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
_isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
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 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:40
+ 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: