ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
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 (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 addanswers ()
 
 removeanswers ()
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 getSpecificFeedbackOutput (array $user_solution)
 Returns the answer specific feedback for the question. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from the request and applies them to the data object. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from the request 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...
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from assQuestionGUI
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getObject ()
 
 setObject (assQuestion $question)
 
 setCopyToExistingPoolOnSave (?int $pool_ref_id)
 
 getCopyToExistingPoolOnSave ()
 
 setCopyToNewPoolOnSave (?string $pool_title)
 
 getCopyToNewPoolOnSave ()
 
 setMoveAfterQuestionId (?int $question_id)
 
 getMoveAfterQuestionId ()
 
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getCommentsPanelHTML ()
 
 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 (string $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)
 
 syncQuestion ()
 
 saveReturn ()
 
 saveQuestion ()
 
 setAdditionalContentEditingModeFromPost ()
 
 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)
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 outQuestionType ()
 
 saveSuggestedSolution ()
 
 cancelSuggestedSolution ()
 
 suggestedsolution (bool $save=false)
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $classname)
 
 getEditQuestionTabCommands ()
 
 isAutosaveable ()
 
 outQuestionForTest (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 getPreviewSession ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 
 cmdNeedsExistingQuestion (string $cmd)
 
 setContextAllowsSyncToPool (bool $sync_allowed)
 
 needsSyncQuery ()
 
 getQuestionSyncModal (string $cmd, string $cmd_class='')
 
 getAutoSavedSolutionOutput (int $active_id, int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false)
 
 buildFileDownloadLink ()
 
- 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 the request 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...
 
- 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 the request 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 ()
 
 setTestSpecificProperties ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (int $active_id, ?int $pass)
 
 getTypeOptions ()
 
 createSuggestedSolutionLinkingTo (string $type, string $target)
 
 setDefaultTabs (ilTabsGUI $tabs_gui)
 
 setQuestionSpecificTabs (ilTabsGUI $tabs_gui)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabs_gui)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction (string $form_action, int $active_id, int $pass)
 
 addBackTab (ilTabsGUI $tabs_gui)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 renderLatex ($content)
 Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in the browser. More...
 
 getSuggestedSolutionsRepo ()
 
 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 ()
 
 resetSavedPreviewSession ()
 

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 getCommandsFromClassConstants (string $guiClassName, string $cmdConstantNameBegin='CMD_')
 
static prepareTextareaOutput (?string $txt_output, bool $prepare_for_latex_output=false, bool $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 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'
 
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 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'
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const CMD_SYNC_QUESTION_AND_RETURN = 'syncQuestionReturn'
 
- Protected Attributes inherited from assQuestionGUI
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
const SUGGESTED_SOLUTION_COMMANDS_CANCEL = 'cancelSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_SAVE = 'saveSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_DEFAULT = 'suggestedsolution'
 
const QUESTION_SAVE_CMDS
 
const ADDITIONAL_CMDS_NEEDING_EXISTING_QST
 There are functions that need an existing question. More...
 
UIServices $ui
 
ilLogger $logger
 
GeneralQuestionPropertiesRepository $questionrepository
 
GUIService $notes_gui
 
ilCtrl $ctrl
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
Refinery $refinery
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $question_count
 question count in test More...
 
ilPropertyFormGUI $editForm = null
 
readonly ilTestLegacyFormsHelper $forms_helper
 
readonly RequestDataCollector $request_data_collector
 
bool $parent_type_is_lm = false
 
SuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

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 34 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 45 of file class.assTextSubsetGUI.php.

46 {
48 $this->object = new assTextSubset();
49 if ($id >= 0) {
50 $this->object->loadFromDb($id);
51 }
52 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class for TextSubset questions.
__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 ( )

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

116 : void
117 {
119 $this->writePostData(true);
120 $cmd = $this->request_data_collector->raw('cmd') ?? [];
121 $add_answers = in_array('addanswers', $cmd) && is_array($cmd['addanswers']) ? $cmd['addanswers'] : [];
122 $this->object->addAnswer('', 0, key($add_answers) + 1);
123 $this->editQuestion();
124 }
writePostData(bool $always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)

◆ completeAddAnswerAction()

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

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

481 {
482 foreach ($answers as $key => $ans) {
483 $found = false;
484
485 foreach ($this->object->getAnswers() as $item) {
486 if ($ans['answer'] !== $item->getAnswerText()) {
487 continue;
488 }
489
490 $found = true;
491 break;
492 }
493
494 if (!$found) {
495 $answers[$key]['addable'] = true;
496 }
497 }
498
499 return $answers;
500 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ editQuestion()

assTextSubsetGUI::editQuestion ( bool  $checkonly = false,
?bool  $is_save_cmd = null 
)

Reimplemented from assQuestionGUI.

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

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

Referenced by writePostData().

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

444 : array
445 {
446 return [];
447 }

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

458 : array
459 {
460 return [];
461 }

◆ getAnswersFrequency()

assTextSubsetGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

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

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

◆ getPreview()

assTextSubsetGUI::getPreview ( bool  $show_question_only = false,
bool  $show_inline_feedback = false 
)

Reimplemented from assQuestionGUI.

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

273 : string {
274 $solutions = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : [];
275 $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", true, true, "components/ILIAS/TestQuestionPool");
276 $width = $this->object->getMaxTextboxWidth();
277 for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
278 $template->setCurrentBlock("textsubset_row");
279 foreach ($solutions as $idx => $solution_value) {
280 if ($idx == $i) {
281 $template->setVariable(
282 "TEXTFIELD_VALUE",
283 " value=\"" . htmlspecialchars(
284 $this->escapeTemplatePlaceholders($solution_value["value1"]),
285 ENT_QUOTES | ENT_SUBSTITUTE,
286 'utf-8'
287 ) . "\""
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->renderLatex($this->object->getQuestionForHTMLOutput()));
297 $questionoutput = $template->get();
298 if (!$show_question_only) {
299 // get page object output
300 $questionoutput = $this->getILIASPage($questionoutput);
301 }
302 return $questionoutput;
303 }
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
escapeTemplatePlaceholders(string $text)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR

◆ getSolutionOutput()

assTextSubsetGUI::getSolutionOutput ( int  $active_id,
?int  $pass = null,
bool  $graphical_output = false,
bool  $result_output = false,
bool  $show_question_only = true,
bool  $show_feedback = false,
bool  $show_correct_solution = false,
bool  $show_manual_scoring = false,
bool  $show_question_text = true,
bool  $show_inline_feedback = true 
)

Reimplemented from assQuestionGUI.

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

147 : string {
148 // get the solution of the user for the active pass or from the last pass if allowed
149 $solutions = [];
150 if (($active_id > 0) && (!$show_correct_solution)) {
151 $solutions = $this->object->getSolutionValues($active_id, $pass);
152 } else {
153 $rank = [];
154 foreach ($this->object->answers as $answer) {
155 $points_string_for_key = (string) $answer->getPoints();
156 if ($answer->getPoints() > 0) {
157 if (!array_key_exists($points_string_for_key, $rank)) {
158 $rank[$points_string_for_key] = [];
159 }
160 array_push($rank[$points_string_for_key], $answer->getAnswertext());
161 }
162 }
163 krsort($rank, SORT_NUMERIC);
164 foreach ($rank as $index => $bestsolutions) {
165 array_push($solutions, ["value1" => join(",", $bestsolutions), "points" => $index]);
166 }
167 }
168
169 return $this->renderSolutionOutput(
170 $solutions,
171 $active_id,
172 $pass,
173 $graphical_output,
174 $result_output,
175 $show_question_only,
176 $show_feedback,
177 $show_correct_solution,
178 $show_manual_scoring,
179 $show_question_text,
180 false,
181 $show_inline_feedback,
182 );
183 }
renderSolutionOutput(mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)

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

343 : string
344 {
345 $output = "";
347 }
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...

References ilLegacyFormElementsUtil\prepareTextareaOutput().

+ Here is the call graph for this function:

◆ getTestOutput()

assTextSubsetGUI::getTestOutput ( int  $active_id,
int  $pass,
bool  $is_question_postponed = false,
array|bool  $user_post_solutions = false,
bool  $show_specific_inline_feedback = false 
)

Reimplemented from assQuestionGUI.

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

311 : string {
312 if ($active_id) {
313 $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
314 }
315
316 $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", true, true, "components/ILIAS/TestQuestionPool");
317 $width = $this->object->getMaxTextboxWidth();
318 for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
319 $template->setCurrentBlock("textsubset_row");
320 foreach ($solutions as $idx => $solution_value) {
321 if ($idx == $i) {
322 $template->setVariable(
323 "TEXTFIELD_VALUE",
324 " value=\"" . htmlspecialchars(
325 $this->escapeTemplatePlaceholders($solution_value["value1"]),
326 ENT_QUOTES | ENT_SUBSTITUTE,
327 'utf-8'
328 ) . "\""
329 );
330 }
331 }
332 $template->setVariable("COUNTER", $i + 1);
333 $template->setVariable("TEXTFIELD_ID", $i);
334 $template->setVariable("TEXTFIELD_SIZE", $width);
335 $template->parseCurrentBlock();
336 }
337 $template->setVariable("QUESTIONTEXT", $this->renderLatex($this->object->getQuestionForHTMLOutput()));
338 $questionoutput = $template->get();
339 $pageoutput = $this->outQuestionPage("", $is_question_postponed, $active_id, $questionoutput);
340 return $pageoutput;
341 }
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)

◆ populateAnswerSpecificFormPart()

assTextSubsetGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

413 {
414 $choices = new ilAnswerWizardInputGUI($this->lng->txt("answers"), "answers");
415 $choices->setRequired(true);
416 $choices->setQuestionObject($this->object);
417 $choices->setSingleline(true);
418 $choices->setAllowMove(false);
419 $choices->setMinValue(0.0);
420 if ($this->object->getAnswerCount() == 0) {
421 $this->object->addAnswer("", 0, 0);
422 }
423 $choices->setValues(array_map(
424 function (ASS_AnswerBinaryStateImage $value) {
425 $value->setAnswerText(html_entity_decode($value->getAnswerText()));
426 return $value;
427 },
428 $this->object->getAnswers()
429 ));
430 $form->addItem($choices);
431 return $form;
432 }
Class for answers with a binary state indicator.
This class represents a single choice wizard property in a property form.

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

+ Here is the call graph for this function:

◆ populateCorrectionsFormProperties()

assTextSubsetGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

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

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

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

372 {
373 // number of requested answers
374 $correctanswers = new ilNumberInputGUI($this->lng->txt("nr_of_correct_answers"), "correctanswers");
375 $correctanswers->setMinValue(1);
376 $correctanswers->setDecimals(0);
377 $correctanswers->setSize(3);
378 $correctanswers->setValue($this->object->getCorrectAnswers());
379 $correctanswers->setRequired(true);
380 $form->addItem($correctanswers);
381
382 // maximum available points
383 $points = new ilNumberInputGUI($this->lng->txt("maximum_points"), "points");
384 $points->setMinValue(0.0);
385 $points->setMinvalueShouldBeGreater(true);
386 $points->setSize(6);
387 $points->setDisabled(true);
388 $points->allowDecimals(true);
389 $points->setValue($this->object->getMaximumPoints());
390 $points->setRequired(false);
391 $form->addItem($points);
392
393 // text rating
394 $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "text_rating");
395 $text_options = [
396 "ci" => $this->lng->txt("cloze_textgap_case_insensitive"),
397 "cs" => $this->lng->txt("cloze_textgap_case_sensitive")
398 ];
399 if (!$this->object->getSelfAssessmentEditingMode()) {
400 $text_options["l1"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1");
401 $text_options["l2"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2");
402 $text_options["l3"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3");
403 $text_options["l4"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4");
404 $text_options["l5"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5");
405 }
406 $textrating->setOptions($text_options);
407 $textrating->setValue($this->object->getTextRating());
408 $form->addItem($textrating);
409 return $form;
410 }
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().

+ Here is the call graph for this function:

◆ removeanswers()

assTextSubsetGUI::removeanswers ( )

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

126 : void
127 {
129 $this->writePostData(true);
130 $cmd = $this->request_data_collector->raw('cmd') ?? [];
131 $remove_answers = in_array('removeanswers', $cmd) && is_array($cmd['removeanswers']) ? $cmd['removeanswers'] : [];
132 $this->object->deleteAnswer(key($remove_answers));
133 $this->editQuestion();
134 }

◆ renderSolutionOutput()

assTextSubsetGUI::renderSolutionOutput ( mixed  $user_solutions,
int  $active_id,
?int  $pass,
bool  $graphical_output = false,
bool  $result_output = false,
bool  $show_question_only = true,
bool  $show_feedback = false,
bool  $show_correct_solution = false,
bool  $show_manual_scoring = false,
bool  $show_question_text = true,
bool  $show_autosave_title = false,
bool  $show_inline_feedback = false 
)

Reimplemented from assQuestionGUI.

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

198 : ?string {
199 $template = new ilTemplate("tpl.il_as_qpl_textsubset_output_solution.html", true, true, "components/ILIAS/TestQuestionPool");
200 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "components/ILIAS/TestQuestionPool");
201
202 $available_answers = $this->object->getAvailableAnswers();
203 for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
204 if (!array_key_exists($i, $user_solutions) || (strcmp($user_solutions[$i]["value1"], "") == 0)) {
205 } else {
206 if (($active_id > 0) && (!$show_correct_solution)) {
207 if ($graphical_output) {
208 // output of ok/not ok icons for user entered solutions
209 $index = $this->object->isAnswerCorrect($available_answers, $user_solutions[$i]["value1"]);
210 $correct = false;
211 if ($index !== false) {
212 unset($available_answers[$index]);
213 $correct = true;
214 }
215
216 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
217 if ($correct) {
218 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
219 }
220 $template->setCurrentBlock("icon_ok");
221 $template->setVariable("ICON_OK", $correctness_icon);
222 $template->parseCurrentBlock();
223 }
224 }
225 $template->setCurrentBlock("textsubset_row");
226 $template->setVariable(
227 'SOLUTION',
229 htmlspecialchars(
230 $user_solutions[$i]['value1'],
231 ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401,
232 null,
233 false
234 )
235 )
236 );
237 $template->setVariable("COUNTER", $i + 1);
238 if ($result_output) {
239 $points = $user_solutions[$i]["points"];
240 $resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
241 $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
242 }
243 $template->parseCurrentBlock();
244 }
245 }
246 if ($show_question_text == true) {
247 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
248 }
249 $questionoutput = $template->get();
250 $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
251 if (strlen($feedback)) {
252 $cssClass = (
253 $this->hasCorrectSolution($active_id, $pass) ?
255 );
256
257 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
258 $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
259 }
260 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
261
262 $solutionoutput = $solutiontemplate->get();
263 if (!$show_question_only) {
264 // get page object output
265 $solutionoutput = $this->getILIASPage($solutionoutput);
266 }
267 return $solutionoutput;
268 }
getGenericFeedbackOutput(int $active_id, ?int $pass)
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)

◆ saveCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

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

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

References 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 the request and applies them to the data object.

Implements ilGuiAnswerScoringAdjustable.

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

355 : void
356 {
357 // Delete all existing answers and create new answers from the form data
358 $this->object->flushAnswers();
359
360 $answers = $this->request_data_collector->raw('answers', 3);
361
362 foreach ($this->answers_from_post as $index => $answertext) {
363 $this->object->addAnswer(
364 assQuestion::extendedTrim($answertext),
365 $this->refinery->kindlyTo()->float()->transform($answers['points'][$index]),
366 $index
367 );
368 }
369 }
static extendedTrim(string $value)
Trim non-printable characters from the beginning and end of a string.

References assQuestion\extendedTrim(), and ILIAS\Repository\refinery().

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

57 : int
58 {
59 /*
60 * sk 26.09.22: This is horrific but I don't see a better way right now,
61 * without needing to check most questions for side-effects.
62 */
63 $answers = $this->request_data_collector->raw('answers');
64 $this->answers_from_post = $answers['answer'] ?? [];
65
66 if (!(!$always && $this->editQuestion(true))) {
71 return 0;
72 }
73
74 return 1;
75 }
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from the request and applies them to the data object.
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object.

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

+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assTextSubsetGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

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

349 : void
350 {
351 $this->object->setCorrectAnswers($this->request_data_collector->int('correctanswers'));
352 $this->object->setTextRating($this->request_data_collector->string('text_rating'));
353 }

Referenced by writePostData().

+ Here is the caller graph for this function:

Field Documentation

◆ $answers_from_post

assTextSubsetGUI::$answers_from_post
private

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


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