ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
assTextQuestionGUI Class Reference

Text question GUI representation. More...

+ Inheritance diagram for assTextQuestionGUI:
+ Collaboration diagram for assTextQuestionGUI:

Public Member Functions

 __construct ($id=-1)
 assTextQuestionGUI constructor More...
 
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 editQuestion ($checkonly=FALSE)
 Creates an output of the edit form for the question. More...
 
 outAdditionalOutput ()
 
 outQuestionForTest ($formaction, $active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE)
 
 getSolutionOutput ( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
 Get the question solution output. More...
 
 getPreview ($show_question_only=FALSE)
 
 getTestOutput ($active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE)
 
 addSuggestedSolution ()
 
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type. More...
 
 getSpecificFeedbackOutput ($active_id, $pass)
 
 writeQuestionSpecificPostData ( $always=true)
 
 writeAnswerSpecificPostData ( $always=true)
 
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 
 populateAnswerSpecificFormPart (\ilPropertyFormGUI $form)
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAggregatedAnswersView ($relevant_answers)
 Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface. More...
 
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor More...
 
executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 
 getType ()
 needed for page editor compliance More...
 
 setTaxonomyIds ($taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui (ilTestPlayerAbstractGUI $linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 assessment ()
 output assessment More...
 
_getQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls. More...
 
 _getGUIClassNameForId ($a_q_id)
 
 _getClassNameForQType ($q_type)
 
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation. More...
 
 getQuestionTemplate ()
 get question template More...
 
 getILIASPage ($html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="")
 output question page More...
 
 cancel ()
 cancel action More...
 
 originalSyncForm ($return_to="", $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 save question More...
 
 save ()
 save question More...
 
 saveReturn ()
 save question More...
 
 apply ()
 apply changes More...
 
 getContextPath ($cont_obj, $a_endnode_id, $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber ($nr)
 
 getSequenceNumber ()
 
 setQuestionCount ($a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage ($errormessage)
 
 addErrorMessage ($errormessage)
 
 outAdditionalOutput ()
 
 getQuestionType ()
 Returns the question type string. More...
 
 getAsValueAttribute ($a_value)
 Returns a HTML value attribute. More...
 
 addNewIdListener (&$a_object, $a_method, $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners ($a_new_id)
 Call the new id listeners. More...
 
 addQuestionFormCommandButtons ($form)
 Add the command buttons of a question properties form. More...
 
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time. More...
 
 getSelfAssessmentTags ()
 Get tags allowed in question tags in self assessment mode. More...
 
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question. More...
 
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 getSpecificFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 showSuggestedSolution ()
 
 suggestedsolution ()
 Allows to add suggested solutions for questions. More...
 
 outSolutionExplorer ()
 
 saveSuggestedSolution ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 getSolutionOutput ( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
 
 isAutosaveable ()
 
 showHints ()
 

Private Member Functions

 getBestAnswer ()
 
 getUserAnswer ($active_id, $pass)
 

Static Private Member Functions

static buildAnswerTextOnlyArray ($answers)
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static getCommandsFromClassConstants ($guiClassName, $cmdConstantNameBegin='CMD_')
 extracts values of all constants of given class with given prefix as array can be used to get all possible commands in case of these commands are defined as constants More...
 
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
 $object
 
 $tpl
 
 $lng
 
 $error
 
 $errormessage
 
 $sequence_no
 sequence number in test More...
 
 $question_count
 question count in test More...
 
- Protected Member Functions inherited from assQuestionGUI
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI More...
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI More...
 
 writeQuestionGenericPostData ()
 

Detailed Description

Text question GUI representation.

The assTextQuestionGUI class encapsulates the GUI representation for text questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

assTextQuestionGUI::__construct (   $id = -1)

assTextQuestionGUI constructor

The constructor takes possible arguments an creates an instance of the assTextQuestionGUI object.

Parameters
integer$idThe database id of a text question object

Definition at line 31 of file class.assTextQuestionGUI.php.

32  {
33  parent::__construct();
34  include_once "./Modules/TestQuestionPool/classes/class.assTextQuestion.php";
35  $this->object = new assTextQuestion();
36  if ($id >= 0)
37  {
38  $this->object->loadFromDb($id);
39  }
40  }
Class for text questions.

Member Function Documentation

◆ addSuggestedSolution()

assTextQuestionGUI::addSuggestedSolution ( )

Definition at line 386 of file class.assTextQuestionGUI.php.

References $_POST, $_SESSION, editQuestion(), assQuestionGUI\getErrorMessage(), assQuestionGUI\getQuestionTemplate(), ilUtil\sendInfo(), and assQuestionGUI\writePostData().

387  {
388  $_SESSION["subquestion_index"] = 0;
389  if ($_POST["cmd"]["addSuggestedSolution"])
390  {
391  if ($this->writePostData())
392  {
394  $this->editQuestion();
395  return;
396  }
397  if (!$this->checkInput())
398  {
399  ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
400  $this->editQuestion();
401  return;
402  }
403  }
404  $this->object->saveToDb();
405  $this->ctrl->setParameter($this, "q_id", $this->object->getId());
406  $this->tpl->setVariable("HEADER", $this->object->getTitle());
407  $this->getQuestionTemplate();
408  parent::addSuggestedSolution();
409  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
$_POST['username']
Definition: cron.php:12
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
getQuestionTemplate()
get question template
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:

◆ buildAnswerTextOnlyArray()

static assTextQuestionGUI::buildAnswerTextOnlyArray (   $answers)
staticprivate

Definition at line 104 of file class.assTextQuestionGUI.php.

105  {
106  $answerTexts = array();
107 
108  foreach($answers as $answer)
109  {
110  $answerTexts[] = $answer->getAnswertext();
111  }
112 
113  return $answerTexts;
114  }

◆ editQuestion()

assTextQuestionGUI::editQuestion (   $checkonly = FALSE)

Creates an output of the edit form for the question.

public

Definition at line 68 of file class.assTextQuestionGUI.php.

References $errors, assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), assQuestionGUI\getQuestionTemplate(), assQuestionGUI\isSaveCommand(), assQuestionGUI\outQuestionType(), populateAnswerSpecificFormPart(), populateQuestionSpecificFormPart(), and assQuestionGUI\populateTaxonomyFormSection().

Referenced by addSuggestedSolution(), and writePostData().

69  {
70  $save = $this->isSaveCommand();
71  $this->getQuestionTemplate();
72 
73  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
74  $form = new ilPropertyFormGUI();
75  $form->setFormAction($this->ctrl->getFormAction($this));
76  $form->setTitle($this->outQuestionType());
77  $form->setMultipart(TRUE);
78  $form->setTableWidth("100%");
79  $form->setId("asstextquestion");
80 
81  $this->addBasicQuestionFormProperties( $form );
82  $this->populateQuestionSpecificFormPart( $form );
83  $this->populateAnswerSpecificFormPart( $form );
84 
85 
86  $this->populateTaxonomyFormSection($form);
87 
88  $this->addQuestionFormCommandButtons($form);
89 
90  $errors = false;
91 
92  if ($save)
93  {
94  $form->setValuesByPost();
95  $errors = !$form->checkInput();
96  $form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
97  if ($errors) $checkonly = false;
98  }
99 
100  if (!$checkonly) $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
101  return $errors;
102  }
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
This class represents a property form user interface.
$errors
getQuestionTemplate()
get question template
populateTaxonomyFormSection(ilPropertyFormGUI $form)
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAfterParticipationSuppressionAnswerPostVars()

assTextQuestionGUI::getAfterParticipationSuppressionAnswerPostVars ( )

Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.

The form elements will be shown disabled, so the users see the usual form but can only edit the settings, which make sense in the given context.

E.g. array('cloze_type', 'image_filename')

Returns
string[]

Definition at line 690 of file class.assTextQuestionGUI.php.

691  {
692  return array();
693  }

◆ getAfterParticipationSuppressionQuestionPostVars()

assTextQuestionGUI::getAfterParticipationSuppressionQuestionPostVars ( )

Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.

The form elements will be shown disabled, so the users see the usual form but can only edit the settings, which make sense in the given context.

E.g. array('cloze_type', 'image_filename')

Returns
string[]

Definition at line 704 of file class.assTextQuestionGUI.php.

705  {
706  return array();
707  }

◆ getAggregatedAnswersView()

assTextQuestionGUI::getAggregatedAnswersView (   $relevant_answers)

Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface.

Parameters
array$relevant_answers
Returns
string

Definition at line 717 of file class.assTextQuestionGUI.php.

718  {
719  return ''; //print_r($relevant_answers,true);
720  }

◆ getBestAnswer()

assTextQuestionGUI::getBestAnswer ( )
private

Definition at line 262 of file class.assTextQuestionGUI.php.

References assTextQuestion\getScoringModesWithPointsByKeyword().

Referenced by getSolutionOutput().

263  {
264  $answers = $this->object->getAnswers();
265  if (count( $answers ))
266  {
267  $user_solution = $this->lng->txt( "solution_contain_keywords" ) . "<ul>";
268 
269  foreach ($answers as $answer)
270  {
271  $user_solution .= '<li>'. $answer->getAnswertext();
272 
273  if( in_array($this->object->getKeywordRelation(), assTextQuestion::getScoringModesWithPointsByKeyword()) )
274  {
275  $user_solution .= ' ' . $this->lng->txt('for') . ' ';
276  $user_solution .= $answer->getPoints() . ' ' . $this->lng->txt('points') . '</li>';
277  }
278  }
279  $user_solution .= '</ul>';
280 
281  $user_solution .= $this->lng->txt('essay_scoring_mode') . ': ';
282 
283  switch( $this->object->getKeywordRelation() )
284  {
285  case 'any':
286  $user_solution .= $this->lng->txt('essay_scoring_mode_keyword_relation_any');
287  break;
288  case 'all':
289  $user_solution .= $this->lng->txt('essay_scoring_mode_keyword_relation_all');
290  break;
291  case 'one':
292  $user_solution .= $this->lng->txt('essay_scoring_mode_keyword_relation_one');
293  break;
294  }
295  }
296  return $user_solution;
297  }
static getScoringModesWithPointsByKeyword()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPreview()

assTextQuestionGUI::getPreview (   $show_question_only = FALSE)

Definition at line 310 of file class.assTextQuestionGUI.php.

References assQuestionGUI\getILIASPage().

311  {
312  // generate the question output
313  include_once "./Services/UICore/classes/class.ilTemplate.php";
314  $template = new ilTemplate("tpl.il_as_qpl_text_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
315  if ($this->object->getMaxNumOfChars())
316  {
317  $template->setCurrentBlock("maximum_char_hint");
318  $template->setVariable("MAXIMUM_CHAR_HINT", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()));
319  $template->parseCurrentBlock();
320  #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
321  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
322  $template->parseCurrentBlock();
323  $template->setCurrentBlock("maxchars_counter");
324  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
325  $template->setVariable("TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
326  $template->setVariable("CHARACTERS", $this->lng->txt("characters"));
327  $template->parseCurrentBlock();
328  }
329  $questiontext = $this->object->getQuestion();
330  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
331  $questionoutput = $template->get();
332  if (!$show_question_only)
333  {
334  // get page object output
335  $questionoutput = $this->getILIASPage($questionoutput);
336  }
337  return $questionoutput;
338  }
getILIASPage($html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:

◆ getSolutionOutput()

assTextQuestionGUI::getSolutionOutput (   $active_id,
  $pass = NULL,
  $graphicalOutput = FALSE,
  $result_output = FALSE,
  $show_question_only = TRUE,
  $show_feedback = FALSE,
  $show_correct_solution = FALSE,
  $show_manual_scoring = FALSE,
  $show_question_text = TRUE 
)

Get the question solution output.

Parameters
integer$active_idThe active user id
integer$passThe test pass
boolean$graphicalOutputShow visual feedback for right/wrong answers
boolean$result_outputShow the reached points for parts of the question
boolean$show_question_onlyShow the question without the ILIAS content around
boolean$show_feedbackShow the question feedback
boolean$show_correct_solutionShow the correct solution instead of the user solution
boolean$show_manual_scoringShow specific information for the manual scoring output
Returns
The solution output of the question as HTML code

Definition at line 156 of file class.assTextQuestionGUI.php.

References $pass, getBestAnswer(), assQuestionGUI\getGenericFeedbackOutput(), ilUtil\getImagePath(), getSpecificFeedbackOutput(), and getUserAnswer().

167  {
168  // get the solution of the user for the active pass or from the last pass if allowed
169 
170  $user_solution = $this->getUserAnswer( $active_id, $pass );
171 
172  if (($active_id > 0) && (!$show_correct_solution))
173  {
174  $solution = $user_solution;
175  }
176  else
177  {
178  $solution = $this->getBestAnswer();
179  }
180 
181  // generate the question output
182  include_once "./Services/UICore/classes/class.ilTemplate.php";
183  $template = new ilTemplate("tpl.il_as_qpl_text_question_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
184  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
185 
186  $solution = $this->object->getHtmlUserSolutionPurifier()->purify($solution);
187  $template->setVariable("ESSAY", $this->object->prepareTextareaOutput($solution, TRUE));
188 
189  $questiontext = $this->object->getQuestion();
190 
191  if (!$show_correct_solution)
192  {
193  $max_no_of_chars = $this->object->getMaxNumOfChars();
194 
195  if ($max_no_of_chars == 0)
196  {
197  $max_no_of_chars = ucfirst($this->lng->txt('unlimited'));
198  }
199 
200  $act_no_of_chars = strlen($user_solution);
201  $template->setVariable("CHARACTER_INFO", '<b>' . $max_no_of_chars . '</b>' .
202  $this->lng->txt('answer_characters') . ' <b>' . $act_no_of_chars . '</b>');
203  }
204  if (($active_id > 0) && (!$show_correct_solution))
205  {
206  if ($graphicalOutput)
207  {
208  // output of ok/not ok icons for user entered solutions
209  $reached_points = $this->object->getReachedPoints($active_id, $pass);
210  if ($reached_points == $this->object->getMaximumPoints())
211  {
212  $template->setCurrentBlock("icon_ok");
213  $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.png"));
214  $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
215  $template->parseCurrentBlock();
216  }
217  else
218  {
219  $template->setCurrentBlock("icon_ok");
220  if ($reached_points > 0)
221  {
222  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.png"));
223  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive"));
224  }
225  else
226  {
227  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.png"));
228  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
229  }
230  $template->parseCurrentBlock();
231  }
232  }
233  }
234  if ($show_question_text==true)
235  {
236  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
237  }
238  $questionoutput = $template->get();
239 
240  $feedback = '';
241  if($show_feedback)
242  {
243  $fb = $this->getGenericFeedbackOutput($active_id, $pass);
244  $feedback .= strlen($fb) ? $fb : '';
245 
246  $fb = $this->getSpecificFeedbackOutput($active_id, $pass);
247  $feedback .= strlen($fb) ? $fb : '';
248  }
249  if (strlen($feedback)) $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $feedback, true ));
250 
251  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
252 
253  $solutionoutput = $solutiontemplate->get();
254  if (!$show_question_only)
255  {
256  // get page object output
257  $solutionoutput = '<div class="ilc_question_Standard">'.$solutionoutput."</div>";
258  }
259  return $solutionoutput;
260  }
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getUserAnswer($active_id, $pass)
special template class to simplify handling of ITX/PEAR
getSpecificFeedbackOutput($active_id, $pass)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assTextQuestionGUI::getSpecificFeedbackOutput (   $active_id,
  $pass 
)

Definition at line 511 of file class.assTextQuestionGUI.php.

Referenced by getSolutionOutput().

512  {
513  $feedback = '<table><tbody>';
514  $user_answers = $this->object->getSolutionValues($active_id);
515  $user_answer = ' '. $user_answers[0]['value1'];
516 
517  foreach ($this->object->getAnswers() as $idx => $ans)
518  {
519  if ($this->object->isKeywordMatching($user_answer, $ans->getAnswertext() ))
520  {
521  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
522  $this->object->getId(), $idx
523  );
524  $feedback .= '<tr><td><b><i>' . $ans->getAnswertext() . '</i></b></td><td>';
525  $feedback .= $fb . '</td> </tr>';
526  }
527  }
528 
529  $feedback .= '</tbody></table>';
530  return $this->object->prepareTextareaOutput($feedback, TRUE);
531  }
+ Here is the caller graph for this function:

◆ getTestOutput()

assTextQuestionGUI::getTestOutput (   $active_id,
  $pass = NULL,
  $is_postponed = FALSE,
  $use_post_solutions = FALSE 
)

Definition at line 340 of file class.assTextQuestionGUI.php.

References $pass, ilObjTest\_getPass(), ilObjTest\_getUsePreviousAnswers(), ilYuiUtil\initDomEvent(), assQuestionGUI\outQuestionPage(), and ilUtil\prepareFormOutput().

Referenced by outQuestionForTest().

341  {
342  // get the solution of the user for the active pass or from the last pass if allowed
343  $user_solution = "";
344  if ($active_id)
345  {
346  $solutions = NULL;
347  include_once "./Modules/Test/classes/class.ilObjTest.php";
348  if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
349  {
350  if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
351  }
352  $solutions =& $this->object->getSolutionValues($active_id, $pass);
353  foreach ($solutions as $idx => $solution_value)
354  {
355  $user_solution = $solution_value["value1"];
356  }
357  }
358 
359  // generate the question output
360  include_once "./Services/UICore/classes/class.ilTemplate.php";
361  $template = new ilTemplate("tpl.il_as_qpl_text_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
362  if ($this->object->getMaxNumOfChars())
363  {
364  $template->setCurrentBlock("maximum_char_hint");
365  $template->setVariable("MAXIMUM_CHAR_HINT", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()));
366  $template->parseCurrentBlock();
367  #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
368  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
369  $template->parseCurrentBlock();
370  $template->setCurrentBlock("maxchars_counter");
371  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
372  $template->setVariable("TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
373  $template->setVariable("CHARACTERS", $this->lng->txt("characters"));
374  $template->parseCurrentBlock();
375  }
376  $template->setVariable("ESSAY", ilUtil::prepareFormOutput($user_solution));
377  $questiontext = $this->object->getQuestion();
378  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
379  $questionoutput = $template->get();
380  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
381  include_once "./Services/YUI/classes/class.ilYuiUtil.php";
383  return $pageoutput;
384  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
special template class to simplify handling of ITX/PEAR
static initDomEvent()
Init YUI DomEvent.
_getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserAnswer()

assTextQuestionGUI::getUserAnswer (   $active_id,
  $pass 
)
private

Definition at line 299 of file class.assTextQuestionGUI.php.

References $pass.

Referenced by getSolutionOutput().

300  {
301  $user_solution = "";
302  $solutions = $this->object->getSolutionValues( $active_id, $pass );
303  foreach ($solutions as $idx => $solution_value)
304  {
305  $user_solution = $solution_value["value1"];
306  }
307  return $user_solution;
308  }
+ Here is the caller graph for this function:

◆ outAdditionalOutput()

assTextQuestionGUI::outAdditionalOutput ( )

Definition at line 116 of file class.assTextQuestionGUI.php.

Referenced by outQuestionForTest().

117  {
118  if ($this->object->getMaxNumOfChars() > 0)
119  {
120  $this->tpl->addBlockFile("CONTENT_BLOCK", "charcounter", "tpl.charcounter.html", "Modules/TestQuestionPool");
121  $this->tpl->setCurrentBlock("charcounter");
122  $this->tpl->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
123  $this->tpl->parseCurrentBlock();
124  }
125  }
+ Here is the caller graph for this function:

◆ outQuestionForTest()

assTextQuestionGUI::outQuestionForTest (   $formaction,
  $active_id,
  $pass = NULL,
  $is_postponed = FALSE,
  $use_post_solutions = FALSE 
)

Definition at line 127 of file class.assTextQuestionGUI.php.

References $_GET, $pass, ilRTE\_getRTEClassname(), ilObject\_lookupObjectId(), ilObject\_lookupType(), getTestOutput(), and outAdditionalOutput().

128  {
129  $test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $use_post_solutions);
130  $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
131  $this->tpl->setVariable("FORMACTION", $formaction);
132  include_once "./Services/RTE/classes/class.ilRTE.php";
133  $rtestring = ilRTE::_getRTEClassname();
134  include_once "./Services/RTE/classes/class.$rtestring.php";
135  $rte = new $rtestring();
136  include_once "./Services/Object/classes/class.ilObject.php";
137  $obj_id = ilObject::_lookupObjectId($_GET["ref_id"]);
138  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
139  $rte->addUserTextEditor("textinput");
140  $this->outAdditionalOutput();
141  }
static _getRTEClassname()
$_GET["client_id"]
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
getTestOutput($active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE)
+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assTextQuestionGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

Definition at line 591 of file class.assTextQuestionGUI.php.

References ilPropertyFormGUI\addItem(), ilSubEnabledFormPropertyGUI\addSubItem(), ilRadioOption\addSubItem(), ilNumberInputGUI\allowDecimals(), ilFormPropertyGUI\setRequired(), ilNumberInputGUI\setValue(), and ilRadioOption\setValue().

Referenced by editQuestion().

592  {
593  $scoringMode = new ilRadioGroupInputGUI(
594  $this->lng->txt( 'essay_scoring_mode' ), 'scoring_mode'
595  );
596 
597  $scoringOptionNone = new ilRadioOption($this->lng->txt( 'essay_scoring_mode_without_keywords' ),
598  'non', $this->lng->txt( 'essay_scoring_mode_without_keywords_desc'
599  )
600  );
601  $scoringOptionAnyKeyword = new ilRadioOption($this->lng->txt( 'essay_scoring_mode_keyword_relation_any' ),
602  'any', $this->lng->txt( 'essay_scoring_mode_keyword_relation_any_desc'
603  )
604  );
605  $scoringOptionAllKeyword = new ilRadioOption($this->lng->txt( 'essay_scoring_mode_keyword_relation_all' ),
606  'all', $this->lng->txt( 'essay_scoring_mode_keyword_relation_all_desc'
607  )
608  );
609  $scoringOptionOneKeyword = new ilRadioOption($this->lng->txt( 'essay_scoring_mode_keyword_relation_one' ),
610  'one', $this->lng->txt( 'essay_scoring_mode_keyword_relation_one_desc'
611  )
612  );
613 
614  $scoringMode->addOption( $scoringOptionNone );
615  $scoringMode->addOption( $scoringOptionAnyKeyword );
616  $scoringMode->addOption( $scoringOptionAllKeyword );
617  $scoringMode->addOption( $scoringOptionOneKeyword );
618  $scoringMode->setRequired( true );
619  $scoringMode->setValue( strlen( $this->object->getKeywordRelation() ) ? $this->object->getKeywordRelation(
620  ) : 'non'
621  );
622 
623  if ($this->object->getAnswerCount() == 0)
624  {
625  $this->object->addAnswer( "", 1, 0, 0 );
626  }
627  require_once "./Modules/TestQuestionPool/classes/class.ilEssayKeywordWizardInputGUI.php";
628 
629  // Without Keywords
630  $nonKeywordPoints = new ilNumberInputGUI($this->lng->txt( "points" ), "non_keyword_points");
631  $nonKeywordPoints->setValue( $this->object->getPoints() );
632  $nonKeywordPoints->setRequired( TRUE );
633  $nonKeywordPoints->setSize( 3 );
634  $nonKeywordPoints->setMinValue( 0.0 );
635  $nonKeywordPoints->setMinvalueShouldBeGreater( true );
636  $scoringOptionNone->addSubItem( $nonKeywordPoints );
637 
638  // Any Keyword
639  $anyKeyword = new ilEssayKeywordWizardInputGUI($this->lng->txt( "answers" ), "any_keyword");
640  $anyKeyword->setRequired( TRUE );
641  $anyKeyword->setQuestionObject( $this->object );
642  $anyKeyword->setSingleline( TRUE );
643  $anyKeyword->setValues( $this->object->getAnswers() );
644  $scoringOptionAnyKeyword->addSubItem( $anyKeyword );
645 
646  // All Keywords
647  $allKeyword = new ilTextWizardInputGUI($this->lng->txt( "answers" ), "all_keyword");
648  $allKeyword->setRequired( TRUE );
649  //$allKeyword->setQuestionObject($this->object);
650  //$allKeyword->setSingleline(TRUE);
651  $allKeyword->setValues( self::buildAnswerTextOnlyArray( $this->object->getAnswers() ) );
652  $scoringOptionAllKeyword->addSubItem( $allKeyword );
653  $allKeywordPoints = new ilNumberInputGUI($this->lng->txt( "points" ), "all_keyword_points");
654  $allKeywordPoints->allowDecimals(TRUE);
655  $allKeywordPoints->setValue( $this->object->getPoints() );
656  $allKeywordPoints->setRequired( TRUE );
657  $allKeywordPoints->setSize( 3 );
658  $allKeywordPoints->setMinValue( 0.0 );
659  $allKeywordPoints->setMinvalueShouldBeGreater( true );
660  $scoringOptionAllKeyword->addSubItem( $allKeywordPoints );
661 
662  // One Keywords
663  $oneKeyword = new ilTextWizardInputGUI($this->lng->txt( "answers" ), "one_keyword");
664  $oneKeyword->setRequired( TRUE );
665  //$oneKeyword->setQuestionObject($this->object);
666  //$oneKeyword->setSingleline(TRUE);
667  $oneKeyword->setValues( self::buildAnswerTextOnlyArray( $this->object->getAnswers() ) );
668  $scoringOptionOneKeyword->addSubItem( $oneKeyword );
669  $oneKeywordPoints = new ilNumberInputGUI($this->lng->txt( "points" ), "one_keyword_points");
670  $oneKeywordPoints->allowDecimals(TRUE);
671  $oneKeywordPoints->setValue( $this->object->getPoints() );
672  $oneKeywordPoints->setRequired( TRUE );
673  $oneKeywordPoints->setSize( 3 );
674  $oneKeywordPoints->setMinValue( 0.0 );
675  $oneKeywordPoints->setMinvalueShouldBeGreater( true );
676  $scoringOptionOneKeyword->addSubItem( $oneKeywordPoints );
677 
678  $form->addItem( $scoringMode );
679  }
This class represents an option in a radio group.
setValue($a_value)
Set Value.
allowDecimals($a_value)
Toggle Decimals.
This class represents a property in a property form.
setValue($a_value)
Set Value.
addSubItem($a_item)
Add Subitem.
This class represents a number property in a property form.
This class represents a text wizard property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateQuestionSpecificFormPart()

assTextQuestionGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

Definition at line 563 of file class.assTextQuestionGUI.php.

References ilPropertyFormGUI\addItem(), and ilNumberInputGUI\setSize().

Referenced by editQuestion().

564  {
565  // maxchars
566  $maxchars = new ilNumberInputGUI($this->lng->txt( "maxchars" ), "maxchars");
567  $maxchars->setSize( 5 );
568  if ($this->object->getMaxNumOfChars() > 0)
569  $maxchars->setValue( $this->object->getMaxNumOfChars() );
570  $maxchars->setInfo( $this->lng->txt( "description_maxchars" ) );
571  $form->addItem( $maxchars );
572 
573  // text rating
574  $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "text_rating");
575  $text_options = array(
576  "ci" => $this->lng->txt("cloze_textgap_case_insensitive"),
577  "cs" => $this->lng->txt("cloze_textgap_case_sensitive"),
578  "l1" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1"),
579  "l2" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2"),
580  "l3" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3"),
581  "l4" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4"),
582  "l5" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5")
583  );
584  $textrating->setOptions($text_options);
585  $textrating->setValue($this->object->getTextRating());
586  $form->addItem($textrating);
587 
588  return $form;
589  }
This class represents a selection list property in a property form.
This class represents a number property in a property form.
setSize($a_size)
Set Size.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setQuestionTabs()

assTextQuestionGUI::setQuestionTabs ( )

Sets the ILIAS tabs for this question type.

public

Todo:
: MOVE THIS STEPS TO COMMON QUESTION CLASS assQuestionGUI

Definition at line 418 of file class.assTextQuestionGUI.php.

References $_GET, $ref_id, assQuestionGUI\addTab_QuestionFeedback(), assQuestionGUI\addTab_QuestionHints(), and ilTestExpressPage\getReturnToPageLink().

419  {
420  global $rbacsystem, $ilTabs;
421 
422  $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
423  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
424  $q_type = $this->object->getQuestionType();
425 
426  if (strlen($q_type))
427  {
428  $classname = $q_type . "GUI";
429  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
430  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
431  }
432 
433  if ($_GET["q_id"])
434  {
435  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
436  {
437  // edit page
438  $ilTabs->addTarget("edit_page",
439  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
440  array("edit", "insert", "exec_pg"),
441  "", "", $force_active);
442  }
443 
444  // edit page
445  $ilTabs->addTarget("preview",
446  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "preview"),
447  array("preview"),
448  "ilAssQuestionPageGUI", "", $force_active);
449  }
450 
451  $force_active = false;
452  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
453  {
454  $url = "";
455  if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
456  // edit question properties
457  $ilTabs->addTarget("edit_question",
458  $url,
459  array("editQuestion", "save", "saveEdit", "originalSyncForm"),
460  $classname, "", $force_active);
461  }
462 
463  // add tab for question feedback within common class assQuestionGUI
464  $this->addTab_QuestionFeedback($ilTabs);
465 
466  // add tab for question hint within common class assQuestionGUI
467  $this->addTab_QuestionHints($ilTabs);
468 
469  if ($_GET["q_id"])
470  {
471  $ilTabs->addTarget("solution_hint",
472  $this->ctrl->getLinkTargetByClass($classname, "suggestedsolution"),
473  array("suggestedsolution", "saveSuggestedSolution", "outSolutionExplorer", "cancel",
474  "addSuggestedSolution","cancelExplorer", "linkChilds", "removeSuggestedSolution"
475  ),
476  $classname,
477  ""
478  );
479  }
480 
481  // Assessment of questions sub menu entry
482  if ($_GET["q_id"])
483  {
484  $ilTabs->addTarget("statistics",
485  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
486  array("assessment"),
487  $classname, "");
488  }
489 
490  if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
491  {
492  $ref_id = $_GET["calling_test"];
493  if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
494 
495  global $___test_express_mode;
496 
497  if (!$_GET['test_express_mode'] && !$___test_express_mode) {
498  $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
499  }
500  else {
502  $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), $link);
503  }
504  }
505  else
506  {
507  $ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
508  }
509  }
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
$_GET["client_id"]
static getReturnToPageLink($q_id=null)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assTextQuestionGUI::writeAnswerSpecificPostData (   $always = true)

Definition at line 540 of file class.assTextQuestionGUI.php.

References $_POST.

Referenced by writePostData().

541  {
542  switch ($this->object->getKeywordRelation())
543  {
544  case 'non':
545  $this->object->setAnswers( array() );
546  $this->object->setPoints( $_POST['non_keyword_points'] );
547  break;
548  case 'any':
549  $this->object->setAnswers( $_POST['any_keyword'] );
550  $this->object->setPoints( $this->object->getMaximumPoints() );
551  break;
552  case 'all':
553  $this->object->setAnswers( $_POST['all_keyword'] );
554  $this->object->setPoints( $_POST['all_keyword_points'] );
555  break;
556  case 'one':
557  $this->object->setAnswers( $_POST['one_keyword'] );
558  $this->object->setPoints( $_POST['one_keyword_points'] );
559  break;
560  }
561  }
$_POST['username']
Definition: cron.php:12
+ Here is the caller graph for this function:

◆ writePostData()

assTextQuestionGUI::writePostData (   $always = false)

Evaluates a posted edit form and writes the form data in the question object.

Parameters
bool$always
Returns
integer A positive value, if one of the required fields wasn't set, else 0

Definition at line 49 of file class.assTextQuestionGUI.php.

References editQuestion(), assQuestionGUI\saveTaxonomyAssignments(), writeAnswerSpecificPostData(), assQuestionGUI\writeQuestionGenericPostData(), and writeQuestionSpecificPostData().

50  {
51  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
52  if (!$hasErrors)
53  {
57  $this->saveTaxonomyAssignments();
58  return 0;
59  }
60  return 1;
61  }
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
writeAnswerSpecificPostData( $always=true)
writeQuestionSpecificPostData( $always=true)
+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assTextQuestionGUI::writeQuestionSpecificPostData (   $always = true)

Definition at line 533 of file class.assTextQuestionGUI.php.

References $_POST.

Referenced by writePostData().

534  {
535  $this->object->setMaxNumOfChars( $_POST["maxchars"] );
536  $this->object->setTextRating( $_POST["text_rating"] );
537  $this->object->setKeywordRelation( $_POST['scoring_mode'] );
538  }
$_POST['username']
Definition: cron.php:12
+ Here is the caller graph for this function:

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