ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 
 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 ()
 
 showHints ()
 
 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)
 
- 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 (bool $always=false)
 {} 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 (string $feedback_correct, string $feedback_incorrect, 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_QuestionHints (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)
 
 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 ()
 

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

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

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

46  {
48  $this->object = new assTextSubset();
49  if ($id >= 0) {
50  $this->object->loadFromDb($id);
51  }
52  }
Class for TextSubset questions.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addanswers()

assTextSubsetGUI::addanswers ( )

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

References editQuestion(), assQuestionGUI\setAdditionalContentEditingModeFromPost(), and writePostData().

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  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ completeAddAnswerAction()

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

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

References ILIAS\Repository\object().

Referenced by getAnswersFrequency().

471  {
472  foreach ($answers as $key => $ans) {
473  $found = false;
474 
475  foreach ($this->object->getAnswers() as $item) {
476  if ($ans['answer'] !== $item->getAnswerText()) {
477  continue;
478  }
479 
480  $found = true;
481  break;
482  }
483 
484  if (!$found) {
485  $answers[$key]['addable'] = true;
486  }
487  }
488 
489  return $answers;
490  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editQuestion()

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

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

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

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

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 
92  $this->addBasicQuestionFormProperties($form);
94  $this->populateAnswerSpecificFormPart($form);
95  $this->populateTaxonomyFormSection($form);
96  $this->addQuestionFormCommandButtons($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  }
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
renderEditForm(ilPropertyFormGUI $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 434 of file class.assTextSubsetGUI.php.

434  : array
435  {
436  return [];
437  }

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

448  : array
449  {
450  return [];
451  }

◆ getAnswersFrequency()

assTextSubsetGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

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

References completeAddAnswerAction().

453  : array
454  {
455  $answers = [];
456 
457  foreach ($relevantAnswers as $ans) {
458  if (!isset($answers[$ans['value1']])) {
459  $answers[$ans['value1']] = [
460  'answer' => $ans['value1'], 'frequency' => 0
461  ];
462  }
463 
464  $answers[$ans['value1']]['frequency']++;
465  }
466  $answers = $this->completeAddAnswerAction($answers, $questionIndex);
467  return $answers;
468  }
completeAddAnswerAction($answers, $questionIndex)
+ Here is the call graph for this function:

◆ getPreview()

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

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

References assQuestionGUI\escapeTemplatePlaceholders(), assQuestionGUI\getILIASPage(), assQuestionGUI\getPreviewSession(), and ILIAS\Repository\object().

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("TEXTFIELD_VALUE", " value=\""
282  . $this->escapeTemplatePlaceholders($solution_value)
283  . "\"");
284  }
285  }
286  $template->setVariable("COUNTER", $i + 1);
287  $template->setVariable("TEXTFIELD_ID", $i);
288  $template->setVariable("TEXTFIELD_SIZE", $width);
289  $template->parseCurrentBlock();
290  }
291  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
292  $questionoutput = $template->get();
293  if (!$show_question_only) {
294  // get page object output
295  $questionoutput = $this->getILIASPage($questionoutput);
296  }
297  return $questionoutput;
298  }
escapeTemplatePlaceholders(string $text)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
+ Here is the call graph for this function:

◆ 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 
)

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

References ILIAS\Repository\object(), and renderSolutionOutput().

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,)
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assTextSubsetGUI::getSpecificFeedbackOutput ( array  $user_solution)

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

References ilLegacyFormElementsUtil\prepareTextareaOutput().

333  : string
334  {
335  $output = "";
337  }
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...
+ 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 
)

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

References assQuestionGUI\escapeTemplatePlaceholders(), ILIAS\Repository\object(), and assQuestionGUI\outQuestionPage().

306  : string {
307  if ($active_id) {
308  $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
309  }
310 
311  $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", true, true, "components/ILIAS/TestQuestionPool");
312  $width = $this->object->getMaxTextboxWidth();
313  for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
314  $template->setCurrentBlock("textsubset_row");
315  foreach ($solutions as $idx => $solution_value) {
316  if ($idx == $i) {
317  $template->setVariable("TEXTFIELD_VALUE", " value=\""
318  . $this->escapeTemplatePlaceholders($solution_value["value1"])
319  . "\"");
320  }
321  }
322  $template->setVariable("COUNTER", $i + 1);
323  $template->setVariable("TEXTFIELD_ID", $i);
324  $template->setVariable("TEXTFIELD_SIZE", $width);
325  $template->parseCurrentBlock();
326  }
327  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
328  $questionoutput = $template->get();
329  $pageoutput = $this->outQuestionPage("", $is_question_postponed, $active_id, $questionoutput);
330  return $pageoutput;
331  }
escapeTemplatePlaceholders(string $text)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assTextSubsetGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

403  {
404  $choices = new ilAnswerWizardInputGUI($this->lng->txt("answers"), "answers");
405  $choices->setRequired(true);
406  $choices->setQuestionObject($this->object);
407  $choices->setSingleline(true);
408  $choices->setAllowMove(false);
409  $choices->setMinValue(0.0);
410  if ($this->object->getAnswerCount() == 0) {
411  $this->object->addAnswer("", 0, 0);
412  }
413  $choices->setValues(array_map(
414  function (ASS_AnswerBinaryStateImage $value) {
415  $value->setAnswerText(html_entity_decode($value->getAnswerText()));
416  return $value;
417  },
418  $this->object->getAnswers()
419  ));
420  $form->addItem($choices);
421  return $form;
422  }
Class for answers with a binary state indicator.
This class represents a single choice wizard property in a property form.
setRequired(bool $a_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 492 of file class.assTextSubsetGUI.php.

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

492  : void
493  {
494  $choices = new ilAssAnswerCorrectionsInputGUI($this->lng->txt("answers"), "answers");
495  $choices->setRequired(true);
496  $choices->setQuestionObject($this->object);
497  $choices->setValues($this->object->getAnswers());
498  $form->addItem($choices);
499  }
setRequired(bool $a_required)
+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assTextSubsetGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilNumberInputGUI\setMinValue(), and ilSelectInputGUI\setOptions().

Referenced by editQuestion().

362  {
363  // number of requested answers
364  $correctanswers = new ilNumberInputGUI($this->lng->txt("nr_of_correct_answers"), "correctanswers");
365  $correctanswers->setMinValue(1);
366  $correctanswers->setDecimals(0);
367  $correctanswers->setSize(3);
368  $correctanswers->setValue($this->object->getCorrectAnswers());
369  $correctanswers->setRequired(true);
370  $form->addItem($correctanswers);
371 
372  // maximum available points
373  $points = new ilNumberInputGUI($this->lng->txt("maximum_points"), "points");
374  $points->setMinValue(0.0);
375  $points->setMinvalueShouldBeGreater(true);
376  $points->setSize(6);
377  $points->setDisabled(true);
378  $points->allowDecimals(true);
379  $points->setValue($this->object->getMaximumPoints());
380  $points->setRequired(false);
381  $form->addItem($points);
382 
383  // text rating
384  $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "text_rating");
385  $text_options = [
386  "ci" => $this->lng->txt("cloze_textgap_case_insensitive"),
387  "cs" => $this->lng->txt("cloze_textgap_case_sensitive")
388  ];
389  if (!$this->object->getSelfAssessmentEditingMode()) {
390  $text_options["l1"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1");
391  $text_options["l2"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2");
392  $text_options["l3"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3");
393  $text_options["l4"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4");
394  $text_options["l5"] = sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5");
395  }
396  $textrating->setOptions($text_options);
397  $textrating->setValue($this->object->getTextRating());
398  $form->addItem($textrating);
399  return $form;
400  }
This class represents a selection list property in a property form.
setOptions(array $a_options)
This class represents a number property in a property form.
setMinValue(float $a_minvalue, bool $a_display_always=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeanswers()

assTextSubsetGUI::removeanswers ( )

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

References editQuestion(), assQuestionGUI\setAdditionalContentEditingModeFromPost(), and writePostData().

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  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ 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 
)

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

References ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, assQuestionGUI\escapeTemplatePlaceholders(), assQuestionGUI\generateCorrectnessIconsForCorrectness(), assQuestionGUI\getGenericFeedbackOutput(), assQuestionGUI\getILIASPage(), assQuestionGUI\hasCorrectSolution(), assQuestionGUI\isTestPresentationContext(), ILIAS\Repository\lng(), null, ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

Referenced by getSolutionOutput().

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  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
escapeTemplatePlaceholders(string $text)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
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...
getGenericFeedbackOutput(int $active_id, ?int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

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

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

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

504  : void
505  {
506  $input = $form->getItemByPostVar('answers');
507  $values = $input->getValues();
508 
509  foreach ($this->object->getAnswers() as $index => $answer) {
510  $points = (float) str_replace(',', '.', $values[$index]->getPoints());
511  $answer->setPoints($points);
512  }
513  }
getItemByPostVar(string $a_post_var)
+ 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 345 of file class.assTextSubsetGUI.php.

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

Referenced by writePostData().

345  : void
346  {
347  // Delete all existing answers and create new answers from the form data
348  $this->object->flushAnswers();
349 
350  $answers = $this->request_data_collector->raw('answers', 3);
351 
352  foreach ($this->answers_from_post as $index => $answertext) {
353  $this->object->addAnswer(
354  assQuestion::extendedTrim($answertext),
355  $this->refinery->kindlyTo()->float()->transform($answers['points'][$index]),
356  $index
357  );
358  }
359  }
static extendedTrim(string $value)
Trim non-printable characters from the beginning and end of a string.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

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

{}

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

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

Referenced by addanswers(), and removeanswers().

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))) {
70  $this->saveTaxonomyAssignments();
71  return 0;
72  }
73 
74  return 1;
75  }
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object...
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from the request and applies them to the data object...
+ 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 the request and applies them to the data object.

Implements ilGuiQuestionScoringAdjustable.

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

Referenced by writePostData().

339  : void
340  {
341  $this->object->setCorrectAnswers($this->request_data_collector->int('correctanswers'));
342  $this->object->setTextRating($this->request_data_collector->string('text_rating'));
343  }
+ 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: