ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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, $showInlineFeedback=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 (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 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 ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 
 setQuestionActionCmd ($questionActionCmd)
 
 getQuestionActionCmd ()
 
_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...
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 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 ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, $classname)
 
 getEditQuestionTabCommands ()
 
 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 ()
 
 getPreview ($show_question_only=FALSE, $showInlineFeedback=false)
 
 outQuestionForTest ( $formaction, $active_id, $pass=NULL, $is_question_postponed=FALSE, $user_post_solutions=FALSE, $show_specific_inline_feedback=FALSE)
 
 setPreviewSession ($previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 

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'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
 $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
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI More...
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI More...
 
 addTab_QuestionPreview (ilTabsGUI $tabsGUI)
 
 writeQuestionGenericPostData ()
 
 getFormEncodingType ()
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 

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 400 of file class.assTextQuestionGUI.php.

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

401  {
402  $_SESSION["subquestion_index"] = 0;
403  if ($_POST["cmd"]["addSuggestedSolution"])
404  {
405  if ($this->writePostData())
406  {
408  $this->editQuestion();
409  return;
410  }
411  if (!$this->checkInput())
412  {
413  ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
414  $this->editQuestion();
415  return;
416  }
417  }
418  $this->object->saveToDb();
419  $this->ctrl->setParameter($this, "q_id", $this->object->getId());
420  $this->tpl->setVariable("HEADER", $this->object->getTitle());
421  $this->getQuestionTemplate();
422  parent::addSuggestedSolution();
423  }
< 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 105 of file class.assTextQuestionGUI.php.

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

◆ editQuestion()

assTextQuestionGUI::editQuestion (   $checkonly = FALSE)

Creates an output of the edit form for the question.

public

Definition at line 69 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().

70  {
71  $save = $this->isSaveCommand();
72  $this->getQuestionTemplate();
73 
74  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
75  $form = new ilPropertyFormGUI();
76  $form->setFormAction($this->ctrl->getFormAction($this));
77  $form->setTitle($this->outQuestionType());
78  $form->setMultipart(TRUE);
79  $form->setTableWidth("100%");
80  $form->setId("asstextquestion");
81 
82  $this->addBasicQuestionFormProperties( $form );
83  $this->populateQuestionSpecificFormPart( $form );
84  $this->populateAnswerSpecificFormPart( $form );
85 
86 
87  $this->populateTaxonomyFormSection($form);
88 
89  $this->addQuestionFormCommandButtons($form);
90 
91  $errors = false;
92 
93  if ($save)
94  {
95  $form->setValuesByPost();
96  $errors = !$form->checkInput();
97  $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
98  if ($errors) $checkonly = false;
99  }
100 
101  if (!$checkonly) $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
102  return $errors;
103  }
$errors
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
This class represents a property form user interface.
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[]

Implements ilGuiAnswerScoringAdjustable.

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

677  {
678  return array();
679  }

◆ 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[]

Implements ilGuiQuestionScoringAdjustable.

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

691  {
692  return array();
693  }

◆ 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

Implements ilGuiQuestionScoringAdjustable.

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

704  {
705  return ''; //print_r($relevant_answers,true);
706  }

◆ getBestAnswer()

assTextQuestionGUI::getBestAnswer ( )
private

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

References assTextQuestion\getScoringModesWithPointsByKeyword().

Referenced by getSolutionOutput().

269  {
270  $answers = $this->object->getAnswers();
271  if (count( $answers ))
272  {
273  $user_solution = $this->lng->txt( "solution_contain_keywords" ) . "<ul>";
274 
275  foreach ($answers as $answer)
276  {
277  $user_solution .= '<li>'. $answer->getAnswertext();
278 
279  if( in_array($this->object->getKeywordRelation(), assTextQuestion::getScoringModesWithPointsByKeyword()) )
280  {
281  $user_solution .= ' ' . $this->lng->txt('for') . ' ';
282  $user_solution .= $answer->getPoints() . ' ' . $this->lng->txt('points') . '</li>';
283  }
284  }
285  $user_solution .= '</ul>';
286 
287  $user_solution .= $this->lng->txt('essay_scoring_mode') . ': ';
288 
289  switch( $this->object->getKeywordRelation() )
290  {
291  case 'any':
292  $user_solution .= $this->lng->txt('essay_scoring_mode_keyword_relation_any');
293  break;
294  case 'all':
295  $user_solution .= $this->lng->txt('essay_scoring_mode_keyword_relation_all');
296  break;
297  case 'one':
298  $user_solution .= $this->lng->txt('essay_scoring_mode_keyword_relation_one');
299  break;
300  }
301  }
302  return $user_solution;
303  }
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,
  $showInlineFeedback = false 
)

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

References assQuestionGUI\getILIASPage(), assQuestionGUI\getPreviewSession(), and ilUtil\prepareFormOutput().

317  {
318  // generate the question output
319  include_once "./Services/UICore/classes/class.ilTemplate.php";
320  $template = new ilTemplate("tpl.il_as_qpl_text_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
321  if ($this->object->getMaxNumOfChars())
322  {
323  $template->setCurrentBlock("maximum_char_hint");
324  $template->setVariable("MAXIMUM_CHAR_HINT", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()));
325  $template->parseCurrentBlock();
326  #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
327  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
328  $template->parseCurrentBlock();
329  $template->setCurrentBlock("maxchars_counter");
330  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
331  $template->setVariable("TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
332  $template->setVariable("CHARACTERS", $this->lng->txt("characters"));
333  $template->parseCurrentBlock();
334  }
335 
336  if( is_object($this->getPreviewSession()) )
337  {
338  $template->setVariable("ESSAY", ilUtil::prepareFormOutput(
339  $this->getPreviewSession()->getParticipantsSolution()
340  ));
341  }
342 
343  $questiontext = $this->object->getQuestion();
344  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
345  $questionoutput = $template->get();
346  if (!$show_question_only)
347  {
348  // get page object output
349  $questionoutput = $this->getILIASPage($questionoutput);
350  }
351  return $questionoutput;
352  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
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 162 of file class.assTextQuestionGUI.php.

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

173  {
174  // get the solution of the user for the active pass or from the last pass if allowed
175 
176  $user_solution = $this->getUserAnswer( $active_id, $pass );
177 
178  if (($active_id > 0) && (!$show_correct_solution))
179  {
180  $solution = $user_solution;
181  }
182  else
183  {
184  $solution = $this->getBestAnswer();
185  }
186 
187  // generate the question output
188  include_once "./Services/UICore/classes/class.ilTemplate.php";
189  $template = new ilTemplate("tpl.il_as_qpl_text_question_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
190  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
191 
192  $solution = $this->object->getHtmlUserSolutionPurifier()->purify($solution);
193  $template->setVariable("ESSAY", $this->object->prepareTextareaOutput($solution, TRUE));
194 
195  $questiontext = $this->object->getQuestion();
196 
197  if (!$show_correct_solution)
198  {
199  $max_no_of_chars = $this->object->getMaxNumOfChars();
200 
201  if ($max_no_of_chars == 0)
202  {
203  $max_no_of_chars = ucfirst($this->lng->txt('unlimited'));
204  }
205 
206  $act_no_of_chars = strlen($user_solution);
207  $template->setVariable("CHARACTER_INFO", '<b>' . $max_no_of_chars . '</b>' .
208  $this->lng->txt('answer_characters') . ' <b>' . $act_no_of_chars . '</b>');
209  }
210  if (($active_id > 0) && (!$show_correct_solution))
211  {
212  if ($graphicalOutput)
213  {
214  // output of ok/not ok icons for user entered solutions
215  $reached_points = $this->object->getReachedPoints($active_id, $pass);
216  if ($reached_points == $this->object->getMaximumPoints())
217  {
218  $template->setCurrentBlock("icon_ok");
219  $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
220  $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
221  $template->parseCurrentBlock();
222  }
223  else
224  {
225  $template->setCurrentBlock("icon_ok");
226  if ($reached_points > 0)
227  {
228  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.svg"));
229  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive"));
230  }
231  else
232  {
233  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
234  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
235  }
236  $template->parseCurrentBlock();
237  }
238  }
239  }
240  if ($show_question_text==true)
241  {
242  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
243  }
244  $questionoutput = $template->get();
245 
246  $feedback = '';
247  if($show_feedback)
248  {
249  $fb = $this->getGenericFeedbackOutput($active_id, $pass);
250  $feedback .= strlen($fb) ? $fb : '';
251 
252  $fb = $this->getSpecificFeedbackOutput($active_id, $pass);
253  $feedback .= strlen($fb) ? $fb : '';
254  }
255  if (strlen($feedback)) $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $feedback, true ));
256 
257  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
258 
259  $solutionoutput = $solutiontemplate->get();
260  if (!$show_question_only)
261  {
262  // get page object output
263  $solutionoutput = $this->getILIASPage($solutionoutput);
264  }
265  return $solutionoutput;
266  }
getILIASPage($html="")
Returns the ILIAS Page around a question.
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 496 of file class.assTextQuestionGUI.php.

Referenced by getSolutionOutput().

497  {
498  $feedback = '<table><tbody>';
499  $user_answers = $this->object->getSolutionValues($active_id);
500  $user_answer = ' '. $user_answers[0]['value1'];
501 
502  foreach ($this->object->getAnswers() as $idx => $ans)
503  {
504  if ($this->object->isKeywordMatching($user_answer, $ans->getAnswertext() ))
505  {
506  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
507  $this->object->getId(), $idx
508  );
509  $feedback .= '<tr><td><b><i>' . $ans->getAnswertext() . '</i></b></td><td>';
510  $feedback .= $fb . '</td> </tr>';
511  }
512  }
513 
514  $feedback .= '</tbody></table>';
515  return $this->object->prepareTextareaOutput($feedback, TRUE);
516  }
+ 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 354 of file class.assTextQuestionGUI.php.

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

