ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assSingleChoiceGUI Class Reference

Single choice question GUI representation. More...

+ Inheritance diagram for assSingleChoiceGUI:
+ Collaboration diagram for assSingleChoiceGUI:

Public Member Functions

 __construct ($id=-1)
 assSingleChoiceGUI constructor More...
 
 hasInlineFeedback ()
 
 editQuestion ($checkonly=false)
 Creates an output of the edit form for the question. More...
 
 uploadchoice ()
 Upload an image. More...
 
 removeimagechoice ()
 Remove an image. More...
 
 addchoice ()
 Add a new answer. More...
 
 removechoice ()
 Remove an answer. More...
 
 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)
 
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type. More...
 
 getChoiceKeys ()
 
 getSpecificFeedbackOutput ($userSolution)
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 populateAnswerSpecificFormPart (\ilPropertyFormGUI $form)
 
 getAfterParticipationSuppressionAnswerPostVars ()
 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...
 

Protected Member Functions

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

Private Member Functions

 populateInlineFeedback ($template, $answer_id, $user_solution)
 

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...
 
- 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 Attributes inherited from assQuestionGUI
 $editForm
 
 $use_intermediate_solution = false
 

Detailed Description

Single choice question GUI representation.

The assSingleChoiceGUI class encapsulates the GUI representation for single choice questions.

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

assSingleChoiceGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

assSingleChoiceGUI::__construct (   $id = -1)

assSingleChoiceGUI constructor

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

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

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

References $id.

33  {
34  parent::__construct();
35  include_once "./Modules/TestQuestionPool/classes/class.assSingleChoice.php";
36  $this->object = new assSingleChoice();
37  if ($id >= 0) {
38  $this->object->loadFromDb($id);
39  }
40  }
if(!array_key_exists('StateId', $_REQUEST)) $id
Class for single choice questions.

Member Function Documentation

◆ addchoice()

assSingleChoiceGUI::addchoice ( )

Add a new answer.

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

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

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

◆ aggregateAnswers()

assSingleChoiceGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)

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

Referenced by getAggregatedAnswersView(), and getAnswersFrequency().

794  {
795  $aggregate = array();
796  foreach ($answers_defined_on_question as $answer) {
797  $aggregated_info_for_answer = array();
798  $aggregated_info_for_answer['answertext'] = $answer->getAnswerText();
799  $aggregated_info_for_answer['count_checked'] = 0;
800 
801  foreach ($relevant_answers_chosen as $relevant_answer) {
802  if ($relevant_answer['value1'] == $answer->getOrder()) {
803  $aggregated_info_for_answer['count_checked']++;
804  }
805  }
806  $aggregated_info_for_answer['count_unchecked'] =
807  ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
808  - $aggregated_info_for_answer['count_checked'];
809 
810  $aggregate[] = $aggregated_info_for_answer;
811  }
812  return $aggregate;
813  }
+ Here is the caller graph for this function:

◆ editQuestion()

assSingleChoiceGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

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

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

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

96  {
97  $save = $this->isSaveCommand();
98  $this->getQuestionTemplate();
99 
100  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
101  $form = new ilPropertyFormGUI();
102  $this->editForm = $form;
103 
104  $form->setFormAction($this->ctrl->getFormAction($this));
105  $form->setTitle($this->outQuestionType());
106  $isSingleline = $this->getEditAnswersSingleLine($checkonly);
107  if ($isSingleline) {
108  $form->setMultipart(true);
109  } else {
110  $form->setMultipart(false);
111  }
112  $form->setTableWidth("100%");
113  $form->setId("asssinglechoice");
114 
118 
119 
121 
123 
124  $errors = false;
125 
126  if ($save) {
127  $form->setValuesByPost();
128  $errors = !$form->checkInput();
129  $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
130  if ($errors) {
131  $checkonly = false;
132  }
133  }
134 
135  if (!$checkonly) {
136  $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
137  }
138  return $errors;
139  }
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
This class represents a property form user interface.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
getQuestionTemplate()
get question template
populateTaxonomyFormSection(ilPropertyFormGUI $form)
if(isset($_POST['submit'])) $form
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
$errors
Definition: index.php:6
getEditAnswersSingleLine($checkonly=false)
Get the single/multiline editing of answers.
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:

◆ getAfterParticipationSuppressionAnswerPostVars()

assSingleChoiceGUI::getAfterParticipationSuppressionAnswerPostVars ( )

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

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

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

Returns
string[]

Implements ilGuiAnswerScoringAdjustable.

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

774  {
775  return array();
776  }

◆ getAfterParticipationSuppressionQuestionPostVars()

assSingleChoiceGUI::getAfterParticipationSuppressionQuestionPostVars ( )

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

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

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

Returns
string[]

Implements ilGuiQuestionScoringAdjustable.

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

704  {
705  return array();
706  }

◆ getAggregatedAnswersView()

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

References aggregateAnswers(), and renderAggregateView().

787  {
788  return $this->renderAggregateView(
789  $this->aggregateAnswers($relevant_answers, $this->object->getAnswers())
790  )->get();
791  }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
+ Here is the call graph for this function:

◆ getAnswersFrequency()

assSingleChoiceGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

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

References aggregateAnswers().

874  {
875  $agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());
876 
877  $answers = array();
878 
879  foreach ($agg as $ans) {
880  $answers[] = array(
881  'answer' => $ans['answertext'],
882  'frequency' => $ans['count_checked']
883  );
884  }
885 
886  return $answers;
887  }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
+ Here is the call graph for this function:

◆ getChoiceKeys()

assSingleChoiceGUI::getChoiceKeys ( )

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

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

619  {
620  $choiceKeys = array_keys($this->object->answers);
621 
622  if ($this->object->getShuffle()) {
623  $choiceKeys = $this->object->getShuffler()->shuffle($choiceKeys);
624  }
625 
626  return $choiceKeys;
627  }
+ Here is the caller graph for this function:

◆ getEditAnswersSingleLine()

assSingleChoiceGUI::getEditAnswersSingleLine (   $checkonly = false)
protected

Get the single/multiline editing of answers.

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

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

References $_POST.

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

75  {
76  if ($checkonly) {
77  // form posting is checked
78  return ($_POST['types'] == 0) ? true : false;
79  }
80 
81  $lastChange = $this->object->getLastChange();
82  if (empty($lastChange) && !isset($_POST['types'])) {
83  // a new question is edited
84  return $this->object->getMultilineAnswerSetting() ? false : true;
85  } else {
86  // a saved question is edited
87  return $this->object->isSingleline;
88  }
89  }
$_POST["username"]
+ Here is the caller graph for this function:

◆ getPreview()

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

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

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

358  {
359  $keys = $this->getChoiceKeys();
360 
361  // generate the question output
362  include_once "./Services/UICore/classes/class.ilTemplate.php";
363  $template = new ilTemplate("tpl.il_as_qpl_mc_sr_output.html", true, true, "Modules/TestQuestionPool");
364  foreach ($keys as $answer_id) {
365  $answer = $this->object->answers[$answer_id];
366  if (strlen($answer->getImage())) {
367  if ($this->object->getThumbSize()) {
368  $template->setCurrentBlock("preview");
369  $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
370  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
371  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
372  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
373  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
374  $alt = $answer->getImage();
375  if (strlen($answer->getAnswertext())) {
376  $alt = $answer->getAnswertext();
377  }
378  $alt = preg_replace("/<[^>]*?>/", "", $alt);
379  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
380  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
381  $template->parseCurrentBlock();
382  } else {
383  $template->setCurrentBlock("answer_image");
384  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
385  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
386  $alt = $answer->getImage();
387  if (strlen($answer->getAnswertext())) {
388  $alt = $answer->getAnswertext();
389  }
390  $alt = preg_replace("/<[^>]*?>/", "", $alt);
391  $template->setVariable("ATTR", $attr);
392  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
393  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
394  $template->parseCurrentBlock();
395  }
396  }
397  if ($showInlineFeedback && is_object($this->getPreviewSession())) {
398  $this->populateInlineFeedback($template, $answer_id, $this->getPreviewSession()->getParticipantsSolution());
399  }
400  $template->setCurrentBlock("answer_row");
401  $template->setVariable("QID", $this->object->getId() . 'ID');
402  $template->setVariable("ANSWER_ID", $answer_id);
403  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), true));
404 
405  if (is_object($this->getPreviewSession())) {
406  $user_solution = $this->getPreviewSession()->getParticipantsSolution();
407  if (strcmp($user_solution, $answer_id) == 0) {
408  $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
409  }
410  }
411 
412  $template->parseCurrentBlock();
413  }
414  $questiontext = $this->object->getQuestion();
415  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
416  $questionoutput = $template->get();
417  if (!$show_question_only) {
418  // get page object output
419  $questionoutput = $this->getILIASPage($questionoutput);
420  }
421  return $questionoutput;
422  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$template
$type
populateInlineFeedback($template, $answer_id, $user_solution)
$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
+ Here is the call graph for this function:

◆ getSolutionOutput()

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

Get the question solution output.

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

Definition at line 208 of file class.assSingleChoiceGUI.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(), populateInlineFeedback(), ilUtil\prepareFormOutput(), and assQuestionGUI\renderPurposeSupportsFormHtml().

218  {
219  // shuffle output
220  $keys = $this->getChoiceKeys();
221 
222  // get the solution of the user for the active pass or from the last pass if allowed
223  $user_solution = "";
224  if (($active_id > 0) && (!$show_correct_solution)) {
225  $solutions = $this->object->getSolutionValues($active_id, $pass, !$this->getUseIntermediateSolution());
226  foreach ($solutions as $idx => $solution_value) {
227  $user_solution = $solution_value["value1"];
228  }
229  } else {
230  $found_index = -1;
231  $max_points = 0;
232  foreach ($this->object->answers as $index => $answer) {
233  if ($answer->getPoints() > $max_points) {
234  $max_points = $answer->getPoints();
235  $found_index = $index;
236  }
237  }
238  $user_solution = $found_index;
239  }
240  // generate the question output
241  include_once "./Services/UICore/classes/class.ilTemplate.php";
242  $template = new ilTemplate("tpl.il_as_qpl_mc_sr_output_solution.html", true, true, "Modules/TestQuestionPool");
243  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
244  foreach ($keys as $answer_id) {
245  $answer = $this->object->answers[$answer_id];
246  if (($active_id > 0) && (!$show_correct_solution)) {
247  if ($graphicalOutput) {
248  // output of ok/not ok icons for user entered solutions
249  $ok = false;
250  if (strcmp($user_solution, $answer_id) == 0) {
251  if ($answer->getPoints() == $this->object->getMaximumPoints()) {
252  $ok = true;
253  } else {
254  $ok = false;
255  }
256  if ($ok) {
257  $template->setCurrentBlock("icon_ok");
258  $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
259  $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
260  $template->parseCurrentBlock();
261  } else {
262  $template->setCurrentBlock("icon_not_ok");
263  if ($answer->getPoints() > 0) {
264  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.svg"));
265  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive"));
266  } else {
267  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
268  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
269  }
270  $template->parseCurrentBlock();
271  }
272  }
273  if (strlen($user_solution) == 0) {
274  $template->setCurrentBlock("icon_not_ok");
275  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
276  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
277  $template->parseCurrentBlock();
278  }
279  }
280  }
281  if (strlen($answer->getImage())) {
282  $template->setCurrentBlock("answer_image");
283  if ($this->object->getThumbSize()) {
284  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
285  } else {
286  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
287  }
288  $alt = $answer->getImage();
289  if (strlen($answer->getAnswertext())) {
290  $alt = $answer->getAnswertext();
291  }
292  $alt = preg_replace("/<[^>]*?>/", "", $alt);
293  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
294  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
295  $template->parseCurrentBlock();
296  }
297  if ($show_feedback) {
298  $this->populateInlineFeedback($template, $answer_id, $user_solution);
299  }
300  $template->setCurrentBlock("answer_row");
301  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), true));
302 
303  if ($this->renderPurposeSupportsFormHtml() || $this->isRenderPurposePrintPdf()) {
304  if (strcmp($user_solution, $answer_id) == 0) {
305  $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_checked.png")));
306  $template->setVariable("SOLUTION_ALT", $this->lng->txt("checked"));
307  } else {
308  $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png")));
309  $template->setVariable("SOLUTION_ALT", $this->lng->txt("unchecked"));
310  }
311  } else {
312  $template->setVariable('QID', $this->object->getId());
313  $template->setVariable('SUFFIX', $show_correct_solution ? 'bestsolution' : 'usersolution');
314  $template->setVariable('SOLUTION_VALUE', $answer_id);
315  if (strcmp($user_solution, $answer_id) == 0) {
316  $template->setVariable('SOLUTION_CHECKED', 'checked');
317  }
318  }
319 
320  if ($result_output) {
321  $points = $this->object->answers[$answer_id]->getPoints();
322  $resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
323  $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
324  }
325  $template->parseCurrentBlock();
326  }
327  $questiontext = $this->object->getQuestion();
328  if ($show_question_text == true) {
329  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
330  }
331  $questionoutput = $template->get();
332  $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
333  if (strlen($feedback)) {
334  $cssClass = (
335  $this->hasCorrectSolution($active_id, $pass) ?
337  );
338 
339  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
340  $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
341  }
342  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
343 
344  $solutionoutput = $solutiontemplate->get();
345 
346  if ($show_feedback && $this->hasInlineFeedback()) {
347  $solutionoutput = $this->buildFocusAnchorHtml() . $solutionoutput;
348  }
349 
350  if (!$show_question_only) {
351  // get page object output
352  $solutionoutput = $this->getILIASPage($solutionoutput);
353  }
354  return $solutionoutput;
355  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
hasCorrectSolution($activeId, $passIndex)
$template
populateInlineFeedback($template, $answer_id, $user_solution)
$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()

assSingleChoiceGUI::getSpecificFeedbackOutput (   $userSolution)

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

References Sabre\VObject\$output.

630  {
631  // No return value, this question type supports inline specific feedback.
632  $output = "";
633  return $this->object->prepareTextareaOutput($output, true);
634  }

◆ getTestOutput()

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

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

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

427  {
428  $keys = $this->getChoiceKeys();
429 
430  // get the solution of the user for the active pass or from the last pass if allowed
431  $user_solution = "";
432  if ($active_id) {
433  // hey: prevPassSolutions - obsolete due to central check
434  #$solutions = NULL;
435  #include_once "./Modules/Test/classes/class.ilObjTest.php";
436  #if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
437  #{
438  # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
439  #}
440  // hey.
441  $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
442  foreach ($solutions as $idx => $solution_value) {
443  $user_solution = $solution_value["value1"];
444  }
445  }
446 
447  // generate the question output
448  include_once "./Services/UICore/classes/class.ilTemplate.php";
449  $template = new ilTemplate("tpl.il_as_qpl_mc_sr_output.html", true, true, "Modules/TestQuestionPool");
450  foreach ($keys as $answer_id) {
451  $answer = $this->object->answers[$answer_id];
452  if (strlen($answer->getImage())) {
453  if ($this->object->getThumbSize()) {
454  $template->setCurrentBlock("preview");
455  $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
456  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
457  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
458  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
459  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
460  $alt = $answer->getImage();
461  if (strlen($answer->getAnswertext())) {
462  $alt = $answer->getAnswertext();
463  }
464  $alt = preg_replace("/<[^>]*?>/", "", $alt);
465  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
466  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
467  $template->parseCurrentBlock();
468  } else {
469  $template->setCurrentBlock("answer_image");
470  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
471  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
472  $alt = $answer->getImage();
473  if (strlen($answer->getAnswertext())) {
474  $alt = $answer->getAnswertext();
475  }
476  $alt = preg_replace("/<[^>]*?>/", "", $alt);
477  $template->setVariable("ATTR", $attr);
478  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
479  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
480  $template->parseCurrentBlock();
481  }
482  }
483  if ($show_feedback) {
484  $feedbackOutputRequired = false;
485 
486  switch ($this->object->getSpecificFeedbackSetting()) {
487  case 1:
488  $feedbackOutputRequired = true;
489  break;
490 
491  case 2:
492  if (strcmp($user_solution, $answer_id) == 0) {
493  $feedbackOutputRequired = true;
494  }
495  break;
496 
497  case 3:
498  if ($this->object->getAnswer($answer_id)->getPoints() > 0) {
499  $feedbackOutputRequired = true;
500  }
501  break;
502  }
503 
504  if ($feedbackOutputRequired) {
505  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
506  $this->object->getId(),
507  0,
508  $answer_id
509  );
510  if (strlen($fb)) {
511  $template->setCurrentBlock("feedback");
512  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
513  $template->parseCurrentBlock();
514  }
515  }
516  }
517  $template->setCurrentBlock("answer_row");
518  $template->setVariable("ANSWER_ID", $answer_id);
519  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), true));
520  if (strcmp($user_solution, $answer_id) == 0) {
521  $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
522  }
523  $template->parseCurrentBlock();
524  }
525  $questiontext = $this->object->getQuestion();
526  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
527  $questionoutput = $template->get();
528  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput, $show_feedback);
529  return $pageoutput;
530  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$template
$type
$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
+ Here is the call graph for this function:

◆ hasInlineFeedback()

assSingleChoiceGUI::hasInlineFeedback ( )
Returns
bool

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

Referenced by getSolutionOutput().

46  {
47  return $this->object->feedbackOBJ->isSpecificAnswerFeedbackAvailable($this->object->getId());
48  }
+ Here is the caller graph for this function:

◆ populateAnswerSpecificFormPart()

assSingleChoiceGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

743  {
744  $isSingleline = $this->getEditAnswersSingleLine();
745 
746  // Choices
747  include_once "./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php";
748  $choices = new ilSingleChoiceWizardInputGUI($this->lng->txt("answers"), "choice");
749  $choices->setRequired(true);
750  $choices->setQuestionObject($this->object);
751  $choices->setSingleline($isSingleline);
752  $choices->setAllowMove(false);
753  if ($this->object->getSelfAssessmentEditingMode()) {
754  $choices->setSize(40);
755  }
756  $choices->setMaxLength(800);
757  if ($this->object->getAnswerCount() == 0) {
758  $this->object->addAnswer("", 0, 0);
759  }
760  $choices->setValues($this->object->getAnswers());
761  $form->addItem($choices);
762  }
if(isset($_POST['submit'])) $form
This class represents a single choice wizard property in a property form.
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:

◆ populateCorrectionsFormProperties()

assSingleChoiceGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

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

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

890  {
891  require_once 'Modules/TestQuestionPool/classes/forms/class.ilAssSingleChoiceCorrectionsInputGUI.php';
892  $choices = new ilAssSingleChoiceCorrectionsInputGUI($this->lng->txt("answers"), "choice");
893  $choices->setRequired(true);
894  $choices->setQuestionObject($this->object);
895  $choices->setValues($this->object->getAnswers());
896  $form->addItem($choices);
897  }
addItem($a_item)
Add Item (Property, SectionHeader).
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:

◆ populateInlineFeedback()

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

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

References $template.

Referenced by getPreview(), and getSolutionOutput().

842  {
843  $feedbackOutputRequired = false;
844 
845  switch ($this->object->getSpecificFeedbackSetting()) {
846  case 1:
847  $feedbackOutputRequired = true;
848  break;
849 
850  case 2:
851  if (strcmp($user_solution, $answer_id) == 0) {
852  $feedbackOutputRequired = true;
853  }
854  break;
855 
856  case 3:
857  if ($this->object->getAnswer($answer_id)->getPoints() > 0) {
858  $feedbackOutputRequired = true;
859  }
860  break;
861  }
862 
863  if ($feedbackOutputRequired) {
864  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
865  if (strlen($fb)) {
866  $template->setCurrentBlock("feedback");
867  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
868  $template->parseCurrentBlock();
869  }
870  }
871  }
$template
+ Here is the caller graph for this function:

◆ populateQuestionSpecificFormPart()

assSingleChoiceGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

650  {
651  $isSingleline = $this->getEditAnswersSingleLine();
652  // shuffle
653  $shuffle = new ilCheckboxInputGUI($this->lng->txt("shuffle_answers"), "shuffle");
654  $shuffle->setValue(1);
655  $shuffle->setChecked($this->object->getShuffle());
656  $shuffle->setRequired(false);
657  $form->addItem($shuffle);
658 
659  if ($this->object->getId()) {
660  $hidden = new ilHiddenInputGUI("", "ID");
661  $hidden->setValue($this->object->getId());
662  $form->addItem($hidden);
663  }
664 
665  if (!$this->object->getSelfAssessmentEditingMode()) {
666  // Answer types
667  $types = new ilSelectInputGUI($this->lng->txt("answer_types"), "types");
668  $types->setRequired(false);
669  $types->setValue(($isSingleline) ? 0 : 1);
670  $types->setOptions(
671  array(
672  0 => $this->lng->txt('answers_singleline'),
673  1 => $this->lng->txt('answers_multiline'),
674  )
675  );
676  $form->addItem($types);
677  }
678 
679  if ($isSingleline) {
680  // thumb size
681  $thumb_size = new ilNumberInputGUI($this->lng->txt("thumb_size"), "thumb_size");
682  $thumb_size->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
683  $thumb_size->setMinValue(20);
684  $thumb_size->setDecimals(0);
685  $thumb_size->setSize(6);
686  $thumb_size->setInfo($this->lng->txt('thumb_size_info'));
687  $thumb_size->setValue($this->object->getThumbSize());
688  $thumb_size->setRequired(false);
689  $form->addItem($thumb_size);
690  }
691  return $form;
692  }
This class represents a selection list property in a property form.
This class represents a checkbox property in a property form.
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:

◆ removechoice()

assSingleChoiceGUI::removechoice ( )

Remove an answer.

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

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

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

◆ removeimagechoice()

assSingleChoiceGUI::removeimagechoice ( )

Remove an image.

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

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

155  {
156  $this->writePostData(true);
157  $position = key($_POST['cmd']['removeimagechoice']);
158  $filename = $_POST['choice']['imagename'][$position];
159  $this->object->removeAnswerImage($position);
160  $this->editQuestion();
161  }
writePostData($always=false)
{}
$filename
Definition: buildRTE.php:89
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
$_POST["username"]
+ Here is the call graph for this function:

◆ renderAggregateView()

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

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

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

821  {
822  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
823 
824  $tpl->setCurrentBlock('headercell');
825  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
826  $tpl->parseCurrentBlock();
827 
828  $tpl->setCurrentBlock('headercell');
829  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
830  $tpl->parseCurrentBlock();
831 
832  foreach ($aggregate as $line_data) {
833  $tpl->setCurrentBlock('aggregaterow');
834  $tpl->setVariable('OPTION', $line_data['answertext']);
835  $tpl->setVariable('COUNT', $line_data['count_checked']);
836  $tpl->parseCurrentBlock();
837  }
838  return $tpl;
839  }
special template class to simplify handling of ITX/PEAR
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

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

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

References $index, and ilPropertyFormGUI\getInput().

903  {
904  $points = $form->getInput('choice')['points'];
905 
906  foreach ($this->object->getAnswers() as $index => $answer) {
907  /* @var ASS_AnswerMultipleResponseImage $answer */
908  $answer->setPoints((float) $points[$index]);
909  }
910  }
$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()

assSingleChoiceGUI::setQuestionTabs ( )

Sets the ILIAS tabs for this question type.

public

Todo:
: MOVE THIS STEPS TO COMMON QUESTION CLASS assQuestionGUI

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

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

540  {
541  global $DIC;
542  $rbacsystem = $DIC['rbacsystem'];
543  $ilTabs = $DIC['ilTabs'];
544 
545  $ilTabs->clearTargets();
546 
547  $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
548  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
549  $q_type = $this->object->getQuestionType();
550 
551  if (strlen($q_type)) {
552  $classname = $q_type . "GUI";
553  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
554  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
555  }
556 
557  if ($_GET["q_id"]) {
558  if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
559  // edit page
560  $ilTabs->addTarget(
561  "edit_page",
562  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
563  array("edit", "insert", "exec_pg"),
564  "",
565  "",
566  $force_active
567  );
568  }
569 
570  $this->addTab_QuestionPreview($ilTabs);
571  }
572 
573  $force_active = false;
574  if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
575  $url = "";
576  if ($classname) {
577  $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
578  }
579  // edit question properties
580  $ilTabs->addTarget(
581  "edit_question",
582  $url,
583  array("editQuestion", "save", "saveEdit", "addchoice", "removechoice", "removeimagechoice", "uploadchoice", "originalSyncForm"),
584  $classname,
585  "",
586  $force_active
587  );
588  }
589 
590  // add tab for question feedback within common class assQuestionGUI
591  $this->addTab_QuestionFeedback($ilTabs);
592 
593  // add tab for question hint within common class assQuestionGUI
594  $this->addTab_QuestionHints($ilTabs);
595 
596  // add tab for question's suggested solution within common class assQuestionGUI
597  $this->addTab_SuggestedSolution($ilTabs, $classname);
598 
599  // Assessment of questions sub menu entry
600  if ($_GET["q_id"]) {
601  $ilTabs->addTarget(
602  "statistics",
603  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
604  array("assessment"),
605  $classname,
606  ""
607  );
608  }
609 
610  $this->addBackTab($ilTabs);
611  }
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:

◆ supportsIntermediateSolutionOutput()

assSingleChoiceGUI::supportsIntermediateSolutionOutput ( )

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

Returns
bool

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

191  {
192  return true;
193  }

◆ uploadchoice()

assSingleChoiceGUI::uploadchoice ( )

Upload an image.

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

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

145  {
146  $this->writePostData(true);
147  $position = key($_POST['cmd']['uploadchoice']);
148  $this->editQuestion();
149  }
writePostData($always=false)
{}
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
$_POST["username"]
+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assSingleChoiceGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

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

Implements ilGuiAnswerScoringAdjustable.

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

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

Referenced by writePostData().

709  {
710  // Delete all existing answers and create new answers from the form data
711  $this->object->flushAnswers();
712  if ($this->object->isSingleline) {
713  foreach ($_POST['choice']['answer'] as $index => $answertext) {
714  $answertext = ilUtil::secureString($answertext);
715 
716  $picturefile = $_POST['choice']['imagename'][$index];
717  $file_org_name = $_FILES['choice']['name']['image'][$index];
718  $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index];
719 
720  if (strlen($file_temp_name)) {
721  // check suffix
722  $suffix = strtolower(array_pop(explode(".", $file_org_name)));
723  if (in_array($suffix, array( "jpg", "jpeg", "png", "gif" ))) {
724  // upload image
725  $filename = $this->object->buildHashedImageFilename($file_org_name);
726  if ($this->object->setImageFile($filename, $file_temp_name) == 0) {
727  $picturefile = $filename;
728  }
729  }
730  }
731 
732  $this->object->addAnswer($answertext, $_POST['choice']['points'][$index], $index, $picturefile);
733  }
734  } else {
735  foreach ($_POST['choice']['answer'] as $index => $answer) {
736  $answertext = $answer;
737  $this->object->addAnswer($answertext, $_POST['choice']['points'][$index], $index);
738  }
739  }
740  }
$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()

assSingleChoiceGUI::writePostData (   $always = false)
protected

{}

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

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

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

54  {
55  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
56  if (!$hasErrors) {
57  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
61  $this->saveTaxonomyAssignments();
62  return 0;
63  }
64  return 1;
65  }
This class represents a property form user interface.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
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()

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

References $_POST, and ilUtil\sendInfo().

Referenced by writePostData().

637  {
638  $this->object->setShuffle($_POST["shuffle"]);
639  $this->object->setMultilineAnswerSetting($_POST["types"]);
640  if (is_array($_POST['choice']['imagename']) && $_POST["types"] == 1) {
641  $this->object->isSingleline = true;
642  ilUtil::sendInfo($this->lng->txt('info_answer_type_change'), true);
643  } else {
644  $this->object->isSingleline = ($_POST["types"] == 0) ? true : false;
645  }
646  $this->object->setThumbSize((strlen($_POST["thumb_size"])) ? $_POST["thumb_size"] : "");
647  }
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:

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