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

Protected Member Functions

 writePostData (bool $always=false)
 {Evaluates a posted edit form and writes the form data in the question object.
Returns
integer A positive value, if one of the required fields wasn't set, else 0
} More...
 
 getEditAnswersSingleLine ($checkonly=false)
 Get the single/multiline editing of answers. More...
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 writePostData (bool $always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm (ilPropertyFormGUI $form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (string $feedback_correct, string $feedback_incorrect, int $active_id, ?int $pass)
 
 setDefaultTabs (ilTabsGUI $ilTabs)
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 cleanupAnswerText (array $answer_text, bool $is_rte)
 sk - 12.05.2023: This is one more of those that we need, but don't want. More...
 
 addSaveOnEnterOnLoadCode ()
 

Private Member Functions

 populateInlineFeedback ($template, $answer_id, $user_solution)
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI (string $question_type='', int $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants (string $guiClassName, string $cmdConstantNameBegin='CMD_')
 
static prepareTextareaOutput ($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output where latex code may be in it If the text is HTML-free, CHR(13) will be converted to a line break. More...
 
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const CORRECTNESS_NOT_OK = 0
 
const CORRECTNESS_MOSTLY_OK = 1
 
const CORRECTNESS_OK = 2
 
const ALLOWED_PLAIN_TEXT_TAGS = "<em>, <strong>"
 sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI. More...
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $question_count
 question count in test More...
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 
- Protected Attributes inherited from assQuestionGUI
const SUGGESTED_SOLUTION_COMMANDS
 
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
ILIAS Notes GUIService $notes_gui
 
ilCtrl $ctrl
 
ilPropertyFormGUI $editForm
 
ILIAS TestQuestionPool InternalRequestService $request
 

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

Constructor & Destructor Documentation

◆ __construct()

assSingleChoiceGUI::__construct (   $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 44 of file class.assSingleChoiceGUI.php.

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

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addchoice()

assSingleChoiceGUI::addchoice ( )

Add a new answer.

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

210 : void
211 {
212 $this->writePostData(true);
213 $position = key($_POST['cmd']['addchoice']);
214 $this->object->addAnswer("", 0, $position + 1);
215 $this->editQuestion();
216 }
writePostData(bool $always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
editQuestion($checkonly=false)
Creates an output of the edit form for the question.

References editQuestion(), and writePostData().

+ Here is the call graph for this function:

◆ aggregateAnswers()

assSingleChoiceGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)

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

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

◆ editQuestion()

assSingleChoiceGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

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

111 : bool
112 {
113 $save = $this->isSaveCommand();
114 $this->getQuestionTemplate();
115
116 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
117 $form = new ilPropertyFormGUI();
118 $this->editForm = $form;
119
120 $form->setFormAction($this->ctrl->getFormAction($this));
121 $form->setTitle($this->outQuestionType());
122 $is_singleline = $this->getEditAnswersSingleLine($checkonly);
123 if ($is_singleline) {
124 $form->setMultipart(true);
125 } else {
126 $form->setMultipart(false);
127 }
128 $form->setTableWidth("100%");
129 $form->setId("asssinglechoice");
130
131 $this->addBasicQuestionFormProperties($form);
132 $this->populateQuestionSpecificFormPart($form, $is_singleline);
133 $this->populateAnswerSpecificFormPart($form, $is_singleline);
134
135
136 $this->populateTaxonomyFormSection($form);
137
138 $this->addQuestionFormCommandButtons($form);
139
140 $errors = false;
141
142 if ($save) {
143 foreach ($this->request->getParsedBody() as $key => $value) {
144 $item = $form->getItemByPostVar($key);
145 if ($item !== null) {
146 switch (get_class($item)) {
147 case 'ilDurationInputGUI':
148 $item->setHours($value['hh']);
149 $item->setMinutes($value['mm']);
150 $item->setSeconds($value['ss']);
151 break;
152 default:
153 $item->setValue($value);
154 }
155 }
156 }
157
158 $errors = !$form->checkInput();
159 foreach ($this->request->getParsedBody() as $key => $value) {
160 $item = $form->getItemByPostVar($key);
161 if ($item !== null) {
162 switch (get_class($item)) {
163 case 'ilDurationInputGUI':
164 $item->setHours($value['hh']);
165 $item->setMinutes($value['mm']);
166 $item->setSeconds($value['ss']);
167 break;
168 default:
169 $item->setValue($value);
170 }
171 }
172 } // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
173
174 if ($errors) {
175 $checkonly = false;
176 }
177 }
178
179 if (!$checkonly) {
180 $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
181 }
182 return $errors;
183 }
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form, bool $is_singleline=false)
getEditAnswersSingleLine($checkonly=false)
Get the single/multiline editing of answers.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form, bool $is_singleline=false)
This class represents a property form user interface.
$errors
Definition: imgupload.php:65
string $key
Consumer key/client ID value.
Definition: System.php:193

References $errors, ILIAS\LTI\ToolProvider\$key, assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), ILIAS\Repository\ctrl(), getEditAnswersSingleLine(), assQuestionGUI\getQuestionTemplate(), assQuestionGUI\isSaveCommand(), assQuestionGUI\outQuestionType(), populateAnswerSpecificFormPart(), populateQuestionSpecificFormPart(), and assQuestionGUI\populateTaxonomyFormSection().

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

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

◆ getAfterParticipationSuppressionAnswerPostVars()

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

723 : array
724 {
725 return array();
726 }

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

638 : array
639 {
640 return array();
641 }

◆ getAggregatedAnswersView()

assSingleChoiceGUI::getAggregatedAnswersView ( array  $relevant_answers)

Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface.

Parameters
array$relevant_answers
Returns
string

Implements ilGuiQuestionScoringAdjustable.

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

734 : string
735 {
736 return $this->renderAggregateView(
737 $this->aggregateAnswers($relevant_answers, $this->object->getAnswers())
738 )->get();
739 }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getAnswersFrequency()

assSingleChoiceGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

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

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

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getChoiceKeys()

assSingleChoiceGUI::getChoiceKeys ( )

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

545 {
546 $choiceKeys = array_keys($this->object->answers);
547
548 if ($this->object->getShuffle()) {
549 $choiceKeys = $this->object->getShuffler()->transform($choiceKeys);
550 }
551
552 return $choiceKeys;
553 }

References ILIAS\Repository\object().

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

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

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

Referenced by editQuestion().

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

◆ getPreview()

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

Reimplemented from assQuestionGUI.

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

370 : string
371 {
372 $keys = $this->getChoiceKeys();
373
374 // generate the question output
375 include_once "./Services/UICore/classes/class.ilTemplate.php";
376 $template = new ilTemplate("tpl.il_as_qpl_mc_sr_output.html", true, true, "Modules/TestQuestionPool");
377 foreach ($keys as $answer_id) {
378 $answer = $this->object->answers[$answer_id];
379 if (strlen($answer->getImage())) {
380 if ($this->object->getThumbSize()) {
381 $template->setCurrentBlock("preview");
382 $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
383 $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
384 $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
385 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
386 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
387 $alt = $answer->getImage();
388 if (strlen($answer->getAnswertext())) {
389 $alt = $answer->getAnswertext();
390 }
391 $alt = preg_replace("/<[^>]*?>/", "", $alt);
392 $template->setVariable("ANSWER_IMAGE_ALT", ilLegacyFormElementsUtil::prepareFormOutput($alt));
393 $template->setVariable("ANSWER_IMAGE_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($alt));
394 $template->parseCurrentBlock();
395 } else {
396 $template->setCurrentBlock("answer_image");
397 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
398 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
399 $alt = $answer->getImage();
400 if (strlen($answer->getAnswertext())) {
401 $alt = $answer->getAnswertext();
402 }
403 $alt = preg_replace("/<[^>]*?>/", "", $alt);
404 $template->setVariable("ATTR", $attr);
405 $template->setVariable("ANSWER_IMAGE_ALT", ilLegacyFormElementsUtil::prepareFormOutput($alt));
406 $template->setVariable("ANSWER_IMAGE_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($alt));
407 $template->parseCurrentBlock();
408 }
409 }
410 if ($showInlineFeedback && is_object($this->getPreviewSession())) {
411 $this->populateInlineFeedback($template, $answer_id, $this->getPreviewSession()->getParticipantsSolution());
412 }
413 $template->setCurrentBlock("answer_row");
414 $template->setVariable("QID", $this->object->getId() . 'ID');
415 $template->setVariable("ANSWER_ID", $answer_id);
416 $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), true));
417
418 if (is_object($this->getPreviewSession())) {
419 $user_solution = $this->getPreviewSession()->getParticipantsSolution();
420 if (strcmp($user_solution, $answer_id) == 0) {
421 $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
422 }
423 }
424
425 $template->parseCurrentBlock();
426 }
427 $questiontext = $this->object->getQuestionForHTMLOutput();
428 if ($showInlineFeedback && $this->hasInlineFeedback()) {
429 $questiontext .= $this->buildFocusAnchorHtml();
430 }
431 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
432 $questionoutput = $template->get();
433 if (!$show_question_only) {
434 // get page object output
435 $questionoutput = $this->getILIASPage($questionoutput);
436 }
437 return $questionoutput;
438 }
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
populateInlineFeedback($template, $answer_id, $user_solution)
static prepareFormOutput($a_str, bool $a_strip=false)
special template class to simplify handling of ITX/PEAR
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$keys
Definition: metadata.php:204
$type

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

+ Here is the call graph for this function:

◆ getSolutionOutput()

assSingleChoiceGUI::getSolutionOutput (   $active_id,
  $pass = null,
  $graphicalOutput = false,
  $result_output = false,
  $show_question_only = true,
  $show_feedback = false,
  $show_correct_solution = false,
  $show_manual_scoring = false,
  $show_question_text = true 
)

Get the question solution output.

Parameters
integer$active_idThe active user id
integer$passThe test pass
boolean$graphicalOutputShow visual feedback for right/wrong answers
boolean$result_outputShow the reached points for parts of the question
boolean$show_question_onlyShow the question without the ILIAS content around
boolean$show_feedbackShow the question feedback
boolean$show_correct_solutionShow the correct solution instead of the user solution
boolean$show_manual_scoringShow specific information for the manual scoring output
Returns
string The solution output of the question as HTML code

Reimplemented from assQuestionGUI.

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

251 : string {
252 // shuffle output
253 $keys = $this->getChoiceKeys();
254
255 // get the solution of the user for the active pass or from the last pass if allowed
256 $user_solution = "";
257 if (($active_id > 0) && (!$show_correct_solution)) {
258 $solutions = $this->object->getSolutionValues($active_id, $pass);
259 foreach ($solutions as $idx => $solution_value) {
260 $user_solution = $solution_value["value1"];
261 }
262 } else {
263 $found_index = -1;
264 $max_points = 0;
265 foreach ($this->object->answers as $index => $answer) {
266 if ($answer->getPoints() > $max_points) {
267 $max_points = $answer->getPoints();
268 $found_index = $index;
269 }
270 }
271 $user_solution = $found_index;
272 }
273 // generate the question output
274 include_once "./Services/UICore/classes/class.ilTemplate.php";
275 $template = new ilTemplate("tpl.il_as_qpl_mc_sr_output_solution.html", true, true, "Modules/TestQuestionPool");
276 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
277 foreach ($keys as $answer_id) {
278 $answer = $this->object->answers[$answer_id];
279 if (($active_id > 0) && (!$show_correct_solution)) {
280 if ($graphicalOutput) {
281 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
282
283 if (strcmp($user_solution, $answer_id) == 0) {
284 if ($answer->getPoints() == $this->object->getMaximumPoints()) {
285 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
286 } elseif ($answer->getPoints() > 0) {
287 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_MOSTLY_OK);
288 }
289 }
290 $template->setCurrentBlock("icon_ok");
291 $template->setVariable("ICON_OK", $correctness_icon);
292 $template->parseCurrentBlock();
293 }
294 }
295 if (strlen($answer->getImage())) {
296 $template->setCurrentBlock("answer_image");
297 if ($this->object->getThumbSize()) {
298 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
299 } else {
300 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
301 }
302 $alt = $answer->getImage();
303 if (strlen($answer->getAnswertext())) {
304 $alt = $answer->getAnswertext();
305 }
306 $alt = preg_replace("/<[^>]*?>/", "", $alt);
307 $template->setVariable("ANSWER_IMAGE_ALT", ilLegacyFormElementsUtil::prepareFormOutput($alt));
308 $template->setVariable("ANSWER_IMAGE_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($alt));
309 $template->parseCurrentBlock();
310 }
311 if ($show_feedback) {
312 $this->populateInlineFeedback($template, $answer_id, $user_solution);
313 }
314 $template->setCurrentBlock("answer_row");
315 $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), true));
316
318 if (strcmp($user_solution, $answer_id) == 0) {
319 $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_checked.png")));
320 $template->setVariable("SOLUTION_ALT", $this->lng->txt("checked"));
321 } else {
322 $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png")));
323 $template->setVariable("SOLUTION_ALT", $this->lng->txt("unchecked"));
324 }
325 } else {
326 $template->setVariable('QID', $this->object->getId());
327 $template->setVariable('SUFFIX', $show_correct_solution ? 'bestsolution' : 'usersolution');
328 $template->setVariable('SOLUTION_VALUE', $answer_id);
329 if (strcmp($user_solution, $answer_id) == 0) {
330 $template->setVariable('SOLUTION_CHECKED', 'checked');
331 }
332 }
333
334 if ($result_output) {
335 $points = $this->object->answers[$answer_id]->getPoints();
336 $resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
337 $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
338 }
339 $template->parseCurrentBlock();
340 }
341 $questiontext = $this->object->getQuestionForHTMLOutput();
342 if ($show_feedback && $this->hasInlineFeedback()) {
343 $questiontext .= $this->buildFocusAnchorHtml();
344 }
345 if ($show_question_text == true) {
346 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
347 }
348 $questionoutput = $template->get();
349 $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
350 if (strlen($feedback)) {
351 $cssClass = (
352 $this->hasCorrectSolution($active_id, $pass) ?
354 );
355
356 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
357 $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
358 }
359 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
360
361 $solutionoutput = $solutiontemplate->get();
362
363 if (!$show_question_only) {
364 // get page object output
365 $solutionoutput = $this->getILIASPage($solutionoutput);
366 }
367 return $solutionoutput;
368 }
getGenericFeedbackOutput(int $active_id, ?int $pass)
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
static getHtmlPath(string $relative_path)
get url of path
$index
Definition: metadata.php:145

◆ getSpecificFeedbackOutput()

assSingleChoiceGUI::getSpecificFeedbackOutput ( array  $userSolution)

Returns the answer specific feedback for the question.

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

Reimplemented from assQuestionGUI.

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

555 : string
556 {
557 // No return value, this question type supports inline specific feedback.
558 $output = "";
559 return $this->object->prepareTextareaOutput($output, true);
560 }

◆ getTestOutput()

assSingleChoiceGUI::getTestOutput (   $active_id,
  $pass,
  $is_postponed = false,
  $use_post_solutions = false,
  $show_feedback = false 
)

Reimplemented from assQuestionGUI.

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

441 : string
442 // hey.
443 {
444 $keys = $this->getChoiceKeys();
445
446 // get the solution of the user for the active pass or from the last pass if allowed
447 $user_solution = "";
448 if ($active_id) {
449 $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
450 foreach ($solutions as $idx => $solution_value) {
451 $user_solution = $solution_value["value1"];
452 }
453 }
454
455 // generate the question output
456 include_once "./Services/UICore/classes/class.ilTemplate.php";
457 $template = new ilTemplate("tpl.il_as_qpl_mc_sr_output.html", true, true, "Modules/TestQuestionPool");
458 foreach ($keys as $answer_id) {
459 $answer = $this->object->answers[$answer_id];
460 if (strlen($answer->getImage())) {
461 if ($this->object->getThumbSize()) {
462 $template->setCurrentBlock("preview");
463 $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
464 $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
465 $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
466 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
467 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
468 $alt = $answer->getImage();
469 if (strlen($answer->getAnswertext())) {
470 $alt = $answer->getAnswertext();
471 }
472 $alt = preg_replace("/<[^>]*?>/", "", $alt);
473 $template->setVariable("ANSWER_IMAGE_ALT", ilLegacyFormElementsUtil::prepareFormOutput($alt));
474 $template->setVariable("ANSWER_IMAGE_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($alt));
475 $template->parseCurrentBlock();
476 } else {
477 $template->setCurrentBlock("answer_image");
478 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
479 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
480 $alt = $answer->getImage();
481 if (strlen($answer->getAnswertext())) {
482 $alt = $answer->getAnswertext();
483 }
484 $alt = preg_replace("/<[^>]*?>/", "", $alt);
485 $template->setVariable("ATTR", $attr);
486 $template->setVariable("ANSWER_IMAGE_ALT", ilLegacyFormElementsUtil::prepareFormOutput($alt));
487 $template->setVariable("ANSWER_IMAGE_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($alt));
488 $template->parseCurrentBlock();
489 }
490 }
491 if ($show_feedback) {
492 $feedbackOutputRequired = false;
493
494 switch ($this->object->getSpecificFeedbackSetting()) {
495 case 1:
496 $feedbackOutputRequired = true;
497 break;
498
499 case 2:
500 if (strcmp($user_solution, $answer_id) == 0) {
501 $feedbackOutputRequired = true;
502 }
503 break;
504
505 case 3:
506 if ($this->object->getAnswer($answer_id)->getPoints() > 0) {
507 $feedbackOutputRequired = true;
508 }
509 break;
510 }
511
512 if ($feedbackOutputRequired) {
513 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
514 $this->object->getId(),
515 0,
516 $answer_id
517 );
518 if (strlen($fb)) {
519 $template->setCurrentBlock("feedback");
520 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
521 $template->parseCurrentBlock();
522 }
523 }
524 }
525 $template->setCurrentBlock("answer_row");
526 $template->setVariable("ANSWER_ID", $answer_id);
527 $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), true));
528 if (strcmp($user_solution, $answer_id) == 0) {
529 $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
530 }
531 $template->parseCurrentBlock();
532 }
533 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
534 $questionoutput = $template->get();
535 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput, $show_feedback);
536 return $pageoutput;
537 }
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)

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