Referenced by outQuestionForTest().

355  {
356  // get the solution of the user for the active pass or from the last pass if allowed
357  $user_solution = "";
358  if ($active_id)
359  {
360  $solutions = NULL;
361  include_once "./Modules/Test/classes/class.ilObjTest.php";
362  if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
363  {
364  if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
365  }
366  $solutions =& $this->object->getSolutionValues($active_id, $pass);
367  foreach ($solutions as $idx => $solution_value)
368  {
369  $user_solution = $solution_value["value1"];
370  }
371  }
372 
373  // generate the question output
374  include_once "./Services/UICore/classes/class.ilTemplate.php";
375  $template = new ilTemplate("tpl.il_as_qpl_text_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
376  if ($this->object->getMaxNumOfChars())
377  {
378  $template->setCurrentBlock("maximum_char_hint");
379  $template->setVariable("MAXIMUM_CHAR_HINT", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()));
380  $template->parseCurrentBlock();
381  #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
382  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
383  $template->parseCurrentBlock();
384  $template->setCurrentBlock("maxchars_counter");
385  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
386  $template->setVariable("TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
387  $template->setVariable("CHARACTERS", $this->lng->txt("characters"));
388  $template->parseCurrentBlock();
389  }
390  $template->setVariable("ESSAY", ilUtil::prepareFormOutput($user_solution));
391  $questiontext = $this->object->getQuestion();
392  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
393  $questionoutput = $template->get();
394  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
395  include_once "./Services/YUI/classes/class.ilYuiUtil.php";
397  return $pageoutput;
398  }
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 305 of file class.assTextQuestionGUI.php.

References $pass.

Referenced by getSolutionOutput().

306  {
307  $user_solution = "";
308  $solutions = $this->object->getSolutionValues( $active_id, $pass );
309  foreach ($solutions as $idx => $solution_value)
310  {
311  $user_solution = $solution_value["value1"];
312  }
313  return $user_solution;
314  }
+ Here is the caller graph for this function:

◆ outAdditionalOutput()

assTextQuestionGUI::outAdditionalOutput ( )

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

Referenced by outQuestionForTest().

118  {
119  if ($this->object->getMaxNumOfChars() > 0)
120  {
121  $this->tpl->addBlockFile("CONTENT_BLOCK", "charcounter", "tpl.charcounter.html", "Modules/TestQuestionPool");
122  $this->tpl->setCurrentBlock("charcounter");
123  $this->tpl->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
124  $this->tpl->parseCurrentBlock();
125  }
126  }
+ 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 128 of file class.assTextQuestionGUI.php.

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

129  {
130  $test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $use_post_solutions);
131  $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
132  $this->tpl->setVariable("FORMACTION", $formaction);
133 
134  // TODO - BEGIN: what exactly is done here? cant we use the parent method?
135 
136  include_once "./Services/RTE/classes/class.ilRTE.php";
137  $rtestring = ilRTE::_getRTEClassname();
138  include_once "./Services/RTE/classes/class.$rtestring.php";
139  $rte = new $rtestring();
140  include_once "./Services/Object/classes/class.ilObject.php";
141  $obj_id = ilObject::_lookupObjectId($_GET["ref_id"]);
142  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
143  $rte->addUserTextEditor("textinput");
144  $this->outAdditionalOutput();
145 
146  // TODO - END: what exactly is done here? cant we use the parent method?
147  }
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 576 of file class.assTextQuestionGUI.php.

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

Referenced by editQuestion().

577  {
578  $scoringMode = new ilRadioGroupInputGUI(
579  $this->lng->txt( 'essay_scoring_mode' ), 'scoring_mode'
580  );
581 
582  $scoringOptionNone = new ilRadioOption($this->lng->txt( 'essay_scoring_mode_without_keywords' ),
583  'non', $this->lng->txt( 'essay_scoring_mode_without_keywords_desc'
584  )
585  );
586  $scoringOptionAnyKeyword = new ilRadioOption($this->lng->txt( 'essay_scoring_mode_keyword_relation_any' ),
587  'any', $this->lng->txt( 'essay_scoring_mode_keyword_relation_any_desc'
588  )
589  );
590  $scoringOptionAllKeyword = new ilRadioOption($this->lng->txt( 'essay_scoring_mode_keyword_relation_all' ),
591  'all', $this->lng->txt( 'essay_scoring_mode_keyword_relation_all_desc'
592  )
593  );
594  $scoringOptionOneKeyword = new ilRadioOption($this->lng->txt( 'essay_scoring_mode_keyword_relation_one' ),
595  'one', $this->lng->txt( 'essay_scoring_mode_keyword_relation_one_desc'
596  )
597  );
598 
599  $scoringMode->addOption( $scoringOptionNone );
600  $scoringMode->addOption( $scoringOptionAnyKeyword );
601  $scoringMode->addOption( $scoringOptionAllKeyword );
602  $scoringMode->addOption( $scoringOptionOneKeyword );
603  $scoringMode->setRequired( true );
604  $scoringMode->setValue( strlen( $this->object->getKeywordRelation() ) ? $this->object->getKeywordRelation(
605  ) : 'non'
606  );
607 
608  if ($this->object->getAnswerCount() == 0)
609  {
610  $this->object->addAnswer( "", 1, 0, 0 );
611  }
612  require_once "./Modules/TestQuestionPool/classes/class.ilEssayKeywordWizardInputGUI.php";
613 
614  // Without Keywords
615  $nonKeywordPoints = new ilNumberInputGUI($this->lng->txt( "points" ), "non_keyword_points");
616  $nonKeywordPoints->allowDecimals(true);
617  $nonKeywordPoints->setValue( $this->object->getPoints() );
618  $nonKeywordPoints->setRequired( TRUE );
619  $nonKeywordPoints->setSize( 3 );
620  $nonKeywordPoints->setMinValue( 0.0 );
621  $nonKeywordPoints->setMinvalueShouldBeGreater( true );
622  $scoringOptionNone->addSubItem( $nonKeywordPoints );
623 
624  // Any Keyword
625  $anyKeyword = new ilEssayKeywordWizardInputGUI($this->lng->txt( "answers" ), "any_keyword");
626  $anyKeyword->setRequired( TRUE );
627  $anyKeyword->setQuestionObject( $this->object );
628  $anyKeyword->setSingleline( TRUE );
629  $anyKeyword->setValues( $this->object->getAnswers() );
630  $scoringOptionAnyKeyword->addSubItem( $anyKeyword );
631 
632  // All Keywords
633  $allKeyword = new ilTextWizardInputGUI($this->lng->txt( "answers" ), "all_keyword");
634  $allKeyword->setRequired( TRUE );
635  //$allKeyword->setQuestionObject($this->object);
636  //$allKeyword->setSingleline(TRUE);
637  $allKeyword->setValues( self::buildAnswerTextOnlyArray( $this->object->getAnswers() ) );
638  $scoringOptionAllKeyword->addSubItem( $allKeyword );
639  $allKeywordPoints = new ilNumberInputGUI($this->lng->txt( "points" ), "all_keyword_points");
640  $allKeywordPoints->allowDecimals(true);
641  $allKeywordPoints->setValue( $this->object->getPoints() );
642  $allKeywordPoints->setRequired( TRUE );
643  $allKeywordPoints->setSize( 3 );
644  $allKeywordPoints->setMinValue( 0.0 );
645  $allKeywordPoints->setMinvalueShouldBeGreater( true );
646  $scoringOptionAllKeyword->addSubItem( $allKeywordPoints );
647 
648  // One Keywords
649  $oneKeyword = new ilTextWizardInputGUI($this->lng->txt( "answers" ), "one_keyword");
650  $oneKeyword->setRequired( TRUE );
651  //$oneKeyword->setQuestionObject($this->object);
652  //$oneKeyword->setSingleline(TRUE);
653  $oneKeyword->setValues( self::buildAnswerTextOnlyArray( $this->object->getAnswers() ) );
654  $scoringOptionOneKeyword->addSubItem( $oneKeyword );
655  $oneKeywordPoints = new ilNumberInputGUI($this->lng->txt( "points" ), "one_keyword_points");
656  $oneKeywordPoints->allowDecimals(true);
657  $oneKeywordPoints->setValue( $this->object->getPoints() );
658  $oneKeywordPoints->setRequired( TRUE );
659  $oneKeywordPoints->setSize( 3 );
660  $oneKeywordPoints->setMinValue( 0.0 );
661  $oneKeywordPoints->setMinvalueShouldBeGreater( true );
662  $scoringOptionOneKeyword->addSubItem( $oneKeywordPoints );
663 
664  $form->addItem( $scoringMode );
665  }
This class represents an option in a radio group.
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 548 of file class.assTextQuestionGUI.php.

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

Referenced by editQuestion().

549  {
550  // maxchars
551  $maxchars = new ilNumberInputGUI($this->lng->txt( "maxchars" ), "maxchars");
552  $maxchars->setSize( 5 );
553  if ($this->object->getMaxNumOfChars() > 0)
554  $maxchars->setValue( $this->object->getMaxNumOfChars() );
555  $maxchars->setInfo( $this->lng->txt( "description_maxchars" ) );
556  $form->addItem( $maxchars );
557 
558  // text rating
559  $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "text_rating");
560  $text_options = array(
561  "ci" => $this->lng->txt("cloze_textgap_case_insensitive"),
562  "cs" => $this->lng->txt("cloze_textgap_case_sensitive"),
563  "l1" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1"),
564  "l2" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2"),
565  "l3" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3"),
566  "l4" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4"),
567  "l5" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5")
568  );
569  $textrating->setOptions($text_options);
570  $textrating->setValue($this->object->getTextRating());
571  $form->addItem($textrating);
572 
573  return $form;
574  }
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 432 of file class.assTextQuestionGUI.php.

References $_GET, assQuestionGUI\addBackTab(), assQuestionGUI\addTab_QuestionFeedback(), assQuestionGUI\addTab_QuestionHints(), assQuestionGUI\addTab_QuestionPreview(), and assQuestionGUI\addTab_SuggestedSolution().

433  {
434  global $rbacsystem, $ilTabs;
435 
436  $ilTabs->clearTargets();
437 
438  $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
439  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
440  $q_type = $this->object->getQuestionType();
441 
442  if (strlen($q_type))
443  {
444  $classname = $q_type . "GUI";
445  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
446  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
447  }
448 
449  if ($_GET["q_id"])
450  {
451  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
452  {
453  // edit page
454  $ilTabs->addTarget("edit_page",
455  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
456  array("edit", "insert", "exec_pg"),
457  "", "", $force_active);
458  }
459 
460  $this->addTab_QuestionPreview($ilTabs);
461  }
462 
463  $force_active = false;
464  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
465  {
466  $url = "";
467  if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
468  // edit question properties
469  $ilTabs->addTarget("edit_question",
470  $url,
471  array("editQuestion", "save", "saveEdit", "originalSyncForm"),
472  $classname, "", $force_active);
473  }
474 
475  // add tab for question feedback within common class assQuestionGUI
476  $this->addTab_QuestionFeedback($ilTabs);
477 
478  // add tab for question hint within common class assQuestionGUI
479  $this->addTab_QuestionHints($ilTabs);
480 
481  // add tab for question's suggested solution within common class assQuestionGUI
482  $this->addTab_SuggestedSolution($ilTabs, $classname);
483 
484  // Assessment of questions sub menu entry
485  if ($_GET["q_id"])
486  {
487  $ilTabs->addTarget("statistics",
488  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
489  array("assessment"),
490  $classname, "");
491  }
492 
493  $this->addBackTab($ilTabs);
494  }
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
$_GET["client_id"]
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBackTab(ilTabsGUI $ilTabs)
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assTextQuestionGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

Extracts the answer specific values from $_POST and applies them to the data object.

Parameters
bool$alwaysIf true, a check for form validity is omitted.
Returns
void

Implements ilGuiAnswerScoringAdjustable.

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

References $_POST.

Referenced by writePostData().

526  {
527  switch ($this->object->getKeywordRelation())
528  {
529  case 'non':
530  $this->object->setAnswers( array() );
531  $this->object->setPoints( $_POST['non_keyword_points'] );
532  break;
533  case 'any':
534  $this->object->setAnswers( $_POST['any_keyword'] );
535  $this->object->setPoints( $this->object->getMaximumPoints() );
536  break;
537  case 'all':
538  $this->object->setAnswers( $_POST['all_keyword'] );
539  $this->object->setPoints( $_POST['all_keyword_points'] );
540  break;
541  case 'one':
542  $this->object->setAnswers( $_POST['one_keyword'] );
543  $this->object->setPoints( $_POST['one_keyword_points'] );
544  break;
545  }
546  }
$_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  {
54  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
58  $this->saveTaxonomyAssignments();
59  return 0;
60  }
61  return 1;
62  }
This class represents a property form user interface.
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assTextQuestionGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

Extracts the question specific values from $_POST and applies them to the data object.

Parameters
bool$alwaysIf true, a check for form validity is omitted.
Returns
void

Implements ilGuiQuestionScoringAdjustable.

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

References $_POST.

Referenced by writePostData().

519  {
520  $this->object->setMaxNumOfChars( $_POST["maxchars"] );
521  $this->object->setTextRating( $_POST["text_rating"] );
522  $this->object->setKeywordRelation( $_POST['scoring_mode'] );
523  }
$_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: