ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
assTextQuestionGUI 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 assTextQuestionGUI:
+ Collaboration diagram for assTextQuestionGUI:

Public Member Functions

 __construct ($id=-1)
 assTextQuestionGUI constructor More...
 
 editQuestion ($checkonly=false)
 Creates an output of the edit form for the question. More...
 
 magicAfterTestOutput ()
 
 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,)
 
 getAutoSavedSolutionOutput ( $active_id, $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_autosave_title=false, bool $show_inline_feedback=false,)
 Get the question solution output. More...
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 getTestOutput ($active_id, $pass=null, $is_postponed=false, $use_post_solutions=false, $inlineFeedback=false)
 
 addSuggestedSolution ()
 
 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...
 
 isAnswerFreuqencyStatisticSupported ()
 
 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...
 
 getJsCode ()
 
- 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 ()
 

Protected Attributes

bool $tiny_mce_enabled
 
- 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
 

Private Member Functions

 getBestAnswer ($asHtml)
 
 getUserAnswer ($active_id, $pass)
 

Static Private Member Functions

static buildAnswerTextOnlyArray ($answers)
 

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'
 

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 Text question GUI representation

The assTextQuestionGUI class encapsulates the GUI representation for text 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$

assTextQuestionGUI: ilFormPropertyDispatchGUI

Definition at line 33 of file class.assTextQuestionGUI.php.

Constructor & Destructor Documentation

◆ __construct()

assTextQuestionGUI::__construct (   $id = -1)

assTextQuestionGUI constructor

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

Parameters
integer$idThe database id of a text question object

Definition at line 43 of file class.assTextQuestionGUI.php.

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

44  {
45  $this->tiny_mce_enabled = (new ilSetting('advanced_editing'))->get('advanced_editing_javascript_editor')
46  === 'tinymce' ? true : false;
48  $this->object = new assTextQuestion();
49  if ($id >= 0) {
50  $this->object->loadFromDb($id);
51  }
52  }
__construct(VocabulariesInterface $vocabularies)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

Member Function Documentation

◆ addSuggestedSolution()

assTextQuestionGUI::addSuggestedSolution ( )

Definition at line 578 of file class.assTextQuestionGUI.php.

References ILIAS\Repository\ctrl(), editQuestion(), assQuestionGUI\getErrorMessage(), assQuestionGUI\getQuestionTemplate(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilSession\set(), and writePostData().

578  : void
579  {
580  ilSession::set("subquestion_index", 0);
581  if ($_POST["cmd"]["addSuggestedSolution"]) {
582  if ($this->writePostData()) {
583  $this->tpl->setOnScreenMessage('info', $this->getErrorMessage());
584  $this->editQuestion();
585  return;
586  }
587  // @MBECKER: Check this in running test
588  if (!$this->checkInput()) {
589  $this->tpl->setOnScreenMessage('info', $this->lng->txt("fill_out_all_required_fields_add_answer"));
590  $this->editQuestion();
591  return;
592  }
593  }
594  $this->object->saveToDb();
595  $this->ctrl->setParameter($this, "q_id", $this->object->getId());
596  $this->tpl->setVariable("HEADER", $this->object->getTitleForHTMLOutput());
597  $this->getQuestionTemplate();
598  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writePostData(bool $always=false)
{}
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ buildAnswerTextOnlyArray()

static assTextQuestionGUI::buildAnswerTextOnlyArray (   $answers)
staticprivate

Definition at line 115 of file class.assTextQuestionGUI.php.

115  : array
116  {
117  $answerTexts = [];
118 
119  foreach ($answers as $answer) {
120  $answerTexts[] = $answer->getAnswertext();
121  }
122 
123  return $answerTexts;
124  }

◆ editQuestion()

assTextQuestionGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

public

Definition at line 75 of file class.assTextQuestionGUI.php.

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

Referenced by addSuggestedSolution(), and writePostData().

75  : bool
76  {
77  $save = $this->isSaveCommand();
78  $this->getQuestionTemplate();
79 
80  $form = new ilPropertyFormGUI();
81  $this->editForm = $form;
82 
83  $form->setFormAction($this->ctrl->getFormAction($this));
84  $form->setTitle($this->outQuestionType());
85  $form->setMultipart(true);
86  $form->setTableWidth("100%");
87  $form->setId("asstextquestion");
88 
89  $this->addBasicQuestionFormProperties($form);
91  $this->populateAnswerSpecificFormPart($form);
92 
93 
94  $this->populateTaxonomyFormSection($form);
95 
96  $this->addQuestionFormCommandButtons($form);
97 
98  $errors = false;
99 
100  if ($save) {
101  $form->setValuesByPost();
102  $errors = !$form->checkInput();
103  $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
104  if ($errors) {
105  $checkonly = false;
106  }
107  }
108 
109  if (!$checkonly) {
110  $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
111  }
112  return $errors;
113  }
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAfterParticipationSuppressionAnswerPostVars()

assTextQuestionGUI::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 785 of file class.assTextQuestionGUI.php.

785  : array
786  {
787  return [];
788  }

◆ getAfterParticipationSuppressionQuestionPostVars()

assTextQuestionGUI::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 799 of file class.assTextQuestionGUI.php.

799  : array
800  {
801  return [];
802  }

◆ getAggregatedAnswersView()

assTextQuestionGUI::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 810 of file class.assTextQuestionGUI.php.

810  : string
811  {
812  return ''; //print_r($relevant_answers,true);
813  }

◆ getAnswersFrequency()

assTextQuestionGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Definition at line 820 of file class.assTextQuestionGUI.php.

820  : array
821  {
822  return [];
823  }

◆ getAutoSavedSolutionOutput()

assTextQuestionGUI::getAutoSavedSolutionOutput (   $active_id,
  $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_autosave_title = false,
bool  $show_inline_feedback = false 
)

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 292 of file class.assTextQuestionGUI.php.

References ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, getBestAnswer(), assQuestionGUI\getGenericFeedbackOutput(), assQuestionGUI\getILIASPage(), getUserAnswer(), assQuestionGUI\hasCorrectSolution(), assQuestionGUI\isTestPresentationContext(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilLegacyFormElementsUtil\prepareTextareaOutput(), and assQuestionGUI\renderPurposeSupportsFormHtml().

304  : string {
305  // get the solution of the user for the active pass or from the last pass if allowed
306 
307  $user_solution = $this->getUserAnswer($active_id, $pass);
308 
309  if (($active_id > 0) && (!$show_correct_solution)) {
310  $solution = $user_solution;
311  } else {
312  $solution = $this->getBestAnswer($this->renderPurposeSupportsFormHtml());
313  }
314 
315  $template = new ilTemplate("tpl.il_as_qpl_text_question_output_solution.html", true, true, "Modules/TestQuestionPool");
316  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
317 
318  $solution = '';
319  $autosaved_solution = $this->object->getLatestAutosaveContent($active_id, $pass);
320  if ($autosaved_solution !== null) {
321  if ($show_autosave_title) {
322  $template->setCurrentBlock('autosave_title');
323  $template->setVariable('AUTOSAVE_TITLE', $this->lng->txt('autosavecontent'));
324  $template->parseCurrentBlock();
325  }
326  $solution = $this->object->getHtmlUserSolutionPurifier()->purify($autosaved_solution);
327  if ($this->renderPurposeSupportsFormHtml()) {
328  $template->setCurrentBlock('essay_div');
329  $template->setVariable("DIV_ESSAY", ilLegacyFormElementsUtil::prepareTextareaOutput($solution, true));
330  } else {
331  $template->setCurrentBlock('essay_textarea');
332  $template->setVariable("TA_ESSAY", ilLegacyFormElementsUtil::prepareTextareaOutput($solution, true, true));
333  }
334  $template->parseCurrentBlock();
335  }
336 
337  if (!$show_correct_solution) {
338  $max_no_of_chars = $this->object->getMaxNumOfChars();
339 
340  if ($max_no_of_chars == 0) {
341  $max_no_of_chars = ucfirst($this->lng->txt('unlimited'));
342  }
343 
344  $act_no_of_chars = $this->object->countLetters($solution);
345  $template->setVariable("CHARACTER_INFO", '<b>' . $max_no_of_chars . '</b>' .
346  $this->lng->txt('answer_characters') . ' <b>' . $act_no_of_chars . '</b>');
347 
348  if ($this->object->isWordCounterEnabled()) {
349  $template->setCurrentBlock('word_count');
350  $template->setVariable(
351  'WORD_COUNT',
352  $this->lng->txt('qst_essay_written_words') .
353  ' <b>' . $this->object->countWords($solution) . '</b>'
354  );
355  $template->parseCurrentBlock();
356  }
357  }
358  if ($show_question_text == true) {
359  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
360  }
361  $questionoutput = $template->get();
362 
363  $feedback = '';
364  if ($show_feedback) {
365  if (!$this->isTestPresentationContext()) {
366  $fb = $this->getGenericFeedbackOutput((int) $active_id, $pass);
367  $feedback .= strlen($fb) ? $fb : '';
368  }
369  }
370  if (strlen($feedback)) {
371  $cssClass = (
372  $this->hasCorrectSolution($active_id, $pass) ?
374  );
375 
376  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
377  $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
378  }
379 
380  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
381 
382  $solutionoutput = $solutiontemplate->get();
383  if (!$show_question_only) {
384  // get page object output
385  $solutionoutput = $this->getILIASPage($solutionoutput);
386  }
387  return $solutionoutput;
388  }
hasCorrectSolution($activeId, $passIndex)
getUserAnswer($active_id, $pass)
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:

◆ getBestAnswer()

assTextQuestionGUI::getBestAnswer (   $asHtml)
private

Definition at line 390 of file class.assTextQuestionGUI.php.

References assQuestionGUI\$tpl, ilGlobalPageTemplate\get(), assTextQuestion\getScoringModesWithPointsByKeyword(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilGlobalPageTemplate\parseCurrentBlock(), ilGlobalPageTemplate\setCurrentBlock(), and ilGlobalPageTemplate\setVariable().

Referenced by getAutoSavedSolutionOutput(), and getSolutionOutput().

390  : string
391  {
392  $answers = $this->object->getAnswers();
393  if (!count($answers)) {
394  return '';
395  }
396 
397  if ($asHtml) {
398  $tplFile = 'tpl.il_as_qpl_text_question_best_solution_html.html';
399  } else {
400  $tplFile = 'tpl.il_as_qpl_text_question_best_solution_ta.html';
401  }
402 
403  $tpl = new ilTemplate($tplFile, true, true, 'Modules/TestQuestionPool');
404 
405  foreach ($answers as $answer) {
406  $keywordString = '';
407  if (in_array($this->object->getKeywordRelation(), assTextQuestion::getScoringModesWithPointsByKeyword())) {
408  $keywordString .= (string) $answer->getPoints() . ' ';
409  if ($answer->getPoints() === 1.0 || $answer->getPoints() === -1.0) {
410  $keywordString .= $this->lng->txt('point');
411  } else {
412  $keywordString .= $this->lng->txt('points');
413  }
414  $keywordString .= ' ' . $this->lng->txt('for') . ' ';
415  }
416  $keywordString .= $answer->getAnswertext();
417 
418  $tpl->setCurrentBlock('keyword');
419  $tpl->setVariable('KEYWORD', $keywordString);
421  }
422 
423  $tpl->setVariable('KEYWORD_HEADER', $this->lng->txt('solution_contain_keywords'));
424  $tpl->setVariable('SCORING_LABEL', $this->lng->txt('essay_scoring_mode') . ': ');
425 
426  switch ($this->object->getKeywordRelation()) {
427  case 'any':
428  $tpl->setVariable('SCORING_MODE', $this->lng->txt('essay_scoring_mode_keyword_relation_any'));
429  break;
430  case 'all':
431  $tpl->setVariable('SCORING_MODE', $this->lng->txt('essay_scoring_mode_keyword_relation_all'));
432  break;
433  case 'one':
434  $tpl->setVariable('SCORING_MODE', $this->lng->txt('essay_scoring_mode_keyword_relation_one'));
435  break;
436  }
437 
438  return $tpl->get();
439  }
static getScoringModesWithPointsByKeyword()
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
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
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:

◆ getJsCode()

assTextQuestionGUI::getJsCode ( )
protected

Definition at line 550 of file class.assTextQuestionGUI.php.

References assQuestionGUI\$tpl, ilGlobalPageTemplate\get(), ILIAS\Repository\object(), ilGlobalPageTemplate\parseCurrentBlock(), ilGlobalPageTemplate\setCurrentBlock(), ilGlobalPageTemplate\setVariable(), and ilGlobalPageTemplate\touchBlock().

Referenced by getPreview(), and getTestOutput().

550  : string
551  {
552  $tpl = new ilTemplate('tpl.charcounter.html', true, true, 'Modules/TestQuestionPool');
553 
554  $tpl->setCurrentBlock('tinymce_handler');
555  $tpl->touchBlock('tinymce_handler');
557 
558  if ($this->object->getMaxNumOfChars() > 0) {
559  $tpl->setCurrentBlock('letter_counter_js');
560  $tpl->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
562  }
563 
564  if ($this->object->isWordCounterEnabled()) {
565  $tpl->setCurrentBlock('word_counter_js');
566  $tpl->touchBlock('word_counter_js');
568  }
569 
570  $tpl->setCurrentBlock('counter_js');
571  $tpl->setVariable("QID", $this->object->getId());
573 
574  $this->tpl->addOnLoadCode('mcQuestionCharCounterInit();');
575  return $tpl->get();
576  }
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
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
touchBlock(string $blockname)
overwrites ITX::touchBlock.
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:

◆ getPreview()

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

Definition at line 451 of file class.assTextQuestionGUI.php.

References assQuestionGUI\getILIASPage(), getJsCode(), assQuestionGUI\getPreviewSession(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareFormOutput().

451  : string
452  {
453  $template = new ilTemplate("tpl.il_as_qpl_text_question_output.html", true, true, "Modules/TestQuestionPool");
454  if ($this->object->getMaxNumOfChars()) {
455  $template->setCurrentBlock("maximum_char_hint");
456  $template->setVariable("MAXIMUM_CHAR_HINT", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()));
457  $template->parseCurrentBlock();
458  #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
459  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
460  $template->parseCurrentBlock();
461  $template->setCurrentBlock("maxchars_counter");
462  $template->setVariable("QID", $this->object->getId());
463  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
464  $template->setVariable("TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
465  $template->setVariable("CHARACTERS", $this->lng->txt("qst_essay_chars_remaining"));
466  $template->parseCurrentBlock();
467  }
468 
469  if ($this->object->isWordCounterEnabled()) {
470  $template->setCurrentBlock("word_counter");
471  $template->setVariable("QID", $this->object->getId());
472  $template->setVariable("WORDCOUNTER", $this->lng->txt("qst_essay_allready_written_words"));
473  $template->parseCurrentBlock();
474  }
475 
476  if (is_object($this->getPreviewSession())) {
477  $template->setVariable(
478  "ESSAY",
480  (string) $this->getPreviewSession()->getParticipantsSolution()
481  )
482  );
483  }
484 
485  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
486  $template->setVariable("QID", $this->object->getId());
487 
488  $questionoutput = $template->get();
489 
490  $questionoutput .= $this->getJsCode();
491 
492  if (!$show_question_only) {
493  // get page object output
494  $questionoutput = $this->getILIASPage($questionoutput);
495  }
496  return $questionoutput;
497  }
static prepareFormOutput($a_str, bool $a_strip=false)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
+ Here is the call graph for this function:

◆ getSolutionOutput()

assTextQuestionGUI::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 149 of file class.assTextQuestionGUI.php.

References getBestAnswer(), getUserAnswer(), assQuestionGUI\renderPurposeSupportsFormHtml(), and renderSolutionOutput().

159  : string {
160  // get the solution of the user for the active pass or from the last pass if allowed
161  if (($active_id > 0) && (!$show_correct_solution)) {
162  $solution = $this->getUserAnswer($active_id, $pass);
163  } else {
164  $solution = $this->getBestAnswer($this->renderPurposeSupportsFormHtml());
165  }
166 
167  return $this->renderSolutionOutput(
168  $solution,
169  $active_id,
170  $pass,
171  $graphicalOutput,
172  $result_output,
173  $show_question_only,
174  $show_feedback,
175  $show_correct_solution,
176  $show_manual_scoring,
177  $show_question_text,
178  false,
179  false,
180  );
181  }
getUserAnswer($active_id, $pass)
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()

assTextQuestionGUI::getSpecificFeedbackOutput ( array  $userSolution)

Definition at line 600 of file class.assTextQuestionGUI.php.

600  : string
601  {
602  return '';
603  }

◆ getTestOutput()

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

Definition at line 499 of file class.assTextQuestionGUI.php.

References getJsCode(), ilYuiUtil\initDomEvent(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and assQuestionGUI\outQuestionPage().

499  : string
500  {
501  // get the solution of the user for the active pass or from the last pass if allowed
502  $user_solution = "";
503  if ($active_id) {
504  $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
505  foreach ($solutions as $idx => $solution_value) {
506  $user_solution = $solution_value['value1'];
507  }
508 
509  if ($this->tiny_mce_enabled) {
510  $user_solution = htmlentities($user_solution);
511  }
512 
513  $user_solution = str_replace(['{', '}', '\\'], ['&#123;', '&#125;', '&#92;'], $user_solution);
514  }
515 
516  $template = new ilTemplate("tpl.il_as_qpl_text_question_output.html", true, true, "Modules/TestQuestionPool");
517  if ($this->object->getMaxNumOfChars()) {
518  $template->setCurrentBlock("maximum_char_hint");
519  $template->setVariable("MAXIMUM_CHAR_HINT", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()));
520  $template->parseCurrentBlock();
521  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
522  $template->parseCurrentBlock();
523  $template->setCurrentBlock("maxchars_counter");
524  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
525  $template->setVariable("QID", $this->object->getId());
526  $template->setVariable("TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
527  $template->setVariable("CHARACTERS", $this->lng->txt("qst_essay_chars_remaining"));
528  $template->parseCurrentBlock();
529  }
530 
531  if ($this->object->isWordCounterEnabled()) {
532  $template->setCurrentBlock("word_counter");
533  $template->setVariable("QID", $this->object->getId());
534  $template->setVariable("WORDCOUNTER", $this->lng->txt("qst_essay_allready_written_words"));
535  $template->parseCurrentBlock();
536  }
537 
538  $template->setVariable("QID", $this->object->getId());
539  $template->setVariable("ESSAY", $user_solution);
540  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
541  $questionoutput = $template->get();
542 
543  $questionoutput .= $this->getJsCode();
544 
545  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
547  return $pageoutput;
548  }
static initDomEvent(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI DomEvent used in Services/Calendar, Modules/Session, Modules/Test (Jan 2022) ...
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
+ Here is the call graph for this function:

◆ getUserAnswer()

assTextQuestionGUI::getUserAnswer (   $active_id,
  $pass 
)
private

Definition at line 441 of file class.assTextQuestionGUI.php.

Referenced by getAutoSavedSolutionOutput(), and getSolutionOutput().

442  {
443  $user_solution = "";
444  $solutions = $this->object->getSolutionValues($active_id, $pass);
445  foreach ($solutions as $idx => $solution_value) {
446  $user_solution = $solution_value['value1'];
447  }
448  return $user_solution;
449  }
+ Here is the caller graph for this function:

◆ isAnswerFreuqencyStatisticSupported()

assTextQuestionGUI::isAnswerFreuqencyStatisticSupported ( )

Definition at line 815 of file class.assTextQuestionGUI.php.

815  : bool
816  {
817  return false;
818  }

◆ magicAfterTestOutput()

assTextQuestionGUI::magicAfterTestOutput ( )

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

References ilRTE\_getRTEClassname(), and assQuestionGUI\outAdditionalOutput().

126  : void
127  {
128  // TODO - BEGIN: what exactly is done here? cant we use the parent method?
129  $rtestring = ilRTE::_getRTEClassname();
130  $rte = new $rtestring();
131  $rte->addUserTextEditor("textinput");
132  $this->outAdditionalOutput();
133 
134  // TODO - END: what exactly is done here? cant we use the parent method?
135  }
static _getRTEClassname()
outAdditionalOutput()
Why are you here? Some magic for plugins?
+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assTextQuestionGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

Definition at line 673 of file class.assTextQuestionGUI.php.

References ilPropertyFormGUI\addItem(), ilSubEnabledFormPropertyGUI\addSubItem(), ilRadioOption\addSubItem(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilFormPropertyGUI\setRequired(), and ilRadioOption\setValue().

Referenced by editQuestion(), and populateCorrectionsFormProperties().

674  {
675  $scoringMode = new ilRadioGroupInputGUI(
676  $this->lng->txt('essay_scoring_mode'),
677  'scoring_mode'
678  );
679 
680  $scoringOptionNone = new ilRadioOption(
681  $this->lng->txt('essay_scoring_mode_without_keywords'),
682  'non',
683  $this->lng->txt(
684  'essay_scoring_mode_without_keywords_desc'
685  )
686  );
687  $scoringOptionAnyKeyword = new ilRadioOption(
688  $this->lng->txt('essay_scoring_mode_keyword_relation_any'),
689  'any',
690  $this->lng->txt(
691  'essay_scoring_mode_keyword_relation_any_desc'
692  )
693  );
694  $scoringOptionAllKeyword = new ilRadioOption(
695  $this->lng->txt('essay_scoring_mode_keyword_relation_all'),
696  'all',
697  $this->lng->txt(
698  'essay_scoring_mode_keyword_relation_all_desc'
699  )
700  );
701  $scoringOptionOneKeyword = new ilRadioOption(
702  $this->lng->txt('essay_scoring_mode_keyword_relation_one'),
703  'one',
704  $this->lng->txt(
705  'essay_scoring_mode_keyword_relation_one_desc'
706  )
707  );
708 
709  $scoringMode->addOption($scoringOptionNone);
710  $scoringMode->addOption($scoringOptionAnyKeyword);
711  $scoringMode->addOption($scoringOptionAllKeyword);
712  $scoringMode->addOption($scoringOptionOneKeyword);
713  $scoringMode->setRequired(true);
714  $scoringMode->setValue($this->object->getKeywordRelation());
715 
716  if ($this->object->getAnswerCount() == 0) {
717  $this->object->addAnswer("", 1, 0, 0);
718  }
719 
720  // Without Keywords
721  $nonKeywordPoints = new ilNumberInputGUI($this->lng->txt("points"), "non_keyword_points");
722  $nonKeywordPoints->allowDecimals(true);
723  $nonKeywordPoints->setValue($this->object->getPoints());
724  $nonKeywordPoints->setRequired(true);
725  $nonKeywordPoints->setSize(3);
726  $nonKeywordPoints->setMinValue(0.0);
727  $nonKeywordPoints->setMinvalueShouldBeGreater(true);
728  $scoringOptionNone->addSubItem($nonKeywordPoints);
729 
730  // Any Keyword
731  $anyKeyword = new ilEssayKeywordWizardInputGUI($this->lng->txt("answers"), "any_keyword");
732  $anyKeyword->setRequired(true);
733  $anyKeyword->setQuestionObject($this->object);
734  $anyKeyword->setSingleline(true);
735  $anyKeyword->setValues($this->object->getAnswers());
736  $scoringOptionAnyKeyword->addSubItem($anyKeyword);
737 
738  // All Keywords
739  $allKeyword = new ilTextWizardInputGUI($this->lng->txt("answers"), "all_keyword");
740  $allKeyword->setRequired(true);
741  //$allKeyword->setQuestionObject($this->object);
742  //$allKeyword->setSingleline(TRUE);
743  $allKeyword->setValues(self::buildAnswerTextOnlyArray($this->object->getAnswers()));
744  $allKeyword->setMaxLength($anyKeyword->getMaxLength());
745  $scoringOptionAllKeyword->addSubItem($allKeyword);
746  $allKeywordPoints = new ilNumberInputGUI($this->lng->txt("points"), "all_keyword_points");
747  $allKeywordPoints->allowDecimals(true);
748  $allKeywordPoints->setValue($this->object->getPoints());
749  $allKeywordPoints->setRequired(true);
750  $allKeywordPoints->setSize(3);
751  $allKeywordPoints->setMinValue(0.0);
752  $allKeywordPoints->setMinvalueShouldBeGreater(true);
753  $scoringOptionAllKeyword->addSubItem($allKeywordPoints);
754 
755  // One Keywords
756  $oneKeyword = new ilTextWizardInputGUI($this->lng->txt("answers"), "one_keyword");
757  $oneKeyword->setRequired(true);
758  //$oneKeyword->setQuestionObject($this->object);
759  //$oneKeyword->setSingleline(TRUE);
760  $oneKeyword->setValues(self::buildAnswerTextOnlyArray($this->object->getAnswers()));
761  $oneKeyword->setMaxLength($anyKeyword->getMaxLength());
762  $scoringOptionOneKeyword->addSubItem($oneKeyword);
763  $oneKeywordPoints = new ilNumberInputGUI($this->lng->txt("points"), "one_keyword_points");
764  $oneKeywordPoints->allowDecimals(true);
765  $oneKeywordPoints->setValue($this->object->getPoints());
766  $oneKeywordPoints->setRequired(true);
767  $oneKeywordPoints->setSize(3);
768  $oneKeywordPoints->setMinValue(0.0);
769  $oneKeywordPoints->setMinvalueShouldBeGreater(true);
770  $scoringOptionOneKeyword->addSubItem($oneKeywordPoints);
771 
772  $form->addItem($scoringMode);
773  return $form;
774  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property in a property form.
setValue(string $a_value)
setRequired(bool $a_required)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text wizard property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateCorrectionsFormProperties()

assTextQuestionGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Definition at line 825 of file class.assTextQuestionGUI.php.

References populateAnswerSpecificFormPart(), populateQuestionSpecificFormPart(), and ilPropertyFormGUI\removeItemByPostVar().

825  : void
826  {
827  $this->populateQuestionSpecificFormPart($form);
828  $this->populateAnswerSpecificFormPart($form);
829 
830  $form->removeItemByPostVar('maxchars');
831  }
removeItemByPostVar(string $a_post_var, bool $a_remove_unused_headers=false)
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assTextQuestionGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

Definition at line 637 of file class.assTextQuestionGUI.php.

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

Referenced by editQuestion(), and populateCorrectionsFormProperties().

638  {
639  // wordcounter
640  $wordcounter = new ilCheckboxInputGUI($this->lng->txt('qst_essay_wordcounter_enabled'), 'wordcounter');
641  $wordcounter->setInfo($this->lng->txt('qst_essay_wordcounter_enabled_info'));
642  $wordcounter->setChecked($this->object->isWordCounterEnabled());
643  $form->addItem($wordcounter);
644 
645  // maxchars
646  $maxchars = new ilNumberInputGUI($this->lng->txt("maxchars"), "maxchars");
647  $maxchars->setSize(5);
648  $maxchars->setMinValue(1);
649  if ($this->object->getMaxNumOfChars() > 0) {
650  $maxchars->setValue($this->object->getMaxNumOfChars());
651  }
652  $maxchars->setInfo($this->lng->txt("description_maxchars"));
653  $form->addItem($maxchars);
654 
655  // text rating
656  $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "text_rating");
657  $text_options = [
658  "ci" => $this->lng->txt("cloze_textgap_case_insensitive"),
659  "cs" => $this->lng->txt("cloze_textgap_case_sensitive"),
660  "l1" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1"),
661  "l2" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2"),
662  "l3" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3"),
663  "l4" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4"),
664  "l5" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5")
665  ];
666  $textrating->setOptions($text_options);
667  $textrating->setValue($this->object->getTextRating());
668  $form->addItem($textrating);
669 
670  return $form;
671  }
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:

◆ renderSolutionOutput()

assTextQuestionGUI::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 183 of file class.assTextQuestionGUI.php.

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

Referenced by getSolutionOutput().

196  : ?string {
197 
198  $solution = $user_solutions;
199  $template = new ilTemplate("tpl.il_as_qpl_text_question_output_solution.html", true, true, "Modules/TestQuestionPool");
200  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
201 
202  $solution = $this->object->getHtmlUserSolutionPurifier()->purify($solution);
203  if ($this->renderPurposeSupportsFormHtml()) {
204  $template->setCurrentBlock('essay_div');
205  $template->setVariable("DIV_ESSAY", ilLegacyFormElementsUtil::prepareTextareaOutput($solution, true));
206  } else {
207  $template->setCurrentBlock('essay_textarea');
208  $template->setVariable("TA_ESSAY", ilLegacyFormElementsUtil::prepareTextareaOutput($solution, true, true));
209  }
210  $template->parseCurrentBlock();
211 
212  if (!$show_correct_solution) {
213  $max_no_of_chars = $this->object->getMaxNumOfChars();
214 
215  if ($max_no_of_chars == 0) {
216  $max_no_of_chars = ucfirst($this->lng->txt('unlimited'));
217  }
218 
219  $act_no_of_chars = $this->object->countLetters($solution);
220  $template->setVariable("CHARACTER_INFO", '<b>' . $max_no_of_chars . '</b>' .
221  $this->lng->txt('answer_characters') . ' <b>' . $act_no_of_chars . '</b>');
222 
223  if ($this->object->isWordCounterEnabled()) {
224  $template->setCurrentBlock('word_count');
225  $template->setVariable(
226  'WORD_COUNT',
227  $this->lng->txt('qst_essay_written_words') .
228  ' <b>' . $this->object->countWords($solution) . '</b>'
229  );
230  $template->parseCurrentBlock();
231  }
232  }
233  if (($active_id > 0) && (!$show_correct_solution)) {
234  if ($graphical_output) {
235  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
236  $reached_points = $this->object->getReachedPoints($active_id, $pass);
237  if ($reached_points == $this->object->getMaximumPoints()) {
238  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
239  } elseif ($reached_points > 0) {
240  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_MOSTLY_OK);
241  }
242  $template->setCurrentBlock("icon_ok");
243  $template->setVariable("ICON_OK", $correctness_icon);
244  $template->parseCurrentBlock();
245  }
246  }
247  if ($show_question_text == true) {
248  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
249  }
250  $questionoutput = $template->get();
251 
252  $feedback = '';
253  if ($show_feedback) {
254  if (!$this->isTestPresentationContext()) {
255  $fb = $this->getGenericFeedbackOutput((int) $active_id, $pass);
256  $feedback .= strlen($fb) ? $fb : '';
257  }
258  }
259  if (strlen($feedback)) {
260  $cssClass = (
261  $this->hasCorrectSolution($active_id, $pass) ?
263  );
264 
265  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
266  $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
267  }
268 
269  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
270 
271  $solutionoutput = $solutiontemplate->get();
272  if (!$show_question_only) {
273  // get page object output
274  $solutionoutput = $this->getILIASPage($solutionoutput);
275  }
276  return $solutionoutput;
277  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
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()

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

Definition at line 836 of file class.assTextQuestionGUI.php.

References writeAnswerSpecificPostData(), and writeQuestionSpecificPostData().

836  : void
837  {
838  $this->writeQuestionSpecificPostData($form);
839  $this->writeAnswerSpecificPostData($form);
840  }
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assTextQuestionGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiAnswerScoringAdjustable.

Definition at line 613 of file class.assTextQuestionGUI.php.

References ILIAS\Repository\object().

Referenced by saveCorrectionsFormProperties(), and writePostData().

613  : void
614  {
615  $points = 0;
616  switch ($this->object->getKeywordRelation()) {
617  case 'non':
618  $this->object->setAnswers([]);
619  $points = str_replace(',', '.', $_POST['non_keyword_points'] ?? '');
620  break;
621  case 'any':
622  $this->object->setAnswers($_POST['any_keyword']);
623  $points = $this->object->getMaximumPoints();
624  break;
625  case 'all':
626  $this->object->setAnswers($_POST['all_keyword']);
627  $points = str_replace(',', '.', $_POST['all_keyword_points'] ?? '');
628  break;
629  case 'one':
630  $this->object->setAnswers($_POST['one_keyword']);
631  $points = (float) str_replace(',', '.', $_POST['one_keyword_points'] ?? '');
632  break;
633  }
634  $this->object->setPoints((float) $points);
635  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

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

{}

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

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

Referenced by addSuggestedSolution().

57  : int
58  {
59  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
60  if (!$hasErrors) {
64  $this->saveTaxonomyAssignments();
65  return 0;
66  }
67  return 1;
68  }
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
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.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeQuestionSpecificPostData()

assTextQuestionGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

Definition at line 605 of file class.assTextQuestionGUI.php.

Referenced by saveCorrectionsFormProperties(), and writePostData().

605  : void
606  {
607  $this->object->setWordCounterEnabled(isset($_POST['wordcounter']) && $_POST['wordcounter']);
608  $this->object->setMaxNumOfChars((int) ($_POST["maxchars"] ?? 0));
609  $this->object->setTextRating($_POST["text_rating"]);
610  $this->object->setKeywordRelation($_POST['scoring_mode']);
611  }
+ Here is the caller graph for this function:

Field Documentation

◆ $tiny_mce_enabled

bool assTextQuestionGUI::$tiny_mce_enabled
protected

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


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