+ Here is the call graph for this function:

◆ hasInlineFeedback()

assSingleChoiceGUI::hasInlineFeedback ( )
Returns
bool

Reimplemented from assQuestionGUI.

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

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

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

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

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

691 {
692 $choices = new ilSingleChoiceWizardInputGUI($this->lng->txt("answers"), "choice");
693 $choices->setRequired(true);
694 $choices->setQuestionObject($this->object);
695 $choices->setSingleline($is_singleline);
696 $choices->setAllowMove(false);
697 if ($this->object->getSelfAssessmentEditingMode()) {
698 $choices->setSize(40);
699 }
700 if ($this->object->getAnswerCount() == 0) {
701 $this->object->addAnswer("", 0, 0);
702 }
703 $choices->setValues(array_map(
704 function (ASS_AnswerBinaryStateImage $value) {
705 $value->setAnswerText(html_entity_decode($value->getAnswerText()));
706 return $value;
707 },
708 $this->object->getAnswers()
709 ));
710 $form->addItem($choices);
711 return $form;
712 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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

Referenced by editQuestion().

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

◆ populateCorrectionsFormProperties()

assSingleChoiceGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

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

837 : void
838 {
839 require_once 'Modules/TestQuestionPool/classes/forms/class.ilAssSingleChoiceCorrectionsInputGUI.php';
840 $choices = new ilAssSingleChoiceCorrectionsInputGUI($this->lng->txt("answers"), "choice");
841 $choices->setRequired(true);
842 $choices->setQuestionObject($this->object);
843 $choices->setValues($this->object->getAnswers());
844 $form->addItem($choices);
845 }

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

789 : void
790 {
791 $feedbackOutputRequired = false;
792
793 switch ($this->object->getSpecificFeedbackSetting()) {
794 case 1:
795 $feedbackOutputRequired = true;
796 break;
797
798 case 2:
799 if (strcmp($user_solution, $answer_id) == 0) {
800 $feedbackOutputRequired = true;
801 }
802 break;
803
804 case 3:
805 if ($this->object->getAnswer($answer_id)->getPoints() > 0) {
806 $feedbackOutputRequired = true;
807 }
808 break;
809 }
810
811 if ($feedbackOutputRequired) {
812 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
813 if (strlen($fb)) {
814 $template->setCurrentBlock("feedback");
815 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
816 $template->parseCurrentBlock();
817 }
818 }
819 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

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

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

581 {
582 // shuffle
583 $shuffle = new ilCheckboxInputGUI($this->lng->txt("shuffle_answers"), "shuffle");
584 $shuffle->setValue(1);
585 $shuffle->setChecked($this->object->getShuffle());
586 $shuffle->setRequired(false);
587 $form->addItem($shuffle);
588
589 if ($this->object->getId()) {
590 $hidden = new ilHiddenInputGUI("", "ID");
591 $hidden->setValue($this->object->getId());
592 $form->addItem($hidden);
593 }
594
595 if (!$this->object->getSelfAssessmentEditingMode()) {
596 // Answer types
597 $types = new ilSelectInputGUI($this->lng->txt("answer_types"), "types");
598 $types->setRequired(false);
599 $types->setValue(($is_singleline) ? 0 : 1);
600 $types->setOptions(
601 array(
602 0 => $this->lng->txt('answers_singleline'),
603 1 => $this->lng->txt('answers_multiline'),
604 )
605 );
606 $form->addItem($types);
607 }
608
609 if ($is_singleline) {
610 // thumb size
611 $thumb_size = new ilNumberInputGUI($this->lng->txt("thumb_size"), "thumb_size");
612 $thumb_size->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
613 $thumb_size->setMinValue($this->object->getMinimumThumbSize());
614 $thumb_size->setMaxValue($this->object->getMaximumThumbSize());
615 $thumb_size->setDecimals(0);
616 $thumb_size->setSize(6);
617 $thumb_size->setInfo($this->lng->txt('thumb_size_info'));
618 $thumb_size->setValue($this->object->getThumbSize());
619 $thumb_size->setRequired(true);
620 } else {
621 $thumb_size = new ilHiddenInputGUI('thumb_size');
622 $thumb_size->setValue($this->object->getThumbSize());
623 }
624 $form->addItem($thumb_size);
625
626 return $form;
627 }
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a number property in a property form.
This class represents a selection list property in a property form.

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

Referenced by editQuestion().

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

◆ removechoice()

assSingleChoiceGUI::removechoice ( )

Remove an answer.

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

221 : void
222 {
223 $this->writePostData(true);
224 $position = key($_POST['cmd']['removechoice']);
225 $this->object->deleteAnswer($position);
226 $this->editQuestion();
227 }

References editQuestion(), and writePostData().

+ Here is the call graph for this function:

◆ removeimagechoice()

assSingleChoiceGUI::removeimagechoice ( )

Remove an image.

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

198 : void
199 {
200 $this->writePostData(true);
201 $position = key($_POST['cmd']['removeimagechoice']);
202 $filename = $_POST['choice']['imagename'][$position];
203 $this->object->removeAnswerImage($position);
204 $this->editQuestion();
205 }
$filename
Definition: buildRTE.php:78

References $filename, editQuestion(), and writePostData().

+ Here is the call graph for this function:

◆ renderAggregateView()

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

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

768 : ilTemplate
769 {
770 $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
771
772 $tpl->setCurrentBlock('headercell');
773 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
775
776 $tpl->setCurrentBlock('headercell');
777 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
779
780 foreach ($aggregate as $line_data) {
781 $tpl->setCurrentBlock('aggregaterow');
782 $tpl->setVariable('OPTION', $line_data['answertext']);
783 $tpl->setVariable('COUNT', $line_data['count_checked']);
785 }
786 return $tpl;
787 }
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 $tpl, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ saveCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

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

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

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

+ Here is the call graph for this function:

◆ uploadchoice()

assSingleChoiceGUI::uploadchoice ( )

Upload an image.

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

188 : void
189 {
190 $this->writePostData(true);
191 $position = key($_POST['cmd']['uploadchoice']);
192 $this->editQuestion();
193 }

References editQuestion(), and writePostData().

+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assSingleChoiceGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiAnswerScoringAdjustable.

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

643 : void
644 {
645 // Delete all existing answers and create new answers from the form data
646 $this->object->flushAnswers();
647 $choice = $this->cleanupAnswerText($_POST['choice'], $this->object->isSingleline() === false);
648 if ($this->object->isSingleline()) {
649 foreach ($choice['answer'] as $index => $answertext) {
650 $answertext = htmlentities($answertext);
651 $picturefile = $choice['imagename'][$index] ?? '';
652 $file_org_name = $_FILES['choice']['name']['image'][$index] ?? '';
653 $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index] ?? '';
654
655 if ($file_temp_name !== '') {
656 // check suffix
657 $file_name_parts = explode(".", $file_org_name);
658 $suffix = strtolower(array_pop($file_name_parts));
659 if (in_array($suffix, array("jpg", "jpeg", "png", "gif"))) {
660 // upload image
661 $filename = $this->object->buildHashedImageFilename($file_org_name);
662 if ($this->object->setImageFile($filename, $file_temp_name) == 0) {
663 $picturefile = $filename;
664 }
665 }
666 }
667 $points = (float) str_replace(',', '.', $choice['points'][$index]);
668 $this->object->addAnswer(
669 $answertext,
670 $points,
671 $index,
672 $picturefile,
673 $choice['answer_id'][$index]
674 );
675 }
676 } else {
677 foreach ($choice['answer'] as $index => $answer) {
678 $answertext = $answer;
679 $this->object->addAnswer(
680 $answertext,
681 $choice['points'][$index],
682 $index,
683 '',
684 $choice['answer_id'][$index]
685 );
686 }
687 }
688 }
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, $index, and ILIAS\Repository\object().

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

65 : int
66 {
67 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
68 if (!$hasErrors) {
69 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
74 return 0;
75 }
76 return 1;
77 }
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.

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

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

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

◆ writeQuestionSpecificPostData()

assSingleChoiceGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

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

562 : void
563 {
564 $types = $_POST["types"] ?? '0';
565
566 $this->object->setShuffle($_POST["shuffle"] ?? '0');
567 $this->object->setMultilineAnswerSetting($types);
568
569 if (isset($_POST['choice']) && isset($_POST['choice']['imagename']) && is_array($_POST['choice']['imagename']) && $types === '1') {
570 $this->object->setIsSingleline(true);
571 $this->tpl->setOnScreenMessage('info', $this->lng->txt('info_answer_type_change'), true);
572 } else {
573 $this->object->setIsSingleline($types === '0' ? true : false);
574 }
575 if (isset($_POST["thumb_size"])) {
576 $this->object->setThumbSize((int) $_POST["thumb_size"]);
577 }
578 }

References ILIAS\Repository\lng().

Referenced by writePostData().

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

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