ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)
 
 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)
 
 populateJavascriptFilesRequiredForWorkForm (ilTemplate $tpl)
 
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type. More...
 
 getChoiceKeys ()
 Create the key index numbers for the array of choices. More...
 
 getSpecificFeedbackOutput ($userSolution)
 
 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...
 
 getCommand ($cmd)
 
 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 (ilTemplate $tpl)
 
 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...
 
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. 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
 
 $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)
 {} More...
 
 getEditAnswersSingleLine ($checkonly=false)
 Get the single/multiline editing of answers. More...
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 buildEditForm ()
 
- Protected Member Functions inherited from assQuestionGUI
 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)
 
 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_QuestionPreview (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 buildEditForm ()
 

Protected Attributes

 $useEmptySolutionInputChecked = false
 
- Protected Attributes inherited from assQuestionGUI
 $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$

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 public

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

References $id.

36  {
37  parent::__construct();
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  }
if(!array_key_exists('StateId', $_REQUEST)) $id
Class for multiple choice tests.

Member Function Documentation

◆ addBasicQuestionFormProperties()

assMultipleChoiceGUI::addBasicQuestionFormProperties (   $form)

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

References $form.

Referenced by buildEditForm().

137  {
138  parent::addBasicQuestionFormProperties($form);
139  $form->getItemByPostVar('question')->setInitialRteWidth('100');
140  }
if(isset($_POST['submit'])) $form
+ Here is the caller graph for this function:

◆ addchoice()

assMultipleChoiceGUI::addchoice ( )

Add a new answer.

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

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

168  {
169  $this->writePostData(true);
170  $position = key($_POST['cmd']['addchoice']);
171  $this->object->addAnswer("", 0, 0, $position + 1);
172  $this->editQuestion();
173  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
$_POST["username"]
+ Here is the call graph for this function:

◆ aggregateAnswers()

assMultipleChoiceGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)

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

Referenced by getAggregatedAnswersView(), and getAnswersFrequency().

948  {
949  $aggregate = array();
950  foreach ($answers_defined_on_question as $answer) {
951  $aggregated_info_for_answer = array();
952  $aggregated_info_for_answer['answertext'] = $answer->getAnswerText();
953  $aggregated_info_for_answer['count_checked'] = 0;
954 
955  foreach ($relevant_answers_chosen as $relevant_answer) {
956  if ($relevant_answer['value1'] == $answer->getOrder()) {
957  $aggregated_info_for_answer['count_checked']++;
958  }
959  }
960  $aggregated_info_for_answer['count_unchecked'] =
961  ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
962  - $aggregated_info_for_answer['count_checked'];
963 
964  $aggregate[] = $aggregated_info_for_answer;
965  }
966  return $aggregate;
967  }
+ Here is the caller graph for this function:

◆ buildEditForm()

assMultipleChoiceGUI::buildEditForm ( )
protected
Returns
ilPropertyFormGUI

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

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

Referenced by editQuestion(), and writePostData().

1047  {
1048  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1049  $form = new ilPropertyFormGUI();
1050  $form->setFormAction($this->ctrl->getFormAction($this));
1051  $form->setTitle($this->outQuestionType());
1052  $form->setTableWidth("100%");
1053  $form->setId("assmultiplechoice");
1054 
1055  // title, author, description, question, working time (assessment mode)
1061  return $form;
1062  }
This class represents a property form user interface.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
if(isset($_POST['submit'])) $form
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
+ 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.

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

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

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  }
getQuestionTemplate()
get question template
if(isset($_POST['submit'])) $form
getEditAnswersSingleLine($checkonly=false)
Get the single/multiline editing of answers.
$errors
Definition: index.php:6
$_POST["username"]
+ 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 913 of file class.assMultipleChoiceGUI.php.

914  {
915  return array();
916  }

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

928  {
929  return array();
930  }

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

References aggregateAnswers(), and renderAggregateView().

941  {
942  return $this->renderAggregateView(
943  $this->aggregateAnswers($relevant_answers, $this->object->getAnswers())
944  )->get();
945  }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
+ Here is the call graph for this function:

◆ getAnswersFrequency()

assMultipleChoiceGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

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

References aggregateAnswers().

1065  {
1066  $agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());
1067 
1068  $answers = array();
1069 
1070  foreach ($agg as $ans) {
1071  $answers[] = array(
1072  'answer' => $ans['answertext'],
1073  'frequency' => $ans['count_checked']
1074  );
1075  }
1076 
1077  return $answers;
1078  }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
+ 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 744 of file class.assMultipleChoiceGUI.php.

References $choiceKeys.

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

745  {
746  $choiceKeys = array_keys($this->object->answers);
747 
748  if ($this->object->getShuffle()) {
749  $choiceKeys = $this->object->getShuffler()->shuffle($choiceKeys);
750  }
751 
752  return $choiceKeys;
753  }
+ 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.

References $_POST.

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

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  }
$_POST["username"]
+ Here is the caller graph for this function:

◆ getPreview()

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

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

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

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

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

References $index, $keys, $ok, $pass, $template, 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().

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) {
364  if ($this->renderPurposeSupportsFormHtml() || $this->isRenderPurposePrintPdf()) {
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) {
377  if ($this->renderPurposeSupportsFormHtml() || $this->isRenderPurposePrintPdf()) {
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->getQuestion();
389  if ($show_question_text == true) {
390  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
391  }
392  $questionoutput = $template->get();
393  $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
394 
395  if (strlen($feedback)) {
396  $cssClass = (
397  $this->hasCorrectSolution($active_id, $pass) ?
399  );
400 
401  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
402  $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
403  }
404  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
405 
406  $solutionoutput = $solutiontemplate->get();
407 
408  if ($show_feedback && $this->hasInlineFeedback()) {
409  $solutionoutput = $this->buildFocusAnchorHtml() . $solutionoutput;
410  }
411 
412  if (!$show_question_only) {
413  // get page object output
414  $solutionoutput = $this->getILIASPage($solutionoutput);
415  }
416  return $solutionoutput;
417  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
hasCorrectSolution($activeId, $passIndex)
$template
getChoiceKeys()
Create the key index numbers for the array of choices.
$index
Definition: metadata.php:60
$keys
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
getILIASPage($html="")
Returns the ILIAS Page around a question.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
static getHtmlPath($relative_path)
get url of path
getAnswerFeedbackOutput($active_id, $pass)
Returns the answer generic feedback depending on the results of the question.
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assMultipleChoiceGUI::getSpecificFeedbackOutput (   $userSolution)

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

References Sabre\VObject\$output.

756  {
757  // No return value, this question type supports inline specific feedback.
758  $output = "";
759  return $this->object->prepareTextareaOutput($output, true);
760  }

◆ 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

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

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

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

◆ getUseUnchangedAnswerCheckboxHtml()

assMultipleChoiceGUI::getUseUnchangedAnswerCheckboxHtml ( )
protected

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

References assQuestionGUI\$tpl, and isUseEmptySolutionInputChecked().

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

◆ hasInlineFeedback()

assMultipleChoiceGUI::hasInlineFeedback ( )
Returns
bool

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

Referenced by getSolutionOutput().

49  {
50  return $this->object->feedbackOBJ->isSpecificAnswerFeedbackAvailable($this->object->getId());
51  }
+ Here is the caller graph for this function:

◆ isUseEmptySolutionInputChecked()

assMultipleChoiceGUI::isUseEmptySolutionInputChecked ( )

Definition at line 622 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 883 of file class.assMultipleChoiceGUI.php.

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

Referenced by buildEditForm().

884  {
885  // Choices
886  include_once "./Modules/TestQuestionPool/classes/class.ilMultipleChoiceWizardInputGUI.php";
887  $choices = new ilMultipleChoiceWizardInputGUI($this->lng->txt("answers"), "choice");
888  $choices->setRequired(true);
889  $choices->setQuestionObject($this->object);
890  $isSingleline = $this->getEditAnswersSingleLine();
891  $choices->setSingleline($isSingleline);
892  $choices->setAllowMove(false);
893  if ($this->object->getSelfAssessmentEditingMode()) {
894  $choices->setSize(40);
895  }
896  $choices->setMaxLength(800);
897  if ($this->object->getAnswerCount() == 0) {
898  $this->object->addAnswer("", 0, 0, 0);
899  }
900  $choices->setValues($this->object->getAnswers());
901  $form->addItem($choices);
902  }
if(isset($_POST['submit'])) $form
getEditAnswersSingleLine($checkonly=false)
Get the single/multiline editing of answers.
This class represents a multiple choice wizard property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateCorrectionsFormProperties()

assMultipleChoiceGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

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

References ilPropertyFormGUI\addItem(), and ilFormPropertyGUI\setRequired().

1081  {
1082  require_once 'Modules/TestQuestionPool/classes/forms/class.ilAssMultipleChoiceCorrectionsInputGUI.php';
1083  $choices = new ilAssMultipleChoiceCorrectionsInputGUI($this->lng->txt("answers"), "choice");
1084  $choices->setRequired(true);
1085  $choices->setQuestionObject($this->object);
1086  $choices->setValues($this->object->getAnswers());
1087  $form->addItem($choices);
1088  }
addItem($a_item)
Add Item (Property, SectionHeader).
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:

◆ populateJavascriptFilesRequiredForWorkForm()

assMultipleChoiceGUI::populateJavascriptFilesRequiredForWorkForm ( ilTemplate  $tpl)

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

References ilTemplate\addJavaScript().

656  {
657  $tpl->addJavaScript('Modules/TestQuestionPool/js/ilAssMultipleChoice.js');
658  }
addJavaScript($a_js_file, $a_add_version_parameter=true, $a_batch=2)
Add a javascript file that should be included in the header.
+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assMultipleChoiceGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

References ilPropertyFormGUI\addItem(), getEditAnswersSingleLine(), ilFormPropertyGUI\setInfo(), ilFormPropertyGUI\setRequired(), ilNumberInputGUI\setSuffix(), and ilCheckboxInputGUI\setValue().

Referenced by buildEditForm().

824  {
825  // shuffle
826  $shuffle = new ilCheckboxInputGUI($this->lng->txt("shuffle_answers"), "shuffle");
827  $shuffle->setValue(1);
828  $shuffle->setChecked($this->object->getShuffle());
829  $shuffle->setRequired(false);
830  $form->addItem($shuffle);
831 
832  require_once 'Services/Form/classes/class.ilNumberInputGUI.php';
833  $selLim = new ilNumberInputGUI($this->lng->txt('ass_mc_sel_lim_setting'), 'selection_limit');
834  $selLim->setInfo($this->lng->txt('ass_mc_sel_lim_setting_desc'));
835  $selLim->setSize(2);
836  $selLim->setRequired(false);
837  $selLim->allowDecimals(false);
838  $selLim->setMinvalueShouldBeGreater(false);
839  $selLim->setMaxvalueShouldBeLess(false);
840  $selLim->setMinValue(1);
841  $selLim->setMaxValue($this->object->getAnswerCount());
842  $selLim->setValue($this->object->getSelectionLimit());
843  $form->addItem($selLim);
844 
845  if ($this->object->getId()) {
846  $hidden = new ilHiddenInputGUI("", "ID");
847  $hidden->setValue($this->object->getId());
848  $form->addItem($hidden);
849  }
850 
851  $isSingleline = $this->getEditAnswersSingleLine();
852 
853  if (!$this->object->getSelfAssessmentEditingMode()) {
854  // Answer types
855  $types = new ilSelectInputGUI($this->lng->txt("answer_types"), "types");
856  $types->setRequired(false);
857  $types->setValue(($isSingleline) ? 0 : 1);
858  $types->setOptions(
859  array(
860  0 => $this->lng->txt('answers_singleline'),
861  1 => $this->lng->txt('answers_multiline'),
862  )
863  );
864  $form->addItem($types);
865  }
866 
867  if ($isSingleline) {
868  // thumb size
869  $thumb_size = new ilNumberInputGUI($this->lng->txt("thumb_size"), "thumb_size");
870  $thumb_size->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
871  $thumb_size->setMinValue(20);
872  $thumb_size->setDecimals(0);
873  $thumb_size->setSize(6);
874  $thumb_size->setInfo($this->lng->txt('thumb_size_info'));
875  $thumb_size->setValue($this->object->getThumbSize());
876  $thumb_size->setRequired(false);
877  $form->addItem($thumb_size);
878  return $isSingleline;
879  }
880  return $isSingleline;
881  }
This class represents a selection list property in a property form.
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Information Text.
This class represents a hidden form property in a property form.
setSuffix($a_value)
Set suffix.
if(isset($_POST['submit'])) $form
This class represents a number property in a property form.
setValue($a_value)
Set Value.
getEditAnswersSingleLine($checkonly=false)
Get the single/multiline editing of answers.
setRequired($a_required)
Set Required.
+ 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 1001 of file class.assMultipleChoiceGUI.php.

References $template.

Referenced by getPreview(), and getTestOutput().

1002  {
1003  if ($this->object->getSpecificFeedbackSetting() == 2) {
1004  foreach ($user_solution as $mc_solution) {
1005  if (strcmp($mc_solution, $answer_id) == 0) {
1006  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
1007  if (strlen($fb)) {
1008  $template->setCurrentBlock("feedback");
1009  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
1010  $template->parseCurrentBlock();
1011  }
1012  }
1013  }
1014  }
1015 
1016  if ($this->object->getSpecificFeedbackSetting() == 1) {
1017  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
1018  if (strlen($fb)) {
1019  $template->setCurrentBlock("feedback");
1020  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
1021  $template->parseCurrentBlock();
1022  }
1023  }
1024 
1025  if ($this->object->getSpecificFeedbackSetting() == 3) {
1026  $answer = $this->object->getAnswer($answer_id);
1027 
1028  if ($answer->getPoints() > 0) {
1029  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
1030  if (strlen($fb)) {
1031  $template->setCurrentBlock("feedback");
1032  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
1033  $template->parseCurrentBlock();
1034  }
1035  }
1036  }
1037  }
$template
+ Here is the caller graph for this function:

◆ removechoice()

assMultipleChoiceGUI::removechoice ( )

Remove an answer.

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

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

179  {
180  $this->writePostData(true);
181  $position = key($_POST['cmd']['removechoice']);
182  $this->object->deleteAnswer($position);
183  $this->editQuestion();
184  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
$_POST["username"]
+ Here is the call graph for this function:

◆ removeimagechoice()

assMultipleChoiceGUI::removeimagechoice ( )

Remove an image.

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

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

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  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
$filename
Definition: buildRTE.php:89
$_POST["username"]
+ Here is the call graph for this function:

◆ renderAggregateView()

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

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

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

975  {
976  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
977 
978  $tpl->setCurrentBlock('headercell');
979  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
980  $tpl->parseCurrentBlock();
981 
982  $tpl->setCurrentBlock('headercell');
983  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
984  $tpl->parseCurrentBlock();
985 
986  foreach ($aggregate as $line_data) {
987  $tpl->setCurrentBlock('aggregaterow');
988  $tpl->setVariable('OPTION', $line_data['answertext']);
989  $tpl->setVariable('COUNT', $line_data['count_checked']);
990  $tpl->parseCurrentBlock();
991  }
992  return $tpl;
993  }
special template class to simplify handling of ITX/PEAR
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

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

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

References $index, and ilPropertyFormGUI\getInput().

1094  {
1095  $pointsChecked = $form->getInput('choice')['points'];
1096  $pointsUnchecked = $form->getInput('choice')['points_unchecked'];
1097 
1098  foreach ($this->object->getAnswers() as $index => $answer) {
1099  /* @var ASS_AnswerMultipleResponseImage $answer */
1100  $answer->setPointsChecked((float) $pointsChecked[$index]);
1101  $answer->setPointsUnchecked((float) $pointsUnchecked[$index]);
1102  }
1103  }
$index
Definition: metadata.php:60
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
+ Here is the call graph for this function:

◆ setQuestionTabs()

assMultipleChoiceGUI::setQuestionTabs ( )

Sets the ILIAS tabs for this question type.

Todo:
: MOVE THIS STEPS TO COMMON QUESTION CLASS assQuestionGUI

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

References $_GET, $DIC, $url, assQuestionGUI\addBackTab(), assQuestionGUI\addTab_QuestionFeedback(), assQuestionGUI\addTab_QuestionHints(), assQuestionGUI\addTab_QuestionPreview(), and assQuestionGUI\addTab_SuggestedSolution().

666  {
667  global $DIC;
668  $rbacsystem = $DIC['rbacsystem'];
669  $ilTabs = $DIC['ilTabs'];
670 
671  $ilTabs->clearTargets();
672 
673  $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
674  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
675  $q_type = $this->object->getQuestionType();
676 
677  if (strlen($q_type)) {
678  $classname = $q_type . "GUI";
679  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
680  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
681  }
682 
683  if ($_GET["q_id"]) {
684  if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
685  // edit page
686  $ilTabs->addTarget(
687  "edit_page",
688  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
689  array("edit", "insert", "exec_pg"),
690  "",
691  "",
692  $force_active
693  );
694  }
695 
696  $this->addTab_QuestionPreview($ilTabs);
697  }
698  $force_active = false;
699  if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
700  $url = "";
701  if ($classname) {
702  $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
703  }
704  $force_active = false;
705  // edit question properties
706  $ilTabs->addTarget(
707  "edit_question",
708  $url,
709  array("editQuestion", "save", "saveEdit", "addchoice", "removechoice", "removeimagechoice", "uploadchoice", "originalSyncForm"),
710  $classname,
711  "",
712  $force_active
713  );
714  }
715 
716  // add tab for question feedback within common class assQuestionGUI
717  $this->addTab_QuestionFeedback($ilTabs);
718 
719  // add tab for question hint within common class assQuestionGUI
720  $this->addTab_QuestionHints($ilTabs);
721 
722  // add tab for question's suggested solution within common class assQuestionGUI
723  $this->addTab_SuggestedSolution($ilTabs, $classname);
724 
725  // Assessment of questions sub menu entry
726  if ($_GET["q_id"]) {
727  $ilTabs->addTarget(
728  "statistics",
729  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
730  array("assessment"),
731  $classname,
732  ""
733  );
734  }
735 
736  $this->addBackTab($ilTabs);
737  }
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
global $DIC
Definition: saml.php:7
$_GET["client_id"]
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBackTab(ilTabsGUI $ilTabs)
$url
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
+ Here is the call graph for this function:

◆ setUseEmptySolutionInputChecked()

assMultipleChoiceGUI::setUseEmptySolutionInputChecked (   $useEmptySolutionInputChecked)

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

References $useEmptySolutionInputChecked.

Referenced by getTestOutput().

628  {
629  $this->useEmptySolutionInputChecked = $useEmptySolutionInputChecked;
630  }
+ 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

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.

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

146  {
147  $this->writePostData(true);
148  $position = key($_POST['cmd']['uploadchoice']);
149  $this->editQuestion();
150  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
$_POST["username"]
+ 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 779 of file class.assMultipleChoiceGUI.php.

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

Referenced by writePostData().

780  {
781  // Delete all existing answers and create new answers from the form data
782  $this->object->flushAnswers();
783  if ($this->object->isSingleline) {
784  foreach ($_POST['choice']['answer'] as $index => $answertext) {
785  $answertext = ilUtil::secureString($answertext);
786 
787  $picturefile = $_POST['choice']['imagename'][$index];
788  $file_org_name = $_FILES['choice']['name']['image'][$index];
789  $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index];
790 
791  if (strlen($file_temp_name)) {
792  // check suffix
793  $suffix = strtolower(array_pop(explode(".", $file_org_name)));
794  if (in_array($suffix, array( "jpg", "jpeg", "png", "gif" ))) {
795  // upload image
796  $filename = $this->object->buildHashedImageFilename($file_org_name);
797  if ($this->object->setImageFile($filename, $file_temp_name) == 0) {
798  $picturefile = $filename;
799  }
800  }
801  }
802  $this->object->addAnswer(
803  $answertext,
804  $_POST['choice']['points'][$index],
805  $_POST['choice']['points_unchecked'][$index],
806  $index,
807  $picturefile
808  );
809  }
810  } else {
811  foreach ($_POST['choice']['answer'] as $index => $answer) {
812  $answertext = $answer;
813  $this->object->addAnswer(
814  $answertext,
815  $_POST['choice']['points'][$index],
816  $_POST['choice']['points_unchecked'][$index],
817  $index
818  );
819  }
820  }
821  }
$index
Definition: metadata.php:60
$filename
Definition: buildRTE.php:89
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

assMultipleChoiceGUI::writePostData (   $always = false)
protected

{}

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

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

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

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';
66  $this->saveTaxonomyAssignments();
67  return 0;
68  }
69  return 1;
70  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
if(isset($_POST['submit'])) $form
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.
+ 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 762 of file class.assMultipleChoiceGUI.php.

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

Referenced by writePostData().

763  {
764  $this->object->setShuffle($_POST["shuffle"]);
765 
766  $selectionLimit = (int) $form->getItemByPostVar('selection_limit')->getValue();
767  $this->object->setSelectionLimit($selectionLimit > 0 ? $selectionLimit : null);
768 
769  $this->object->setMultilineAnswerSetting($_POST["types"]);
770  if (is_array($_POST['choice']['imagename']) && $_POST["types"] == 1) {
771  $this->object->isSingleline = true;
772  ilUtil::sendInfo($this->lng->txt('info_answer_type_change'), true);
773  } else {
774  $this->object->isSingleline = ($_POST["types"] == 0) ? true : false;
775  }
776  $this->object->setThumbSize((strlen($_POST["thumb_size"])) ? $_POST["thumb_size"] : "");
777  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_POST["username"]
+ 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: