ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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...
 
 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 ($show_question_only=false, $showInlineFeedback=false)
 
 getTestOutput ($active_id, $pass=null, $is_postponed=false, $use_post_solutions=false, $inlineFeedback=false)
 
 getSpecificFeedbackOutput (array $userSolution)
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 
 populateAnswerSpecificFormPart (\ilPropertyFormGUI $form)
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAggregatedAnswersView (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 ()
 
 geCommentsPanelHTML ()
 
 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)
 
 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,)
 
 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)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 
 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 ()
 
 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 $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)
 
 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 _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
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 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_CANCEL = 'cancelSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_SAVE = 'saveSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_DEFAULT = 'suggestedsolution'
 
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
ilLogger $logger
 
ILIAS TestQuestionPool QuestionInfoService $questioninfo
 
ILIAS Notes GUIService $notes_gui
 
ilCtrl $ctrl
 
Refinery $refinery
 
ilPropertyFormGUI $editForm
 
ILIAS TestQuestionPool InternalRequestService $request
 
bool $parent_type_is_lm = false
 
assQuestionSuggestedSolutionsDatabaseRepository $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 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.

References $id, and ILIAS\MetaData\Repository\Validation\Data\__construct().

48  {
50  $this->object = new assTextSubset();
51  if ($id >= 0) {
52  $this->object->loadFromDb($id);
53  }
54  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(VocabulariesInterface $vocabularies)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ 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.

References editQuestion(), and writePostData().

121  : void
122  {
123  $this->writePostData(true);
124  $position = key($_POST['cmd']['addanswers']);
125  $this->object->addAnswer("", 0, $position + 1);
126  $this->editQuestion();
127  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ aggregateAnswers()

assTextSubsetGUI::aggregateAnswers (   $relevant_answers_chosen)

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

Referenced by getAggregatedAnswersView().

470  : array
471  {
472  $aggregate = array();
473 
474  foreach ($relevant_answers_chosen as $relevant_answer) {
475  if (array_key_exists($relevant_answer['value1'], $aggregate)) {
476  $aggregate[$relevant_answer['value1']]++;
477  } else {
478  $aggregate[$relevant_answer['value1']] = 1;
479  }
480  }
481  return $aggregate;
482  }
+ Here is the caller graph for this function:

◆ completeAddAnswerAction()

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

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

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

Referenced by getAnswersFrequency().

520  {
521  foreach ($answers as $key => $ans) {
522  $found = false;
523 
524  foreach ($this->object->getAnswers() as $item) {
525  if ($ans['answer'] !== $item->getAnswerText()) {
526  continue;
527  }
528 
529  $found = true;
530  break;
531  }
532 
533  if (!$found) {
534  $answers[$key]['addable'] = true;
535  }
536  }
537 
538  return $answers;
539  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editQuestion()

assTextSubsetGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

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

References 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().

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

438  : array
439  {
440  return array();
441  }

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

452  : array
453  {
454  return array();
455  }

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

References aggregateAnswers(), and renderAggregateView().

463  : string
464  {
465  return $this->renderAggregateView(
466  $this->aggregateAnswers($relevant_answers)
467  )->get();
468  }
aggregateAnswers($relevant_answers_chosen)
+ Here is the call graph for this function:

◆ getAnswersFrequency()

assTextSubsetGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

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

References completeAddAnswerAction().

502  : array
503  {
504  $answers = array();
505 
506  foreach ($relevantAnswers as $ans) {
507  if (!isset($answers[$ans['value1']])) {
508  $answers[$ans['value1']] = array(
509  'answer' => $ans['value1'], 'frequency' => 0
510  );
511  }
512 
513  $answers[$ans['value1']]['frequency']++;
514  }
515  $answers = $this->completeAddAnswerAction($answers, $questionIndex);
516  return $answers;
517  }
completeAddAnswerAction($answers, $questionIndex)
+ Here is the call graph for this function:

◆ getPreview()

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

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

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

286  : string
287  {
288  $solutions = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : array();
289  $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", true, true, "Modules/TestQuestionPool");
290  $width = $this->object->getMaxTextboxWidth();
291  for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
292  $template->setCurrentBlock("textsubset_row");
293  foreach ($solutions as $idx => $solution_value) {
294  if ($idx == $i) {
295  $template->setVariable("TEXTFIELD_VALUE", " value=\""
296  . $this->escapeTemplatePlaceholders($solution_value)
297  . "\"");
298  }
299  }
300  $template->setVariable("COUNTER", $i + 1);
301  $template->setVariable("TEXTFIELD_ID", $i);
302  $template->setVariable("TEXTFIELD_SIZE", $width);
303  $template->parseCurrentBlock();
304  }
305  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
306  $questionoutput = $template->get();
307  if (!$show_question_only) {
308  // get page object output
309  $questionoutput = $this->getILIASPage($questionoutput);
310  }
311  return $questionoutput;
312  }
escapeTemplatePlaceholders(string $text)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
+ 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

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

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

162  : string {
163  // get the solution of the user for the active pass or from the last pass if allowed
164  $solutions = [];
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  $show_inline_feedback = false;
185  return $this->renderSolutionOutput(
186  $solutions,
187  $active_id,
188  $pass,
189  $graphicalOutput,
190  $result_output,
191  $show_question_only,
192  $show_feedback,
193  $show_correct_solution,
194  $show_manual_scoring,
195  $show_question_text,
196  false,
197  $show_inline_feedback,
198  );
199  }
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  $userSolution)

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

References ilLegacyFormElementsUtil\prepareTextareaOutput().

344  : string
345  {
346  $output = "";
348  }
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 (   $active_id,
  $pass = null,
  $is_postponed = false,
  $use_post_solutions = false,
  $inlineFeedback = false 
)

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

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

314  : string
315  {
316  // get the solution of the user for the active pass or from the last pass if allowed
317  $user_solution = "";
318  if ($active_id) {
319  $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
320  }
321 
322  $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", true, true, "Modules/TestQuestionPool");
323  $width = $this->object->getMaxTextboxWidth();
324  for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
325  $template->setCurrentBlock("textsubset_row");
326  foreach ($solutions as $idx => $solution_value) {
327  if ($idx == $i) {
328  $template->setVariable("TEXTFIELD_VALUE", " value=\""
329  . $this->escapeTemplatePlaceholders($solution_value['value1'])
330  . "\"");
331  }
332  }
333  $template->setVariable("COUNTER", $i + 1);
334  $template->setVariable("TEXTFIELD_ID", $i);
335  $template->setVariable("TEXTFIELD_SIZE", $width);
336  $template->parseCurrentBlock();
337  }
338  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
339  $questionoutput = $template->get();
340  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
341  return $pageoutput;
342  }
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 406 of file class.assTextSubsetGUI.php.

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

Referenced by editQuestion().

407  {
408  $choices = new ilAnswerWizardInputGUI($this->lng->txt("answers"), "answers");
409  $choices->setRequired(true);
410  $choices->setQuestionObject($this->object);
411  $choices->setSingleline(true);
412  $choices->setAllowMove(false);
413  $choices->setMinValue(0.0);
414  if ($this->object->getAnswerCount() == 0) {
415  $this->object->addAnswer("", 0, 0);
416  }
417  $choices->setValues(array_map(
418  function (ASS_AnswerBinaryStateImage $value) {
419  $value->setAnswerText(html_entity_decode($value->getAnswerText()));
420  return $value;
421  },
422  $this->object->getAnswers()
423  ));
424  $form->addItem($choices);
425  return $form;
426  }
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 541 of file class.assTextSubsetGUI.php.

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

541  : void
542  {
543  $choices = new ilAssAnswerCorrectionsInputGUI($this->lng->txt("answers"), "answers");
544  $choices->setRequired(true);
545  $choices->setQuestionObject($this->object);
546  $choices->setValues($this->object->getAnswers());
547  $form->addItem($choices);
548  }
setRequired(bool $a_required)
+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assTextSubsetGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

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

◆ removeanswers()

assTextSubsetGUI::removeanswers ( )

Remove an answer.

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

References editQuestion(), and writePostData().

132  : void
133  {
134  $this->writePostData(true);
135  $position = key($_POST['cmd']['removeanswers']);
136  $this->object->deleteAnswer($position);
137  $this->editQuestion();
138  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ renderAggregateView()

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

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

References ILIAS\LTI\ToolProvider\$key, assQuestionGUI\$tpl, ilGlobalPageTemplate\parseCurrentBlock(), ilGlobalPageTemplate\setCurrentBlock(), and ilGlobalPageTemplate\setVariable().

Referenced by getAggregatedAnswersView().

489  : ilTemplate
490  {
491  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
492 
493  foreach ($aggregate as $key => $value) {
494  $tpl->setCurrentBlock('aggregaterow');
495  $tpl->setVariable('OPTION', $key);
496  $tpl->setVariable('COUNT', $value);
498  }
499  return $tpl;
500  }
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
ilGlobalPageTemplate $tpl
string $key
Consumer key/client ID value.
Definition: System.php:193
setVariable(string $variable, $value='')
Sets the given variable to the given value.
+ Here is the call graph for this function:
+ Here is the caller 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 201 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(), ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

Referenced by getSolutionOutput().

214  : ?string {
215 
216  $template = new ilTemplate("tpl.il_as_qpl_textsubset_output_solution.html", true, true, "Modules/TestQuestionPool");
217  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
218  $available_answers = &$this->object->getAvailableAnswers();
219  for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) {
220  if (!array_key_exists($i, $user_solutions) || (strcmp($user_solutions[$i]['value1'], "") == 0)) {
221  } else {
222  if (($active_id > 0) && (!$show_correct_solution)) {
223  if ($graphical_output) {
224  // output of ok/not ok icons for user entered solutions
225  $index = $this->object->isAnswerCorrect($available_answers, $user_solutions[$i]['value1']);
226  $correct = false;
227  if ($index !== false) {
228  unset($available_answers[$index]);
229  $correct = true;
230  }
231 
232  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
233  if ($correct) {
234  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
235  }
236  $template->setCurrentBlock("icon_ok");
237  $template->setVariable("ICON_OK", $correctness_icon);
238  $template->parseCurrentBlock();
239  }
240  }
241  $template->setCurrentBlock("textsubset_row");
242  $template->setVariable(
243  "SOLUTION",
245  htmlspecialchars(
246  $user_solutions[$i]['value1'],
247  ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401,
248  null,
249  false
250  )
251  )
252  );
253  $template->setVariable("COUNTER", $i + 1);
254  if ($result_output) {
255  $points = $user_solutions[$i]["points"];
256  $resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
257  $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
258  }
259  $template->parseCurrentBlock();
260  }
261  }
262  if ($show_question_text == true) {
263  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
264  }
265  $questionoutput = $template->get();
266  $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
267  if (strlen($feedback)) {
268  $cssClass = (
269  $this->hasCorrectSolution($active_id, $pass) ?
271  );
272 
273  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
274  $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
275  }
276  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
277 
278  $solutionoutput = $solutiontemplate->get();
279  if (!$show_question_only) {
280  // get page object output
281  $solutionoutput = $this->getILIASPage($solutionoutput);
282  }
283  return $solutionoutput;
284  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
escapeTemplatePlaceholders(string $text)
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 553 of file class.assTextSubsetGUI.php.

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

553  : void
554  {
555  $input = $form->getItemByPostVar('answers');
556  $values = $input->getValues();
557 
558  foreach ($this->object->getAnswers() as $index => $answer) {
559  $points = (float) str_replace(',', '.', $values[$index]->getPoints());
560  $answer->setPoints($points);
561  }
562  }
getItemByPostVar(string $a_post_var)
+ 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 356 of file class.assTextSubsetGUI.php.

References assQuestion\extendedTrim().

Referenced by writePostData().

356  : void
357  {
358  // Delete all existing answers and create new answers from the form data
359  $this->object->flushAnswers();
360  foreach ($this->answers_from_post as $index => $answertext) {
361  $this->object->addAnswer(assQuestion::extendedTrim($answertext), $_POST['answers']['points'][$index], $index);
362  }
363  }
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 59 of file class.assTextSubsetGUI.php.

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

Referenced by addanswers(), and removeanswers().

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) {
71  $this->saveTaxonomyAssignments();
72  return 0;
73  }
74  return 1;
75  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
+ 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 350 of file class.assTextSubsetGUI.php.

Referenced by writePostData().

350  : void
351  {
352  $this->object->setCorrectAnswers((int) $_POST["correctanswers"]);
353  $this->object->setTextRating($_POST["text_rating"]);
354  }
+ 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: