ILIAS  trunk Revision v5.2.0beta1-34132-g2d4d73d4a0
assMultipleChoiceGUI 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 assMultipleChoiceGUI:
+ Collaboration diagram for assMultipleChoiceGUI:

Public Member Functions

 __construct ($id=-1)
 assMultipleChoiceGUI constructor More...
 
 hasInlineFeedback ()
 
 editQuestion ($checkonly=false)
 Creates an output of the edit form for the question. More...
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 uploadchoice ()
 Upload an image. More...
 
 removeimagechoice ()
 Remove an image. More...
 
 addchoice ()
 Add a new answer. More...
 
 removechoice ()
 Remove an answer. More...
 
 getSolutionOutput ( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true, $show_inline_feedback=true)
 Get the question solution output. More...
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 getTestOutput ( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
 
 isUseEmptySolutionInputChecked ()
 
 setUseEmptySolutionInputChecked ($useEmptySolutionInputChecked)
 
 getPresentationJavascripts ()
 
 getChoiceKeys ()
 Create the key index numbers for the array of choices. More...
 
 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, bool $is_singleline=false)
 
 populateAnswerSpecificFormPart (\ilPropertyFormGUI $form, bool $is_singleline=false)
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAggregatedAnswersView (array $relevant_answers)
 Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface. More...
 
 aggregateAnswers ($relevant_answers_chosen, $answers_defined_on_question)
 
 renderAggregateView ($aggregate)
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from assQuestionGUI
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 geCommentsPanelHTML ()
 
 executeCommand ()
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext (string $presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled (bool $previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose (string $renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext (string $editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI (?ilTestQuestionNavigationGUI $navigationGUI)
 
 setTaxonomyIds (array $taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder (\ilQuestionHeaderBlockBuilder $questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd (string $questionActionCmd)
 
 getQuestionActionCmd ()
 
 assessment ()
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 
 getILIASPage (string $html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
 cancel ()
 
 originalSyncForm (string $return_to="", string $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 
 save ()
 
 saveReturn ()
 
 apply ()
 
 getContextPath ($cont_obj, int $a_endnode_id, int $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber (int $nr)
 
 getSequenceNumber ()
 
 setQuestionCount (int $a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage (string $errormessage)
 
 addErrorMessage (string $errormessage)
 
 outAdditionalOutput ()
 Why are you here? Some magic for plugins? More...
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addNewIdListener ($a_object, string $a_method, string $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners (int $a_new_id)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 suggestedsolution ()
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $classname)
 
 getEditQuestionTabCommands ()
 
 getSolutionOutput ( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
 
 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)
 
- 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...
 
 getEditAnswersSingleLine ($checkonly=false)
 Get the single/multiline editing of answers. More...
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 buildEditForm (bool $is_singleline=true)
 
- 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)
 
 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...
 

Protected Attributes

 $useEmptySolutionInputChecked = false
 
- 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
 
ilPropertyFormGUI $editForm
 
ILIAS TestQuestionPool InternalRequestService $request
 
bool $parent_type_is_lm = false
 
assQuestionSuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

Private Member Functions

 populateSpecificFeedbackInline ($user_solution, $answer_id, $template)
 

Private Attributes

bool $rebuild_thumbnails = false
 

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 Multiple choice question GUI representation

The assMultipleChoiceGUI class encapsulates the GUI representation for multiple choice questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

\ assMultipleChoiceGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

assMultipleChoiceGUI::__construct (   $id = -1)

assMultipleChoiceGUI constructor

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

Parameters
integer$idThe database id of a multiple choice question object public

Definition at line 45 of file class.assMultipleChoiceGUI.php.

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

46  {
48  $this->object = new assMultipleChoice();
49  if ($id >= 0) {
50  $this->object->loadFromDb($id);
51  }
52  }
Class for multiple choice tests.
$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

◆ addBasicQuestionFormProperties()

assMultipleChoiceGUI::addBasicQuestionFormProperties ( ilPropertyFormGUI  $form)

Definition at line 145 of file class.assMultipleChoiceGUI.php.

References ilPropertyFormGUI\getItemByPostVar().

Referenced by buildEditForm().

145  : void
146  {
147  parent::addBasicQuestionFormProperties($form);
148  $form->getItemByPostVar('question')->setInitialRteWidth('100');
149  }
getItemByPostVar(string $a_post_var)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addchoice()

assMultipleChoiceGUI::addchoice ( )

Add a new answer.

Definition at line 174 of file class.assMultipleChoiceGUI.php.

References editQuestion(), and writePostData().

174  : void
175  {
176  $this->writePostData(true);
177  $position = key($_POST['cmd']['addchoice']);
178  $this->object->addAnswer("", 0, 0, $position + 1);
179  $this->editQuestion();
180  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ aggregateAnswers()

assMultipleChoiceGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)

Definition at line 881 of file class.assMultipleChoiceGUI.php.

Referenced by getAggregatedAnswersView(), and getAnswersFrequency().

881  : array
882  {
883  $aggregate = [];
884  foreach ($answers_defined_on_question as $answer) {
885  $aggregated_info_for_answer = [];
886  $aggregated_info_for_answer['answertext'] = $answer->getAnswerText();
887  $aggregated_info_for_answer['count_checked'] = 0;
888 
889  foreach ($relevant_answers_chosen as $relevant_answer) {
890  if ($relevant_answer['value1'] == $answer->getOrder()) {
891  $aggregated_info_for_answer['count_checked']++;
892  }
893  }
894  $aggregated_info_for_answer['count_unchecked'] =
895  ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
896  - $aggregated_info_for_answer['count_checked'];
897 
898  $aggregate[] = $aggregated_info_for_answer;
899  }
900  return $aggregate;
901  }
+ Here is the caller graph for this function:

◆ buildEditForm()

assMultipleChoiceGUI::buildEditForm ( bool  $is_singleline = true)
protected
Returns
ilPropertyFormGUI

Definition at line 974 of file class.assMultipleChoiceGUI.php.

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

975  {
976  $form = new ilPropertyFormGUI();
977  $form->setFormAction($this->ctrl->getFormAction($this));
978  $form->setTitle($this->outQuestionType());
979  $form->setTableWidth("100%");
980  $form->setId("assmultiplechoice");
981 
982  $this->addBasicQuestionFormProperties($form);
983  $this->populateQuestionSpecificFormPart($form, $is_singleline);
984  $this->populateAnswerSpecificFormPart($form, $is_singleline);
985  $this->populateTaxonomyFormSection($form);
986  $this->addQuestionFormCommandButtons($form);
987  return $form;
988  }
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form, bool $is_singleline=false)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form, bool $is_singleline=false)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
+ Here is the call graph for this function:

◆ editQuestion()

assMultipleChoiceGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

Parameters
bool$checkonly
Returns
bool

Definition at line 112 of file class.assMultipleChoiceGUI.php.

References assQuestionGUI\buildEditForm(), getEditAnswersSingleLine(), assQuestionGUI\getQuestionTemplate(), and assQuestionGUI\isSaveCommand().

Referenced by addchoice(), removechoice(), removeimagechoice(), uploadchoice(), and writePostData().

112  : bool
113  {
114  $save = $this->isSaveCommand();
115  $this->getQuestionTemplate();
116 
117  $is_singleline = $this->getEditAnswersSingleLine($checkonly);
118 
119  $form = $this->buildEditForm($is_singleline);
120 
121  if ($is_singleline) {
122  $form->setMultipart(true);
123  } else {
124  $form->setMultipart(false);
125  }
126 
127  $errors = false;
128 
129  if ($save) {
130  $form->getItemByPostVar('selection_limit')->setMaxValue(count((array) $_POST['choice']['answer']));
131 
132  $form->setValuesByPost();
133  $errors = !$form->checkInput();
134  if ($errors) {
135  $checkonly = false;
136  }
137  }
138 
139  if (!$checkonly) {
140  $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
141  }
142  return $errors;
143  }
getEditAnswersSingleLine($checkonly=false)
Get the single/multiline editing of answers.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAfterParticipationSuppressionAnswerPostVars()

assMultipleChoiceGUI::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 849 of file class.assMultipleChoiceGUI.php.

849  : array
850  {
851  return [];
852  }

◆ getAfterParticipationSuppressionQuestionPostVars()

assMultipleChoiceGUI::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 863 of file class.assMultipleChoiceGUI.php.

863  : array
864  {
865  return [];
866  }

◆ getAggregatedAnswersView()

assMultipleChoiceGUI::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 874 of file class.assMultipleChoiceGUI.php.

References aggregateAnswers(), ILIAS\Repository\object(), and renderAggregateView().

874  : string
875  {
876  return $this->renderAggregateView(
877  $this->aggregateAnswers($relevant_answers, $this->object->getAnswers())
878  )->get();
879  }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
+ Here is the call graph for this function:

◆ getAnswersFrequency()

assMultipleChoiceGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Definition at line 990 of file class.assMultipleChoiceGUI.php.

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

990  : array
991  {
992  $agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());
993 
994  $answers = [];
995 
996  foreach ($agg as $ans) {
997  $answers[] = [
998  'answer' => $ans['answertext'],
999  'frequency' => $ans['count_checked']
1000  ];
1001  }
1002 
1003  return $answers;
1004  }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
+ Here is the call graph for this function:

◆ getChoiceKeys()

assMultipleChoiceGUI::getChoiceKeys ( )

Create the key index numbers for the array of choices.

Returns
array

Definition at line 652 of file class.assMultipleChoiceGUI.php.

References ILIAS\Repository\object().

Referenced by getPreview(), getSolutionOutput(), and getTestOutput().

652  : array
653  {
654  $choice_keys = array_keys($this->object->answers);
655 
656  if ($this->object->getShuffle()) {
657  $choice_keys = $this->object->getShuffler()->transform($choice_keys);
658  }
659 
660  return $choice_keys;
661  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEditAnswersSingleLine()

assMultipleChoiceGUI::getEditAnswersSingleLine (   $checkonly = false)
protected

Get the single/multiline editing of answers.

  • The settings of an already saved question is preferred
  • A new question will use the setting of the last edited question by the user
    Parameters
    bool$checkonlyget the setting for checking a POST
    Returns
    bool

Definition at line 88 of file class.assMultipleChoiceGUI.php.

Referenced by editQuestion(), and writePostData().

88  : bool
89  {
90  if ($checkonly) {
91  $types = $_POST['types'] ?? '0';
92  return $types === '0' ? true : false;
93  }
94 
95  $lastChange = $this->object->getLastChange();
96  if (empty($lastChange) && !isset($_POST['types'])) {
97  // a new question is edited
98  return $this->object->getMultilineAnswerSetting() ? false : true;
99  } else {
100  // a saved question is edited
101  return $this->object->isSingleline();
102  }
103  }
+ Here is the caller graph for this function:

◆ getPresentationJavascripts()

assMultipleChoiceGUI::getPresentationJavascripts ( )

Definition at line 642 of file class.assMultipleChoiceGUI.php.

642  : array
643  {
644  return ['components/ILIAS/TestQuestionPool/js/ilAssMultipleChoice.js'];
645  }

◆ getPreview()

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

Definition at line 411 of file class.assMultipleChoiceGUI.php.

References assQuestionGUI\buildFocusAnchorHtml(), getChoiceKeys(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), assQuestionGUI\getPreviewSession(), hasInlineFeedback(), ILIAS\Repository\lng(), ILIAS\Repository\object(), populateSpecificFeedbackInline(), ilLegacyFormElementsUtil\prepareFormOutput(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

411  : string
412  {
413  $user_solution = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : [];
414  // shuffle output
415  $keys = $this->getChoiceKeys();
416 
417  $this->tpl->addOnLoadCode('ilAssMultipleChoiceCharCounterInit();');
418  $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output.html", true, true, "components/ILIAS/TestQuestionPool");
419  foreach ($keys as $answer_id) {
420  $answer = $this->object->answers[$answer_id];
421  if ($answer->hasImage()) {
422  if ($this->object->getThumbSize()) {
423  $template->setCurrentBlock("preview");
424  $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
425  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
426  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('media/enlarge.svg'));
427  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
428  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
429  $alt = $answer->getImage();
430  if (strlen($answer->getAnswertext())) {
431  $alt = $answer->getAnswertext();
432  }
433  $alt = preg_replace("/<[^>]*?>/", "", $alt);
434  $template->setVariable("ANSWER_IMAGE_ALT", ilLegacyFormElementsUtil::prepareFormOutput($alt));
435  $template->setVariable("ANSWER_IMAGE_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($alt));
436  $template->parseCurrentBlock();
437  } else {
438  $template->setCurrentBlock("answer_image");
439  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
440  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
441  $alt = $answer->getImage();
442  if (strlen($answer->getAnswertext())) {
443  $alt = $answer->getAnswertext();
444  }
445  $alt = preg_replace("/<[^>]*?>/", "", $alt);
446  $template->setVariable("ATTR", $attr);
447  $template->setVariable("ANSWER_IMAGE_ALT", ilLegacyFormElementsUtil::prepareFormOutput($alt));
448  $template->setVariable("ANSWER_IMAGE_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($alt));
449  $template->parseCurrentBlock();
450  }
451  }
452 
453  if ($showInlineFeedback) {
454  $this->populateSpecificFeedbackInline($user_solution, $answer_id, $template);
455  }
456 
457  $template->setCurrentBlock("answer_row");
458  $template->setVariable("QID", $this->object->getId());
459  $template->setVariable("ANSWER_ID", $answer_id);
460  $template->setVariable("ANSWER_TEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($answer->getAnswertext(), true));
461  foreach ($user_solution as $mc_solution) {
462  if (strcmp($mc_solution, $answer_id) == 0) {
463  $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
464  }
465  }
466  $template->parseCurrentBlock();
467  }
468  if ($this->object->getSelectionLimit()) {
469  $template->setVariable('SELECTION_LIMIT_HINT', sprintf(
470  $this->lng->txt('ass_mc_sel_lim_hint'),
471  $this->object->getSelectionLimit(),
472  $this->object->getAnswerCount()
473  ));
474 
475  $template->setVariable('SELECTION_LIMIT_VALUE', $this->object->getSelectionLimit());
476  } else {
477  $template->setVariable('SELECTION_LIMIT_VALUE', 'null');
478  }
479  $template->setVariable("QUESTION_ID", $this->object->getId());
480  $questiontext = $this->object->getQuestionForHTMLOutput();
481  if ($showInlineFeedback && $this->hasInlineFeedback()) {
482  $questiontext .= $this->buildFocusAnchorHtml();
483  }
484  $template->setVariable("QUESTIONTEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($questiontext, true));
485  $questionoutput = $template->get();
486  if (!$show_question_only) {
487  // get page object output
488  $questionoutput = $this->getILIASPage($questionoutput);
489  }
490  return $questionoutput;
491  }
getChoiceKeys()
Create the key index numbers for the array of choices.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, bool $a_strip=false)
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...
populateSpecificFeedbackInline($user_solution, $answer_id, $template)
+ Here is the call graph for this function:

◆ getSolutionOutput()

assMultipleChoiceGUI::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,
  $show_inline_feedback = 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
bool$show_question_text
Returns
string The solution output of the question as HTML code

Definition at line 206 of file class.assMultipleChoiceGUI.php.

References assQuestionGUI\buildFocusAnchorHtml(), ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, assQuestionGUI\generateCorrectnessIconsForCorrectness(), getChoiceKeys(), assQuestionGUI\getGenericFeedbackOutput(), ilUtil\getHtmlPath(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), assQuestionGUI\hasCorrectSolution(), hasInlineFeedback(), assQuestionGUI\isRenderPurposePrintPdf(), assQuestionGUI\isTestPresentationContext(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilLegacyFormElementsUtil\prepareFormOutput(), ilLegacyFormElementsUtil\prepareTextareaOutput(), and assQuestionGUI\renderPurposeSupportsFormHtml().

217  : string {
218  // shuffle output
219  $keys = $this->getChoiceKeys();
220 
221 
222  // get the solution of the user for the active pass or from the last pass if allowed
223  $user_solution = [];
224  if (($active_id > 0) && (!$show_correct_solution)) {
225  $solutions = $this->object->getSolutionValues($active_id, $pass);
226  foreach ($solutions as $idx => $solution_value) {
227  array_push($user_solution, $solution_value["value1"]);
228  }
229  } else {
230  // take the correct solution instead of the user solution
231  foreach ($this->object->answers as $index => $answer) {
232  $points_checked = $answer->getPointsChecked();
233  $points_unchecked = $answer->getPointsUnchecked();
234  if ($points_checked > $points_unchecked) {
235  if ($points_checked > 0) {
236  array_push($user_solution, $index);
237  }
238  }
239  }
240  }
241 
242  $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output_solution.html", true, true, "components/ILIAS/TestQuestionPool");
243  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "components/ILIAS/TestQuestionPool");
244  foreach ($keys as $answer_id) {
245  $answer = $this->object->answers[$answer_id];
246  if (($active_id > 0) && (!$show_correct_solution)) {
247  if ($graphicalOutput) {
248  // output of ok/not ok icons for user entered solutions
249  $ok = false;
250  $checked = false;
251  foreach ($user_solution as $mc_solution) {
252  if (strcmp($mc_solution, $answer_id) == 0) {
253  $checked = true;
254  }
255  }
256  if ($checked) {
257  if ($answer->getPointsChecked() > $answer->getPointsUnchecked()) {
258  $ok = self::CORRECTNESS_OK;
259  } else {
260  $ok = self::CORRECTNESS_NOT_OK;
261  }
262  } else {
263  if ($answer->getPointsChecked() > $answer->getPointsUnchecked()) {
264  $ok = self::CORRECTNESS_NOT_OK;
265  } else {
266  $ok = self::CORRECTNESS_OK;
267  }
268  }
269  $icon = $this->generateCorrectnessIconsForCorrectness($ok);
270  $template->setCurrentBlock("icon_ok");
271  $template->setVariable("ICON_OK", $icon);
272  $template->parseCurrentBlock();
273  }
274  }
275  if ($answer->hasImage()) {
276  $template->setCurrentBlock("answer_image");
277  if ($this->object->getThumbSize()) {
278  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
279  } else {
280  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
281  }
282  $alt = $answer->getImage();
283  if (strlen($answer->getAnswertext())) {
284  $alt = $answer->getAnswertext();
285  }
286  $alt = preg_replace("/<[^>]*?>/", "", $alt);
287  $template->setVariable("ANSWER_IMAGE_ALT", ilLegacyFormElementsUtil::prepareFormOutput($alt));
288  $template->setVariable("ANSWER_IMAGE_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($alt));
289  $template->parseCurrentBlock();
290  }
291 
292 
293  if (($show_feedback || !$this->isTestPresentationContext()) && $show_inline_feedback) {
294  if ($this->object->getSpecificFeedbackSetting() == 2) {
295  foreach ($user_solution as $mc_solution) {
296  if (strcmp($mc_solution, $answer_id) == 0) {
297  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
298  $this->object->getId(),
299  0,
300  $answer_id
301  );
302  if (strlen($fb)) {
303  $template->setCurrentBlock("feedback");
304  $template->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($fb, true));
305  $template->parseCurrentBlock();
306  }
307  }
308  }
309  }
310 
311  if ($this->object->getSpecificFeedbackSetting() == 1) {
312  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
313  $this->object->getId(),
314  0,
315  $answer_id
316  );
317  if (strlen($fb)) {
318  $template->setCurrentBlock("feedback");
319  $template->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($fb, true));
320  $template->parseCurrentBlock();
321  }
322  }
323  }
324  if ($show_feedback) {
325  if ($this->object->getSpecificFeedbackSetting() == 3) {
326  $answer = $this->object->getAnswer($answer_id);
327 
328  if ($answer->getPoints() > 0) {
329  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
330  $this->object->getId(),
331  0,
332  $answer_id
333  );
334  if (strlen($fb)) {
335  $template->setCurrentBlock("feedback");
336  $template->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($fb, true));
337  $template->parseCurrentBlock();
338  }
339  }
340  }
341  }
342 
343 
344 
345  $template->setCurrentBlock("answer_row");
346  $template->setVariable("ANSWER_TEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($answer->getAnswertext(), true));
347  $checked = false;
348  if ($result_output) {
349  $pointschecked = $this->object->answers[$answer_id]->getPointsChecked();
350  $pointsunchecked = $this->object->answers[$answer_id]->getPointsUnchecked();
351  $resulttextchecked = ($pointschecked == 1) || ($pointschecked == -1) ? "%s " . $this->lng->txt("point") : "%s " . $this->lng->txt("points");
352  $resulttextunchecked = ($pointsunchecked == 1) || ($pointsunchecked == -1) ? "%s " . $this->lng->txt("point") : "%s " . $this->lng->txt("points");
353  $template->setVariable("RESULT_OUTPUT", sprintf("(" . $this->lng->txt("checkbox_checked") . " = $resulttextchecked, " . $this->lng->txt("checkbox_unchecked") . " = $resulttextunchecked)", $pointschecked, $pointsunchecked));
354  }
355  foreach ($user_solution as $mc_solution) {
356  if (strcmp($mc_solution, $answer_id) == 0) {
357  if ($this->renderPurposeSupportsFormHtml() || $this->isRenderPurposePrintPdf()) {
358  $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("object/checkbox_checked.png")));
359  $template->setVariable("SOLUTION_ALT", $this->lng->txt("checked"));
360  } else {
361  $template->setVariable('QID', $this->object->getId());
362  $template->setVariable('SUFFIX', $show_correct_solution ? 'bestsolution' : 'usersolution');
363  $template->setVariable('SOLUTION_VALUE', $answer_id);
364  $template->setVariable('SOLUTION_CHECKED', 'checked');
365  }
366  $checked = true;
367  }
368  }
369  if (!$checked) {
370  if ($this->renderPurposeSupportsFormHtml() || $this->isRenderPurposePrintPdf()) {
371  $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("object/checkbox_unchecked.png")));
372  $template->setVariable("SOLUTION_ALT", $this->lng->txt("unchecked"));
373  } else {
374  $template->setVariable('QID', $this->object->getId());
375  $template->setVariable('SUFFIX', $show_correct_solution ? 'bestsolution' : 'usersolution');
376  $template->setVariable('SOLUTION_VALUE', $answer_id);
377  }
378  }
379  $template->parseCurrentBlock();
380  }
381  $questiontext = $this->object->getQuestionForHTMLOutput();
382  if ($show_feedback && $this->hasInlineFeedback()) {
383  $questiontext .= $this->buildFocusAnchorHtml();
384  }
385  if ($show_question_text == true) {
386  $template->setVariable("QUESTIONTEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($questiontext, true));
387  }
388  $questionoutput = $template->get();
389  $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
390 
391  if (strlen($feedback)) {
392  $cssClass = (
393  $this->hasCorrectSolution($active_id, $pass) ?
395  );
396 
397  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
398  $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
399  }
400  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
401 
402  $solutionoutput = $solutiontemplate->get();
403 
404  if (!$show_question_only) {
405  // get page object output
406  $solutionoutput = $this->getILIASPage($solutionoutput);
407  }
408  return $solutionoutput;
409  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
getChoiceKeys()
Create the key index numbers for the array of choices.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, bool $a_strip=false)
static getHtmlPath(string $relative_path)
get url of path
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:

◆ getSpecificFeedbackOutput()

assMultipleChoiceGUI::getSpecificFeedbackOutput ( array  $userSolution)

Definition at line 663 of file class.assMultipleChoiceGUI.php.

References ilLegacyFormElementsUtil\prepareTextareaOutput().

663  : string
664  {
665  // No return value, this question type supports inline specific feedback.
666  $output = "";
668  }
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:

◆ getTestOutput()

assMultipleChoiceGUI::getTestOutput (   $active_id,
  $pass,
  $is_postponed = false,
  $use_post_solutions = false,
  $show_feedback = false 
)
Parameters
integer$active_id
integer | null$pass
bool$is_postponed
bool$use_post_solutions
bool$show_feedback
Returns
string

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

References getChoiceKeys(), ilUtil\getImagePath(), ILIAS\Repository\lng(), ILIAS\Repository\object(), assQuestionGUI\outQuestionPage(), populateSpecificFeedbackInline(), ilLegacyFormElementsUtil\prepareFormOutput(), ilLegacyFormElementsUtil\prepareTextareaOutput(), and setUseEmptySolutionInputChecked().

510  : string {
511  // shuffle output
512  $keys = $this->getChoiceKeys();
513 
514  // get the solution of the user for the active pass or from the last pass if allowed
515  $user_solution = [];
516  if ($active_id) {
517  $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
518  // hey.
519  foreach ($solutions as $idx => $solution_value) {
520  // fau: testNav - don't add the dummy entry for 'none of the above' to the user options
521  if ($solution_value["value1"] == 'mc_none_above') {
522  $this->setUseEmptySolutionInputChecked(true);
523  continue;
524  }
525 
526  $user_solution[] = $solution_value["value1"];
527  // fau.
528  }
529 
530  if (empty($user_solution) && $this->object->getTestPresentationConfig()->isWorkedThrough()) {
531  $this->setUseEmptySolutionInputChecked(true);
532  }
533  }
534  // generate the question output
535  $this->tpl->addJavaScript('components/ILIAS/TestQuestionPool/js/ilAssMultipleChoice.js');
536  $this->tpl->addOnLoadCode('ilAssMultipleChoiceCharCounterInit();');
537 
538  $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output.html", true, true, "components/ILIAS/TestQuestionPool");
539  foreach ($keys as $answer_id) {
540  $answer = $this->object->answers[$answer_id];
541  if ($answer->hasImage()) {
542  if ($this->object->getThumbSize()) {
543  $template->setCurrentBlock("preview");
544  $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
545  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
546  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('media/enlarge.svg'));
547  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
548  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
549  $alt = $answer->getImage();
550  if (strlen($answer->getAnswertext())) {
551  $alt = $answer->getAnswertext();
552  }
553  $alt = preg_replace("/<[^>]*?>/", "", $alt);
554  $template->setVariable("ANSWER_IMAGE_ALT", ilLegacyFormElementsUtil::prepareFormOutput($alt));
555  $template->setVariable("ANSWER_IMAGE_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($alt));
556  $template->parseCurrentBlock();
557  } else {
558  $template->setCurrentBlock("answer_image");
559  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
560  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
561  $alt = $answer->getImage();
562  if (strlen($answer->getAnswertext())) {
563  $alt = $answer->getAnswertext();
564  }
565  $alt = preg_replace("/<[^>]*?>/", "", $alt);
566  $template->setVariable("ATTR", $attr);
567  $template->setVariable("ANSWER_IMAGE_ALT", ilLegacyFormElementsUtil::prepareFormOutput($alt));
568  $template->setVariable("ANSWER_IMAGE_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($alt));
569  $template->parseCurrentBlock();
570  }
571  }
572 
573  if ($show_feedback) {
574  $this->populateSpecificFeedbackInline($user_solution, $answer_id, $template);
575  }
576 
577  $template->setCurrentBlock("answer_row");
578  $template->setVariable("QID", $this->object->getId());
579  $template->setVariable("ANSWER_ID", $answer_id);
580  $template->setVariable("ANSWER_TEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($answer->getAnswertext(), true));
581  foreach ($user_solution as $mc_solution) {
582  if (strcmp($mc_solution, $answer_id) == 0) {
583  $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
584  }
585  }
586  $template->parseCurrentBlock();
587  }
588 
589  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
590  $template->setVariable("QUESTION_ID", $this->object->getId());
591  if ($this->object->getSelectionLimit()) {
592  $template->setVariable('SELECTION_LIMIT_HINT', sprintf(
593  $this->lng->txt('ass_mc_sel_lim_hint'),
594  $this->object->getSelectionLimit(),
595  $this->object->getAnswerCount()
596  ));
597 
598  $template->setVariable('SELECTION_LIMIT_VALUE', $this->object->getSelectionLimit());
599  } else {
600  $template->setVariable('SELECTION_LIMIT_VALUE', 'null');
601  }
602  $questionoutput = $template->get();
603  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput, $show_feedback);
604  return $pageoutput;
605  }
setUseEmptySolutionInputChecked($useEmptySolutionInputChecked)
getChoiceKeys()
Create the key index numbers for the array of choices.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, bool $a_strip=false)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
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...
populateSpecificFeedbackInline($user_solution, $answer_id, $template)
+ Here is the call graph for this function:

◆ getUseUnchangedAnswerCheckboxHtml()

assMultipleChoiceGUI::getUseUnchangedAnswerCheckboxHtml ( )
protected

Definition at line 619 of file class.assMultipleChoiceGUI.php.

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

619  : string
620  {
621  // hey: prevPassSolutions - use abstracted template to share with other purposes of this kind
622  $this->tpl->addJavaScript('components/ILIAS/TestQuestionPool/js/ilAssMultipleChoice.js');
623 
624  $tpl = new ilTemplate('tpl.tst_question_additional_behaviour_checkbox.html', true, true, 'components/ILIAS/TestQuestionPool');
625 
626  // HEY: affects next if (!) /// noneAboveChecked repaired but disabled because the checked input ..
627  if (false) { // .. makes the qstEditController initialize the "edit" instead of the "answered" state
628  if ($this->isUseEmptySolutionInputChecked()) {
629  $tpl->setCurrentBlock('checked');
630  $tpl->touchBlock('checked');
632  }
633  }
634 
635  $tpl->setCurrentBlock('checkbox');
636  $tpl->setVariable('TXT_FORCE_FORM_DIFF_LABEL', $this->object->getTestPresentationConfig()->getUseUnchangedAnswerLabel());
638  // hey.
639  return $tpl->get();
640  }
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:

◆ hasInlineFeedback()

assMultipleChoiceGUI::hasInlineFeedback ( )
Returns
bool

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

References ILIAS\Repository\object().

Referenced by getPreview(), and getSolutionOutput().

57  : bool
58  {
59  return $this->object->feedbackOBJ->isSpecificAnswerFeedbackAvailable($this->object->getId());
60  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isUseEmptySolutionInputChecked()

assMultipleChoiceGUI::isUseEmptySolutionInputChecked ( )

Definition at line 609 of file class.assMultipleChoiceGUI.php.

References $useEmptySolutionInputChecked.

Referenced by getUseUnchangedAnswerCheckboxHtml().

609  : bool
610  {
612  }
+ Here is the caller graph for this function:

◆ populateAnswerSpecificFormPart()

assMultipleChoiceGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form,
bool  $is_singleline = false 
)

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

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

Referenced by buildEditForm().

816  {
817  $choices = new ilMultipleChoiceWizardInputGUI($this->lng->txt("answers"), "choice");
818  $choices->setRequired(true);
819  $choices->setQuestionObject($this->object);
820  $choices->setSingleline($is_singleline);
821  $choices->setAllowMove(false);
822  if ($this->object->getSelfAssessmentEditingMode()) {
823  $choices->setSize(40);
824  }
825  $choices->setMaxLength(800);
826  if ($this->object->getAnswerCount() == 0) {
827  $this->object->addAnswer("", 0, 0, 0);
828  }
829  $choices->setValues(array_map(
830  function (ASS_AnswerMultipleResponseImage $value) {
831  $value->setAnswerText(html_entity_decode($value->getAnswerText()));
832  return $value;
833  },
834  $this->object->getAnswers()
835  ));
836  $form->addItem($choices);
837  return $form;
838  }
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file.
setRequired(bool $a_required)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateCorrectionsFormProperties()

assMultipleChoiceGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Definition at line 1006 of file class.assMultipleChoiceGUI.php.

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

1006  : void
1007  {
1008  $choices = new ilAssMultipleChoiceCorrectionsInputGUI($this->lng->txt("answers"), "choice");
1009  $choices->setRequired(true);
1010  $choices->setQuestionObject($this->object);
1011  $choices->setValues($this->object->getAnswers());
1012  $form->addItem($choices);
1013  }
setRequired(bool $a_required)
+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assMultipleChoiceGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form,
bool  $is_singleline = false 
)

Definition at line 757 of file class.assMultipleChoiceGUI.php.

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

Referenced by buildEditForm().

758  {
759  // shuffle
760  $shuffle = new ilCheckboxInputGUI($this->lng->txt("shuffle_answers"), "shuffle");
761  $shuffle->setValue(1);
762  $shuffle->setChecked($this->object->getShuffle());
763  $shuffle->setRequired(false);
764  $form->addItem($shuffle);
765 
766  $selLim = new ilNumberInputGUI($this->lng->txt('ass_mc_sel_lim_setting'), 'selection_limit');
767  $selLim->setInfo($this->lng->txt('ass_mc_sel_lim_setting_desc'));
768  $selLim->setSize(2);
769  $selLim->setRequired(false);
770  $selLim->allowDecimals(false);
771  $selLim->setMinvalueShouldBeGreater(false);
772  $selLim->setMaxvalueShouldBeLess(false);
773  $selLim->setMinValue(1);
774  $selLim->setMaxValue($this->object->getAnswerCount());
775  $selLim->setValue($this->object->getSelectionLimit());
776  $form->addItem($selLim);
777 
778  if ($this->object->getId()) {
779  $hidden = new ilHiddenInputGUI("ID");
780  $hidden->setValue($this->object->getId());
781  $form->addItem($hidden);
782  }
783 
784  if (!$this->object->getSelfAssessmentEditingMode()) {
785  // Answer types
786  $types = new ilSelectInputGUI($this->lng->txt("answer_types"), "types");
787  $types->setRequired(false);
788  $types->setValue(($is_singleline) ? 0 : 1);
789  $types->setOptions([
790  0 => $this->lng->txt('answers_singleline'),
791  1 => $this->lng->txt('answers_multiline'),
792  ]);
793  $form->addItem($types);
794  }
795 
796  if ($is_singleline) {
797  // thumb size
798  $thumb_size = new ilNumberInputGUI($this->lng->txt("thumb_size"), "thumb_size");
799  $thumb_size->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
800  $thumb_size->setMinValue($this->object->getMinimumThumbSize());
801  $thumb_size->setDecimals(0);
802  $thumb_size->setSize(6);
803  $thumb_size->setInfo($this->lng->txt('thumb_size_info'));
804  $thumb_size->setValue($this->object->getThumbSize());
805  $thumb_size->setRequired(true);
806  } else {
807  $thumb_size = new ilHiddenInputGUI('thumb_size');
808  $thumb_size->setValue($this->object->getThumbSize());
809  }
810  $form->addItem($thumb_size);
811 
812  return $form;
813  }
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRequired(bool $a_required)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateSpecificFeedbackInline()

assMultipleChoiceGUI::populateSpecificFeedbackInline (   $user_solution,
  $answer_id,
  $template 
)
private

Definition at line 929 of file class.assMultipleChoiceGUI.php.

References ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

Referenced by getPreview(), and getTestOutput().

929  : void
930  {
931  if ($this->object->getSpecificFeedbackSetting() == 2) {
932  foreach ($user_solution as $mc_solution) {
933  if (strcmp($mc_solution, $answer_id) == 0) {
934  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
935  if (strlen($fb)) {
936  $template->setCurrentBlock("feedback");
937  $template->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($fb, true));
938  $template->parseCurrentBlock();
939  }
940  }
941  }
942  }
943 
944  if ($this->object->getSpecificFeedbackSetting() == 1) {
945  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
946  if (strlen($fb)) {
947  $template->setCurrentBlock("feedback");
948  $template->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($fb, true));
949  $template->parseCurrentBlock();
950  }
951  }
952 
953  if ($this->object->getSpecificFeedbackSetting() == 3) {
954  $answer = $this->object->getAnswer($answer_id);
955 
956  if ($answer->getPoints() > 0) {
957  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
958  if (strlen($fb)) {
959  $template->setCurrentBlock("feedback");
960  $template->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($fb, true));
961  $template->parseCurrentBlock();
962  }
963  }
964  }
965  }
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removechoice()

assMultipleChoiceGUI::removechoice ( )

Remove an answer.

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

References editQuestion(), and writePostData().

185  : void
186  {
187  $this->writePostData(true);
188  $position = key($_POST['cmd']['removechoice']);
189  $this->object->deleteAnswer($position);
190  $this->editQuestion();
191  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ removeimagechoice()

assMultipleChoiceGUI::removeimagechoice ( )

Remove an image.

Definition at line 163 of file class.assMultipleChoiceGUI.php.

References editQuestion(), and writePostData().

163  : void
164  {
165  $this->writePostData(true);
166  $position = key($_POST['cmd']['removeimagechoice']);
167  $this->object->removeAnswerImage($position);
168  $this->editQuestion();
169  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ renderAggregateView()

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

Definition at line 908 of file class.assMultipleChoiceGUI.php.

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

Referenced by getAggregatedAnswersView().

908  : ilTemplate
909  {
910  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "components/ILIAS/TestQuestionPool");
911 
912  $tpl->setCurrentBlock('headercell');
913  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
915 
916  $tpl->setCurrentBlock('headercell');
917  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
919 
920  foreach ($aggregate as $line_data) {
921  $tpl->setCurrentBlock('aggregaterow');
922  $tpl->setVariable('OPTION', $line_data['answertext']);
923  $tpl->setVariable('COUNT', $line_data['count_checked']);
925  }
926  return $tpl;
927  }
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
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:

◆ saveCorrectionsFormProperties()

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

Definition at line 1018 of file class.assMultipleChoiceGUI.php.

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

1018  : void
1019  {
1020  $input = $form->getItemByPostVar('choice');
1021  $answerElements = $input->getValues();
1022 
1023  foreach ($this->object->getAnswers() as $index => $answer) {
1024  /* @var ASS_AnswerMultipleResponseImage $answer */
1025  $answer->setPointsChecked((float) str_replace(',', '.', $answerElements[$index]->getPointsChecked()));
1026  $answer->setPointsUnchecked((float) str_replace(',', '.', $answerElements[$index]->getPointsUnchecked()));
1027  }
1028  }
getItemByPostVar(string $a_post_var)
+ Here is the call graph for this function:

◆ setUseEmptySolutionInputChecked()

assMultipleChoiceGUI::setUseEmptySolutionInputChecked (   $useEmptySolutionInputChecked)

Definition at line 614 of file class.assMultipleChoiceGUI.php.

References $useEmptySolutionInputChecked.

Referenced by getTestOutput().

614  : void
615  {
616  $this->useEmptySolutionInputChecked = $useEmptySolutionInputChecked;
617  }
+ Here is the caller graph for this function:

◆ uploadchoice()

assMultipleChoiceGUI::uploadchoice ( )

Upload an image.

Definition at line 154 of file class.assMultipleChoiceGUI.php.

References editQuestion(), and writePostData().

154  : void
155  {
156  $this->writePostData(true);
157  $this->editQuestion();
158  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assMultipleChoiceGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiAnswerScoringAdjustable.

Definition at line 696 of file class.assMultipleChoiceGUI.php.

References $filename, $parts, assQuestionGUI\cleanupAnswerText(), and ILIAS\Repository\object().

Referenced by writePostData().

696  : void
697  {
698  // Delete all existing answers and create new answers from the form data
699  $this->object->flushAnswers();
700  $choice = $this->cleanupAnswerText($_POST['choice'], $this->object->isSingleline() === false);
701  if (!$this->object->isSingleline()) {
702  foreach ($choice['answer'] as $index => $answer) {
703  $answertext = $answer;
704  $this->object->addAnswer(
705  $answertext,
706  (float) str_replace(',', '.', $choice['points'][$index]),
707  (float) str_replace(',', '.', $choice['points_unchecked'][$index]),
708  $index,
709  null,
710  (int) $choice['answer_id'][$index]
711  );
712  }
713  return;
714  }
715 
716  foreach ($choice['answer'] as $index => $answertext) {
717  $answertext = htmlentities($answertext);
718  $picturefile = $choice['imagename'][$index] ?? null;
719  $file_org_name = $_FILES['choice']['name']['image'][$index] ?? '';
720  $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index] ?? '';
721 
722  if ($file_temp_name !== '') {
723  // check suffix
724  $parts = explode(".", $file_org_name);
725  $suffix = strtolower(array_pop($parts));
726  if (in_array($suffix, ["jpg", "jpeg", "png", "gif"])) {
727  // upload image
728  $filename = $this->object->buildHashedImageFilename($file_org_name);
729  if ($this->object->setImageFile($filename, $file_temp_name) == 0) {
730  $picturefile = $filename;
731  }
732  }
733  }
734 
735  $this->object->addAnswer(
736  $answertext,
737  (float) str_replace(',', '.', $choice['points'][$index]),
738  (float) str_replace(',', '.', $choice['points_unchecked'][$index]),
739  $index,
740  $picturefile,
741  $choice['answer_id'][$index]
742  );
743  }
744 
745  if ($this->rebuild_thumbnails) {
746  $this->object->setAnswers(
747  $this->object->rebuildThumbnails(
748  $this->object->isSingleline(),
749  $this->object->getThumbSize(),
750  $this->object->getImagePath(),
751  $this->object->getAnswers()
752  )
753  );
754  }
755  }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:62
$filename
Definition: buildRTE.php:78
cleanupAnswerText(array $answer_text, bool $is_rte)
sk - 12.05.2023: This is one more of those that we need, but don&#39;t want.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

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

{}

Definition at line 65 of file class.assMultipleChoiceGUI.php.

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

Referenced by addchoice(), removechoice(), removeimagechoice(), and uploadchoice().

65  : int
66  {
67  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
68  if (!$hasErrors) {
69  $is_singleline = $this->getEditAnswersSingleLine();
70  $form = $this->buildEditForm($is_singleline);
71  $form->setValuesByPost();
73  $this->writeQuestionSpecificPostData($form);
74  $this->writeAnswerSpecificPostData($form);
75  $this->saveTaxonomyAssignments();
76  return 0;
77  }
78  return 1;
79  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
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.
getEditAnswersSingleLine($checkonly=false)
Get the single/multiline editing of answers.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeQuestionSpecificPostData()

assMultipleChoiceGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

Definition at line 670 of file class.assMultipleChoiceGUI.php.

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

Referenced by writePostData().

670  : void
671  {
672  $this->object->setShuffle($_POST["shuffle"] ?? '0');
673 
674  $selectionLimit = (int) $form->getItemByPostVar('selection_limit')->getValue();
675  $this->object->setSelectionLimit($selectionLimit > 0 ? $selectionLimit : null);
676 
677  if (isset($_POST['feedback_setting'])) {
678  $this->object->setSpecificFeedbackSetting($_POST['feedback_setting']);
679  }
680 
681  $types = (int) ($_POST['types'] ?? '0');
682  $this->object->setMultilineAnswerSetting($types);
683  if (isset($_POST['choice']['imagename']) && is_array($_POST['choice']['imagename']) && $types === 1) {
684  $this->object->setIsSingleline(true);
685  $this->tpl->setOnScreenMessage('info', $this->lng->txt('info_answer_type_change'), true);
686  } else {
687  $this->object->setIsSingleline(($types === 0) ? true : false);
688  }
689  if (isset($_POST["thumb_size"])
690  && (int) $_POST["thumb_size"] !== $this->object->getThumbSize()) {
691  $this->object->setThumbSize((int) $_POST["thumb_size"]);
692  $this->rebuild_thumbnails = true;
693  }
694  }
getItemByPostVar(string $a_post_var)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $rebuild_thumbnails

bool assMultipleChoiceGUI::$rebuild_thumbnails = false
private

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

◆ $useEmptySolutionInputChecked

assMultipleChoiceGUI::$useEmptySolutionInputChecked = false
protected

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