ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
assTextSubsetGUI Class Reference

Multiple choice question GUI representation. More...

+ Inheritance diagram for assTextSubsetGUI:
+ Collaboration diagram for assTextSubsetGUI:

Public Member Functions

 __construct ($id=-1)
 assTextSubsetGUI constructor More...
 
 editQuestion ($checkonly=false)
 Creates an output of the edit form for the question. More...
 
 addanswers ()
 Add a new answer. More...
 
 removeanswers ()
 Remove an answer. More...
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() More...
 
 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, $inlineFeedback=false)
 
 getSpecificFeedbackOutput ($userSolution)
 
 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...
 
 aggregateAnswers ($relevant_answers_chosen)
 
 renderAggregateView ($aggregate)
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor More...
 
 hasInlineFeedback ()
 this method can be overwritten per question type More...
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getNotesHTML ()
 
 executeCommand ()
 execute command More...
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext ($presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled ($previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose ($renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext ($editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI ($navigationGUI)
 
 setTaxonomyIds ($taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd ($questionActionCmd)
 
 getQuestionActionCmd ()
 
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation. More...
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 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="", $inlineFeedbackEnabled=false)
 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...
 
 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 ($userSolution)
 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)
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() More...
 
 hasIntermediateSolution ($activeId, $passIndex)
 Check if the question has an intermediate solution. More...
 
 setUseIntermediateSolution ($use)
 
 getUseIntermediateSolution ()
 Get if intermediate solution should be used for solution output. More...
 
 isAutosaveable ()
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 outQuestionForTest ( $formaction, $active_id, $pass, $is_question_postponed=false, $user_post_solutions=false, $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession ($previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFreuqencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- 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...
 

Protected Member Functions

 writePostData ($always=false)
 {} More...
 
 completeAddAnswerAction ($answers, $questionIndex)
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm ($form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 setDefaultTabs (ilTabsGUI $ilTabs)
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 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_Question (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 addSaveOnEnterOnLoadCode ()
 

Private Attributes

 $answers_from_post
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _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...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
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
 
 $request
 
 $sequence_no
 sequence number in test More...
 
 $question_count
 question count in test More...
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 
- Protected Attributes inherited from assQuestionGUI
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
 $ctrl
 
 $editForm
 
 $use_intermediate_solution = false
 

Detailed Description

Multiple choice question GUI representation.

The assTextSubsetGUI class encapsulates the GUI representation for multiple choice 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$

assTextSubsetGUI: ilFormPropertyDispatchGUI

Definition at line 24 of file class.assTextSubsetGUI.php.

Constructor & Destructor Documentation

◆ __construct()

assTextSubsetGUI::__construct (   $id = -1)

assTextSubsetGUI constructor

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

Parameters
integer$idThe database id of a text subset question object

Definition at line 35 of file class.assTextSubsetGUI.php.

References ILIAS\GlobalScreen\Provider\__construct().

36  {
38  require_once './Modules/TestQuestionPool/classes/class.assTextSubset.php';
39  $this->object = new assTextSubset();
40  if ($id >= 0) {
41  $this->object->loadFromDb($id);
42  }
43  }
Class for TextSubset questions.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addanswers()

assTextSubsetGUI::addanswers ( )

Add a new answer.

Definition at line 112 of file class.assTextSubsetGUI.php.

References $_POST, editQuestion(), and writePostData().

113  {
114  $this->writePostData(true);
115  $position = key($_POST['cmd']['addanswers']);
116  $this->object->addAnswer("", 0, $position + 1);
117  $this->editQuestion();
118  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writePostData($always=false)
{}
$_POST["username"]
+ Here is the call graph for this function:

◆ aggregateAnswers()

assTextSubsetGUI::aggregateAnswers (   $relevant_answers_chosen)

Definition at line 446 of file class.assTextSubsetGUI.php.

Referenced by getAggregatedAnswersView().

447  {
448  $aggregate = array();
449 
450  foreach ($relevant_answers_chosen as $relevant_answer) {
451  if (array_key_exists($relevant_answer['value1'], $aggregate)) {
452  $aggregate[$relevant_answer['value1']]++;
453  } else {
454  $aggregate[$relevant_answer['value1']] = 1;
455  }
456  }
457  return $aggregate;
458  }
+ Here is the caller graph for this function:

◆ completeAddAnswerAction()

assTextSubsetGUI::completeAddAnswerAction (   $answers,
  $questionIndex 
)
protected

Definition at line 495 of file class.assTextSubsetGUI.php.

Referenced by getAnswersFrequency().

496  {
497  foreach ($answers as $key => $ans) {
498  $found = false;
499 
500  foreach ($this->object->getAnswers() as $item) {
501  if ($ans['answer'] !== $item->getAnswerText()) {
502  continue;
503  }
504 
505  $found = true;
506  break;
507  }
508 
509  if (!$found) {
510  $answers[$key]['addable'] = true;
511  }
512  }
513 
514  return $answers;
515  }
+ Here is the caller graph for this function:

◆ editQuestion()

assTextSubsetGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

Definition at line 70 of file class.assTextSubsetGUI.php.

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

Referenced by addanswers(), removeanswers(), and writePostData().

71  {
72  $save = $this->isSaveCommand();
73  $this->getQuestionTemplate();
74 
75  require_once './Services/Form/classes/class.ilPropertyFormGUI.php';
76  $form = new ilPropertyFormGUI();
77  $this->editForm = $form;
78 
79  $form->setFormAction($this->ctrl->getFormAction($this));
80  $form->setTitle($this->outQuestionType());
81  $form->setMultipart(false);
82  $form->setTableWidth("100%");
83  $form->setId("asstextsubset");
84 
85  $this->addBasicQuestionFormProperties($form);
87  $this->populateAnswerSpecificFormPart($form);
88  $this->populateTaxonomyFormSection($form);
89  $this->addQuestionFormCommandButtons($form);
90 
91  $errors = false;
92  if ($save) {
93  $form->setValuesByPost();
94  $points = $form->getItemByPostVar('points');
95  $points->setValue($this->object->getMaximumPoints());
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) {
99  $checkonly = false;
100  }
101  }
102 
103  if (!$checkonly) {
104  $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
105  }
106  return $errors;
107  }
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
$errors
Definition: imgupload.php:49
This class represents a property form user interface.
getQuestionTemplate()
get question template
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateTaxonomyFormSection(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()

assTextSubsetGUI::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 412 of file class.assTextSubsetGUI.php.

413  {
414  return array();
415  }

◆ getAfterParticipationSuppressionQuestionPostVars()

assTextSubsetGUI::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 426 of file class.assTextSubsetGUI.php.

427  {
428  return array();
429  }

◆ getAggregatedAnswersView()

assTextSubsetGUI::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 439 of file class.assTextSubsetGUI.php.

References aggregateAnswers(), and renderAggregateView().

440  {
441  return $this->renderAggregateView(
442  $this->aggregateAnswers($relevant_answers)
443  )->get();
444  }
aggregateAnswers($relevant_answers_chosen)
+ Here is the call graph for this function:

◆ getAnswersFrequency()

assTextSubsetGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Definition at line 478 of file class.assTextSubsetGUI.php.

References completeAddAnswerAction().

479  {
480  $answers = array();
481 
482  foreach ($relevantAnswers as $ans) {
483  if (!isset($answers[$ans['value1']])) {
484  $answers[$ans['value1']] = array(
485  'answer' => $ans['value1'], 'frequency' => 0
486  );
487  }
488 
489  $answers[$ans['value1']]['frequency']++;
490  }
491  $answers = $this->completeAddAnswerAction($answers, $questionIndex);
492  return $answers;
493  }
completeAddAnswerAction($answers, $questionIndex)
+ Here is the call graph for this function:

◆ getPreview()

assTextSubsetGUI::getPreview (   $show_question_only = false,
  $showInlineFeedback = false 
)

Definition at line 250 of file class.assTextSubsetGUI.php.

References $i, assQuestionGUI\escapeTemplatePlaceholders(), assQuestionGUI\getILIASPage(), and assQuestionGUI\getPreviewSession().

251  {
252  $solutions = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : array();
253  // generate the question output
254  include_once "./Services/UICore/classes/class.ilTemplate.php";
255  $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", true, true, "Modules/TestQuestionPool");
256  $width = $this->object->getMaxTextboxWidth();
257  for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
258  $template->setCurrentBlock("textsubset_row");
259  foreach ($solutions as $idx => $solution_value) {
260  if ($idx == $i) {
261  $template->setVariable("TEXTFIELD_VALUE", " value=\"" . $this->escapeTemplatePlaceholders($solution_value) . "\"");
262  }
263  }
264  $template->setVariable("COUNTER", $i + 1);
265  $template->setVariable("TEXTFIELD_ID", sprintf("%02d", $i + 1));
266  $template->setVariable("TEXTFIELD_SIZE", $width);
267  $template->parseCurrentBlock();
268  }
269  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
270  $questionoutput = $template->get();
271  if (!$show_question_only) {
272  // get page object output
273  $questionoutput = $this->getILIASPage($questionoutput);
274  }
275  return $questionoutput;
276  }
escapeTemplatePlaceholders(string $text)
getILIASPage($html="")
Returns the ILIAS Page around a question.
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ getSolutionOutput()

assTextSubsetGUI::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 154 of file class.assTextSubsetGUI.php.

References $i, $index, $pass, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, assQuestionGUI\escapeTemplatePlaceholders(), assQuestionGUI\getAnswerFeedbackOutput(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), assQuestionGUI\getUseIntermediateSolution(), assQuestionGUI\hasCorrectSolution(), and assQuestionGUI\isTestPresentationContext().

164  {
165  // get the solution of the user for the active pass or from the last pass if allowed
166  $solutions = array();
167  if (($active_id > 0) && (!$show_correct_solution)) {
168  $solutions = $this->object->getSolutionValues($active_id, $pass, !$this->getUseIntermediateSolution());
169  } else {
170  $rank = array();
171  foreach ($this->object->answers as $answer) {
172  if ($answer->getPoints() > 0) {
173  if (!is_array($rank[$answer->getPoints()])) {
174  $rank[$answer->getPoints()] = array();
175  }
176  array_push($rank[$answer->getPoints()], $answer->getAnswertext());
177  }
178  }
179  krsort($rank, SORT_NUMERIC);
180  foreach ($rank as $index => $bestsolutions) {
181  array_push($solutions, array("value1" => join(",", $bestsolutions), "points" => $index));
182  }
183  }
184 
185  // generate the question output
186  include_once "./Services/UICore/classes/class.ilTemplate.php";
187  $template = new ilTemplate("tpl.il_as_qpl_textsubset_output_solution.html", true, true, "Modules/TestQuestionPool");
188  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
189  $available_answers = &$this->object->getAvailableAnswers();
190  for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
191  if ((!$test_id) && (strcmp($solutions[$i]["value1"], "") == 0)) {
192  } else {
193  if (($active_id > 0) && (!$show_correct_solution)) {
194  if ($graphicalOutput) {
195  // output of ok/not ok icons for user entered solutions
196  $index = $this->object->isAnswerCorrect($available_answers, $solutions[$i]["value1"]);
197  $correct = false;
198  if ($index !== false) {
199  unset($available_answers[$index]);
200  $correct = true;
201  }
202  if ($correct) {
203  $template->setCurrentBlock("icon_ok");
204  $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
205  $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
206  $template->parseCurrentBlock();
207  } else {
208  $template->setCurrentBlock("icon_ok");
209  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
210  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
211  $template->parseCurrentBlock();
212  }
213  }
214  }
215  $template->setCurrentBlock("textsubset_row");
216  $template->setVariable("SOLUTION", $this->escapeTemplatePlaceholders($solutions[$i]["value1"]));
217  $template->setVariable("COUNTER", $i + 1);
218  if ($result_output) {
219  $points = $solutions[$i]["points"];
220  $resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
221  $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
222  }
223  $template->parseCurrentBlock();
224  }
225  }
226  if ($show_question_text == true) {
227  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
228  }
229  $questionoutput = $template->get();
230  $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
231  if (strlen($feedback)) {
232  $cssClass = (
233  $this->hasCorrectSolution($active_id, $pass) ?
235  );
236 
237  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
238  $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
239  }
240  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
241 
242  $solutionoutput = $solutiontemplate->get();
243  if (!$show_question_only) {
244  // get page object output
245  $solutionoutput = $this->getILIASPage($solutionoutput);
246  }
247  return $solutionoutput;
248  }
hasCorrectSolution($activeId, $passIndex)
escapeTemplatePlaceholders(string $text)
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
$index
Definition: metadata.php:128
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)
getAnswerFeedbackOutput($active_id, $pass)
Returns the answer generic feedback depending on the results of the question.
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assTextSubsetGUI::getSpecificFeedbackOutput (   $userSolution)

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

317  {
318  $output = "";
319  return $this->object->prepareTextareaOutput($output, true);
320  }

◆ getTestOutput()

assTextSubsetGUI::getTestOutput (   $active_id,
  $pass = null,
  $is_postponed = false,
  $use_post_solutions = false,
  $inlineFeedback = false 
)

Definition at line 278 of file class.assTextSubsetGUI.php.

References $i, $pass, assQuestionGUI\escapeTemplatePlaceholders(), and assQuestionGUI\outQuestionPage().

279  {
280  // get the solution of the user for the active pass or from the last pass if allowed
281  $user_solution = "";
282  if ($active_id) {
283  $solutions = null;
284  // hey: prevPassSolutions - obsolete due to central check
285  #include_once "./Modules/Test/classes/class.ilObjTest.php";
286  #if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
287  #{
288  # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
289  #}
290  // hey.
291  $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
292  }
293 
294  // generate the question output
295  include_once "./Services/UICore/classes/class.ilTemplate.php";
296  $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", true, true, "Modules/TestQuestionPool");
297  $width = $this->object->getMaxTextboxWidth();
298  for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
299  $template->setCurrentBlock("textsubset_row");
300  foreach ($solutions as $idx => $solution_value) {
301  if ($idx == $i) {
302  $template->setVariable("TEXTFIELD_VALUE", " value=\"" . $this->escapeTemplatePlaceholders($solution_value["value1"]) . "\"");
303  }
304  }
305  $template->setVariable("COUNTER", $i + 1);
306  $template->setVariable("TEXTFIELD_ID", sprintf("%02d", $i + 1));
307  $template->setVariable("TEXTFIELD_SIZE", $width);
308  $template->parseCurrentBlock();
309  }
310  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
311  $questionoutput = $template->get();
312  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
313  return $pageoutput;
314  }
escapeTemplatePlaceholders(string $text)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assTextSubsetGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

Definition at line 378 of file class.assTextSubsetGUI.php.

References ilPropertyFormGUI\addItem(), and ilFormPropertyGUI\setRequired().

Referenced by editQuestion().

379  {
380  // Choices
381  include_once "./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
382  $choices = new ilAnswerWizardInputGUI($this->lng->txt("answers"), "answers");
383  $choices->setRequired(true);
384  $choices->setQuestionObject($this->object);
385  $choices->setSingleline(true);
386  $choices->setAllowMove(false);
387  $choices->setMinValue(0.0);
388  if ($this->object->getAnswerCount() == 0) {
389  $this->object->addAnswer("", 0, 0);
390  }
391  $choices->setValues(array_map(
392  function (ASS_AnswerBinaryStateImage $value) {
393  $value->setAnswerText(html_entity_decode($value->getAnswerText()));
394  return $value;
395  },
396  $this->object->getAnswers()
397  ));
398  $form->addItem($choices);
399  return $form;
400  }
Class for answers with a binary state indicator.
This class represents a single choice 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:

◆ populateCorrectionsFormProperties()

assTextSubsetGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Definition at line 517 of file class.assTextSubsetGUI.php.

References ilPropertyFormGUI\addItem(), and ilFormPropertyGUI\setRequired().

518  {
519  // Choices
520  require_once 'Modules/TestQuestionPool/classes/forms/class.ilAssAnswerCorrectionsInputGUI.php';
521  $choices = new ilAssAnswerCorrectionsInputGUI($this->lng->txt("answers"), "answers");
522  $choices->setRequired(true);
523  $choices->setQuestionObject($this->object);
524  $choices->setValues($this->object->getAnswers());
525  $form->addItem($choices);
526 
527  return $form;
528  }
addItem($a_item)
Add Item (Property, SectionHeader).
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assTextSubsetGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

Definition at line 337 of file class.assTextSubsetGUI.php.

References ilPropertyFormGUI\addItem(), ilNumberInputGUI\setMinValue(), and ilSelectInputGUI\setOptions().

Referenced by editQuestion().

338  {
339  // number of requested answers
340  $correctanswers = new ilNumberInputGUI($this->lng->txt("nr_of_correct_answers"), "correctanswers");
341  $correctanswers->setMinValue(1);
342  $correctanswers->setDecimals(0);
343  $correctanswers->setSize(3);
344  $correctanswers->setValue($this->object->getCorrectAnswers());
345  $correctanswers->setRequired(true);
346  $form->addItem($correctanswers);
347 
348  // maximum available points
349  $points = new ilNumberInputGUI($this->lng->txt("maximum_points"), "points");
350  $points->setMinValue(0.0);
351  $points->setMinvalueShouldBeGreater(true);
352  $points->setSize(6);
353  $points->setDisabled(true);
354  $points->allowDecimals(true);
355  $points->setValue($this->object->getMaximumPoints());
356  $points->setRequired(false);
357  $form->addItem($points);
358 
359  // text rating
360  $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "text_rating");
361  $text_options = array(
362  "ci" => $this->lng->txt("cloze_textgap_case_insensitive"),
363  "cs" => $this->lng->txt("cloze_textgap_case_sensitive")
364  );
365  if (!$this->object->getSelfAssessmentEditingMode()) {
366  $text_options["l1"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1");
367  $text_options["l2"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2");
368  $text_options["l3"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3");
369  $text_options["l4"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4");
370  $text_options["l5"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5");
371  }
372  $textrating->setOptions($text_options);
373  $textrating->setValue($this->object->getTextRating());
374  $form->addItem($textrating);
375  return $form;
376  }
setMinValue($a_minvalue, $a_display_always=false)
Set Minimum Value.
This class represents a number property in a property form.
setOptions($a_options)
Set Options.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeanswers()

assTextSubsetGUI::removeanswers ( )

Remove an answer.

Definition at line 123 of file class.assTextSubsetGUI.php.

References $_POST, editQuestion(), and writePostData().

124  {
125  $this->writePostData(true);
126  $position = key($_POST['cmd']['removeanswers']);
127  $this->object->deleteAnswer($position);
128  $this->editQuestion();
129  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writePostData($always=false)
{}
$_POST["username"]
+ Here is the call graph for this function:

◆ renderAggregateView()

assTextSubsetGUI::renderAggregateView (   $aggregate)
Parameters
$aggregate
Returns
ilTemplate

Definition at line 465 of file class.assTextSubsetGUI.php.

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

466  {
467  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
468 
469  foreach ($aggregate as $key => $value) {
470  $tpl->setCurrentBlock('aggregaterow');
471  $tpl->setVariable('OPTION', $key);
472  $tpl->setVariable('COUNT', $value);
473  $tpl->parseCurrentBlock();
474  }
475  return $tpl;
476  }
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

assTextSubsetGUI::saveCorrectionsFormProperties ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form

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

References $index, and ilPropertyFormGUI\getInput().

534  {
535  $points = $form->getInput('answers')['points'];
536 
537  foreach ($this->object->getAnswers() as $index => $answer) {
538  /* @var ASS_AnswerBinaryStateImage $answer */
539  $answer->setPoints((float) $points[$index]);
540  }
541  }
$index
Definition: metadata.php:128
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
+ Here is the call graph for this function:

◆ supportsIntermediateSolutionOutput()

assTextSubsetGUI::supportsIntermediateSolutionOutput ( )

Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution()

Returns
bool

Definition at line 136 of file class.assTextSubsetGUI.php.

137  {
138  return true;
139  }

◆ writeAnswerSpecificPostData()

assTextSubsetGUI::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 328 of file class.assTextSubsetGUI.php.

References $_POST, $index, and ilUtil\secureString().

Referenced by writePostData().

329  {
330  // Delete all existing answers and create new answers from the form data
331  $this->object->flushAnswers();
332  foreach ($this->answers_from_post as $index => $answertext) {
333  $this->object->addAnswer(ilUtil::secureString(htmlentities(trim($answertext))), $_POST['answers']['points'][$index], $index);
334  }
335  }
$index
Definition: metadata.php:128
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

assTextSubsetGUI::writePostData (   $always = false)
protected

{}

Definition at line 48 of file class.assTextSubsetGUI.php.

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

Referenced by addanswers(), and removeanswers().

49  {
50  /*
51  * sk 26.09.22: This is horrific but I don't see a better way right now,
52  * without needing to check most questions for side-effects.
53  */
54  $this->answers_from_post = $_POST['answers']['answer'];
55  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
56  if (!$hasErrors) {
57  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
61  $this->saveTaxonomyAssignments();
62  return 0;
63  }
64  return 1;
65  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
This class represents a property form user interface.
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeQuestionSpecificPostData()

assTextSubsetGUI::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 322 of file class.assTextSubsetGUI.php.

References $_POST.

Referenced by writePostData().

323  {
324  $this->object->setCorrectAnswers($_POST["correctanswers"]);
325  $this->object->setTextRating($_POST["text_rating"]);
326  }
$_POST["username"]
+ Here is the caller graph for this function:

Field Documentation

◆ $answers_from_post

assTextSubsetGUI::$answers_from_post
private

Definition at line 26 of file class.assTextSubsetGUI.php.


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