ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 
 editQuestion ($checkonly=false)
 Creates an output of the edit form for the question. More...
 
 uploadchoice ()
 Upload an image. More...
 
 removeimagechoice ()
 Remove an image. More...
 
 addchoice ()
 Add a new answer. More...
 
 removechoice ()
 Remove an answer. More...
 
 getSolutionOutput ( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
 Get the question solution output. More...
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 getTestOutput ($active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
 
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type. More...
 
 getChoiceKeys ()
 
 getSpecificFeedbackOutput ($active_id, $pass)
 
 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)
 
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor More...
 
 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="")
 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 ($active_id, $pass)
 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)
 
 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 ()
 
- 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
 

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

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

159  {
160  $this->writePostData(true);
161  $position = key($_POST['cmd']['addchoice']);
162  $this->object->addAnswer("", 0, $position+1);
163  $this->editQuestion();
164  }
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 767 of file class.assSingleChoiceGUI.php.

References array.

Referenced by getAggregatedAnswersView().

768  {
769  $aggregate = array();
770  foreach ($answers_defined_on_question as $answer) {
771  $aggregated_info_for_answer = array();
772  $aggregated_info_for_answer['answertext'] = $answer->getAnswerText();
773  $aggregated_info_for_answer['count_checked'] = 0;
774 
775  foreach ($relevant_answers_chosen as $relevant_answer) {
776  if ($relevant_answer['value1'] == $answer->getOrder()) {
777  $aggregated_info_for_answer['count_checked']++;
778  }
779  }
780  $aggregated_info_for_answer['count_unchecked'] =
781  ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
782  - $aggregated_info_for_answer['count_checked'];
783 
784  $aggregate[] = $aggregated_info_for_answer;
785  }
786  return $aggregate;
787  }
Create styles array
The data for the language used.
+ 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 87 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().

88  {
89  $save = $this->isSaveCommand();
90  $this->getQuestionTemplate();
91 
92  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
93  $form = new ilPropertyFormGUI();
94  $this->editForm = $form;
95 
96  $form->setFormAction($this->ctrl->getFormAction($this));
97  $form->setTitle($this->outQuestionType());
98  $isSingleline = $this->getEditAnswersSingleLine($checkonly);
99  if ($isSingleline) {
100  $form->setMultipart(true);
101  } else {
102  $form->setMultipart(false);
103  }
104  $form->setTableWidth("100%");
105  $form->setId("asssinglechoice");
106 
110 
111 
113 
115 
116  $errors = false;
117 
118  if ($save) {
119  $form->setValuesByPost();
120  $errors = !$form->checkInput();
121  $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
122  if ($errors) {
123  $checkonly = false;
124  }
125  }
126 
127  if (!$checkonly) {
128  $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
129  }
130  return $errors;
131  }
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 747 of file class.assSingleChoiceGUI.php.

References array.

748  {
749  return array();
750  }
Create styles array
The data for the language used.

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

References array.

678  {
679  return array();
680  }
Create styles array
The data for the language used.

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

References aggregateAnswers(), object, and renderAggregateView().

761  {
762  return $this->renderAggregateView(
763  $this->aggregateAnswers($relevant_answers, $this->object->getAnswers())
764  )->get();
765  }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
Create new PHPExcel object
obj_idprivate
+ Here is the call graph for this function:

◆ getChoiceKeys()

assSingleChoiceGUI::getChoiceKeys ( )

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

References object.

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

593  {
594  $choiceKeys = array_keys($this->object->answers);
595 
596  if ($this->object->getShuffle()) {
597  $choiceKeys = $this->object->getShuffler()->shuffle($choiceKeys);
598  }
599 
600  return $choiceKeys;
601  }
Create new PHPExcel object
obj_idprivate
+ 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 66 of file class.assSingleChoiceGUI.php.

References $_POST.

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

67  {
68  if ($checkonly) {
69  // form posting is checked
70  return ($_POST['types'] == 0) ? true : false;
71  }
72 
73  $lastChange = $this->object->getLastChange();
74  if (empty($lastChange) && !isset($_POST['types'])) {
75  // a new question is edited
76  return $this->object->getMultilineAnswerSetting() ? false : true;
77  } else {
78  // a saved question is edited
79  return $this->object->isSingleline;
80  }
81  }
$_POST["username"]
+ Here is the caller graph for this function:

◆ getPreview()

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

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

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

335  {
336  $keys = $this->getChoiceKeys();
337 
338  // generate the question output
339  include_once "./Services/UICore/classes/class.ilTemplate.php";
340  $template = new ilTemplate("tpl.il_as_qpl_mc_sr_output.html", true, true, "Modules/TestQuestionPool");
341  foreach ($keys as $answer_id) {
342  $answer = $this->object->answers[$answer_id];
343  if (strlen($answer->getImage())) {
344  if ($this->object->getThumbSize()) {
345  $template->setCurrentBlock("preview");
346  $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
347  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
348  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
349  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
350  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
351  $alt = $answer->getImage();
352  if (strlen($answer->getAnswertext())) {
353  $alt = $answer->getAnswertext();
354  }
355  $alt = preg_replace("/<[^>]*?>/", "", $alt);
356  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
357  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
358  $template->parseCurrentBlock();
359  } else {
360  $template->setCurrentBlock("answer_image");
361  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
362  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
363  $alt = $answer->getImage();
364  if (strlen($answer->getAnswertext())) {
365  $alt = $answer->getAnswertext();
366  }
367  $alt = preg_replace("/<[^>]*?>/", "", $alt);
368  $template->setVariable("ATTR", $attr);
369  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
370  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
371  $template->parseCurrentBlock();
372  }
373  }
374  if ($showInlineFeedback && is_object($this->getPreviewSession())) {
375  $this->populateInlineFeedback($template, $answer_id, $this->getPreviewSession()->getParticipantsSolution());
376  }
377  $template->setCurrentBlock("answer_row");
378  $template->setVariable("QID", $this->object->getId() . 'ID');
379  $template->setVariable("ANSWER_ID", $answer_id);
380  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), true));
381 
382  if (is_object($this->getPreviewSession())) {
383  $user_solution = $this->getPreviewSession()->getParticipantsSolution();
384  if (strcmp($user_solution, $answer_id) == 0) {
385  $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
386  }
387  }
388 
389  $template->parseCurrentBlock();
390  }
391  $questiontext = $this->object->getQuestion();
392  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
393  $questionoutput = $template->get();
394  if (!$show_question_only) {
395  // get page object output
396  $questionoutput = $this->getILIASPage($questionoutput);
397  }
398  return $questionoutput;
399  }
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
Create new PHPExcel object
obj_idprivate
+ 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 190 of file class.assSingleChoiceGUI.php.

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

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

◆ getSpecificFeedbackOutput()

assSingleChoiceGUI::getSpecificFeedbackOutput (   $active_id,
  $pass 
)

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

References $output.

604  {
605  // No return value, this question type supports inline specific feedback.
606  $output = "";
607  return $this->object->prepareTextareaOutput($output, true);
608  }
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output

◆ getTestOutput()

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

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

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

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

◆ populateAnswerSpecificFormPart()

assSingleChoiceGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

717  {
718  $isSingleline = $this->getEditAnswersSingleLine();
719 
720  // Choices
721  include_once "./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php";
722  $choices = new ilSingleChoiceWizardInputGUI($this->lng->txt("answers"), "choice");
723  $choices->setRequired(true);
724  $choices->setQuestionObject($this->object);
725  $choices->setSingleline($isSingleline);
726  $choices->setAllowMove(false);
727  if ($this->object->getSelfAssessmentEditingMode()) {
728  $choices->setSize(40);
729  }
730  $choices->setMaxLength(800);
731  if ($this->object->getAnswerCount() == 0) {
732  $this->object->addAnswer("", 0, 0);
733  }
734  $choices->setValues($this->object->getAnswers());
735  $form->addItem($choices);
736  }
if(isset($_POST['submit'])) $form
This class represents a single choice wizard property in a property form.
Create new PHPExcel object
obj_idprivate
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:

◆ populateInlineFeedback()

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

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

References $template, and object.

Referenced by getPreview(), and getSolutionOutput().

816  {
817  $feedbackOutputRequired = false;
818 
819  switch ($this->object->getSpecificFeedbackSetting()) {
820  case 1:
821  $feedbackOutputRequired = true;
822  break;
823 
824  case 2:
825  if (strcmp($user_solution, $answer_id) == 0) {
826  $feedbackOutputRequired = true;
827  }
828  break;
829 
830  case 3:
831  if ($this->object->getAnswer($answer_id)->getPoints() > 0) {
832  $feedbackOutputRequired = true;
833  }
834  break;
835  }
836 
837  if ($feedbackOutputRequired) {
838  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id);
839  if (strlen($fb)) {
840  $template->setCurrentBlock("feedback");
841  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
842  $template->parseCurrentBlock();
843  }
844  }
845  }
$template
Create new PHPExcel object
obj_idprivate
+ Here is the caller graph for this function:

◆ populateQuestionSpecificFormPart()

assSingleChoiceGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

624  {
625  $isSingleline = $this->getEditAnswersSingleLine();
626  // shuffle
627  $shuffle = new ilCheckboxInputGUI($this->lng->txt("shuffle_answers"), "shuffle");
628  $shuffle->setValue(1);
629  $shuffle->setChecked($this->object->getShuffle());
630  $shuffle->setRequired(false);
631  $form->addItem($shuffle);
632 
633  if ($this->object->getId()) {
634  $hidden = new ilHiddenInputGUI("", "ID");
635  $hidden->setValue($this->object->getId());
636  $form->addItem($hidden);
637  }
638 
639  if (!$this->object->getSelfAssessmentEditingMode()) {
640  // Answer types
641  $types = new ilSelectInputGUI($this->lng->txt("answer_types"), "types");
642  $types->setRequired(false);
643  $types->setValue(($isSingleline) ? 0 : 1);
644  $types->setOptions(
645  array(
646  0 => $this->lng->txt('answers_singleline'),
647  1 => $this->lng->txt('answers_multiline'),
648  )
649  );
650  $form->addItem($types);
651  }
652 
653  if ($isSingleline) {
654  // thumb size
655  $thumb_size = new ilNumberInputGUI($this->lng->txt("thumb_size"), "thumb_size");
656  $thumb_size->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
657  $thumb_size->setMinValue(20);
658  $thumb_size->setDecimals(0);
659  $thumb_size->setSize(6);
660  $thumb_size->setInfo($this->lng->txt('thumb_size_info'));
661  $thumb_size->setValue($this->object->getThumbSize());
662  $thumb_size->setRequired(false);
663  $form->addItem($thumb_size);
664  }
665  return $form;
666  }
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.
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
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 169 of file class.assSingleChoiceGUI.php.

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

170  {
171  $this->writePostData(true);
172  $position = key($_POST['cmd']['removechoice']);
173  $this->object->deleteAnswer($position);
174  $this->editQuestion();
175  }
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 146 of file class.assSingleChoiceGUI.php.

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

147  {
148  $this->writePostData(true);
149  $position = key($_POST['cmd']['removeimagechoice']);
150  $filename = $_POST['choice']['imagename'][$position];
151  $this->object->removeAnswerImage($position);
152  $this->editQuestion();
153  }
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:

◆ renderAggregateView()

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

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

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

795  {
796  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
797 
798  $tpl->setCurrentBlock('headercell');
799  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
800  $tpl->parseCurrentBlock();
801 
802  $tpl->setCurrentBlock('headercell');
803  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
804  $tpl->parseCurrentBlock();
805 
806  foreach ($aggregate as $line_data) {
807  $tpl->setCurrentBlock('aggregaterow');
808  $tpl->setVariable('OPTION', $line_data['answertext']);
809  $tpl->setVariable('COUNT', $line_data['count_checked']);
810  $tpl->parseCurrentBlock();
811  }
812  return $tpl;
813  }
special template class to simplify handling of ITX/PEAR
+ Here is the caller 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 515 of file class.assSingleChoiceGUI.php.

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

516  {
517  global $rbacsystem, $ilTabs;
518 
519  $ilTabs->clearTargets();
520 
521  $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
522  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
523  $q_type = $this->object->getQuestionType();
524 
525  if (strlen($q_type)) {
526  $classname = $q_type . "GUI";
527  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
528  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
529  }
530 
531  if ($_GET["q_id"]) {
532  if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
533  // edit page
534  $ilTabs->addTarget(
535  "edit_page",
536  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
537  array("edit", "insert", "exec_pg"),
538  "",
539  "",
540  $force_active
541  );
542  }
543 
544  $this->addTab_QuestionPreview($ilTabs);
545  }
546 
547  $force_active = false;
548  if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
549  $url = "";
550  if ($classname) {
551  $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
552  }
553  // edit question properties
554  $ilTabs->addTarget(
555  "edit_question",
556  $url,
557  array("editQuestion", "save", "saveEdit", "addchoice", "removechoice", "removeimagechoice", "uploadchoice", "originalSyncForm"),
558  $classname,
559  "",
560  $force_active
561  );
562  }
563 
564  // add tab for question feedback within common class assQuestionGUI
565  $this->addTab_QuestionFeedback($ilTabs);
566 
567  // add tab for question hint within common class assQuestionGUI
568  $this->addTab_QuestionHints($ilTabs);
569 
570  // add tab for question's suggested solution within common class assQuestionGUI
571  $this->addTab_SuggestedSolution($ilTabs, $classname);
572 
573  // Assessment of questions sub menu entry
574  if ($_GET["q_id"]) {
575  $ilTabs->addTarget(
576  "statistics",
577  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
578  array("assessment"),
579  $classname,
580  ""
581  );
582  }
583 
584  $this->addBackTab($ilTabs);
585  }
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
$_GET["client_id"]
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
Create styles array
The data for the language used.
addBackTab(ilTabsGUI $ilTabs)
$url
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
+ Here is the call graph for this function:

◆ uploadchoice()

assSingleChoiceGUI::uploadchoice ( )

Upload an image.

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

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

137  {
138  $this->writePostData(true);
139  $position = key($_POST['cmd']['uploadchoice']);
140  $this->editQuestion();
141  }
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 682 of file class.assSingleChoiceGUI.php.

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

Referenced by writePostData().

683  {
684  // Delete all existing answers and create new answers from the form data
685  $this->object->flushAnswers();
686  if ($this->object->isSingleline) {
687  foreach ($_POST['choice']['answer'] as $index => $answertext) {
688  $answertext = ilUtil::secureString($answertext);
689 
690  $picturefile = $_POST['choice']['imagename'][$index];
691  $file_org_name = $_FILES['choice']['name']['image'][$index];
692  $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index];
693 
694  if (strlen($file_temp_name)) {
695  // check suffix
696  $suffix = strtolower(array_pop(explode(".", $file_org_name)));
697  if (in_array($suffix, array( "jpg", "jpeg", "png", "gif" ))) {
698  // upload image
699  $filename = $this->object->buildHashedImageFilename($file_org_name);
700  if ($this->object->setImageFile($filename, $file_temp_name) == 0) {
701  $picturefile = $filename;
702  }
703  }
704  }
705 
706  $this->object->addAnswer($answertext, $_POST['choice']['points'][$index], $index, $picturefile);
707  }
708  } else {
709  foreach ($_POST['choice']['answer'] as $index => $answer) {
710  $answertext = $answer;
711  $this->object->addAnswer($answertext, $_POST['choice']['points'][$index], $index);
712  }
713  }
714  }
$index
Definition: metadata.php:60
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
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 45 of file class.assSingleChoiceGUI.php.

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

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

46  {
47  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
48  if (!$hasErrors) {
49  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
53  $this->saveTaxonomyAssignments();
54  return 0;
55  }
56  return 1;
57  }
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 610 of file class.assSingleChoiceGUI.php.

References $_POST, and ilUtil\sendInfo().

Referenced by writePostData().

611  {
612  $this->object->setShuffle($_POST["shuffle"]);
613  $this->object->setMultilineAnswerSetting($_POST["types"]);
614  if (is_array($_POST['choice']['imagename']) && $_POST["types"] == 1) {
615  $this->object->isSingleline = true;
616  ilUtil::sendInfo($this->lng->txt('info_answer_type_change'), true);
617  } else {
618  $this->object->isSingleline = ($_POST["types"] == 0) ? true : false;
619  }
620  $this->object->setThumbSize((strlen($_POST["thumb_size"])) ? $_POST["thumb_size"] : "");
621  }
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: