ILIAS  release_8 Revision v8.24
assTextSubsetGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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...
 
 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 (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 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 (array $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
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getNotesHTML ()
 
 executeCommand ()
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext (string $presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled (bool $previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose (string $renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext (string $editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI (?ilTestQuestionNavigationGUI $navigationGUI)
 
 setTaxonomyIds (array $taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder (\ilQuestionHeaderBlockBuilder $questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd (string $questionActionCmd)
 
 getQuestionActionCmd ()
 
 assessment ()
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 
 getILIASPage (string $html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
 cancel ()
 
 originalSyncForm (string $return_to="", string $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 
 save ()
 
 saveReturn ()
 
 apply ()
 
 getContextPath ($cont_obj, int $a_endnode_id, int $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber (int $nr)
 
 getSequenceNumber ()
 
 setQuestionCount (int $a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage (string $errormessage)
 
 addErrorMessage (string $errormessage)
 
 outAdditionalOutput ()
 Why are you here? Some magic for plugins? More...
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addNewIdListener ($a_object, string $a_method, string $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners (int $a_new_id)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 suggestedsolution ()
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $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 (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 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...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAggregatedAnswersView (array $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 ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 

Protected Member Functions

 writePostData (bool $always=false)
 {Evaluates a posted edit form and writes the form data in the question object.
Returns
integer A positive value, if one of the required fields wasn't set, else 0
} More...
 
 completeAddAnswerAction ($answers, $questionIndex)
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 writePostData (bool $always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm (ilPropertyFormGUI $form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (string $feedback_correct, string $feedback_incorrect, int $active_id, ?int $pass)
 
 setDefaultTabs (ilTabsGUI $ilTabs)
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 cleanupAnswerText (array $answer_text, bool $is_rte)
 sk - 12.05.2023: This is one more of those that we need, but don't want. More...
 
 addSaveOnEnterOnLoadCode ()
 

Private Attributes

 $answers_from_post
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI (string $question_type='', int $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants (string $guiClassName, string $cmdConstantNameBegin='CMD_')
 
static prepareTextareaOutput ($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output where latex code may be in it If the text is HTML-free, CHR(13) will be converted to a line break. 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 CORRECTNESS_NOT_OK = 0
 
const CORRECTNESS_MOSTLY_OK = 1
 
const CORRECTNESS_OK = 2
 
const ALLOWED_PLAIN_TEXT_TAGS = "<em>, <strong>"
 sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI. More...
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $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 SUGGESTED_SOLUTION_COMMANDS
 
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
ILIAS Notes GUIService $notes_gui
 
ilCtrl $ctrl
 
ilPropertyFormGUI $editForm
 
ILIAS TestQuestionPool InternalRequestService $request
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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$

@ilCtrl_Calls assTextSubsetGUI: ilFormPropertyDispatchGUI

Definition at line 36 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 47 of file class.assTextSubsetGUI.php.

48 {
50 $this->object = new assTextSubset();
51 if ($id >= 0) {
52 $this->object->loadFromDb($id);
53 }
54 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $id, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ addanswers()

assTextSubsetGUI::addanswers ( )

Add a new answer.

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

121 : void
122 {
123 $this->writePostData(true);
124 $position = key($_POST['cmd']['addanswers']);
125 $this->object->addAnswer("", 0, $position + 1);
126 $this->editQuestion();
127 }
writePostData(bool $always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
editQuestion($checkonly=false)
Creates an output of the edit form for the question.

References editQuestion(), and writePostData().

+ Here is the call graph for this function:

◆ aggregateAnswers()

assTextSubsetGUI::aggregateAnswers (   $relevant_answers_chosen)

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

429 : array
430 {
431 $aggregate = array();
432
433 foreach ($relevant_answers_chosen as $relevant_answer) {
434 if (array_key_exists($relevant_answer['value1'], $aggregate)) {
435 $aggregate[$relevant_answer['value1']]++;
436 } else {
437 $aggregate[$relevant_answer['value1']] = 1;
438 }
439 }
440 return $aggregate;
441 }

◆ completeAddAnswerAction()

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

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

479 {
480 foreach ($answers as $key => $ans) {
481 $found = false;
482
483 foreach ($this->object->getAnswers() as $item) {
484 if ($ans['answer'] !== $item->getAnswerText()) {
485 continue;
486 }
487
488 $found = true;
489 break;
490 }
491
492 if (!$found) {
493 $answers[$key]['addable'] = true;
494 }
495 }
496
497 return $answers;
498 }
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ editQuestion()

assTextSubsetGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

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

80 : bool
81 {
82 $save = $this->isSaveCommand();
83 $this->getQuestionTemplate();
84
85 $form = new ilPropertyFormGUI();
86 $this->editForm = $form;
87
88 $form->setFormAction($this->ctrl->getFormAction($this));
89 $form->setTitle($this->outQuestionType());
90 $form->setMultipart(false);
91 $form->setTableWidth("100%");
92 $form->setId("asstextsubset");
93
97 $this->populateTaxonomyFormSection($form);
99
100 $errors = false;
101 if ($save) {
102 $form->setValuesByPost();
103 $points = $form->getItemByPostVar('points');
104 $points->setValue($this->object->getMaximumPoints());
105 $errors = !$form->checkInput();
106 $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
107 if ($errors) {
108 $checkonly = false;
109 }
110 }
111
112 if (!$checkonly) {
113 $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
114 }
115 return $errors;
116 }
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
This class represents a property form user interface.
$errors
Definition: imgupload.php:65

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

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

+ 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 397 of file class.assTextSubsetGUI.php.

397 : array
398 {
399 return array();
400 }

◆ 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 411 of file class.assTextSubsetGUI.php.

411 : array
412 {
413 return array();
414 }

◆ getAggregatedAnswersView()

assTextSubsetGUI::getAggregatedAnswersView ( array  $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 422 of file class.assTextSubsetGUI.php.

422 : string
423 {
424 return $this->renderAggregateView(
425 $this->aggregateAnswers($relevant_answers)
426 )->get();
427 }
aggregateAnswers($relevant_answers_chosen)

◆ getAnswersFrequency()

assTextSubsetGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

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

461 : array
462 {
463 $answers = array();
464
465 foreach ($relevantAnswers as $ans) {
466 if (!isset($answers[$ans['value1']])) {
467 $answers[$ans['value1']] = array(
468 'answer' => $ans['value1'], 'frequency' => 0
469 );
470 }
471
472 $answers[$ans['value1']]['frequency']++;
473 }
474 $answers = $this->completeAddAnswerAction($answers, $questionIndex);
475 return $answers;
476 }
completeAddAnswerAction($answers, $questionIndex)

◆ getPreview()

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

Reimplemented from assQuestionGUI.

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

244 : string
245 {
246 $solutions = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : array();
247 $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", true, true, "Modules/TestQuestionPool");
248 $width = $this->object->getMaxTextboxWidth();
249 for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
250 $template->setCurrentBlock("textsubset_row");
251 foreach ($solutions as $idx => $solution_value) {
252 if ($idx == $i) {
253 $template->setVariable("TEXTFIELD_VALUE", " value=\""
254 . $this->escapeTemplatePlaceholders($solution_value)
255 . "\"");
256 }
257 }
258 $template->setVariable("COUNTER", $i + 1);
259 $template->setVariable("TEXTFIELD_ID", $i);
260 $template->setVariable("TEXTFIELD_SIZE", $width);
261 $template->parseCurrentBlock();
262 }
263 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
264 $questionoutput = $template->get();
265 if (!$show_question_only) {
266 // get page object output
267 $questionoutput = $this->getILIASPage($questionoutput);
268 }
269 return $questionoutput;
270 }
escapeTemplatePlaceholders(string $text)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR
$i
Definition: metadata.php:41

References $i, and ILIAS\Repository\object().

+ 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
string The solution output of the question as HTML code

Reimplemented from assQuestionGUI.

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

162 : string {
163 // get the solution of the user for the active pass or from the last pass if allowed
164 $solutions = array();
165 if (($active_id > 0) && (!$show_correct_solution)) {
166 $solutions = $this->object->getSolutionValues($active_id, $pass);
167 } else {
168 $rank = array();
169 foreach ($this->object->answers as $answer) {
170 $points_string_for_key = (string) $answer->getPoints();
171 if ($answer->getPoints() > 0) {
172 if (!array_key_exists($points_string_for_key, $rank)) {
173 $rank[$points_string_for_key] = array();
174 }
175 array_push($rank[$points_string_for_key], $answer->getAnswertext());
176 }
177 }
178 krsort($rank, SORT_NUMERIC);
179 foreach ($rank as $index => $bestsolutions) {
180 array_push($solutions, array("value1" => join(",", $bestsolutions), "points" => $index));
181 }
182 }
183
184 $template = new ilTemplate("tpl.il_as_qpl_textsubset_output_solution.html", true, true, "Modules/TestQuestionPool");
185 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
186 $available_answers = &$this->object->getAvailableAnswers();
187 for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
188 if (!array_key_exists($i, $solutions) || (strcmp($solutions[$i]["value1"], "") == 0)) {
189 } else {
190 if (($active_id > 0) && (!$show_correct_solution)) {
191 if ($graphicalOutput) {
192 // output of ok/not ok icons for user entered solutions
193 $index = $this->object->isAnswerCorrect($available_answers, $solutions[$i]["value1"]);
194 $correct = false;
195 if ($index !== false) {
196 unset($available_answers[$index]);
197 $correct = true;
198 }
199
200 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
201 if ($correct) {
202 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
203 }
204 $template->setCurrentBlock("icon_ok");
205 $template->setVariable("ICON_OK", $correctness_icon);
206 $template->parseCurrentBlock();
207 }
208 }
209 $template->setCurrentBlock("textsubset_row");
210 $template->setVariable("SOLUTION", $this->escapeTemplatePlaceholders($solutions[$i]["value1"]));
211 $template->setVariable("COUNTER", $i + 1);
212 if ($result_output) {
213 $points = $solutions[$i]["points"];
214 $resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
215 $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
216 }
217 $template->parseCurrentBlock();
218 }
219 }
220 if ($show_question_text == true) {
221 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
222 }
223 $questionoutput = $template->get();
224 $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
225 if (strlen($feedback)) {
226 $cssClass = (
227 $this->hasCorrectSolution($active_id, $pass) ?
229 );
230
231 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
232 $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
233 }
234 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
235
236 $solutionoutput = $solutiontemplate->get();
237 if (!$show_question_only) {
238 // get page object output
239 $solutionoutput = $this->getILIASPage($solutionoutput);
240 }
241 return $solutionoutput;
242 }
getGenericFeedbackOutput(int $active_id, ?int $pass)
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
$index
Definition: metadata.php:145

◆ getSpecificFeedbackOutput()

assTextSubsetGUI::getSpecificFeedbackOutput ( array  $userSolution)

Returns the answer specific feedback for the question.

Parameters
array$userSolution($userSolution[<value1>] = <value2>)

Reimplemented from assQuestionGUI.

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

302 : string
303 {
304 $output = "";
305 return $this->object->prepareTextareaOutput($output, true);
306 }

◆ getTestOutput()

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

Reimplemented from assQuestionGUI.

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

272 : string
273 {
274 // get the solution of the user for the active pass or from the last pass if allowed
275 $user_solution = "";
276 if ($active_id) {
277 $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
278 }
279
280 $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", true, true, "Modules/TestQuestionPool");
281 $width = $this->object->getMaxTextboxWidth();
282 for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
283 $template->setCurrentBlock("textsubset_row");
284 foreach ($solutions as $idx => $solution_value) {
285 if ($idx == $i) {
286 $template->setVariable("TEXTFIELD_VALUE", " value=\""
287 . $this->escapeTemplatePlaceholders($solution_value["value1"])
288 . "\"");
289 }
290 }
291 $template->setVariable("COUNTER", $i + 1);
292 $template->setVariable("TEXTFIELD_ID", $i);
293 $template->setVariable("TEXTFIELD_SIZE", $width);
294 $template->parseCurrentBlock();
295 }
296 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
297 $questionoutput = $template->get();
298 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
299 return $pageoutput;
300 }
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)

References $i, and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assTextSubsetGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

366 {
367 $choices = new ilAnswerWizardInputGUI($this->lng->txt("answers"), "answers");
368 $choices->setRequired(true);
369 $choices->setQuestionObject($this->object);
370 $choices->setSingleline(true);
371 $choices->setAllowMove(false);
372 $choices->setMinValue(0.0);
373 if ($this->object->getAnswerCount() == 0) {
374 $this->object->addAnswer("", 0, 0);
375 }
376 $choices->setValues(array_map(
377 function (ASS_AnswerBinaryStateImage $value) {
378 $value->setAnswerText(html_entity_decode($value->getAnswerText()));
379 return $value;
380 },
381 $this->object->getAnswers()
382 ));
383 $form->addItem($choices);
384 return $form;
385 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

Referenced by editQuestion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateCorrectionsFormProperties()

assTextSubsetGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

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

500 : void
501 {
502 $choices = new ilAssAnswerCorrectionsInputGUI($this->lng->txt("answers"), "answers");
503 $choices->setRequired(true);
504 $choices->setQuestionObject($this->object);
505 $choices->setValues($this->object->getAnswers());
506 $form->addItem($choices);
507 }

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assTextSubsetGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

325 {
326 // number of requested answers
327 $correctanswers = new ilNumberInputGUI($this->lng->txt("nr_of_correct_answers"), "correctanswers");
328 $correctanswers->setMinValue(1);
329 $correctanswers->setDecimals(0);
330 $correctanswers->setSize(3);
331 $correctanswers->setValue($this->object->getCorrectAnswers());
332 $correctanswers->setRequired(true);
333 $form->addItem($correctanswers);
334
335 // maximum available points
336 $points = new ilNumberInputGUI($this->lng->txt("maximum_points"), "points");
337 $points->setMinValue(0.0);
338 $points->setMinvalueShouldBeGreater(true);
339 $points->setSize(6);
340 $points->setDisabled(true);
341 $points->allowDecimals(true);
342 $points->setValue($this->object->getMaximumPoints());
343 $points->setRequired(false);
344 $form->addItem($points);
345
346 // text rating
347 $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "text_rating");
348 $text_options = array(
349 "ci" => $this->lng->txt("cloze_textgap_case_insensitive"),
350 "cs" => $this->lng->txt("cloze_textgap_case_sensitive")
351 );
352 if (!$this->object->getSelfAssessmentEditingMode()) {
353 $text_options["l1"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1");
354 $text_options["l2"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2");
355 $text_options["l3"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3");
356 $text_options["l4"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4");
357 $text_options["l5"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5");
358 }
359 $textrating->setOptions($text_options);
360 $textrating->setValue($this->object->getTextRating());
361 $form->addItem($textrating);
362 return $form;
363 }
This class represents a number property in a property form.
This class represents a selection list property in a property form.

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

Referenced by editQuestion().

+ 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 132 of file class.assTextSubsetGUI.php.

132 : void
133 {
134 $this->writePostData(true);
135 $position = key($_POST['cmd']['removeanswers']);
136 $this->object->deleteAnswer($position);
137 $this->editQuestion();
138 }

References editQuestion(), and writePostData().

+ Here is the call graph for this function:

◆ renderAggregateView()

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

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

448 : ilTemplate
449 {
450 $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
451
452 foreach ($aggregate as $key => $value) {
453 $tpl->setCurrentBlock('aggregaterow');
454 $tpl->setVariable('OPTION', $key);
455 $tpl->setVariable('COUNT', $value);
457 }
458 return $tpl;
459 }
ilGlobalPageTemplate $tpl
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.

References ILIAS\LTI\ToolProvider\$key, and $tpl.

◆ saveCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

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

512 : void
513 {
514 $input = $form->getItemByPostVar('answers');
515 $values = $input->getValues();
516
517 foreach ($this->object->getAnswers() as $index => $answer) {
518 $points = (float) str_replace(',', '.', $values[$index]->getPoints());
519 $answer->setPoints($points);
520 }
521 }
getItemByPostVar(string $a_post_var)

References $index, ilPropertyFormGUI\getItemByPostVar(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assTextSubsetGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiAnswerScoringAdjustable.

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

314 : void
315 {
316 // Delete all existing answers and create new answers from the form data
317 $this->object->flushAnswers();
318 foreach ($this->answers_from_post as $index => $answertext) {
319 $answertext = assQuestion::extendedTrim($answertext);
320 $this->object->addAnswer(htmlentities($answertext), $_POST['answers']['points'][$index], $index);
321 }
322 }
static extendedTrim(string $value)
Trim non-printable characters from the beginning and end of a string.

References $index, and assQuestion\extendedTrim().

Referenced by writePostData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

assTextSubsetGUI::writePostData ( bool  $always = false)
protected

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

Returns
integer A positive value, if one of the required fields wasn't set, else 0
}

Reimplemented from assQuestionGUI.

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

59 : int
60 {
61 /*
62 * sk 26.09.22: This is horrific but I don't see a better way right now,
63 * without needing to check most questions for side-effects.
64 */
65 $this->answers_from_post = $_POST['answers']['answer'];
66 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
67 if (!$hasErrors) {
72 return 0;
73 }
74 return 1;
75 }
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.

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

Referenced by addanswers(), and removeanswers().

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

Implements ilGuiQuestionScoringAdjustable.

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

308 : void
309 {
310 $this->object->setCorrectAnswers($_POST["correctanswers"]);
311 $this->object->setTextRating($_POST["text_rating"]);
312 }

Referenced by writePostData().

+ Here is the caller graph for this function:

Field Documentation

◆ $answers_from_post

assTextSubsetGUI::$answers_from_post
private

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


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