ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 magicAfterTestOutput ()
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getAutoSavedSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 addSuggestedSolution ()
 
 getSpecificFeedbackOutput (array $userSolution)
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from the request and applies them to the data object. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from the request and applies them to the data object. More...
 
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 
 populateAnswerSpecificFormPart (\ilPropertyFormGUI $form)
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 isAnswerFreuqencyStatisticSupported ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from assQuestionGUI
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getObject ()
 
 setObject (assQuestion $question)
 
 setCopyToExistingPoolOnSave (?int $pool_ref_id)
 
 getCopyToExistingPoolOnSave ()
 
 setCopyToNewPoolOnSave (?string $pool_title)
 
 getCopyToNewPoolOnSave ()
 
 setMoveAfterQuestionId (?int $question_id)
 
 getMoveAfterQuestionId ()
 
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getCommentsPanelHTML ()
 
 executeCommand ()
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext (string $presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled (bool $previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose (string $renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext (string $editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI (?ilTestQuestionNavigationGUI $navigationGUI)
 
 setTaxonomyIds (array $taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass (string $targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder (\ilQuestionHeaderBlockBuilder $questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd (string $questionActionCmd)
 
 getQuestionActionCmd ()
 
 assessment ()
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 
 getILIASPage (string $html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
 syncQuestion ()
 
 saveReturn ()
 
 saveQuestion ()
 
 setAdditionalContentEditingModeFromPost ()
 
 getContextPath ($cont_obj, int $a_endnode_id, int $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber (int $nr)
 
 getSequenceNumber ()
 
 setQuestionCount (int $a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage (string $errormessage)
 
 addErrorMessage (string $errormessage)
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 outQuestionType ()
 
 saveSuggestedSolution ()
 
 cancelSuggestedSolution ()
 
 suggestedsolution (bool $save=false)
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $classname)
 
 getEditQuestionTabCommands ()
 
 isAutosaveable ()
 
 outQuestionForTest (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 getPreviewSession ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 
 cmdNeedsExistingQuestion (string $cmd)
 
 setContextAllowsSyncToPool (bool $sync_allowed)
 
 needsSyncQuery ()
 
 getQuestionSyncModal (string $cmd, string $cmd_class='')
 
 getAutoSavedSolutionOutput (int $active_id, int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false)
 
 buildFileDownloadLink ()
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
- 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 ()
 
 setTestSpecificProperties ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (int $active_id, ?int $pass)
 
 getTypeOptions ()
 
 createSuggestedSolutionLinkingTo (string $type, string $target)
 
 setDefaultTabs (ilTabsGUI $tabs_gui)
 
 setQuestionSpecificTabs (ilTabsGUI $tabs_gui)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabs_gui)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction (string $form_action, int $active_id, int $pass)
 
 addBackTab (ilTabsGUI $tabs_gui)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 renderLatex ($content)
 Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in the browser. More...
 
 getSuggestedSolutionsRepo ()
 
 cleanupAnswerText (array $answer_text, bool $is_rte)
 sk - 12.05.2023: This is one more of those that we need, but don't want. More...
 
 addSaveOnEnterOnLoadCode ()
 

Protected Attributes

bool $tiny_mce_enabled
 
- Protected Attributes inherited from assQuestionGUI
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
const SUGGESTED_SOLUTION_COMMANDS_CANCEL = 'cancelSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_SAVE = 'saveSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_DEFAULT = 'suggestedsolution'
 
const QUESTION_SAVE_CMDS
 
const ADDITIONAL_CMDS_NEEDING_EXISTING_QST
 There are functions that need an existing question. More...
 
ilLogger $logger
 
GeneralQuestionPropertiesRepository $questionrepository
 
GUIService $notes_gui
 
ilCtrl $ctrl
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
Refinery $refinery
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $question_count
 question count in test More...
 
ilPropertyFormGUI $editForm = null
 
readonly ilTestLegacyFormsHelper $forms_helper
 
readonly RequestDataCollector $request_data_collector
 
bool $parent_type_is_lm = false
 
SuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

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 getCommandsFromClassConstants (string $guiClassName, string $cmdConstantNameBegin='CMD_')
 
static prepareTextareaOutput (?string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output where latex code may be in it If the text is HTML-free, CHR(13) will be converted to a line break. More...
 
- Data Fields inherited from assQuestionGUI
const ALLOWED_PLAIN_TEXT_TAGS = "<em>, <strong>"
 sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI. More...
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const CORRECTNESS_NOT_OK = 0
 
const CORRECTNESS_MOSTLY_OK = 1
 
const CORRECTNESS_OK = 2
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const CMD_SYNC_QUESTION_AND_RETURN = 'syncQuestionReturn'
 

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\GlobalScreen\Provider\__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  }
Class for text questions.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addSuggestedSolution()

assTextQuestionGUI::addSuggestedSolution ( )

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

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

555  : void
556  {
558  ilSession::set('subquestion_index', 0);
559  $cmd = $this->request_data_collector->rawArray('cmd');
560 
561  if ($cmd['addSuggestedSolution'] && $this->writePostData()) {
562  $this->tpl->setOnScreenMessage('info', $this->getErrorMessage());
563  $this->editQuestion();
564  return;
565  }
566  $this->object->saveToDb();
567  $this->ctrl->setParameter($this, 'q_id', $this->object->getId());
568  $this->tpl->setVariable('HEADER', $this->object->getTitleForHTMLOutput());
569  $this->getQuestionTemplate();
570  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
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 111 of file class.assTextQuestionGUI.php.

111  : array
112  {
113  $answerTexts = [];
114 
115  foreach ($answers as $answer) {
116  $answerTexts[] = $answer->getAnswertext();
117  }
118 
119  return $answerTexts;
120  }

◆ editQuestion()

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

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

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

Referenced by addSuggestedSolution(), and writePostData().

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

◆ getAfterParticipationSuppressionAnswerPostVars()

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

757  : array
758  {
759  return [];
760  }

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

771  : array
772  {
773  return [];
774  }

◆ getAnswersFrequency()

assTextQuestionGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

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

781  : array
782  {
783  return [];
784  }

◆ getAutoSavedSolutionOutput()

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

Definition at line 265 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(), null, ILIAS\Repository\object(), ilLegacyFormElementsUtil\prepareTextareaOutput(), and assQuestionGUI\renderPurposeSupportsFormHtml().

277  : string {
278  $user_solution = $this->getUserAnswer($active_id, $pass);
279 
280  if (($active_id > 0) && (!$show_correct_solution)) {
281  $solution = $user_solution;
282  } else {
283  $solution = $this->getBestAnswer($this->renderPurposeSupportsFormHtml());
284  }
285 
286  $template = new ilTemplate("tpl.il_as_qpl_text_question_output_solution.html", true, true, "components/ILIAS/TestQuestionPool");
287  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "components/ILIAS/TestQuestionPool");
288 
289  $solution = '';
290  $autosaved_solution = $this->object->getLatestAutosaveContent($active_id, $pass);
291  if ($autosaved_solution !== null) {
292  if ($show_autosave_title) {
293  $template->setCurrentBlock('autosave_title');
294  $template->setVariable('AUTOSAVE_TITLE', $this->lng->txt('autosavecontent'));
295  $template->parseCurrentBlock();
296  }
297  $solution = $this->object->getHtmlUserSolutionPurifier()->purify($autosaved_solution);
298  if ($this->renderPurposeSupportsFormHtml()) {
299  $template->setCurrentBlock('essay_div');
300  $template->setVariable("DIV_ESSAY", ilLegacyFormElementsUtil::prepareTextareaOutput($solution, true));
301  } else {
302  $template->setCurrentBlock('essay_textarea');
303  $template->setVariable("TA_ESSAY", ilLegacyFormElementsUtil::prepareTextareaOutput($solution, true, true));
304  }
305  $template->parseCurrentBlock();
306  }
307 
308  if (!$show_correct_solution) {
309  $max_no_of_chars = $this->object->getMaxNumOfChars();
310 
311  if ($max_no_of_chars == 0) {
312  $max_no_of_chars = ucfirst($this->lng->txt('unlimited'));
313  }
314 
315  $act_no_of_chars = $this->object->countLetters($solution);
316  $template->setVariable("CHARACTER_INFO", '<b>' . $max_no_of_chars . '</b>' .
317  $this->lng->txt('answer_characters') . ' <b>' . $act_no_of_chars . '</b>');
318 
319  if ($this->object->isWordCounterEnabled()) {
320  $template->setCurrentBlock('word_count');
321  $template->setVariable(
322  'WORD_COUNT',
323  $this->lng->txt('qst_essay_written_words') .
324  ' <b>' . $this->object->countWords($solution) . '</b>'
325  );
326  $template->parseCurrentBlock();
327  }
328  }
329  if ($show_question_text == true) {
330  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
331  }
332  $questionoutput = $template->get();
333 
334  $feedback = '';
335  if ($show_feedback) {
336  if (!$this->isTestPresentationContext()) {
337  $fb = $this->getGenericFeedbackOutput((int) $active_id, $pass);
338  $feedback .= strlen($fb) ? $fb : '';
339  }
340  }
341  if (strlen($feedback)) {
342  $cssClass = (
343  $this->hasCorrectSolution($active_id, $pass) ?
345  );
346 
347  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
348  $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
349  }
350 
351  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
352 
353  $solutionoutput = $solutiontemplate->get();
354  if (!$show_question_only) {
355  // get page object output
356  $solutionoutput = $this->getILIASPage($solutionoutput);
357  }
358  return $solutionoutput;
359  }
hasCorrectSolution($activeId, $passIndex)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 361 of file class.assTextQuestionGUI.php.

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

Referenced by getAutoSavedSolutionOutput(), and getSolutionOutput().

361  : string
362  {
363  $answers = $this->object->getAnswers();
364  if (!count($answers)) {
365  return '';
366  }
367 
368  if ($asHtml) {
369  $tplFile = 'tpl.il_as_qpl_text_question_best_solution_html.html';
370  } else {
371  $tplFile = 'tpl.il_as_qpl_text_question_best_solution_ta.html';
372  }
373 
374  $tpl = new ilTemplate($tplFile, true, true, 'components/ILIAS/TestQuestionPool');
375 
376  foreach ($answers as $answer) {
377  $keywordString = '';
378  if (in_array($this->object->getKeywordRelation(), assTextQuestion::getScoringModesWithPointsByKeyword())) {
379  $keywordString .= (string) $answer->getPoints() . ' ';
380  if ($answer->getPoints() === 1.0 || $answer->getPoints() === -1.0) {
381  $keywordString .= $this->lng->txt('point');
382  } else {
383  $keywordString .= $this->lng->txt('points');
384  }
385  $keywordString .= ' ' . $this->lng->txt('for') . ' ';
386  }
387  $keywordString .= $answer->getAnswertext();
388 
389  $tpl->setCurrentBlock('keyword');
390  $tpl->setVariable('KEYWORD', $this->renderLatex($keywordString));
392  }
393 
394  $tpl->setVariable('KEYWORD_HEADER', $this->lng->txt('solution_contain_keywords'));
395  $tpl->setVariable('SCORING_LABEL', $this->lng->txt('essay_scoring_mode') . ': ');
396 
397  switch ($this->object->getKeywordRelation()) {
399  $tpl->setVariable('SCORING_MODE', $this->lng->txt('essay_scoring_mode_keyword_relation_any'));
400  break;
402  $tpl->setVariable('SCORING_MODE', $this->lng->txt('essay_scoring_mode_keyword_relation_all'));
403  break;
405  $tpl->setVariable('SCORING_MODE', $this->lng->txt('essay_scoring_mode_keyword_relation_one'));
406  break;
407  }
408 
409  return $tpl->get();
410  }
static getScoringModesWithPointsByKeyword()
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
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 527 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().

527  : string
528  {
529  $tpl = new ilTemplate('tpl.charcounter.html', true, true, 'components/ILIAS/TestQuestionPool');
530 
531  $tpl->setCurrentBlock('tinymce_handler');
532  $tpl->touchBlock('tinymce_handler');
534 
535  if ($this->object->getMaxNumOfChars() > 0) {
536  $tpl->setCurrentBlock('letter_counter_js');
537  $tpl->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
539  }
540 
541  if ($this->object->isWordCounterEnabled()) {
542  $tpl->setCurrentBlock('word_counter_js');
543  $tpl->touchBlock('word_counter_js');
545  }
546 
547  $tpl->setCurrentBlock('counter_js');
548  $tpl->setVariable("QID", $this->object->getId());
550 
551  $this->tpl->addOnLoadCode('mcQuestionCharCounterInit();');
552  return $tpl->get();
553  }
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 ( bool  $show_question_only = false,
bool  $show_inline_feedback = false 
)

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

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

425  : string {
426  $template = new ilTemplate("tpl.il_as_qpl_text_question_output.html", true, true, "components/ILIAS/TestQuestionPool");
427  if ($this->object->getMaxNumOfChars()) {
428  $template->setCurrentBlock("maximum_char_hint");
429  $template->setVariable("MAXIMUM_CHAR_HINT", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()));
430  $template->parseCurrentBlock();
431  #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
432  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
433  $template->parseCurrentBlock();
434  $template->setCurrentBlock("maxchars_counter");
435  $template->setVariable("QID", $this->object->getId());
436  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
437  $template->setVariable("TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
438  $template->setVariable("CHARACTERS", $this->lng->txt("qst_essay_chars_remaining"));
439  $template->parseCurrentBlock();
440  }
441 
442  if ($this->object->isWordCounterEnabled()) {
443  $template->setCurrentBlock("word_counter");
444  $template->setVariable("QID", $this->object->getId());
445  $template->setVariable("WORDCOUNTER", $this->lng->txt("qst_essay_allready_written_words"));
446  $template->parseCurrentBlock();
447  }
448 
449  if (is_object($this->getPreviewSession())) {
450  $template->setVariable(
451  "ESSAY",
453  (string) $this->getPreviewSession()->getParticipantsSolution()
454  )
455  );
456  }
457 
458  $template->setVariable("QUESTIONTEXT", $this->renderLatex($this->object->getQuestionForHTMLOutput()));
459  $template->setVariable("QID", $this->object->getId());
460 
461  $questionoutput = $template->get();
462 
463  $questionoutput .= $this->getJsCode();
464 
465  if (!$show_question_only) {
466  // get page object output
467  $questionoutput = $this->getILIASPage($questionoutput);
468  }
469  return $questionoutput;
470  }
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
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 ( int  $active_id,
?int  $pass = null,
bool  $graphical_output = false,
bool  $result_output = false,
bool  $show_question_only = true,
bool  $show_feedback = false,
bool  $show_correct_solution = false,
bool  $show_manual_scoring = false,
bool  $show_question_text = true,
bool  $show_inline_feedback = true 
)

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

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

143  : string {
144  if (($active_id > 0) && (!$show_correct_solution)) {
145  $solution = $this->getUserAnswer($active_id, $pass);
146  } else {
147  $solution = $this->getBestAnswer($this->renderPurposeSupportsFormHtml());
148  }
149 
150  return $this->renderSolutionOutput(
151  $solution,
152  $active_id,
153  $pass,
154  $graphical_output,
155  $result_output,
156  $show_question_only,
157  $show_feedback,
158  $show_correct_solution,
159  $show_manual_scoring,
160  $show_question_text,
161  false,
162  false,
163  );
164  }
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 572 of file class.assTextQuestionGUI.php.

572  : string
573  {
574  return '';
575  }

◆ getTestOutput()

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

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

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

478  : string {
479  // get the solution of the user for the active pass or from the last pass if allowed
480  $user_solution = "";
481  if ($active_id) {
482  $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
483  foreach ($solutions as $solution_value) {
484  $user_solution = $solution_value["value1"];
485  }
486 
487  if ($this->tiny_mce_enabled) {
488  $user_solution = htmlentities($user_solution);
489  }
490 
491  $user_solution = str_replace(['{', '}', '\\'], ['&#123;', '&#125;', '&#92;'], $user_solution);
492  }
493 
494  $template = new ilTemplate("tpl.il_as_qpl_text_question_output.html", true, true, "components/ILIAS/TestQuestionPool");
495  if ($this->object->getMaxNumOfChars()) {
496  $template->setCurrentBlock("maximum_char_hint");
497  $template->setVariable("MAXIMUM_CHAR_HINT", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()));
498  $template->parseCurrentBlock();
499  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
500  $template->parseCurrentBlock();
501  $template->setCurrentBlock("maxchars_counter");
502  $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars());
503  $template->setVariable("QID", $this->object->getId());
504  $template->setVariable("TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
505  $template->setVariable("CHARACTERS", $this->lng->txt("qst_essay_chars_remaining"));
506  $template->parseCurrentBlock();
507  }
508 
509  if ($this->object->isWordCounterEnabled()) {
510  $template->setCurrentBlock("word_counter");
511  $template->setVariable("QID", $this->object->getId());
512  $template->setVariable("WORDCOUNTER", $this->lng->txt("qst_essay_allready_written_words"));
513  $template->parseCurrentBlock();
514  }
515 
516  $template->setVariable("QID", $this->object->getId());
517  $template->setVariable("ESSAY", $user_solution);
518  $template->setVariable("QUESTIONTEXT", $this->renderLatex($this->object->getQuestionForHTMLOutput()));
519  $questionoutput = $template->get();
520 
521  $questionoutput .= $this->getJsCode();
522 
523  $pageoutput = $this->outQuestionPage("", $is_question_postponed, $active_id, $questionoutput);
524  return $pageoutput;
525  }
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
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 412 of file class.assTextQuestionGUI.php.

Referenced by getAutoSavedSolutionOutput(), and getSolutionOutput().

413  {
414  $user_solution = "";
415  $solutions = $this->object->getSolutionValues($active_id, $pass);
416  foreach ($solutions as $idx => $solution_value) {
417  $user_solution = $solution_value["value1"];
418  }
419  return $user_solution;
420  }
+ Here is the caller graph for this function:

◆ isAnswerFreuqencyStatisticSupported()

assTextQuestionGUI::isAnswerFreuqencyStatisticSupported ( )

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

776  : bool
777  {
778  return false;
779  }

◆ magicAfterTestOutput()

assTextQuestionGUI::magicAfterTestOutput ( )

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

References ilRTE\_getRTEClassname().

122  : void
123  {
124  // TODO - BEGIN: what exactly is done here? cant we use the parent method?
125  $rtestring = ilRTE::_getRTEClassname();
126  $rte = new $rtestring();
127  $rte->addUserTextEditor('textarea.textinput');
128 
129  // TODO - END: what exactly is done here? cant we use the parent method?
130  }
static _getRTEClassname()
+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assTextQuestionGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

References ilPropertyFormGUI\addItem(), ilSubEnabledFormPropertyGUI\addSubItem(), ilRadioOption\addSubItem(), ilNumberInputGUI\allowDecimals(), ILIAS\Repository\lng(), ILIAS\Repository\object(), assTextQuestion\SCORING_MODE_KEYWORD_RELATION_ALL, assTextQuestion\SCORING_MODE_KEYWORD_RELATION_ANY, assTextQuestion\SCORING_MODE_KEYWORD_RELATION_NONE, assTextQuestion\SCORING_MODE_KEYWORD_RELATION_ONE, ilFormPropertyGUI\setRequired(), and ilRadioOption\setValue().

Referenced by editQuestion(), and populateCorrectionsFormProperties().

646  {
647  $scoringMode = new ilRadioGroupInputGUI(
648  $this->lng->txt('essay_scoring_mode'),
649  'scoring_mode'
650  );
651 
652  $scoringOptionNone = new ilRadioOption(
653  $this->lng->txt('essay_scoring_mode_without_keywords'),
655  $this->lng->txt(
656  'essay_scoring_mode_without_keywords_desc'
657  )
658  );
659  $scoringOptionAnyKeyword = new ilRadioOption(
660  $this->lng->txt('essay_scoring_mode_keyword_relation_any'),
662  $this->lng->txt(
663  'essay_scoring_mode_keyword_relation_any_desc'
664  )
665  );
666  $scoringOptionAllKeyword = new ilRadioOption(
667  $this->lng->txt('essay_scoring_mode_keyword_relation_all'),
669  $this->lng->txt(
670  'essay_scoring_mode_keyword_relation_all_desc'
671  )
672  );
673  $scoringOptionOneKeyword = new ilRadioOption(
674  $this->lng->txt('essay_scoring_mode_keyword_relation_one'),
676  $this->lng->txt(
677  'essay_scoring_mode_keyword_relation_one_desc'
678  )
679  );
680 
681  $scoringMode->addOption($scoringOptionNone);
682  $scoringMode->addOption($scoringOptionAnyKeyword);
683  $scoringMode->addOption($scoringOptionAllKeyword);
684  $scoringMode->addOption($scoringOptionOneKeyword);
685  $scoringMode->setRequired(true);
686  $scoringMode->setValue($this->object->getKeywordRelation());
687 
688  if ($this->object->getAnswerCount() == 0) {
689  $this->object->addAnswer("", 1, 0, 0);
690  }
691 
692  // Without Keywords
693  $nonKeywordPoints = new ilNumberInputGUI($this->lng->txt("points"), "non_keyword_points");
694  $nonKeywordPoints->allowDecimals(true);
695  $nonKeywordPoints->setValue($this->object->getPoints());
696  $nonKeywordPoints->setRequired(true);
697  $nonKeywordPoints->setSize(3);
698  $nonKeywordPoints->setMinValue(0.0);
699  $nonKeywordPoints->setMinvalueShouldBeGreater(true);
700  $scoringOptionNone->addSubItem($nonKeywordPoints);
701 
702  // Any Keyword
703  $anyKeyword = new ilEssayKeywordWizardInputGUI($this->lng->txt("answers"), "any_keyword");
704  $anyKeyword->setRequired(true);
705  $anyKeyword->setQuestionObject($this->object);
706  $anyKeyword->setSingleline(true);
707  $anyKeyword->setValues($this->object->getAnswers());
708  $scoringOptionAnyKeyword->addSubItem($anyKeyword);
709 
710  // All Keywords
711  $allKeyword = new ilTextWizardInputGUI($this->lng->txt("answers"), "all_keyword");
712  $allKeyword->setRequired(true);
713  //$allKeyword->setQuestionObject($this->object);
714  //$allKeyword->setSingleline(TRUE);
715  $allKeyword->setValues(self::buildAnswerTextOnlyArray($this->object->getAnswers()));
716  $allKeyword->setMaxLength($anyKeyword->getMaxLength());
717  $scoringOptionAllKeyword->addSubItem($allKeyword);
718  $allKeywordPoints = new ilNumberInputGUI($this->lng->txt("points"), "all_keyword_points");
719  $allKeywordPoints->allowDecimals(true);
720  $allKeywordPoints->setValue($this->object->getPoints());
721  $allKeywordPoints->setRequired(true);
722  $allKeywordPoints->setSize(3);
723  $allKeywordPoints->setMinValue(0.0);
724  $allKeywordPoints->setMinvalueShouldBeGreater(true);
725  $scoringOptionAllKeyword->addSubItem($allKeywordPoints);
726 
727  // One Keywords
728  $oneKeyword = new ilTextWizardInputGUI($this->lng->txt("answers"), "one_keyword");
729  $oneKeyword->setRequired(true);
730  //$oneKeyword->setQuestionObject($this->object);
731  //$oneKeyword->setSingleline(TRUE);
732  $oneKeyword->setValues(self::buildAnswerTextOnlyArray($this->object->getAnswers()));
733  $oneKeyword->setMaxLength($anyKeyword->getMaxLength());
734  $scoringOptionOneKeyword->addSubItem($oneKeyword);
735  $oneKeywordPoints = new ilNumberInputGUI($this->lng->txt("points"), "one_keyword_points");
736  $oneKeywordPoints->allowDecimals(true);
737  $oneKeywordPoints->setValue($this->object->getPoints());
738  $oneKeywordPoints->setRequired(true);
739  $oneKeywordPoints->setSize(3);
740  $oneKeywordPoints->setMinValue(0.0);
741  $oneKeywordPoints->setMinvalueShouldBeGreater(true);
742  $scoringOptionOneKeyword->addSubItem($oneKeywordPoints);
743 
744  $form->addItem($scoringMode);
745  return $form;
746  }
This class represents an option in a radio group.
allowDecimals(bool $a_value)
This class represents a property in a property form.
This class represents a number 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.
const SCORING_MODE_KEYWORD_RELATION_NONE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateCorrectionsFormProperties()

assTextQuestionGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

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

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

786  : void
787  {
788  $this->populateQuestionSpecificFormPart($form);
789  $this->populateAnswerSpecificFormPart($form);
790 
791  $form->removeItemByPostVar('maxchars');
792  }
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 609 of file class.assTextQuestionGUI.php.

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

Referenced by editQuestion(), and populateCorrectionsFormProperties().

610  {
611  // wordcounter
612  $wordcounter = new ilCheckboxInputGUI($this->lng->txt('qst_essay_wordcounter_enabled'), 'wordcounter');
613  $wordcounter->setInfo($this->lng->txt('qst_essay_wordcounter_enabled_info'));
614  $wordcounter->setChecked($this->object->isWordCounterEnabled());
615  $form->addItem($wordcounter);
616 
617  // maxchars
618  $maxchars = new ilNumberInputGUI($this->lng->txt("maxchars"), "maxchars");
619  $maxchars->setSize(5);
620  $maxchars->setMinValue(1);
621  if ($this->object->getMaxNumOfChars() > 0) {
622  $maxchars->setValue($this->object->getMaxNumOfChars());
623  }
624  $maxchars->setInfo($this->lng->txt("description_maxchars"));
625  $form->addItem($maxchars);
626 
627  // text rating
628  $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "text_rating");
629  $text_options = [
630  "ci" => $this->lng->txt("cloze_textgap_case_insensitive"),
631  "cs" => $this->lng->txt("cloze_textgap_case_sensitive"),
632  "l1" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1"),
633  "l2" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2"),
634  "l3" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3"),
635  "l4" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4"),
636  "l5" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5")
637  ];
638  $textrating->setOptions($text_options);
639  $textrating->setValue($this->object->getTextRating());
640  $form->addItem($textrating);
641 
642  return $form;
643  }
This class represents a selection list property in a property form.
setOptions(array $a_options)
This class represents a number property in a property form.
+ 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 166 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(), assQuestionGUI\renderLatex(), and assQuestionGUI\renderPurposeSupportsFormHtml().

Referenced by getSolutionOutput().

179  : ?string {
180 
181  $template = new ilTemplate("tpl.il_as_qpl_text_question_output_solution.html", true, true, "components/ILIAS/TestQuestionPool");
182  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "components/ILIAS/TestQuestionPool");
183 
184  $solution = $this->object->getHtmlUserSolutionPurifier()->purify($user_solutions);
185  if ($this->renderPurposeSupportsFormHtml()) {
186  $template->setCurrentBlock('essay_div');
187  $template->setVariable("DIV_ESSAY", ilLegacyFormElementsUtil::prepareTextareaOutput($solution, true));
188  } else {
189  $template->setCurrentBlock('essay_textarea');
190  $template->setVariable("TA_ESSAY", ilLegacyFormElementsUtil::prepareTextareaOutput($solution, true, true));
191  }
192  $template->parseCurrentBlock();
193 
194  if (!$show_correct_solution) {
195  $max_no_of_chars = $this->object->getMaxNumOfChars();
196 
197  if ($max_no_of_chars == 0) {
198  $max_no_of_chars = ucfirst($this->lng->txt('unlimited'));
199  }
200 
201  $act_no_of_chars = $this->object->countLetters($solution);
202  $template->setVariable("CHARACTER_INFO", '<b>' . $max_no_of_chars . '</b>' .
203  $this->lng->txt('answer_characters') . ' <b>' . $act_no_of_chars . '</b>');
204 
205  if ($this->object->isWordCounterEnabled()) {
206  $template->setCurrentBlock('word_count');
207  $template->setVariable(
208  'WORD_COUNT',
209  $this->lng->txt('qst_essay_written_words') .
210  ' <b>' . $this->object->countWords($solution) . '</b>'
211  );
212  $template->parseCurrentBlock();
213  }
214  }
215  if (($active_id > 0) && (!$show_correct_solution)) {
216  if ($graphical_output) {
217  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
218  $reached_points = $this->object->getReachedPoints($active_id, $pass);
219  if ($reached_points == $this->object->getMaximumPoints()) {
220  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
221  } elseif ($reached_points > 0) {
222  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_MOSTLY_OK);
223  }
224  $template->setCurrentBlock("icon_ok");
225  $template->setVariable("ICON_OK", $correctness_icon);
226  $template->parseCurrentBlock();
227  }
228  }
229  if ($show_question_text == true) {
230  $template->setVariable("QUESTIONTEXT", $this->renderLatex(
231  $this->object->getQuestionForHTMLOutput()
232  ));
233  }
234  $questionoutput = $template->get();
235 
236  $feedback = '';
237  if ($show_feedback) {
238  if (!$this->isTestPresentationContext()) {
239  $fb = $this->getGenericFeedbackOutput((int) $active_id, $pass);
240  $feedback .= strlen($fb) ? $fb : '';
241  }
242  }
243  if (strlen($feedback)) {
244  $cssClass = (
245  $this->hasCorrectSolution($active_id, $pass) ?
247  );
248 
249  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
250  $solutiontemplate->setVariable("FEEDBACK", $this->renderLatex(
252  ));
253  }
254 
255  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
256 
257  $solutionoutput = $solutiontemplate->get();
258  if (!$show_question_only) {
259  // get page object output
260  $solutionoutput = $this->getILIASPage($solutionoutput);
261  }
262  return $solutionoutput;
263  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
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 797 of file class.assTextQuestionGUI.php.

References writeAnswerSpecificPostData(), and writeQuestionSpecificPostData().

797  : void
798  {
799  $this->writeQuestionSpecificPostData($form);
800  $this->writeAnswerSpecificPostData($form);
801  }
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from the request and applies them to the data object...
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object...
+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assTextQuestionGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiAnswerScoringAdjustable.

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

References ILIAS\Repository\object(), assTextQuestion\SCORING_MODE_KEYWORD_RELATION_ALL, assTextQuestion\SCORING_MODE_KEYWORD_RELATION_ANY, assTextQuestion\SCORING_MODE_KEYWORD_RELATION_NONE, and assTextQuestion\SCORING_MODE_KEYWORD_RELATION_ONE.

Referenced by saveCorrectionsFormProperties(), and writePostData().

585  : void
586  {
587  $points = 0;
588  switch ($this->object->getKeywordRelation()) {
590  $this->object->setAnswers([]);
591  $points = $this->request_data_collector->float('non_keyword_points');
592  break;
594  $this->object->setAnswers($this->request_data_collector->raw('any_keyword'));
595  $points = $this->object->getMaximumPoints();
596  break;
598  $this->object->setAnswers($this->request_data_collector->raw('all_keyword'));
599  $points = $this->request_data_collector->float('all_keyword_points');
600  break;
602  $this->object->setAnswers($this->request_data_collector->raw('one_keyword'));
603  $points = $this->request_data_collector->float('one_keyword_points');
604  break;
605  }
606  $this->object->setPoints((float) $points);
607  }
const SCORING_MODE_KEYWORD_RELATION_NONE
+ 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 the request and applies them to the data object...
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeQuestionSpecificPostData()

assTextQuestionGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

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

Referenced by saveCorrectionsFormProperties(), and writePostData().

577  : void
578  {
579  $this->object->setWordCounterEnabled($this->request_data_collector->bool('wordcounter') ?? false);
580  $this->object->setMaxNumOfChars($this->request_data_collector->int('maxchars'));
581  $this->object->setTextRating($this->request_data_collector->string('text_rating'));
582  $this->object->setKeywordRelation($this->request_data_collector->string('scoring_mode'));
583  }
+ 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: