ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 
 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 ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 
 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)
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 

Protected Member Functions

 writePostData (bool $always=false)
 {} More...
 
 getEditAnswersSingleLine ($checkonly=false)
 Get the single/multiline editing of answers. More...
 
- 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 (string $feedback_correct, string $feedback_incorrect, 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_QuestionHints (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)
 
 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 ()
 

Private Member Functions

 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$

\ 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.

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

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

Member Function Documentation

◆ addchoice()

assSingleChoiceGUI::addchoice ( )

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

References editQuestion(), and writePostData().

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  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ aggregateAnswers()

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

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

Referenced by getAnswersFrequency().

704  : array
705  {
706  $aggregate = [];
707  foreach ($answers_defined_on_question as $answer) {
708  $aggregated_info_for_answer = [];
709  $aggregated_info_for_answer['answertext'] = $answer->getAnswerText();
710  $aggregated_info_for_answer['count_checked'] = 0;
711 
712  foreach ($relevant_answers_chosen as $relevant_answer) {
713  if ($relevant_answer['value1'] == $answer->getOrder()) {
714  $aggregated_info_for_answer['count_checked']++;
715  }
716  }
717  $aggregated_info_for_answer['count_unchecked'] =
718  ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
719  - $aggregated_info_for_answer['count_checked'];
720 
721  $aggregate[] = $aggregated_info_for_answer;
722  }
723  return $aggregate;
724  }
+ Here is the caller graph for this function:

◆ editQuestion()

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

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

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

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

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  }
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form, bool $is_singleline=false)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form, bool $is_singleline=false)
getEditAnswersSingleLine($checkonly=false)
Get the single/multiline editing of answers.
renderEditForm(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 699 of file class.assSingleChoiceGUI.php.

699  : array
700  {
701  return [];
702  }

◆ 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 592 of file class.assSingleChoiceGUI.php.

592  : array
593  {
594  return [];
595  }

◆ getAnswersFrequency()

assSingleChoiceGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

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

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

784  : array
785  {
786  $agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());
787 
788  $answers = [];
789 
790  foreach ($agg as $ans) {
791  $answers[] = [
792  'answer' => $ans['answertext'],
793  'frequency' => $ans['count_checked']
794  ];
795  }
796 
797  return $answers;
798  }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
+ Here is the call graph for this function:

◆ getChoiceKeys()

assSingleChoiceGUI::getChoiceKeys ( )

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

References ILIAS\Repository\object().

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

498  {
499  $choice_keys = array_keys($this->object->answers);
500 
501  if ($this->object->getShuffle()) {
502  $choice_keys = $this->object->getShuffler()->transform($choice_keys);
503  }
504 
505  return $choice_keys;
506  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEditAnswersSingleLine()

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

References ILIAS\Repository\object().

Referenced by editQuestion().

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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPreview()

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

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

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

357  : string {
358  $keys = $this->getChoiceKeys();
359 
360  $template = new ilTemplate('tpl.il_as_qpl_mc_sr_output.html', true, true, 'components/ILIAS/TestQuestionPool');
361  foreach ($keys as $answer_id) {
362  $answer = $this->object->answers[$answer_id];
363  if ($answer->hasImage()) {
364  if ($this->object->getThumbSize()) {
365  $template->setCurrentBlock('preview');
366  $template->setVariable('URL_PREVIEW', $this->object->getImagePathWeb() . $answer->getImage());
367  $template->setVariable('TEXT_PREVIEW', $this->lng->txt('preview'));
368  $template->setVariable('IMG_PREVIEW', ilUtil::getImagePath('media/enlarge.svg'));
369  $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
370  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
371  $alt = $answer->getImage();
372  if (strlen($answer->getAnswertext())) {
373  $alt = $answer->getAnswertext();
374  }
375  $alt = preg_replace('/<[^>]*?>/', '', $alt);
376  $template->setVariable('ANSWER_IMAGE_ALT', ilLegacyFormElementsUtil::prepareFormOutput($alt));
377  $template->setVariable('ANSWER_IMAGE_TITLE', ilLegacyFormElementsUtil::prepareFormOutput($alt));
378  $template->parseCurrentBlock();
379  } else {
380  $template->setCurrentBlock('answer_image');
381  $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $answer->getImage());
382  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
383  $alt = $answer->getImage();
384  if (strlen($answer->getAnswertext())) {
385  $alt = $answer->getAnswertext();
386  }
387  $alt = preg_replace('/<[^>]*?>/', '', $alt);
388  $template->setVariable('ATTR', $attr);
389  $template->setVariable('ANSWER_IMAGE_ALT', ilLegacyFormElementsUtil::prepareFormOutput($alt));
390  $template->setVariable('ANSWER_IMAGE_TITLE', ilLegacyFormElementsUtil::prepareFormOutput($alt));
391  $template->parseCurrentBlock();
392  }
393  }
394  if ($show_inline_feedback && is_object($this->getPreviewSession())) {
395  $this->populateInlineFeedback($template, $answer_id, $this->getPreviewSession()->getParticipantsSolution());
396  }
397  $template->setCurrentBlock('answer_row');
398  $template->setVariable('QID', $this->object->getId() . 'ID');
399  $template->setVariable('ANSWER_ID', $answer_id);
400  $template->setVariable('ANSWER_TEXT', ilLegacyFormElementsUtil::prepareTextareaOutput($answer->getAnswertext(), true));
401 
402  if (is_object($this->getPreviewSession())) {
403  $user_solution = $this->getPreviewSession()->getParticipantsSolution();
404  if ($user_solution === (string) $answer_id) {
405  $template->setVariable('CHECKED_ANSWER', ' checked="checked"');
406  }
407  }
408 
409  $template->parseCurrentBlock();
410  }
411  $questiontext = $this->object->getQuestionForHTMLOutput();
412  if ($show_inline_feedback && $this->hasInlineFeedback()) {
413  $questiontext .= $this->buildFocusAnchorHtml();
414  }
415  $template->setVariable('QUESTIONTEXT', ilLegacyFormElementsUtil::prepareTextareaOutput($questiontext, true));
416  $questionoutput = $template->get();
417  if (!$show_question_only) {
418  // get page object output
419  $questionoutput = $this->getILIASPage($questionoutput);
420  }
421  return $questionoutput;
422  }
populateInlineFeedback($template, $answer_id, $user_solution)
static prepareFormOutput($a_str, bool $a_strip=false)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:

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

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

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

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,)
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assSingleChoiceGUI::getSpecificFeedbackOutput ( array  $user_solution)

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

References ilLegacyFormElementsUtil\prepareTextareaOutput().

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

◆ getTestOutput()

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

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

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

430  : string {
431  $keys = $this->getChoiceKeys();
432 
433  $user_solution = '';
434  if ($active_id !== 0) {
435  $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
436  foreach ($solutions as $solution_value) {
437  $user_solution = $solution_value['value1'];
438  }
439  }
440 
441  $template = new ilTemplate('tpl.il_as_qpl_mc_sr_output.html', true, true, 'components/ILIAS/TestQuestionPool');
442  foreach ($keys as $answer_id) {
443  $answer = $this->object->answers[$answer_id];
444  if ($answer->hasImage()) {
445  if ($this->object->getThumbSize()) {
446  $template->setCurrentBlock('preview');
447  $template->setVariable('URL_PREVIEW', $this->object->getImagePathWeb() . $answer->getImage());
448  $template->setVariable('TEXT_PREVIEW', $this->lng->txt('preview'));
449  $template->setVariable('IMG_PREVIEW', ilUtil::getImagePath('media/enlarge.svg'));
450  $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
451  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
452  $alt = $answer->getImage();
453  if (strlen($answer->getAnswertext())) {
454  $alt = $answer->getAnswertext();
455  }
456  $alt = preg_replace('/<[^>]*?>/', '', $alt);
457  $template->setVariable('ANSWER_IMAGE_ALT', ilLegacyFormElementsUtil::prepareFormOutput($alt));
458  $template->setVariable('ANSWER_IMAGE_TITLE', ilLegacyFormElementsUtil::prepareFormOutput($alt));
459  $template->parseCurrentBlock();
460  } else {
461  $template->setCurrentBlock('answer_image');
462  $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $answer->getImage());
463  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
464  $alt = $answer->getImage();
465  if (strlen($answer->getAnswertext())) {
466  $alt = $answer->getAnswertext();
467  }
468  $alt = preg_replace('/<[^>]*?>/', '', $alt);
469  $template->setVariable('ATTR', $attr);
470  $template->setVariable('ANSWER_IMAGE_ALT', ilLegacyFormElementsUtil::prepareFormOutput($alt));
471  $template->setVariable('ANSWER_IMAGE_TITLE', ilLegacyFormElementsUtil::prepareFormOutput($alt));
472  $template->parseCurrentBlock();
473  }
474  }
475  if ($show_specific_inline_feedback) {
476  $this->populateInlineFeedback($template, $answer_id, $user_solution);
477  }
478  $template->setCurrentBlock('answer_row');
479  $template->setVariable('ANSWER_ID', $answer_id);
480  $template->setVariable('ANSWER_TEXT', ilLegacyFormElementsUtil::prepareTextareaOutput($answer->getAnswertext(), true));
481  if (strcmp($user_solution, $answer_id) == 0) {
482  $template->setVariable('CHECKED_ANSWER', ' checked="checked"');
483  }
484  $template->parseCurrentBlock();
485  }
486  $template->setVariable('QUESTIONTEXT', $this->object->getQuestionForHTMLOutput());
487  $questionoutput = $template->get();
488  $pageoutput = $this->outQuestionPage('', $is_question_postponed, $active_id, $questionoutput, $show_specific_inline_feedback);
489  return $pageoutput;
490  }
populateInlineFeedback($template, $answer_id, $user_solution)
static prepareFormOutput($a_str, bool $a_strip=false)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:

◆ hasInlineFeedback()

assSingleChoiceGUI::hasInlineFeedback ( )
Returns
bool

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

References ILIAS\Repository\object().

Referenced by getPreview(), and renderSolutionOutput().

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

◆ populateAnswerSpecificFormPart()

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

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

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

Referenced by editQuestion().

667  {
668  $choices = new ilSingleChoiceWizardInputGUI($this->lng->txt('answers'), 'choice');
669  $choices->setRequired(true);
670  $choices->setQuestionObject($this->object);
671  $choices->setSingleline($is_singleline);
672  $choices->setAllowMove(false);
673  if ($this->object->getSelfAssessmentEditingMode()) {
674  $choices->setSize(40);
675  }
676  if ($this->object->getAnswerCount() == 0) {
677  $this->object->addAnswer('', 0, 0);
678  }
679  $choices->setValues(array_map(
680  function (ASS_AnswerBinaryStateImage $value) {
681  $value->setAnswerText(html_entity_decode($value->getAnswerText()));
682  return $value;
683  },
684  $this->object->getAnswers()
685  ));
686  $form->addItem($choices);
687  return $form;
688  }
Class for answers with a binary state indicator.
setRequired(bool $a_required)
This class represents a single choice wizard property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateCorrectionsFormProperties()

assSingleChoiceGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

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

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

800  : void
801  {
802  $choices = new ilAssSingleChoiceCorrectionsInputGUI($this->lng->txt('answers'), 'choice');
803  $choices->setRequired(true);
804  $choices->setQuestionObject($this->object);
805  $choices->setValues($this->object->getAnswers());
806  $form->addItem($choices);
807  }
setRequired(bool $a_required)
+ Here is the call graph for this function:

◆ populateInlineFeedback()

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

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

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

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

752  : void
753  {
754  $feedbackOutputRequired = false;
755 
756  switch ($this->object->getSpecificFeedbackSetting()) {
757  case 1:
758  $feedbackOutputRequired = true;
759  break;
760 
761  case 2:
762  if (strcmp((string) $user_solution, $answer_id) == 0) {
763  $feedbackOutputRequired = true;
764  }
765  break;
766 
767  case 3:
768  if ($this->object->getAnswer($answer_id)->getPoints() > 0) {
769  $feedbackOutputRequired = true;
770  }
771  break;
772  }
773 
774  if ($feedbackOutputRequired) {
775  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
776  if (strlen($fb)) {
777  $template->setCurrentBlock('feedback');
778  $template->setVariable('FEEDBACK', ilLegacyFormElementsUtil::prepareTextareaOutput($fb, true));
779  $template->parseCurrentBlock();
780  }
781  }
782  }
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateQuestionSpecificFormPart()

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

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

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

Referenced by editQuestion().

541  {
542  // shuffle
543  $shuffle = new ilCheckboxInputGUI($this->lng->txt('shuffle_answers'), 'shuffle');
544  $shuffle->setValue(1);
545  $shuffle->setChecked($this->object->getShuffle());
546  $shuffle->setRequired(false);
547  $form->addItem($shuffle);
548 
549  if (!$this->object->getSelfAssessmentEditingMode()) {
550  // Answer types
551  $types = new ilSelectInputGUI($this->lng->txt('answer_types'), 'types');
552  $types->setRequired(false);
553  $types->setOptions(
554  [
555  0 => $this->lng->txt('answers_singleline'),
556  1 => $this->lng->txt('answers_multiline'),
557  ]
558  );
559  $types->setValue($is_singleline ? 0 : 1);
560  $form->addItem($types);
561  }
562 
563  if ($is_singleline) {
564  // thumb size
565  $thumb_size = new ilNumberInputGUI($this->lng->txt('thumb_size'), 'thumb_size');
566  $thumb_size->setSuffix($this->lng->txt('thumb_size_unit_pixel'));
567  $thumb_size->setMinValue($this->object->getMinimumThumbSize());
568  $thumb_size->setMaxValue($this->object->getMaximumThumbSize());
569  $thumb_size->setDecimals(0);
570  $thumb_size->setSize(6);
571  $thumb_size->setInfo($this->lng->txt('thumb_size_info'));
572  $thumb_size->setValue($this->object->getThumbSize());
573  $thumb_size->setRequired(true);
574  } else {
575  $thumb_size = new ilHiddenInputGUI('thumb_size');
576  $thumb_size->setValue($this->object->getThumbSize());
577  }
578  $form->addItem($thumb_size);
579 
580  return $form;
581  }
setSuffix(string $a_value)
This class represents a selection list 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.
setRequired(bool $a_required)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removechoice()

assSingleChoiceGUI::removechoice ( )

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

References editQuestion(), and writePostData().

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  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ removeimagechoice()

assSingleChoiceGUI::removeimagechoice ( )

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

References editQuestion(), assQuestionGUI\setAdditionalContentEditingModeFromPost(), and writePostData().

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  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ renderAggregateView()

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

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

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

731  : ilTemplate
732  {
733  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, 'components/ILIAS/TestQuestionPool');
734 
735  $tpl->setCurrentBlock('headercell');
736  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
738 
739  $tpl->setCurrentBlock('headercell');
740  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
742 
743  foreach ($aggregate as $line_data) {
744  $tpl->setCurrentBlock('aggregaterow');
745  $tpl->setVariable('OPTION', $line_data['answertext']);
746  $tpl->setVariable('COUNT', $line_data['count_checked']);
748  }
749  return $tpl;
750  }
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
ilGlobalPageTemplate $tpl
setVariable(string $variable, $value='')
Sets the given variable to the given value.
+ Here is the call graph for this function:

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

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

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

Referenced by getSolutionOutput().

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)) {
262  if ($graphical_output) {
263  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
264 
265  if (strcmp($user_solution, $answer_id) == 0) {
266  if ($answer->getPoints() == $this->object->getMaximumPoints()) {
267  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
268  } elseif ($answer->getPoints() > 0) {
269  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_MOSTLY_OK);
270  }
271  }
272  $template->setCurrentBlock('icon_ok');
273  $template->setVariable('ICON_OK', $correctness_icon);
274  $template->parseCurrentBlock();
275  }
276  }
277  if ($answer->hasImage()) {
278  $template->setCurrentBlock('answer_image');
279  if ($this->object->getThumbSize()) {
280  $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
281  } else {
282  $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $answer->getImage());
283  }
284  $alt = $answer->getImage();
285  if (strlen($answer->getAnswertext())) {
286  $alt = $answer->getAnswertext();
287  }
288  $alt = preg_replace('/<[^>]*?>/', '', $alt);
289  $template->setVariable('ANSWER_IMAGE_ALT', ilLegacyFormElementsUtil::prepareFormOutput($alt));
290  $template->setVariable('ANSWER_IMAGE_TITLE', ilLegacyFormElementsUtil::prepareFormOutput($alt));
291  $template->parseCurrentBlock();
292  }
293 
294  if (($show_feedback || !$this->isTestPresentationContext()) && $show_inline_feedback) {
295  $this->populateInlineFeedback($template, $answer_id, $user_solution);
296  }
297  $template->setCurrentBlock('answer_row');
298  $template->setVariable('ANSWER_TEXT', ilLegacyFormElementsUtil::prepareTextareaOutput($answer->getAnswertext(), true));
299 
300  if ($this->renderPurposeSupportsFormHtml() || $this->isRenderPurposePrintPdf()) {
301  if (strcmp($user_solution, $answer_id) == 0) {
302  $template->setVariable('SOLUTION_IMAGE', ilUtil::getHtmlPath(ilUtil::getImagePath('object/radiobutton_checked.png')));
303  $template->setVariable('SOLUTION_ALT', $this->lng->txt('checked'));
304  } else {
305  $template->setVariable('SOLUTION_IMAGE', ilUtil::getHtmlPath(ilUtil::getImagePath('object/radiobutton_unchecked.png')));
306  $template->setVariable('SOLUTION_ALT', $this->lng->txt('unchecked'));
307  }
308  } else {
309  $template->setVariable('QID', $this->object->getId());
310  $template->setVariable('SUFFIX', $show_correct_solution ? 'bestsolution' : 'usersolution');
311  $template->setVariable('SOLUTION_VALUE', $answer_id);
312  if (strcmp($user_solution, $answer_id) == 0) {
313  $template->setVariable('SOLUTION_CHECKED', 'checked');
314  }
315  }
316 
317  if ($result_output) {
318  $points = $this->object->answers[$answer_id]->getPoints();
319  $resulttext = ($points == 1) ? "(%s {$this->lng->txt('point')})" : "(%s {$this->lng->txt('points')})";
320  $template->setVariable('RESULT_OUTPUT', sprintf($resulttext, $points));
321  }
322  $template->parseCurrentBlock();
323  }
324 
325  $questiontext = $this->object->getQuestionForHTMLOutput();
326  if ($show_inline_feedback && $this->hasInlineFeedback()) {
327  $questiontext .= $this->buildFocusAnchorHtml();
328  }
329  if ($show_question_text === true) {
330  $template->setVariable('QUESTIONTEXT', ilLegacyFormElementsUtil::prepareTextareaOutput($questiontext, true));
331  }
332  $questionoutput = $template->get();
333  $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : '';
334  if ($feedback !== '') {
335  $cssClass = (
336  $this->hasCorrectSolution($active_id, $pass) ?
338  );
339 
340  $solutiontemplate->setVariable('ILC_FB_CSS_CLASS', $cssClass);
341  $solutiontemplate->setVariable('FEEDBACK', ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
342  }
343  $solutiontemplate->setVariable('SOLUTION_OUTPUT', $questionoutput);
344 
345  $solutionoutput = $solutiontemplate->get();
346 
347  if (!$show_question_only) {
348  // get page object output
349  $solutionoutput = $this->getILIASPage($solutionoutput);
350  }
351  return $solutionoutput;
352  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
populateInlineFeedback($template, $answer_id, $user_solution)
static prepareFormOutput($a_str, bool $a_strip=false)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static getHtmlPath(string $relative_path)
get url of path
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
getGenericFeedbackOutput(int $active_id, ?int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

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

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

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

812  : void
813  {
814  $input = $form->getItemByPostVar('choice');
815  $values = $input->getValues();
816 
817  foreach ($this->object->getAnswers() as $index => $answer) {
818  /* @var ASS_AnswerMultipleResponseImage $answer */
819  $points = (float) str_replace(',', '.', $values[$index]->getPoints());
820  $answer->setPoints($points);
821  }
822  }
getItemByPostVar(string $a_post_var)
+ Here is the call graph for this function:

◆ uploadchoice()

assSingleChoiceGUI::uploadchoice ( )

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

References editQuestion(), assQuestionGUI\setAdditionalContentEditingModeFromPost(), and writePostData().

160  : void
161  {
163  $this->writePostData(true);
164  $this->editQuestion();
165  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ 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 597 of file class.assSingleChoiceGUI.php.

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

Referenced by writePostData().

597  : void
598  {
599  // Delete all existing answers and create new answers from the form data
600  $this->object->flushAnswers();
601  $choice = $this->cleanupAnswerText(
602  $this->request_data_collector->raw('choice') ?? [],
603  $this->object->isSingleline() === false
604  );
605 
606  if ($choice === []) {
607  return;
608  }
609 
610  if (!$this->object->isSingleline()) {
611  foreach ($choice['answer'] as $index => $answer) {
612  $answertext = $answer;
613  $this->object->addAnswer(
614  $answertext,
615  $choice['points'][$index],
616  $index,
617  null,
618  $choice['answer_id'][$index]
619  );
620  }
621 
622  return;
623  }
624 
625  foreach ($choice['answer'] as $index => $answertext) {
626  $answertext = htmlentities($answertext);
627  $picturefile = $choice['imagename'][$index] ?? null;
628  $file_org_name = $_FILES['choice']['name']['image'][$index] ?? '';
629  $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index] ?? '';
630 
631  if ($file_temp_name !== '') {
632  // check suffix
633  $file_name_parts = explode('.', $file_org_name);
634  $suffix = strtolower(array_pop($file_name_parts));
635  if (in_array($suffix, ['jpg', 'jpeg', 'png', 'gif'])) {
636  // upload image
637  $filename = $this->object->buildHashedImageFilename($file_org_name);
638  if ($this->object->setImageFile($filename, $file_temp_name) == 0) {
639  $picturefile = $filename;
640  }
641  }
642  }
643 
644  $points = (float) str_replace(',', '.', $choice['points'][$index]);
645  $this->object->addAnswer(
646  $answertext,
647  $points,
648  $index,
649  $picturefile,
650  $choice['answer_id'][$index]
651  );
652  }
653 
654  if ($this->rebuild_thumbnails) {
655  $this->object->setAnswers(
656  $this->object->rebuildThumbnails(
657  $this->object->isSingleline(),
658  $this->object->getThumbSize(),
659  $this->object->getImagePath(),
660  $this->object->getAnswers()
661  )
662  );
663  }
664  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$filename
Definition: buildRTE.php:78
cleanupAnswerText(array $answer_text, bool $is_rte)
sk - 12.05.2023: This is one more of those that we need, but don&#39;t want.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

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

{}

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

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

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

63  : int
64  {
65  if ($always || !$this->editQuestion(true)) {
69  $this->saveTaxonomyAssignments();
70  return 0;
71  }
72  return 1;
73  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from the request and applies them to the data object...
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object...
+ Here is the call graph for this function:
+ Here is the caller 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 515 of file class.assSingleChoiceGUI.php.

References ILIAS\Repository\lng().

Referenced by writePostData().

515  : void
516  {
517  $is_multi_line = $this->request_data_collector->string('types');
518  if ($is_multi_line === '') {
519  $is_multi_line = '0';
520  }
521  $this->object->setMultilineAnswerSetting($is_multi_line);
522  $this->object->setShuffle($this->request_data_collector->bool('shuffle') ?? false);
523 
524  $choice = $this->request_data_collector->raw('choice');
525  if (isset($choice['imagename']) && is_array($choice['imagename']) && $is_multi_line === '1') {
526  $this->object->setIsSingleline(true);
527  $this->tpl->setOnScreenMessage('info', $this->lng->txt('info_answer_type_change'), true);
528  } else {
529  $this->object->setIsSingleline($is_multi_line === '0');
530  }
531 
532  $object_thumb_size = $this->object->getThumbSize();
533  $thumb_size = $this->request_data_collector->int('thumb_size') ?? $object_thumb_size;
534  if ($thumb_size !== $object_thumb_size) {
535  $this->object->setThumbSize($thumb_size);
536  $this->rebuild_thumbnails = true;
537  }
538  }
+ 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: