ILIAS  release_7 Revision v7.30-3-g800a261c036
assMultipleChoiceGUI Class Reference

Multiple choice question GUI representation. More...

+ Inheritance diagram for assMultipleChoiceGUI:
+ Collaboration diagram for assMultipleChoiceGUI:

Public Member Functions

 __construct ($id=-1)
 assMultipleChoiceGUI constructor More...
 
 hasInlineFeedback ()
 
 editQuestion ($checkonly=false)
 Creates an output of the edit form for the question. More...
 
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time. More...
 
 uploadchoice ()
 Upload an image. More...
 
 removeimagechoice ()
 Remove an image. More...
 
 addchoice ()
 Add a new answer. More...
 
 removechoice ()
 Remove an answer. More...
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() More...
 
 getSolutionOutput ( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
 Get the question solution output. More...
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 getTestOutput ( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
 
 isUseEmptySolutionInputChecked ()
 
 setUseEmptySolutionInputChecked ($useEmptySolutionInputChecked)
 
 getPresentationJavascripts ()
 
 getChoiceKeys ()
 Create the key index numbers for the array of choices. More...
 
 getSpecificFeedbackOutput ($userSolution)
 Returns the answer specific feedback for the question. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 
 populateAnswerSpecificFormPart (\ilPropertyFormGUI $form)
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAggregatedAnswersView ($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
 __construct ()
 assQuestionGUI constructor More...
 
 hasInlineFeedback ()
 this method can be overwritten per question type More...
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getNotesHTML ()
 
 executeCommand ()
 execute command More...
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext ($presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled ($previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose ($renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext ($editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI ($navigationGUI)
 
 setTaxonomyIds ($taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd ($questionActionCmd)
 
 getQuestionActionCmd ()
 
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation. More...
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 get question template More...
 
 getILIASPage ($html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 output question page More...
 
 cancel ()
 cancel action More...
 
 originalSyncForm ($return_to="", $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 save question More...
 
 save ()
 save question More...
 
 saveReturn ()
 save question More...
 
 apply ()
 apply changes More...
 
 getContextPath ($cont_obj, $a_endnode_id, $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber ($nr)
 
 getSequenceNumber ()
 
 setQuestionCount ($a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage ($errormessage)
 
 addErrorMessage ($errormessage)
 
 outAdditionalOutput ()
 
 getQuestionType ()
 Returns the question type string. More...
 
 getAsValueAttribute ($a_value)
 Returns a HTML value attribute. More...
 
 addNewIdListener (&$a_object, $a_method, $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners ($a_new_id)
 Call the new id listeners. More...
 
 addQuestionFormCommandButtons ($form)
 Add the command buttons of a question properties form. More...
 
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time. More...
 
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question. More...
 
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput ($userSolution)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 showSuggestedSolution ()
 
 suggestedsolution ()
 Allows to add suggested solutions for questions. More...
 
 outSolutionExplorer ()
 
 saveSuggestedSolution ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, $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)
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() More...
 
 hasIntermediateSolution ($activeId, $passIndex)
 Check if the question has an intermediate solution. More...
 
 setUseIntermediateSolution ($use)
 
 getUseIntermediateSolution ()
 Get if intermediate solution should be used for solution output. More...
 
 isAutosaveable ()
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 outQuestionForTest ( $formaction, $active_id, $pass, $is_question_postponed=false, $user_post_solutions=false, $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession ($previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFreuqencyStatisticSupported ()
 
 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 ($relevant_answers)
 Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface. More...
 
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 

Data Fields

 $choiceKeys
 
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
 $object
 
 $tpl
 
 $lng
 
 $error
 
 $errormessage
 
 $request
 
 $sequence_no
 sequence number in test More...
 
 $question_count
 question count in test More...
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 

Protected Member Functions

 writePostData ($always=false)
 {Evaluates a posted edit form and writes the form data in the question object.
Returns
integer A positive value, if one of the required fields wasn't set, else 0
} More...
 
 getEditAnswersSingleLine ($checkonly=false)
 Get the single/multiline editing of answers. More...
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 buildEditForm ()
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm ($form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 setDefaultTabs (ilTabsGUI $ilTabs)
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI More...
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI More...
 
 addTab_Question (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 addSaveOnEnterOnLoadCode ()
 

Protected Attributes

 $useEmptySolutionInputChecked = false
 
- Protected Attributes inherited from assQuestionGUI
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
 $ctrl
 
 $editForm
 
 $use_intermediate_solution = false
 

Private Member Functions

 populateSpecificFeedbackInline ($user_solution, $answer_id, $template)
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants ($guiClassName, $cmdConstantNameBegin='CMD_')
 extracts values of all constants of given class with given prefix as array can be used to get all possible commands in case of these commands are defined as constants More...
 

Detailed Description

Multiple choice question GUI representation.

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

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

@ilCtrl_Calls assMultipleChoiceGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

assMultipleChoiceGUI::__construct (   $id = -1)

assMultipleChoiceGUI constructor

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

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

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

36 {
38 include_once "./Modules/TestQuestionPool/classes/class.assMultipleChoice.php";
39 $this->object = new assMultipleChoice();
40 if ($id >= 0) {
41 $this->object->loadFromDb($id);
42 }
43 }
Class for multiple choice tests.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ addBasicQuestionFormProperties()

assMultipleChoiceGUI::addBasicQuestionFormProperties (   $form)

Add basic question form properties: assessment: title, author, description, question, working time.

Returns
int Default Nr of Tries

Reimplemented from assQuestionGUI.

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

137 {
138 parent::addBasicQuestionFormProperties($form);
139 $form->getItemByPostVar('question')->setInitialRteWidth('100');
140 }

Referenced by buildEditForm().

+ Here is the caller graph for this function:

◆ addchoice()

assMultipleChoiceGUI::addchoice ( )

Add a new answer.

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

168 {
169 $this->writePostData(true);
170 $position = key($_POST['cmd']['addchoice']);
171 $this->object->addAnswer("", 0, 0, $position + 1);
172 $this->editQuestion();
173 }
$_POST["username"]
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writePostData($always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...

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

+ Here is the call graph for this function:

◆ aggregateAnswers()

assMultipleChoiceGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)

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

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

Referenced by getAggregatedAnswersView(), and getAnswersFrequency().

+ Here is the caller graph for this function:

◆ buildEditForm()

assMultipleChoiceGUI::buildEditForm ( )
protected
Returns
ilPropertyFormGUI

Reimplemented from assQuestionGUI.

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

979 {
980 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
981 $form = new ilPropertyFormGUI();
982 $form->setFormAction($this->ctrl->getFormAction($this));
983 $form->setTitle($this->outQuestionType());
984 $form->setTableWidth("100%");
985 $form->setId("assmultiplechoice");
986
987 // title, author, description, question, working time (assessment mode)
988 $this->addBasicQuestionFormProperties($form);
990 $this->populateAnswerSpecificFormPart($form);
991 $this->populateTaxonomyFormSection($form);
992 $this->addQuestionFormCommandButtons($form);
993 return $form;
994 }
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question,...
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
This class represents a property form user interface.

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

Referenced by editQuestion(), and writePostData().

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

◆ editQuestion()

assMultipleChoiceGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

Parameters
bool$checkonly
Returns
bool

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

104 {
105 $save = $this->isSaveCommand();
106 $this->getQuestionTemplate();
107
108 $form = $this->buildEditForm();
109
110 $isSingleline = $this->getEditAnswersSingleLine($checkonly);
111 if ($isSingleline) {
112 $form->setMultipart(true);
113 } else {
114 $form->setMultipart(false);
115 }
116
117 $errors = false;
118
119 if ($save) {
120 $form->getItemByPostVar('selection_limit')->setMaxValue(count((array) $_POST['choice']['answer']));
121
122 $form->setValuesByPost();
123 $errors = !$form->checkInput();
124 $form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
125 if ($errors) {
126 $checkonly = false;
127 }
128 }
129
130 if (!$checkonly) {
131 $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
132 }
133 return $errors;
134 }
getEditAnswersSingleLine($checkonly=false)
Get the single/multiline editing of answers.
getQuestionTemplate()
get question template
$errors
Definition: imgupload.php:49

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

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

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

◆ getAfterParticipationSuppressionAnswerPostVars()

assMultipleChoiceGUI::getAfterParticipationSuppressionAnswerPostVars ( )

Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.

The form elements will be shown disabled, so the users see the usual form but can only edit the settings, which make sense in the given context.

E.g. array('cloze_type', 'image_filename')

Returns
string[]

Implements ilGuiAnswerScoringAdjustable.

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

846 {
847 return array();
848 }

◆ getAfterParticipationSuppressionQuestionPostVars()

assMultipleChoiceGUI::getAfterParticipationSuppressionQuestionPostVars ( )

Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.

The form elements will be shown disabled, so the users see the usual form but can only edit the settings, which make sense in the given context.

E.g. array('cloze_type', 'image_filename')

Returns
string[]

Implements ilGuiQuestionScoringAdjustable.

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

860 {
861 return array();
862 }

◆ getAggregatedAnswersView()

assMultipleChoiceGUI::getAggregatedAnswersView (   $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 872 of file class.assMultipleChoiceGUI.php.

873 {
874 return $this->renderAggregateView(
875 $this->aggregateAnswers($relevant_answers, $this->object->getAnswers())
876 )->get();
877 }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)

References aggregateAnswers(), and renderAggregateView().

+ Here is the call graph for this function:

◆ getAnswersFrequency()

assMultipleChoiceGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

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

997 {
998 $agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());
999
1000 $answers = array();
1001
1002 foreach ($agg as $ans) {
1003 $answers[] = array(
1004 'answer' => $ans['answertext'],
1005 'frequency' => $ans['count_checked']
1006 );
1007 }
1008
1009 return $answers;
1010 }

References aggregateAnswers().

+ Here is the call graph for this function:

◆ getChoiceKeys()

assMultipleChoiceGUI::getChoiceKeys ( )

Create the key index numbers for the array of choices.

Returns
array

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

667 {
668 $choiceKeys = array_keys($this->object->answers);
669
670 if ($this->object->getShuffle()) {
671 $choiceKeys = $this->object->getShuffler()->shuffle($choiceKeys);
672 }
673
674 return $choiceKeys;
675 }

References $choiceKeys.

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

+ Here is the caller graph for this function:

◆ getEditAnswersSingleLine()

assMultipleChoiceGUI::getEditAnswersSingleLine (   $checkonly = false)
protected

Get the single/multiline editing of answers.

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

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

80 {
81 if ($checkonly) {
82 // form posting is checked
83 return ($_POST['types'] == 0) ? true : false;
84 }
85
86 $lastChange = $this->object->getLastChange();
87 if (empty($lastChange) && !isset($_POST['types'])) {
88 // a new question is edited
89 return $this->object->getMultilineAnswerSetting() ? false : true;
90 } else {
91 // a saved question is edited
92 return $this->object->isSingleline;
93 }
94 }
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.

References $_POST, and true.

Referenced by editQuestion(), populateAnswerSpecificFormPart(), and populateQuestionSpecificFormPart().

+ Here is the caller graph for this function:

◆ getPresentationJavascripts()

assMultipleChoiceGUI::getPresentationJavascripts ( )

Reimplemented from assQuestionGUI.

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

657 {
658 return array('Modules/TestQuestionPool/js/ilAssMultipleChoice.js');
659 }

◆ getPreview()

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

Reimplemented from assQuestionGUI.

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

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

References $keys, $type, assQuestionGUI\buildFocusAnchorHtml(), getChoiceKeys(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), assQuestionGUI\getPreviewSession(), hasInlineFeedback(), populateSpecificFeedbackInline(), and ilUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ getSolutionOutput()

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

Get the question solution output.

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

Reimplemented from assQuestionGUI.

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

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

References $index, $keys, $ok, $pass, assQuestionGUI\buildFocusAnchorHtml(), ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, assQuestionGUI\getAnswerFeedbackOutput(), getChoiceKeys(), ilUtil\getHtmlPath(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), assQuestionGUI\getUseIntermediateSolution(), assQuestionGUI\hasCorrectSolution(), hasInlineFeedback(), assQuestionGUI\isRenderPurposePrintPdf(), assQuestionGUI\isTestPresentationContext(), ilUtil\prepareFormOutput(), and assQuestionGUI\renderPurposeSupportsFormHtml().

+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assMultipleChoiceGUI::getSpecificFeedbackOutput (   $userSolution)

Returns the answer specific feedback for the question.

This method should be overwritten by the actual question.

Todo:
Mark this method abstract!
Parameters
array$userSolution($userSolution[<value1>] = <value2>)
Returns
string HTML Code with the answer specific feedback @access public

Reimplemented from assQuestionGUI.

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

678 {
679 // No return value, this question type supports inline specific feedback.
680 $output = "";
681 return $this->object->prepareTextareaOutput($output, true);
682 }

◆ getTestOutput()

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

Reimplemented from assQuestionGUI.

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

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

References $keys, $pass, $type, getChoiceKeys(), ilUtil\getImagePath(), assQuestionGUI\outQuestionPage(), populateSpecificFeedbackInline(), ilUtil\prepareFormOutput(), and setUseEmptySolutionInputChecked().

+ Here is the call graph for this function:

◆ getUseUnchangedAnswerCheckboxHtml()

assMultipleChoiceGUI::getUseUnchangedAnswerCheckboxHtml ( )
protected

Reimplemented from assQuestionGUI.

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

634 {
635 // hey: prevPassSolutions - use abstracted template to share with other purposes of this kind
636 $this->tpl->addJavaScript('Modules/TestQuestionPool/js/ilAssMultipleChoice.js');
637
638 $tpl = new ilTemplate('tpl.tst_question_additional_behaviour_checkbox.html', true, true, 'Modules/TestQuestionPool');
639
640 // HEY: affects next if (!) /// noneAboveChecked repaired but disabled because the checked input ..
641 if (false) { // .. makes the qstEditController initialize the "edit" instead of the "answered" state
642 if ($this->isUseEmptySolutionInputChecked()) {
643 $tpl->setCurrentBlock('checked');
644 $tpl->touchBlock('checked');
645 $tpl->parseCurrentBlock();
646 }
647 }
648
649 $tpl->setCurrentBlock('checkbox');
650 $tpl->setVariable('TXT_FORCE_FORM_DIFF_LABEL', $this->object->getTestPresentationConfig()->getUseUnchangedAnswerLabel());
651 $tpl->parseCurrentBlock();
652 // hey.
653 return $tpl->get();
654 }

References assQuestionGUI\$tpl, and isUseEmptySolutionInputChecked().

+ Here is the call graph for this function:

◆ hasInlineFeedback()

assMultipleChoiceGUI::hasInlineFeedback ( )
Returns
bool

Reimplemented from assQuestionGUI.

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

49 {
50 return $this->object->feedbackOBJ->isSpecificAnswerFeedbackAvailable($this->object->getId());
51 }

Referenced by getPreview(), and getSolutionOutput().

+ Here is the caller graph for this function:

◆ isUseEmptySolutionInputChecked()

assMultipleChoiceGUI::isUseEmptySolutionInputChecked ( )

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

References $useEmptySolutionInputChecked.

Referenced by getUseUnchangedAnswerCheckboxHtml().

+ Here is the caller graph for this function:

◆ populateAnswerSpecificFormPart()

assMultipleChoiceGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

810 {
811 // Choices
812 include_once "./Modules/TestQuestionPool/classes/class.ilMultipleChoiceWizardInputGUI.php";
813 $choices = new ilMultipleChoiceWizardInputGUI($this->lng->txt("answers"), "choice");
814 $choices->setRequired(true);
815 $choices->setQuestionObject($this->object);
816 $isSingleline = $this->getEditAnswersSingleLine();
817 $choices->setSingleline($isSingleline);
818 $choices->setAllowMove(false);
819 if ($this->object->getSelfAssessmentEditingMode()) {
820 $choices->setSize(40);
821 }
822 $choices->setMaxLength(800);
823 if ($this->object->getAnswerCount() == 0) {
824 $this->object->addAnswer("", 0, 0, 0);
825 }
826 $choices->setValues(array_map(
827 function (ASS_AnswerMultipleResponseImage $value) {
828 $value->setAnswerText(html_entity_decode($value->getAnswerText()));
829 return $value;
830 },
831 $this->object->getAnswers()
832 ));
833 $form->addItem($choices);
834 }
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked,...
This class represents a multiple choice wizard property in a property form.

References ilPropertyFormGUI\addItem(), and getEditAnswersSingleLine().

Referenced by buildEditForm().

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

◆ populateCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

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

1013 {
1014 require_once 'Modules/TestQuestionPool/classes/forms/class.ilAssMultipleChoiceCorrectionsInputGUI.php';
1015 $choices = new ilAssMultipleChoiceCorrectionsInputGUI($this->lng->txt("answers"), "choice");
1016 $choices->setRequired(true);
1017 $choices->setQuestionObject($this->object);
1018 $choices->setValues($this->object->getAnswers());
1019 $form->addItem($choices);
1020 }
addItem($a_item)
Add Item (Property, SectionHeader).

References ilPropertyFormGUI\addItem().

+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assMultipleChoiceGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

References ilPropertyFormGUI\addItem(), and getEditAnswersSingleLine().

Referenced by buildEditForm().

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

◆ populateSpecificFeedbackInline()

assMultipleChoiceGUI::populateSpecificFeedbackInline (   $user_solution,
  $answer_id,
  $template 
)
private
Parameters
$user_solution
$answer_id
$template
Returns
array

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

934 {
935 if ($this->object->getSpecificFeedbackSetting() == 2) {
936 foreach ($user_solution as $mc_solution) {
937 if (strcmp($mc_solution, $answer_id) == 0) {
938 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
939 if (strlen($fb)) {
940 $template->setCurrentBlock("feedback");
941 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
942 $template->parseCurrentBlock();
943 }
944 }
945 }
946 }
947
948 if ($this->object->getSpecificFeedbackSetting() == 1) {
949 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
950 if (strlen($fb)) {
951 $template->setCurrentBlock("feedback");
952 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
953 $template->parseCurrentBlock();
954 }
955 }
956
957 if ($this->object->getSpecificFeedbackSetting() == 3) {
958 $answer = $this->object->getAnswer($answer_id);
959
960 if ($answer->getPoints() > 0) {
961 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
962 if (strlen($fb)) {
963 $template->setCurrentBlock("feedback");
964 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
965 $template->parseCurrentBlock();
966 }
967 }
968 }
969 }

Referenced by getPreview(), and getTestOutput().

+ Here is the caller graph for this function:

◆ removechoice()

assMultipleChoiceGUI::removechoice ( )

Remove an answer.

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

179 {
180 $this->writePostData(true);
181 $position = key($_POST['cmd']['removechoice']);
182 $this->object->deleteAnswer($position);
183 $this->editQuestion();
184 }

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

+ Here is the call graph for this function:

◆ removeimagechoice()

assMultipleChoiceGUI::removeimagechoice ( )

Remove an image.

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

156 {
157 $this->writePostData(true);
158 $position = key($_POST['cmd']['removeimagechoice']);
159 $filename = $_POST['choice']['imagename'][$position];
160 $this->object->removeAnswerImage($position);
161 $this->editQuestion();
162 }
$filename
Definition: buildRTE.php:89

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

+ Here is the call graph for this function:

◆ renderAggregateView()

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

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

907 {
908 $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
909
910 $tpl->setCurrentBlock('headercell');
911 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
912 $tpl->parseCurrentBlock();
913
914 $tpl->setCurrentBlock('headercell');
915 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
916 $tpl->parseCurrentBlock();
917
918 foreach ($aggregate as $line_data) {
919 $tpl->setCurrentBlock('aggregaterow');
920 $tpl->setVariable('OPTION', $line_data['answertext']);
921 $tpl->setVariable('COUNT', $line_data['count_checked']);
922 $tpl->parseCurrentBlock();
923 }
924 return $tpl;
925 }

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

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

1026 {
1027 $pointsChecked = $form->getInput('choice')['points'];
1028 $pointsUnchecked = $form->getInput('choice')['points_unchecked'];
1029
1030 foreach ($this->object->getAnswers() as $index => $answer) {
1031 /* @var ASS_AnswerMultipleResponseImage $answer */
1032 $answer->setPointsChecked((float) $pointsChecked[$index]);
1033 $answer->setPointsUnchecked((float) $pointsUnchecked[$index]);
1034 }
1035 }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.

References $index, and ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ setUseEmptySolutionInputChecked()

assMultipleChoiceGUI::setUseEmptySolutionInputChecked (   $useEmptySolutionInputChecked)

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

629 {
630 $this->useEmptySolutionInputChecked = $useEmptySolutionInputChecked;
631 }

References $useEmptySolutionInputChecked.

Referenced by getTestOutput().

+ Here is the caller graph for this function:

◆ supportsIntermediateSolutionOutput()

assMultipleChoiceGUI::supportsIntermediateSolutionOutput ( )

Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution()

Returns
bool

Reimplemented from assQuestionGUI.

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

192 {
193 return true;
194 }

◆ uploadchoice()

assMultipleChoiceGUI::uploadchoice ( )

Upload an image.

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

146 {
147 $this->writePostData(true);
148 $position = key($_POST['cmd']['uploadchoice']);
149 $this->editQuestion();
150 }

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

+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assMultipleChoiceGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Parameters
bool$alwaysIf true, a check for form validity is omitted.
Returns
void

Implements ilGuiAnswerScoringAdjustable.

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

704 {
705 // Delete all existing answers and create new answers from the form data
706 $this->object->flushAnswers();
707 if ($this->object->isSingleline) {
708 foreach ($_POST['choice']['answer'] as $index => $answertext) {
709 $answertext = ilUtil::secureString(htmlentities($answertext));
710 $picturefile = $_POST['choice']['imagename'][$index];
711 $file_org_name = $_FILES['choice']['name']['image'][$index];
712 $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index];
713
714 if (strlen($file_temp_name)) {
715 // check suffix
716 $suffix = strtolower(array_pop(explode(".", $file_org_name)));
717 if (in_array($suffix, array( "jpg", "jpeg", "png", "gif" ))) {
718 // upload image
719 $filename = $this->object->buildHashedImageFilename($file_org_name);
720 if ($this->object->setImageFile($filename, $file_temp_name) == 0) {
721 $picturefile = $filename;
722 }
723 }
724 }
725 $this->object->addAnswer(
726 $answertext,
727 $_POST['choice']['points'][$index],
728 $_POST['choice']['points_unchecked'][$index],
729 $index,
730 $picturefile,
731 $_POST['choice']['answer_id'][$index]
732 );
733 }
734 } else {
735 foreach ($_POST['choice']['answer'] as $index => $answer) {
736 $answertext = $answer;
737 $this->object->addAnswer(
738 $answertext,
739 $_POST['choice']['points'][$index],
740 $_POST['choice']['points_unchecked'][$index],
741 $index,
742 "",
743 $_POST['choice']['answer_id'][$index]
744 );
745 }
746 }
747 }
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.

References $_POST, $filename, $index, and ilUtil\secureString().

Referenced by writePostData().

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

◆ writePostData()

assMultipleChoiceGUI::writePostData (   $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 56 of file class.assMultipleChoiceGUI.php.

57 {
58 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
59 if (!$hasErrors) {
60 $form = $this->buildEditForm();
61 $form->setValuesByPost();
62 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
65 $this->writeAnswerSpecificPostData($form);
67 return 0;
68 }
69 return 1;
70 }
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 buildEditForm(), 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()

assMultipleChoiceGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Parameters
bool$alwaysIf true, a check for form validity is omitted.
Returns
void

Implements ilGuiQuestionScoringAdjustable.

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

685 {
686 $this->object->setShuffle($_POST["shuffle"]);
687
688 $selectionLimit = (int) $form->getItemByPostVar('selection_limit')->getValue();
689 $this->object->setSelectionLimit($selectionLimit > 0 ? $selectionLimit : null);
690
691 $this->object->setSpecificFeedbackSetting($_POST['feedback_setting']);
692
693 $this->object->setMultilineAnswerSetting($_POST["types"]);
694 if (is_array($_POST['choice']['imagename']) && $_POST["types"] == 1) {
695 $this->object->isSingleline = true;
696 ilUtil::sendInfo($this->lng->txt('info_answer_type_change'), true);
697 } else {
698 $this->object->isSingleline = ($_POST["types"] == 0) ? true : false;
699 }
700 $this->object->setThumbSize((strlen($_POST["thumb_size"])) ? $_POST["thumb_size"] : "");
701 }
getItemByPostVar($a_post_var)
Get Item by POST variable.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $_POST, ilPropertyFormGUI\getItemByPostVar(), and ilUtil\sendInfo().

Referenced by writePostData().

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

Field Documentation

◆ $choiceKeys

assMultipleChoiceGUI::$choiceKeys

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

Referenced by getChoiceKeys().

◆ $useEmptySolutionInputChecked

assMultipleChoiceGUI::$useEmptySolutionInputChecked = false
protected

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