ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
assSingleChoiceGUI 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 assSingleChoiceGUI:
+ Collaboration diagram for assSingleChoiceGUI:

Public Member Functions

 __construct (int $id=-1)
 assSingleChoiceGUI constructor More...
 
 hasInlineFeedback ()
 
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 uploadchoice ()
 
 removeimagechoice ()
 
 addchoice ()
 
 removechoice ()
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 getChoiceKeys ()
 
 getSpecificFeedbackOutput (array $user_solution)
 Returns the answer specific feedback for the question. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from the request and applies them to the data object. More...
 
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form, bool $is_singleline=false)
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from the request and applies them to the data object. More...
 
 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...
 
 renderAggregateView ($aggregate)
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from assQuestionGUI
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getObject ()
 
 setObject (assQuestion $question)
 
 setCopyToExistingPoolOnSave (?int $pool_ref_id)
 
 getCopyToExistingPoolOnSave ()
 
 setCopyToNewPoolOnSave (?string $pool_title)
 
 getCopyToNewPoolOnSave ()
 
 setMoveAfterQuestionId (?int $question_id)
 
 getMoveAfterQuestionId ()
 
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getCommentsPanelHTML ()
 
 executeCommand ()
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext (string $presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled (bool $previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose (string $renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext (string $editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI (?ilTestQuestionNavigationGUI $navigationGUI)
 
 setTaxonomyIds (array $taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass (string $targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder (\ilQuestionHeaderBlockBuilder $questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd (string $questionActionCmd)
 
 getQuestionActionCmd ()
 
 assessment ()
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 
 getILIASPage (string $html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
 syncQuestion ()
 
 saveReturn ()
 
 saveQuestion ()
 
 setAdditionalContentEditingModeFromPost ()
 
 getContextPath ($cont_obj, int $a_endnode_id, int $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber (int $nr)
 
 getSequenceNumber ()
 
 setQuestionCount (int $a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage (string $errormessage)
 
 addErrorMessage (string $errormessage)
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 outQuestionType ()
 
 saveSuggestedSolution ()
 
 cancelSuggestedSolution ()
 
 suggestedsolution (bool $save=false)
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $classname)
 
 getEditQuestionTabCommands ()
 
 isAutosaveable ()
 
 outQuestionForTest (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 getPreviewSession ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 
 cmdNeedsExistingQuestion (string $cmd)
 
 setContextAllowsSyncToPool (bool $sync_allowed)
 
 needsSyncQuery ()
 
 getQuestionSyncModal (string $cmd, string $cmd_class='')
 
 getAutoSavedSolutionOutput (int $active_id, int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false)
 
 buildFileDownloadLink ()
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from the request 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...
 
- 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 the request 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...
 

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 (bool $checkonly=false)
 Get the single/multiline editing of answers. More...
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 writePostData (bool $always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm (ilPropertyFormGUI $form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 setTestSpecificProperties ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (int $active_id, ?int $pass)
 
 getTypeOptions ()
 
 createSuggestedSolutionLinkingTo (string $type, string $target)
 
 setDefaultTabs (ilTabsGUI $tabs_gui)
 
 setQuestionSpecificTabs (ilTabsGUI $tabs_gui)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabs_gui)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction (string $form_action, int $active_id, int $pass)
 
 addBackTab (ilTabsGUI $tabs_gui)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 renderLatex ($content)
 Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in the browser. More...
 
 getSuggestedSolutionsRepo ()
 
 cleanupAnswerText (array $answer_text, bool $is_rte)
 sk - 12.05.2023: This is one more of those that we need, but don't want. More...
 
 addSaveOnEnterOnLoadCode ()
 
 resetSavedPreviewSession ()
 

Private Member Functions

 generateCorrectness (string $user_solution, string $answer_id, float $answer_points, float $maximum_points)
 
 aggregateAnswers ($relevant_answers_chosen, $answers_defined_on_question)
 
 populateInlineFeedback ($template, $answer_id, $user_solution)
 

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 getCommandsFromClassConstants (string $guiClassName, string $cmdConstantNameBegin='CMD_')
 
static prepareTextareaOutput (?string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output where latex code may be in it If the text is HTML-free, CHR(13) will be converted to a line break. More...
 
- Data Fields inherited from assQuestionGUI
const ALLOWED_PLAIN_TEXT_TAGS = "<em>, <strong>"
 sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI. More...
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const CORRECTNESS_NOT_OK = 0
 
const CORRECTNESS_MOSTLY_OK = 1
 
const CORRECTNESS_OK = 2
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const CMD_SYNC_QUESTION_AND_RETURN = 'syncQuestionReturn'
 
- Protected Attributes inherited from assQuestionGUI
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
const SUGGESTED_SOLUTION_COMMANDS_CANCEL = 'cancelSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_SAVE = 'saveSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_DEFAULT = 'suggestedsolution'
 
const QUESTION_SAVE_CMDS
 
const ADDITIONAL_CMDS_NEEDING_EXISTING_QST
 There are functions that need an existing question. More...
 
ilLogger $logger
 
GeneralQuestionPropertiesRepository $questionrepository
 
GUIService $notes_gui
 
ilCtrl $ctrl
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
Refinery $refinery
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $question_count
 question count in test More...
 
ilPropertyFormGUI $editForm = null
 
readonly ilTestLegacyFormsHelper $forms_helper
 
readonly RequestDataCollector $request_data_collector
 
bool $parent_type_is_lm = false
 
SuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

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

The assSingleChoiceGUI class encapsulates the GUI representation for single 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 assSingleChoiceGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

assSingleChoiceGUI::__construct ( int  $id = -1)

assSingleChoiceGUI constructor

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

Parameters
integer$idThe database id of a single choice question object

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

44 {
46 $this->object = new assSingleChoice();
47 if ($id >= 0) {
48 $this->object->loadFromDb($id);
49 }
50 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class for single choice questions.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addchoice()

assSingleChoiceGUI::addchoice ( )

Definition at line 176 of file class.assSingleChoiceGUI.php.

176 : void
177 {
178 $this->writePostData(true);
179 $position = key($this->request_data_collector->raw('cmd')['addchoice']);
180 $this->object->addAnswer('', 0, $position + 1);
181 $this->editQuestion();
182 }
writePostData(bool $always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)

◆ aggregateAnswers()

assSingleChoiceGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)
private

Definition at line 735 of file class.assSingleChoiceGUI.php.

735 : array
736 {
737 $aggregate = [];
738 foreach ($answers_defined_on_question as $answer) {
739 $aggregated_info_for_answer = [];
740 $aggregated_info_for_answer['answertext'] = $answer->getAnswerText();
741 $aggregated_info_for_answer['count_checked'] = 0;
742
743 foreach ($relevant_answers_chosen as $relevant_answer) {
744 if ($relevant_answer['value1'] == $answer->getOrder()) {
745 $aggregated_info_for_answer['count_checked']++;
746 }
747 }
748 $aggregated_info_for_answer['count_unchecked'] =
749 ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
750 - $aggregated_info_for_answer['count_checked'];
751
752 $aggregate[] = $aggregated_info_for_answer;
753 }
754 return $aggregate;
755 }

◆ editQuestion()

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

Reimplemented from assQuestionGUI.

Definition at line 101 of file class.assSingleChoiceGUI.php.

104 : bool {
105 $save = $is_save_cmd ?? $this->isSaveCommand();
106
107 $form = new ilPropertyFormGUI();
108 $this->editForm = $form;
109
110 $form->setFormAction($this->ctrl->getFormAction($this));
111 $form->setTitle($this->outQuestionType());
112 $is_singleline = $this->getEditAnswersSingleLine($checkonly);
113 if ($is_singleline) {
114 $form->setMultipart(true);
115 } else {
116 $form->setMultipart(false);
117 }
118 $form->setTableWidth('100%');
119 $form->setId('asssinglechoice');
120
121 $this->addBasicQuestionFormProperties($form);
122 $this->populateQuestionSpecificFormPart($form, $is_singleline);
123 $this->populateAnswerSpecificFormPart($form, $is_singleline);
124
125 $this->populateTaxonomyFormSection($form);
126
127 $this->addQuestionFormCommandButtons($form);
128
129 $errors = false;
130
131 if ($save) {
132 foreach ($this->request_data_collector->getParsedBody() as $key => $value) {
133 $item = $form->getItemByPostVar($key);
134 if ($item === null) {
135 continue;
136 }
137 switch (get_class($item)) {
138 case 'ilDurationInputGUI':
139 $item->setHours($value['hh']);
140 $item->setMinutes($value['mm']);
141 $item->setSeconds($value['ss']);
142 break;
143 default:
144 $item->setValue($value);
145 }
146 }
147
148 $errors = !$form->checkInput();
149 if ($errors) {
150 $checkonly = false;
151 }
152 }
153
154 if (!$checkonly) {
155 $this->renderEditForm($form);
156 }
157 return $errors;
158 }
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
renderEditForm(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form, bool $is_singleline=false)
getEditAnswersSingleLine(bool $checkonly=false)
Get the single/multiline editing of answers.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form, bool $is_singleline=false)
This class represents a property form user interface.

Referenced by writePostData().

+ Here is the caller graph for this function:

◆ generateCorrectness()

assSingleChoiceGUI::generateCorrectness ( string  $user_solution,
string  $answer_id,
float  $answer_points,
float  $maximum_points 
)
private

Definition at line 353 of file class.assSingleChoiceGUI.php.

358 : int {
359 if ($user_solution === $answer_id
360 && $answer_points === $maximum_points
361 || $user_solution !== $answer_id
362 && $answer_points === 0.0
363 ) {
365 }
366
367 if ($user_solution === $answer_id
368 && $answer_points > 0.0) {
370 }
371
373 }

◆ getAfterParticipationSuppressionAnswerPostVars()

assSingleChoiceGUI::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 730 of file class.assSingleChoiceGUI.php.

730 : array
731 {
732 return [];
733 }

◆ getAfterParticipationSuppressionQuestionPostVars()

assSingleChoiceGUI::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 622 of file class.assSingleChoiceGUI.php.

622 : array
623 {
624 return [];
625 }

◆ getAnswersFrequency()

assSingleChoiceGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

Definition at line 817 of file class.assSingleChoiceGUI.php.

817 : array
818 {
819 $agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());
820
821 $answers = [];
822
823 foreach ($agg as $ans) {
824 $answers[] = [
825 'answer' => $ans['answertext'],
826 'frequency' => $ans['count_checked']
827 ];
828 }
829
830 return $answers;
831 }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getChoiceKeys()

assSingleChoiceGUI::getChoiceKeys ( )

Definition at line 527 of file class.assSingleChoiceGUI.php.

528 {
529 $choice_keys = array_keys($this->object->answers);
530
531 if ($this->object->getShuffle()) {
532 $choice_keys = $this->object->getShuffler()->transform($choice_keys);
533 }
534
535 return $choice_keys;
536 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getEditAnswersSingleLine()

assSingleChoiceGUI::getEditAnswersSingleLine ( bool  $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 82 of file class.assSingleChoiceGUI.php.

82 : bool
83 {
84 if ($this->object->getSelfAssessmentEditingMode()) {
85 return $this->object->isSingleline();
86 }
87
88 if ($checkonly) {
89 return $this->request_data_collector->int('types') === 0;
90 }
91
92 if (empty($this->object->getLastChange())
93 && !$this->request_data_collector->isset('types')) {
94 // a new question is edited
95 return $this->object->getMultilineAnswerSetting() === 0;
96 }
97 // a saved question is edited
98 return $this->object->isSingleline();
99 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getPreview()

assSingleChoiceGUI::getPreview ( bool  $show_question_only = false,
bool  $show_inline_feedback = false 
)

Reimplemented from assQuestionGUI.

Definition at line 375 of file class.assSingleChoiceGUI.php.

378 : string {
379 $keys = $this->getChoiceKeys();
380
381 $template = new ilTemplate('tpl.il_as_qpl_mc_sr_output.html', true, true, 'components/ILIAS/TestQuestionPool');
382 foreach ($keys as $answer_id) {
383 $answer = $this->object->answers[$answer_id];
384 if ($answer->hasImage()) {
385 if ($this->object->getThumbSize()) {
386 $template->setCurrentBlock('preview');
387 $template->setVariable('URL_PREVIEW', $this->object->getImagePathWeb() . $answer->getImage());
388 $template->setVariable('TEXT_PREVIEW', $this->lng->txt('preview'));
389 $template->setVariable('IMG_PREVIEW', ilUtil::getImagePath('media/enlarge.svg'));
390 $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
391 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
392 $alt = $answer->getImage();
393 if (strlen($answer->getAnswertext())) {
394 $alt = $answer->getAnswertext();
395 }
396 $alt = preg_replace('/<[^>]*?>/', '', $alt);
397 $template->setVariable('ANSWER_IMAGE_ALT', ilLegacyFormElementsUtil::prepareFormOutput($alt));
398 $template->setVariable('ANSWER_IMAGE_TITLE', ilLegacyFormElementsUtil::prepareFormOutput($alt));
399 $template->parseCurrentBlock();
400 } else {
401 $template->setCurrentBlock('answer_image');
402 $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $answer->getImage());
403 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
404 $alt = $answer->getImage();
405 if (strlen($answer->getAnswertext())) {
406 $alt = $answer->getAnswertext();
407 }
408 $alt = preg_replace('/<[^>]*?>/', '', $alt);
409 $template->setVariable('ATTR', $attr);
410 $template->setVariable('ANSWER_IMAGE_ALT', ilLegacyFormElementsUtil::prepareFormOutput($alt));
411 $template->setVariable('ANSWER_IMAGE_TITLE', ilLegacyFormElementsUtil::prepareFormOutput($alt));
412 $template->parseCurrentBlock();
413 }
414 }
415 if ($show_inline_feedback && is_object($this->getPreviewSession())) {
416 $this->populateInlineFeedback($template, $answer_id, $this->getPreviewSession()->getParticipantsSolution());
417 }
418 $template->setCurrentBlock('answer_row');
419 $template->setVariable('QID', $this->object->getId() . 'ID');
420 $template->setVariable('ANSWER_ID', $answer_id);
421 $template->setVariable('ANSWER_TEXT', $this->renderLatex(
422 ilLegacyFormElementsUtil::prepareTextareaOutput($answer->getAnswertext(), true)
423 ));
424
425 if (is_object($this->getPreviewSession())) {
426 $user_solution = $this->getPreviewSession()->getParticipantsSolution();
427 if ((string) $user_solution === (string) $answer_id) {
428 $template->setVariable('CHECKED_ANSWER', ' checked="checked"');
429 }
430 }
431
432 $template->parseCurrentBlock();
433 }
434 $questiontext = $this->object->getQuestionForHTMLOutput();
435 if ($show_inline_feedback && $this->hasInlineFeedback()) {
436 $questiontext .= $this->buildFocusAnchorHtml();
437 }
438 $template->setVariable('QUESTIONTEXT', $this->renderLatex(
440 ));
441 $questionoutput = $template->get();
442 if (!$show_question_only) {
443 // get page object output
444 $questionoutput = $this->getILIASPage($questionoutput);
445 }
446 return $questionoutput;
447 }
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
populateInlineFeedback($template, $answer_id, $user_solution)
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,...
static prepareFormOutput($a_str, bool $a_strip=false)
special template class to simplify handling of ITX/PEAR
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

◆ getSolutionOutput()

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

Reimplemented from assQuestionGUI.

Definition at line 192 of file class.assSingleChoiceGUI.php.

203 : string {
204
205 if (($active_id > 0) && (!$show_correct_solution)) {
206 $user_solutions = $this->object->getSolutionValues($active_id, $pass);
207
208 } else {
209 $found_index = -1;
210 $max_points = 0;
211 foreach ($this->object->answers as $index => $answer) {
212 if ($answer->getPoints() > $max_points) {
213 $max_points = $answer->getPoints();
214 $found_index = $index;
215 }
216 }
217 $user_solutions = [['value1' => $found_index]];
218 }
219
220 return $this->renderSolutionOutput(
221 $user_solutions,
222 $active_id,
223 $pass,
224 $graphical_output,
225 $result_output,
226 $show_question_only,
227 $show_feedback,
228 $show_correct_solution,
229 $show_manual_scoring,
230 $show_question_text,
231 false,
232 $show_inline_feedback,
233 );
234 }
renderSolutionOutput(mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)

◆ getSpecificFeedbackOutput()

assSingleChoiceGUI::getSpecificFeedbackOutput ( array  $userSolution)

Returns the answer specific feedback for the question.

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

Reimplemented from assQuestionGUI.

Definition at line 538 of file class.assSingleChoiceGUI.php.

538 : string
539 {
540 // No return value, this question type supports inline specific feedback.
541 $output = '';
543 }

References ilLegacyFormElementsUtil\prepareTextareaOutput().

+ Here is the call graph for this function:

◆ getTestOutput()

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

Reimplemented from assQuestionGUI.

Definition at line 449 of file class.assSingleChoiceGUI.php.

455 : string {
456 $keys = $this->getChoiceKeys();
457
458 $user_solution = '';
459 if ($active_id !== 0) {
460 $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
461 foreach ($solutions as $solution_value) {
462 $user_solution = $solution_value['value1'];
463 }
464 }
465
466 $template = new ilTemplate('tpl.il_as_qpl_mc_sr_output.html', true, true, 'components/ILIAS/TestQuestionPool');
467 foreach ($keys as $answer_id) {
468 $answer = $this->object->answers[$answer_id];
469 if ($answer->hasImage()) {
470 if ($this->object->getThumbSize()) {
471 $template->setCurrentBlock('preview');
472 $template->setVariable('URL_PREVIEW', $this->object->getImagePathWeb() . $answer->getImage());
473 $template->setVariable('TEXT_PREVIEW', $this->lng->txt('preview'));
474 $template->setVariable('IMG_PREVIEW', ilUtil::getImagePath('media/enlarge.svg'));
475 $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
476 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
477 $alt = $answer->getImage();
478 if (strlen($answer->getAnswertext())) {
479 $alt = $answer->getAnswertext();
480 }
481 $alt = preg_replace('/<[^>]*?>/', '', $alt);
482 $template->setVariable('ANSWER_IMAGE_ALT', ilLegacyFormElementsUtil::prepareFormOutput($alt));
483 $template->setVariable('ANSWER_IMAGE_TITLE', ilLegacyFormElementsUtil::prepareFormOutput($alt));
484 $template->parseCurrentBlock();
485 } else {
486 $template->setCurrentBlock('answer_image');
487 $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $answer->getImage());
488 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
489 $alt = $answer->getImage();
490 if (strlen($answer->getAnswertext())) {
491 $alt = $answer->getAnswertext();
492 }
493 $alt = preg_replace('/<[^>]*?>/', '', $alt);
494 $template->setVariable('ATTR', $attr);
495 $template->setVariable('ANSWER_IMAGE_ALT', ilLegacyFormElementsUtil::prepareFormOutput($alt));
496 $template->setVariable('ANSWER_IMAGE_TITLE', ilLegacyFormElementsUtil::prepareFormOutput($alt));
497 $template->parseCurrentBlock();
498 }
499 }
500
501 if ($show_specific_inline_feedback) {
502 $this->populateInlineFeedback($template, $answer_id, $user_solution);
503 }
504 $template->setCurrentBlock('answer_row');
505 $template->setVariable('ANSWER_ID', $answer_id);
506 $template->setVariable('ANSWER_TEXT', $this->renderLatex(
507 ilLegacyFormElementsUtil::prepareTextareaOutput($answer->getAnswertext(), true)
508 ));
509 if ($user_solution === (string) $answer_id) {
510 $template->setVariable('CHECKED_ANSWER', ' checked="checked"');
511 }
512 $template->parseCurrentBlock();
513 }
514 $template->setVariable('QUESTIONTEXT', $this->renderLatex(
515 $this->object->getQuestionForHTMLOutput()
516 ));
517 $questionoutput = $template->get();
518 $pageoutput = $this->outQuestionPage('', $is_question_postponed, $active_id, $questionoutput, $show_specific_inline_feedback);
519 return $pageoutput;
520 }
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)

◆ hasInlineFeedback()

assSingleChoiceGUI::hasInlineFeedback ( )
Returns
bool

Reimplemented from assQuestionGUI.

Definition at line 55 of file class.assSingleChoiceGUI.php.

55 : bool
56 {
57 return $this->object->feedbackOBJ->isSpecificAnswerFeedbackAvailable($this->object->getId());
58 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

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

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

697 {
698 $choices = new ilSingleChoiceWizardInputGUI($this->lng->txt('answers'), 'choice');
699 $choices->setRequired(true);
700 $choices->setQuestionObject($this->object);
701 $choices->setSingleline($is_singleline);
702 $choices->setAllowMove(false);
703 if ($this->object->getSelfAssessmentEditingMode()) {
704 $choices->setSize(40);
705 }
706 if ($this->object->getAnswerCount() == 0) {
707 $this->object->addAnswer('', 0, 0);
708 }
709 $choices->setValues(array_map(
710 function (ASS_AnswerBinaryStateImage $value) {
711 $value->setAnswerText(html_entity_decode($value->getAnswerText()));
712 return $value;
713 },
714 $this->object->getAnswers()
715 ));
716 $choices->setInfo($choices->getInfo() . ' ' . $this->lng->txt('latex_edit_info'));
717 $form->addItem($choices);
718 return $form;
719 }
Class for answers with a binary state indicator.
This class represents a single choice wizard property in a property form.

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

+ Here is the call graph for this function:

◆ populateCorrectionsFormProperties()

assSingleChoiceGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

Definition at line 833 of file class.assSingleChoiceGUI.php.

833 : void
834 {
835 $choices = new ilAssSingleChoiceCorrectionsInputGUI($this->lng->txt('answers'), 'choice');
836 $choices->setRequired(true);
837 $choices->setQuestionObject($this->object);
838 $choices->setValues($this->object->getAnswers());
839 $form->addItem($choices);
840 }

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

+ Here is the call graph for this function:

◆ populateInlineFeedback()

assSingleChoiceGUI::populateInlineFeedback (   $template,
  $answer_id,
  $user_solution 
)
private

Definition at line 783 of file class.assSingleChoiceGUI.php.

783 : void
784 {
785 $feedbackOutputRequired = false;
786
787 switch ($this->object->getSpecificFeedbackSetting()) {
788 case 1:
789 $feedbackOutputRequired = true;
790 break;
791
792 case 2:
793 if ((string) $user_solution === (string) $answer_id) {
794 $feedbackOutputRequired = true;
795 }
796 break;
797
798 case 3:
799 if ($this->object->getAnswer($answer_id)->getPoints() > 0) {
800 $feedbackOutputRequired = true;
801 }
802 break;
803 }
804
805 if ($feedbackOutputRequired) {
806 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
807 if (strlen($fb)) {
808 $template->setCurrentBlock('feedback');
809 $template->setVariable('FEEDBACK', $this->renderLatex(
811 ));
812 $template->parseCurrentBlock();
813 }
814 }
815 }

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

+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

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

Definition at line 570 of file class.assSingleChoiceGUI.php.

571 {
572 // shuffle
573 $shuffle = new ilCheckboxInputGUI($this->lng->txt('shuffle_answers'), 'shuffle');
574 $shuffle->setValue(1);
575 $shuffle->setChecked($this->object->getShuffle());
576 $shuffle->setRequired(false);
577 $form->addItem($shuffle);
578
579 if (!$this->object->getSelfAssessmentEditingMode()) {
580 // Answer types
581 $types = new ilSelectInputGUI($this->lng->txt('answer_types'), 'types');
582 $types->setRequired(false);
583 $types->setOptions(
584 [
585 0 => $this->lng->txt('answers_singleline'),
586 1 => $this->lng->txt('answers_multiline'),
587 ]
588 );
589 $types->setValue($is_singleline ? 0 : 1);
590 $form->addItem($types);
591 }
592
593 if ($is_singleline) {
594 // thumb size
595 $thumb_size = new ilNumberInputGUI($this->lng->txt('thumb_size'), 'thumb_size');
596 $thumb_size->setSuffix($this->lng->txt('thumb_size_unit_pixel'));
597 $thumb_size->setMinValue($this->object->getMinimumThumbSize());
598 $thumb_size->setMaxValue($this->object->getMaximumThumbSize());
599 $thumb_size->setDecimals(0);
600 $thumb_size->setSize(6);
601 $thumb_size->setInfo($this->lng->txt('thumb_size_info'));
602 $thumb_size->setValue($this->object->getThumbSize());
603 $thumb_size->setRequired(true);
604 } else {
605 $thumb_size = new ilHiddenInputGUI('thumb_size');
606 $thumb_size->setValue($this->object->getThumbSize());
607 }
608 $form->addItem($thumb_size);
609
610 return $form;
611 }
This class represents a checkbox property in a property form.
This class represents a hidden form property in a property form.
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:

◆ removechoice()

assSingleChoiceGUI::removechoice ( )

Definition at line 184 of file class.assSingleChoiceGUI.php.

184 : void
185 {
186 $this->writePostData(true);
187 $position = key($this->request_data_collector->raw('cmd')['removechoice']);
188 $this->object->deleteAnswer($position);
189 $this->editQuestion();
190 }

◆ removeimagechoice()

assSingleChoiceGUI::removeimagechoice ( )

Definition at line 167 of file class.assSingleChoiceGUI.php.

167 : void
168 {
170 $this->writePostData(true);
171 $position = key($this->request_data_collector->raw('cmd')['removeimagechoice']);
172 $this->object->removeAnswerImage($position);
173 $this->editQuestion();
174 }

◆ renderAggregateView()

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

Definition at line 762 of file class.assSingleChoiceGUI.php.

762 : ilTemplate
763 {
764 $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, 'components/ILIAS/TestQuestionPool');
765
766 $tpl->setCurrentBlock('headercell');
767 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
769
770 $tpl->setCurrentBlock('headercell');
771 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
773
774 foreach ($aggregate as $line_data) {
775 $tpl->setCurrentBlock('aggregaterow');
776 $tpl->setVariable('OPTION', $line_data['answertext']);
777 $tpl->setVariable('COUNT', $line_data['count_checked']);
779 }
780 return $tpl;
781 }
ilGlobalPageTemplate $tpl
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ renderSolutionOutput()

assSingleChoiceGUI::renderSolutionOutput ( mixed  $user_solutions,
int  $active_id,
?int  $pass,
bool  $graphical_output = false,
bool  $result_output = false,
bool  $show_question_only = true,
bool  $show_feedback = false,
bool  $show_correct_solution = false,
bool  $show_manual_scoring = false,
bool  $show_question_text = true,
bool  $show_autosave_title = false,
bool  $show_inline_feedback = false 
)

Reimplemented from assQuestionGUI.

Definition at line 236 of file class.assSingleChoiceGUI.php.

249 : ?string {
250 $user_solution = '';
251 foreach ($user_solutions as $idx => $solution_value) {
252 $user_solution = $solution_value['value1'];
253 }
254
255 $template = new ilTemplate('tpl.il_as_qpl_mc_sr_output_solution.html', true, true, 'components/ILIAS/TestQuestionPool');
256 $solutiontemplate = new ilTemplate('tpl.il_as_tst_solution_output.html', true, true, 'components/ILIAS/TestQuestionPool');
257
258 $keys = $this->getChoiceKeys();
259 foreach ($keys as $answer_id) {
260 $answer = $this->object->answers[$answer_id];
261 if ($active_id > 0 && !$show_correct_solution && $graphical_output) {
262 $correctness = $this->generateCorrectness(
263 (string) $user_solution,
264 (string) $answer_id,
265 $answer->getPoints(),
266 $this->object->getMaximumPoints()
267 );
268 $template->setCurrentBlock('icon_ok');
269 $template->setVariable('ICON_OK', $this->generateCorrectnessIconsForCorrectness($correctness));
270 $template->parseCurrentBlock();
271 }
272 if ($answer->hasImage()) {
273 $template->setCurrentBlock('answer_image');
274 if ($this->object->getThumbSize()) {
275 $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
276 } else {
277 $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $answer->getImage());
278 }
279 $alt = $answer->getImage();
280 if (strlen($answer->getAnswertext())) {
281 $alt = $answer->getAnswertext();
282 }
283 $alt = preg_replace('/<[^>]*?>/', '', $alt);
284 $template->setVariable('ANSWER_IMAGE_ALT', ilLegacyFormElementsUtil::prepareFormOutput($alt));
285 $template->setVariable('ANSWER_IMAGE_TITLE', ilLegacyFormElementsUtil::prepareFormOutput($alt));
286 $template->parseCurrentBlock();
287 }
288
289 if (($show_feedback || !$this->isTestPresentationContext()) && $show_inline_feedback) {
290 $this->populateInlineFeedback($template, $answer_id, $user_solution);
291 }
292 $template->setCurrentBlock('answer_row');
293 $template->setVariable('ANSWER_TEXT', $this->renderLatex(
294 ilLegacyFormElementsUtil::prepareTextareaOutput($answer->getAnswertext(), true)
295 ));
296
298 if ((string) $user_solution === (string) $answer_id) {
299 $template->setVariable('SOLUTION_IMAGE', ilUtil::getHtmlPath(ilUtil::getImagePath('object/radiobutton_checked.png')));
300 $template->setVariable('SOLUTION_ALT', $this->lng->txt('checked'));
301 } else {
302 $template->setVariable('SOLUTION_IMAGE', ilUtil::getHtmlPath(ilUtil::getImagePath('object/radiobutton_unchecked.png')));
303 $template->setVariable('SOLUTION_ALT', $this->lng->txt('unchecked'));
304 }
305 } else {
306 $template->setVariable('QID', $this->object->getId());
307 $template->setVariable('SUFFIX', $show_correct_solution ? 'bestsolution' : 'usersolution');
308 $template->setVariable('SOLUTION_VALUE', $answer_id);
309 if ((string) $user_solution === (string) $answer_id) {
310 $template->setVariable('SOLUTION_CHECKED', 'checked');
311 }
312 }
313
314 if ($result_output) {
315 $points = $this->object->answers[$answer_id]->getPoints();
316 $resulttext = ($points == 1) ? "(%s {$this->lng->txt('point')})" : "(%s {$this->lng->txt('points')})";
317 $template->setVariable('RESULT_OUTPUT', sprintf($resulttext, $points));
318 }
319 $template->parseCurrentBlock();
320 }
321
322 $questiontext = $this->object->getQuestionForHTMLOutput();
323 if ($show_inline_feedback && $this->hasInlineFeedback()) {
324 $questiontext .= $this->buildFocusAnchorHtml();
325 }
326 if ($show_question_text === true) {
327 $template->setVariable('QUESTIONTEXT', $this->renderLatex(
329 ));
330 }
331 $questionoutput = $template->get();
332 $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : '';
333 if ($feedback !== '') {
334 $cssClass = (
335 $this->hasCorrectSolution($active_id, $pass) ?
337 );
338
339 $solutiontemplate->setVariable('ILC_FB_CSS_CLASS', $cssClass);
340 $solutiontemplate->setVariable('FEEDBACK', ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
341 }
342 $solutiontemplate->setVariable('SOLUTION_OUTPUT', $questionoutput);
343
344 $solutionoutput = $solutiontemplate->get();
345
346 if (!$show_question_only) {
347 // get page object output
348 $solutionoutput = $this->getILIASPage($solutionoutput);
349 }
350 return $solutionoutput;
351 }
getGenericFeedbackOutput(int $active_id, ?int $pass)
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
generateCorrectness(string $user_solution, string $answer_id, float $answer_points, float $maximum_points)
static getHtmlPath(string $relative_path)
get url of path

◆ saveCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

Definition at line 845 of file class.assSingleChoiceGUI.php.

845 : void
846 {
847 $input = $form->getItemByPostVar('choice');
848 $values = $input->getValues();
849
850 foreach ($this->object->getAnswers() as $index => $answer) {
851 /* @var ASS_AnswerMultipleResponseImage $answer */
852 $points = (float) str_replace(',', '.', $values[$index]->getPoints());
853 $answer->setPoints($points);
854 }
855 }
getItemByPostVar(string $a_post_var)

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

+ Here is the call graph for this function:

◆ uploadchoice()

assSingleChoiceGUI::uploadchoice ( )

Definition at line 160 of file class.assSingleChoiceGUI.php.

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

◆ writeAnswerSpecificPostData()

assSingleChoiceGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiAnswerScoringAdjustable.

Definition at line 627 of file class.assSingleChoiceGUI.php.

627 : void
628 {
629 // Delete all existing answers and create new answers from the form data
630 $this->object->flushAnswers();
631 $choice = $this->cleanupAnswerText(
632 $this->request_data_collector->raw('choice') ?? [],
633 $this->object->isSingleline() === false
634 );
635
636 if ($choice === []) {
637 return;
638 }
639
640 if (!$this->object->isSingleline()) {
641 foreach ($choice['answer'] as $index => $answer) {
642 $answertext = $answer;
643 $this->object->addAnswer(
644 $answertext,
645 $this->refinery->kindlyTo()->float()->transform($choice['points'][$index]),
646 $index,
647 null,
648 $choice['answer_id'][$index]
649 );
650 }
651
652 return;
653 }
654
655 foreach ($choice['answer'] as $index => $answertext) {
656 $answertext = htmlentities($answertext);
657 $picturefile = $choice['imagename'][$index] ?? null;
658 $file_org_name = $_FILES['choice']['name']['image'][$index] ?? '';
659 $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index] ?? '';
660
661 if ($file_temp_name !== '') {
662 // check suffix
663 $file_name_parts = explode('.', $file_org_name);
664 $suffix = strtolower(array_pop($file_name_parts));
665 if (in_array($suffix, ['jpg', 'jpeg', 'png', 'gif'])) {
666 // upload image
667 $filename = $this->object->buildHashedImageFilename($file_org_name);
668 if ($this->object->setImageFile($filename, $file_temp_name) == 0) {
669 $picturefile = $filename;
670 }
671 }
672 }
673
674 $points = (float) str_replace(',', '.', $choice['points'][$index]);
675 $this->object->addAnswer(
676 $answertext,
677 $points,
678 $index,
679 $picturefile,
680 $choice['answer_id'][$index]
681 );
682 }
683
684 if ($this->rebuild_thumbnails) {
685 $this->object->setAnswers(
686 $this->object->rebuildThumbnails(
687 $this->object->isSingleline(),
688 $this->object->getThumbSize(),
689 $this->object->getImagePath(),
690 $this->object->getAnswers()
691 )
692 );
693 }
694 }
$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.

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

Referenced by writePostData().

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

◆ writePostData()

assSingleChoiceGUI::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 63 of file class.assSingleChoiceGUI.php.

63 : int
64 {
65 if ($always || !$this->editQuestion(true)) {
70 return 0;
71 }
72 return 1;
73 }
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from the request and applies them to the data object.
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object.

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

+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assSingleChoiceGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

Definition at line 545 of file class.assSingleChoiceGUI.php.

545 : void
546 {
547 $is_multi_line = $this->request_data_collector->string('types');
548 if ($is_multi_line === '') {
549 $is_multi_line = '0';
550 }
551 $this->object->setMultilineAnswerSetting($is_multi_line);
552 $this->object->setShuffle($this->request_data_collector->bool('shuffle') ?? false);
553
554 $choice = $this->request_data_collector->raw('choice');
555 if (isset($choice['imagename']) && is_array($choice['imagename']) && $is_multi_line === '1') {
556 $this->object->setIsSingleline(true);
557 $this->tpl->setOnScreenMessage('info', $this->lng->txt('info_answer_type_change'), true);
558 } else {
559 $this->object->setIsSingleline($is_multi_line === '0');
560 }
561
562 $object_thumb_size = $this->object->getThumbSize();
563 $thumb_size = $this->request_data_collector->int('thumb_size') ?? $object_thumb_size;
564 if ($thumb_size !== $object_thumb_size) {
565 $this->object->setThumbSize($thumb_size);
566 $this->rebuild_thumbnails = true;
567 }
568 }

References ILIAS\Repository\lng().

Referenced by writePostData().

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

Field Documentation

◆ $rebuild_thumbnails

bool assSingleChoiceGUI::$rebuild_thumbnails = false
private

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


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