ILIAS  release_8 Revision v8.24
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)
 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)
 Returns the answer specific feedback for the question. More...
 
 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 ()
 
 getNotesHTML ()
 
 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)
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. 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...
 
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 

Data Fields

 $choiceKeys
 
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const CORRECTNESS_NOT_OK = 0
 
const CORRECTNESS_MOSTLY_OK = 1
 
const CORRECTNESS_OK = 2
 
const ALLOWED_PLAIN_TEXT_TAGS = "<em>, <strong>"
 sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI. More...
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $question_count
 question count in test More...
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 

Protected Member Functions

 writePostData (bool $always=false)
 {Evaluates a posted edit form and writes the form data in the question object.
Returns
integer A positive value, if one of the required fields wasn't set, else 0
} 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)
 
 genericFeedbackOutputBuilder (string $feedback_correct, string $feedback_incorrect, int $active_id, ?int $pass)
 
 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)
 
 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

 $useEmptySolutionInputChecked = false
 
- Protected Attributes inherited from assQuestionGUI
const SUGGESTED_SOLUTION_COMMANDS
 
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
ILIAS Notes GUIService $notes_gui
 
ilCtrl $ctrl
 
ilPropertyFormGUI $editForm
 
ILIAS TestQuestionPool InternalRequestService $request
 

Private Member Functions

 populateSpecificFeedbackInline ($user_solution, $answer_id, $template)
 

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 ($txt_output, $prepare_for_latex_output=false, $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...
 

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$

@ilCtrl_Calls assMultipleChoiceGUI: ilFormPropertyDispatchGUI

Definition at line 35 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 @access public

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

48 {
50 include_once "./Modules/TestQuestionPool/classes/class.assMultipleChoice.php";
51 $this->object = new assMultipleChoice();
52 if ($id >= 0) {
53 $this->object->loadFromDb($id);
54 }
55 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addBasicQuestionFormProperties()

assMultipleChoiceGUI::addBasicQuestionFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

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

153 : void
154 {
155 parent::addBasicQuestionFormProperties($form);
156 $form->getItemByPostVar('question')->setInitialRteWidth('100');
157 }
getItemByPostVar(string $a_post_var)

References ilPropertyFormGUI\getItemByPostVar().

+ Here is the call graph for this function:

◆ addchoice()

assMultipleChoiceGUI::addchoice ( )

Add a new answer.

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

182 : void
183 {
184 $this->writePostData(true);
185 $position = key($_POST['cmd']['addchoice']);
186 $this->object->addAnswer("", 0, 0, $position + 1);
187 $this->editQuestion();
188 }
writePostData(bool $always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
editQuestion($checkonly=false)
Creates an output of the edit form for the question.

References editQuestion(), and writePostData().

+ Here is the call graph for this function:

◆ aggregateAnswers()

assMultipleChoiceGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)

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

875 : array
876 {
877 $aggregate = array();
878 foreach ($answers_defined_on_question as $answer) {
879 $aggregated_info_for_answer = array();
880 $aggregated_info_for_answer['answertext'] = $answer->getAnswerText();
881 $aggregated_info_for_answer['count_checked'] = 0;
882
883 foreach ($relevant_answers_chosen as $relevant_answer) {
884 if ($relevant_answer['value1'] == $answer->getOrder()) {
885 $aggregated_info_for_answer['count_checked']++;
886 }
887 }
888 $aggregated_info_for_answer['count_unchecked'] =
889 ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
890 - $aggregated_info_for_answer['count_checked'];
891
892 $aggregate[] = $aggregated_info_for_answer;
893 }
894 return $aggregate;
895 }

◆ buildEditForm()

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

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

969 {
970 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
971 $form = new ilPropertyFormGUI();
972 $form->setFormAction($this->ctrl->getFormAction($this));
973 $form->setTitle($this->outQuestionType());
974 $form->setTableWidth("100%");
975 $form->setId("assmultiplechoice");
976
977 $this->addBasicQuestionFormProperties($form);
978 $this->populateQuestionSpecificFormPart($form, $is_singleline);
979 $this->populateAnswerSpecificFormPart($form, $is_singleline);
980 $this->populateTaxonomyFormSection($form);
981 $this->addQuestionFormCommandButtons($form);
982 return $form;
983 }
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form, bool $is_singleline=false)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form, bool $is_singleline=false)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
This class represents a property form user interface.

References ILIAS\Repository\ctrl().

+ 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 120 of file class.assMultipleChoiceGUI.php.

120 : bool
121 {
122 $save = $this->isSaveCommand();
123 $this->getQuestionTemplate();
124
125 $is_singleline = $this->getEditAnswersSingleLine($checkonly);
126
127 $form = $this->buildEditForm($is_singleline);
128
129 if ($is_singleline) {
130 $form->setMultipart(true);
131 } else {
132 $form->setMultipart(false);
133 }
134
135 $errors = false;
136
137 if ($save) {
138 $form->getItemByPostVar('selection_limit')->setMaxValue(count((array) $_POST['choice']['answer']));
139
140 $form->setValuesByPost();
141 $errors = !$form->checkInput();
142 if ($errors) {
143 $checkonly = false;
144 }
145 }
146
147 if (!$checkonly) {
148 $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
149 }
150 return $errors;
151 }
getEditAnswersSingleLine($checkonly=false)
Get the single/multiline editing of answers.
$errors
Definition: imgupload.php:65

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

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

+ 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 843 of file class.assMultipleChoiceGUI.php.

843 : array
844 {
845 return array();
846 }

◆ 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 857 of file class.assMultipleChoiceGUI.php.

857 : array
858 {
859 return array();
860 }

◆ 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 868 of file class.assMultipleChoiceGUI.php.

868 : string
869 {
870 return $this->renderAggregateView(
871 $this->aggregateAnswers($relevant_answers, $this->object->getAnswers())
872 )->get();
873 }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getAnswersFrequency()

assMultipleChoiceGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

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

985 : array
986 {
987 $agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());
988
989 $answers = array();
990
991 foreach ($agg as $ans) {
992 $answers[] = array(
993 'answer' => $ans['answertext'],
994 'frequency' => $ans['count_checked']
995 );
996 }
997
998 return $answers;
999 }

References ILIAS\Repository\object().

+ 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 657 of file class.assMultipleChoiceGUI.php.

657 : array
658 {
659 $choiceKeys = array_keys($this->object->answers);
660
661 if ($this->object->getShuffle()) {
662 $choiceKeys = $this->object->getShuffler()->transform($choiceKeys);
663 }
664
665 return $choiceKeys;
666 }

References ILIAS\Repository\object().

+ Here is the call 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 92 of file class.assMultipleChoiceGUI.php.

92 : bool
93 {
94 if ($this->object->getSelfAssessmentEditingMode()) {
95 return $this->object->isSingleline();
96 }
97
98 if ($checkonly) {
99 $types = $_POST['types'] ?? '0';
100 return $types === '0' ? true : false;
101 }
102
103 $lastChange = $this->object->getLastChange();
104 if (empty($lastChange) && !isset($_POST['types'])) {
105 // a new question is edited
106 return $this->object->getMultilineAnswerSetting() ? false : true;
107 } else {
108 // a saved question is edited
109 return $this->object->isSingleline();
110 }
111 }
return true

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

Referenced by editQuestion(), and writePostData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPresentationJavascripts()

assMultipleChoiceGUI::getPresentationJavascripts ( )

Reimplemented from assQuestionGUI.

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

647 : array
648 {
649 return array('Modules/TestQuestionPool/js/ilAssMultipleChoice.js');
650 }

◆ getPreview()

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

Reimplemented from assQuestionGUI.

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

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

References $keys, $type, ilUtil\getImagePath(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareFormOutput().

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

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

Reimplemented from assQuestionGUI.

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

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

◆ getSpecificFeedbackOutput()

assMultipleChoiceGUI::getSpecificFeedbackOutput ( array  $userSolution)

Returns the answer specific feedback for the question.

Parameters
array$userSolution($userSolution[<value1>] = <value2>)

Reimplemented from assQuestionGUI.

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

668 : string
669 {
670 // No return value, this question type supports inline specific feedback.
671 $output = "";
672 return $this->object->prepareTextareaOutput($output, true);
673 }

◆ 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

Reimplemented from assQuestionGUI.

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

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

◆ getUseUnchangedAnswerCheckboxHtml()

assMultipleChoiceGUI::getUseUnchangedAnswerCheckboxHtml ( )
protected

Reimplemented from assQuestionGUI.

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

624 : string
625 {
626 // hey: prevPassSolutions - use abstracted template to share with other purposes of this kind
627 $this->tpl->addJavaScript('Modules/TestQuestionPool/js/ilAssMultipleChoice.js');
628
629 $tpl = new ilTemplate('tpl.tst_question_additional_behaviour_checkbox.html', true, true, 'Modules/TestQuestionPool');
630
631 // HEY: affects next if (!) /// noneAboveChecked repaired but disabled because the checked input ..
632 if (false) { // .. makes the qstEditController initialize the "edit" instead of the "answered" state
633 if ($this->isUseEmptySolutionInputChecked()) {
634 $tpl->setCurrentBlock('checked');
635 $tpl->touchBlock('checked');
637 }
638 }
639
640 $tpl->setCurrentBlock('checkbox');
641 $tpl->setVariable('TXT_FORCE_FORM_DIFF_LABEL', $this->object->getTestPresentationConfig()->getUseUnchangedAnswerLabel());
643 // hey.
644 return $tpl->get();
645 }
ilGlobalPageTemplate $tpl
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
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.
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
touchBlock(string $blockname)
overwrites ITX::touchBlock.

References $tpl, and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ hasInlineFeedback()

assMultipleChoiceGUI::hasInlineFeedback ( )
Returns
bool

Reimplemented from assQuestionGUI.

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

60 : bool
61 {
62 return $this->object->feedbackOBJ->isSpecificAnswerFeedbackAvailable($this->object->getId());
63 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ isUseEmptySolutionInputChecked()

assMultipleChoiceGUI::isUseEmptySolutionInputChecked ( )

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

◆ populateAnswerSpecificFormPart()

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

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

809 {
810 // Choices
811 include_once "./Modules/TestQuestionPool/classes/class.ilMultipleChoiceWizardInputGUI.php";
812 $choices = new ilMultipleChoiceWizardInputGUI($this->lng->txt("answers"), "choice");
813 $choices->setRequired(true);
814 $choices->setQuestionObject($this->object);
815 $choices->setSingleline($is_singleline);
816 $choices->setAllowMove(false);
817 if ($this->object->getSelfAssessmentEditingMode()) {
818 $choices->setSize(40);
819 }
820 if ($this->object->getAnswerCount() == 0) {
821 $this->object->addAnswer("", 0, 0, 0);
822 }
823 $choices->setValues(array_map(
824 function (ASS_AnswerMultipleResponseImage $value) {
825 $value->setAnswerText(html_entity_decode($value->getAnswerText()));
826 return $value;
827 },
828 $this->object->getAnswers()
829 ));
830 $form->addItem($choices);
831 return $form;
832 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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

+ Here is the call graph for this function:

◆ populateCorrectionsFormProperties()

assMultipleChoiceGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

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

1001 : void
1002 {
1003 require_once 'Modules/TestQuestionPool/classes/forms/class.ilAssMultipleChoiceCorrectionsInputGUI.php';
1004 $choices = new ilAssMultipleChoiceCorrectionsInputGUI($this->lng->txt("answers"), "choice");
1005 $choices->setRequired(true);
1006 $choices->setQuestionObject($this->object);
1007 $choices->setValues($this->object->getAnswers());
1008 $form->addItem($choices);
1009 }

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

+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

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

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

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

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

+ Here is the call graph for this function:

◆ populateSpecificFeedbackInline()

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

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

923 : void
924 {
925 if ($this->object->getSpecificFeedbackSetting() == 2) {
926 foreach ($user_solution as $mc_solution) {
927 if (strcmp($mc_solution, $answer_id) == 0) {
928 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
929 if (strlen($fb)) {
930 $template->setCurrentBlock("feedback");
931 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
932 $template->parseCurrentBlock();
933 }
934 }
935 }
936 }
937
938 if ($this->object->getSpecificFeedbackSetting() == 1) {
939 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
940 if (strlen($fb)) {
941 $template->setCurrentBlock("feedback");
942 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
943 $template->parseCurrentBlock();
944 }
945 }
946
947 if ($this->object->getSpecificFeedbackSetting() == 3) {
948 $answer = $this->object->getAnswer($answer_id);
949
950 if ($answer->getPoints() > 0) {
951 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
952 if (strlen($fb)) {
953 $template->setCurrentBlock("feedback");
954 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
955 $template->parseCurrentBlock();
956 }
957 }
958 }
959 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ removechoice()

assMultipleChoiceGUI::removechoice ( )

Remove an answer.

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

193 : void
194 {
195 $this->writePostData(true);
196 $position = key($_POST['cmd']['removechoice']);
197 $this->object->deleteAnswer($position);
198 $this->editQuestion();
199 }

References editQuestion(), and writePostData().

+ Here is the call graph for this function:

◆ removeimagechoice()

assMultipleChoiceGUI::removeimagechoice ( )

Remove an image.

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

171 : void
172 {
173 $this->writePostData(true);
174 $position = key($_POST['cmd']['removeimagechoice']);
175 $this->object->removeAnswerImage($position);
176 $this->editQuestion();
177 }

References editQuestion(), and writePostData().

+ Here is the call graph for this function:

◆ renderAggregateView()

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

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

902 : ilTemplate
903 {
904 $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
905
906 $tpl->setCurrentBlock('headercell');
907 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
909
910 $tpl->setCurrentBlock('headercell');
911 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
913
914 foreach ($aggregate as $line_data) {
915 $tpl->setCurrentBlock('aggregaterow');
916 $tpl->setVariable('OPTION', $line_data['answertext']);
917 $tpl->setVariable('COUNT', $line_data['count_checked']);
919 }
920 return $tpl;
921 }

References $tpl, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ saveCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

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

1014 : void
1015 {
1016 $input = $form->getItemByPostVar('choice');
1017 $answerElements = $input->getValues();
1018
1019 foreach ($this->object->getAnswers() as $index => $answer) {
1020 /* @var ASS_AnswerMultipleResponseImage $answer */
1021 $answer->setPointsChecked((float) str_replace(',', '.', $answerElements[$index]->getPointsChecked()));
1022 $answer->setPointsUnchecked((float) str_replace(',', '.', $answerElements[$index]->getPointsUnchecked()));
1023 }
1024 }

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

+ Here is the call graph for this function:

◆ setUseEmptySolutionInputChecked()

assMultipleChoiceGUI::setUseEmptySolutionInputChecked (   $useEmptySolutionInputChecked)

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

619 : void
620 {
621 $this->useEmptySolutionInputChecked = $useEmptySolutionInputChecked;
622 }

◆ uploadchoice()

assMultipleChoiceGUI::uploadchoice ( )

Upload an image.

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

162 : void
163 {
164 $this->writePostData(true);
165 $this->editQuestion();
166 }

References editQuestion(), and writePostData().

+ 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 699 of file class.assMultipleChoiceGUI.php.

699 : void
700 {
701 // Delete all existing answers and create new answers from the form data
702 $this->object->flushAnswers();
703 $choice = $this->cleanupAnswerText($_POST['choice'], $this->object->isSingleline() === false);
704 if ($this->object->isSingleline()) {
705 foreach ($choice['answer'] as $index => $answertext) {
706 $answertext = htmlentities($answertext);
707 $picturefile = $choice['imagename'][$index] ?? '';
708 $file_org_name = $_FILES['choice']['name']['image'][$index] ?? '';
709 $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index] ?? '';
710
711 if ($file_temp_name !== '') {
712 // check suffix
713 $parts = explode(".", $file_org_name);
714 $suffix = strtolower(array_pop($parts));
715 if (in_array($suffix, ["jpg", "jpeg", "png", "gif"])) {
716 // upload image
717 $filename = $this->object->buildHashedImageFilename($file_org_name);
718 if ($this->object->setImageFile($filename, $file_temp_name) == 0) {
719 $picturefile = $filename;
720 }
721 }
722 }
723
724 $this->object->addAnswer(
725 $answertext,
726 (float) str_replace(',', '.', $choice['points'][$index]),
727 (float) str_replace(',', '.', $choice['points_unchecked'][$index]),
728 $index,
729 $picturefile,
730 $choice['answer_id'][$index]
731 );
732 }
733 } else {
734 foreach ($choice['answer'] as $index => $answer) {
735 $answertext = $answer;
736 $this->object->addAnswer(
737 $answertext,
738 (float) str_replace(',', '.', $choice['points'][$index]),
739 (float) str_replace(',', '.', $choice['points_unchecked'][$index]),
740 $index,
741 '',
742 (int) $choice['answer_id'][$index]
743 );
744 }
745 }
746 }
$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't want.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64

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

Referenced by writePostData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

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

{Evaluates a posted edit form and writes the form data in the question object.

Returns
integer A positive value, if one of the required fields wasn't set, else 0
}

Reimplemented from assQuestionGUI.

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

68 : int
69 {
70 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
71 if (!$hasErrors) {
72 $is_singleline = $this->getEditAnswersSingleLine();
73 $form = $this->buildEditForm($is_singleline);
74 $form->setValuesByPost();
75 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
78 $this->writeAnswerSpecificPostData($form);
80 return 0;
81 }
82 return 1;
83 }
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.

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

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

+ 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 675 of file class.assMultipleChoiceGUI.php.

675 : void
676 {
677 $this->object->setShuffle($_POST["shuffle"] ?? '0');
678
679 $selectionLimit = (int) $form->getItemByPostVar('selection_limit')->getValue();
680 $this->object->setSelectionLimit($selectionLimit > 0 ? $selectionLimit : null);
681
682 if (isset($_POST['feedback_setting'])) {
683 $this->object->setSpecificFeedbackSetting($_POST['feedback_setting']);
684 }
685
686 $types = (int) ($_POST['types'] ?? '0');
687 $this->object->setMultilineAnswerSetting($types);
688 if (isset($_POST['choice']['imagename']) && is_array($_POST['choice']['imagename']) && $types === 1) {
689 $this->object->setIsSingleline(true);
690 $this->tpl->setOnScreenMessage('info', $this->lng->txt('info_answer_type_change'), true);
691 } else {
692 $this->object->setIsSingleline(($types === 0) ? true : false);
693 }
694 if (isset($_POST["thumb_size"])) {
695 $this->object->setThumbSize((int) $_POST["thumb_size"]);
696 }
697 }

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

Referenced by writePostData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $choiceKeys

assMultipleChoiceGUI::$choiceKeys

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

◆ $useEmptySolutionInputChecked

assMultipleChoiceGUI::$useEmptySolutionInputChecked = false
protected

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


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