ILIAS  release_7 Revision v7.30-3-g800a261c036
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

@access private @global ilCtrl $ilCtrl @global ilLanguage $lng

Returns
ilPropertyFormGUI $form

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

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

References $DIC, $lng, and ilObjAdvancedEditing\_getUsedHTMLTags().

Referenced by saveFormCmd(), and showFormCmd().

+ 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

@access private @global ilCtrl $ilCtrl

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

178 {
179 global $DIC;
180 $ilCtrl = $DIC['ilCtrl'];
181
182 $ilCtrl->redirectByClass('ilAssQuestionHintsGUI');
183 }

References $DIC.

◆ executeCommand()

ilAssQuestionHintGUI::executeCommand ( )

Execute Command.

@access public @global ilCtrl $ilCtrl

Returns
mixed

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

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 }
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

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

◆ saveFormCmd()

ilAssQuestionHintGUI::saveFormCmd ( )
private

saves the form on successfull validation and redirects to showForm command

@access private @global ilCtrl $ilCtrl @global ilLanguage $lng

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

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
136 if ($this->questionOBJ->isAdditionalContentEditingModePageObject() && !ilAssHintPage::_exists(
137 'qht',
138 $form->getInput('hint_id')
139 )) {
140 $pageObject = new ilAssHintPage();
141 $pageObject->setParentId($this->questionOBJ->getId());
142 $pageObject->setId($questionHint->getId());
143 $pageObject->createFromXML();
144 }
145
146 ilUtil::sendSuccess($lng->txt('tst_question_hints_form_saved_msg'), true);
147
148 if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
149 $this->questionOBJ->updateTimestamp();
150 }
151
152 $originalexists = $this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id);
153 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
154 if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId())) {
155 $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
156 }
157
158
159 if ($hintJustCreated && $this->questionOBJ->isAdditionalContentEditingModePageObject()) {
160 $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $questionHint->getId());
161 $ilCtrl->redirectByClass('ilasshintpagegui', 'edit');
162 } else {
163 $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
164 }
165 }
166
167 ilUtil::sendFailure($lng->txt('tst_question_hints_form_invalid_msg'));
168 $this->showFormCmd($form);
169 }
$_GET["client_id"]
static _isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
Assessment hint page object.
buildForm(ilAssQuestionHint $questionHint=null)
builds the questions hints form
showFormCmd(ilPropertyFormGUI $form=null)
shows the form for managing a new/existing hint
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...
const CMD_SHOW_LIST
command constants
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$ilUser
Definition: imgupload.php:18

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

+ Here is the call graph for this function:

◆ showFormCmd()

ilAssQuestionHintGUI::showFormCmd ( ilPropertyFormGUI  $form = null)
private

shows the form for managing a new/existing hint

@access private @global ilCtrl $ilCtrl @global ilTemplate $tpl

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

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 }
setValuesByPost()
Set form values from POST values.

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

Referenced by saveFormCmd().

+ 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: