ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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...
 
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. 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=NULL, $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...
 
 setTaxonomyIds ($taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 
 setQuestionActionCmd ($questionActionCmd)
 
 getQuestionActionCmd ()
 
_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...
 
 _getGUIClassNameForId ($a_q_id)
 
 _getClassNameForQType ($q_type)
 
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation. More...
 
 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...
 
 getSelfAssessmentTags ()
 Get tags allowed in question tags in self assessment mode. 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=NULL, $is_question_postponed=FALSE, $user_post_solutions=FALSE, $show_specific_inline_feedback=FALSE)
 
 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...
 

Data Fields

 $choiceKeys
 
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
 $object
 
 $tpl
 
 $lng
 
 $error
 
 $errormessage
 
 $sequence_no
 sequence number in test More...
 
 $question_count
 question count in test More...
 

Private Member Functions

 populateInlineFeedback ($template, $answer_id, $user_solution)
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
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...
 
- Protected Member Functions inherited from assQuestionGUI
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 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)
 
 writeQuestionGenericPostData ()
 
 getFormEncodingType ()
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 

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$

Definition at line 22 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 33 of file class.assSingleChoiceGUI.php.

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

Member Function Documentation

◆ addchoice()

assSingleChoiceGUI::addchoice ( )

Add a new answer.

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

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

141  {
142  $this->writePostData(true);
143  $position = key($_POST['cmd']['addchoice']);
144  $this->object->addAnswer("", 0, $position+1);
145  $this->editQuestion();
146  }
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
$_POST['username']
Definition: cron.php:12
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
+ Here is the call graph for this function:

◆ aggregateAnswers()

assSingleChoiceGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)

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

Referenced by getAggregatedAnswersView().

797  {
798  $aggregate = array();
799  foreach ($answers_defined_on_question as $answer)
800  {
801  $aggregated_info_for_answer = array();
802  $aggregated_info_for_answer['answertext'] = $answer->getAnswerText();
803  $aggregated_info_for_answer['count_checked'] = 0;
804 
805  foreach ($relevant_answers_chosen as $relevant_answer)
806  {
807  if ($relevant_answer['value1'] == $answer->getOrder())
808  {
809  $aggregated_info_for_answer['count_checked']++;
810  }
811  }
812  $aggregated_info_for_answer['count_unchecked'] =
813  ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
814  - $aggregated_info_for_answer['count_checked'];
815 
816  $aggregate[] = $aggregated_info_for_answer;
817  }
818  return $aggregate;
819  }
+ 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 70 of file class.assSingleChoiceGUI.php.

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

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

71  {
72  $save = $this->isSaveCommand();
73  $this->getQuestionTemplate();
74 
75  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
76  $form = new ilPropertyFormGUI();
77  $form->setFormAction($this->ctrl->getFormAction($this));
78  $form->setTitle($this->outQuestionType());
79  $isSingleline = ($this->object->lastChange == 0 && !array_key_exists('types', $_POST)) ? (($this->object->getMultilineAnswerSetting()) ? false : true) : $this->object->isSingleline;
80  if ($checkonly) $isSingleline = ($_POST['types'] == 0) ? true : false;
81  if ($isSingleline)
82  {
83  $form->setMultipart(TRUE);
84  }
85  else
86  {
87  $form->setMultipart(FALSE);
88  }
89  $form->setTableWidth("100%");
90  $form->setId("asssinglechoice");
91 
92  $this->addBasicQuestionFormProperties( $form );
93  $this->populateQuestionSpecificFormPart( $form );
94  $this->populateAnswerSpecificFormPart( $form );
95 
96 
97  $this->populateTaxonomyFormSection($form);
98 
99  $this->addQuestionFormCommandButtons($form);
100 
101  $errors = false;
102 
103  if ($save)
104  {
105  $form->setValuesByPost();
106  $errors = !$form->checkInput();
107  $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
108  if ($errors) $checkonly = false;
109  }
110 
111  if (!$checkonly) $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
112  return $errors;
113  }
$errors
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
$_POST['username']
Definition: cron.php:12
This class represents a property form user interface.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
getQuestionTemplate()
get question template
populateTaxonomyFormSection(ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

778  {
779  return array();
780  }

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

700  {
701  return array();
702  }

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

References aggregateAnswers(), and renderAggregateView().

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

◆ getChoiceKeys()

assSingleChoiceGUI::getChoiceKeys ( )

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

References $_GET, $_SESSION, and $choiceKeys.

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

603  {
604  if (strcmp($_GET["activecommand"], "directfeedback") == 0)
605  {
606  if (is_array($_SESSION["choicekeys"])) $this->choiceKeys = $_SESSION["choicekeys"];
607  }
608  if (!is_array($this->choiceKeys))
609  {
610  $this->choiceKeys = array_keys($this->object->answers);
611  if ($this->object->getShuffle())
612  {
613  $this->choiceKeys = $this->object->pcArrayShuffle($this->choiceKeys);
614  }
615  }
616  $_SESSION["choicekeys"] = $this->choiceKeys;
617  return $this->choiceKeys;
618  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
$_GET["client_id"]
+ Here is the caller graph for this function:

◆ getPreview()

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

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

References getChoiceKeys(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), assQuestionGUI\getPreviewSession(), populateInlineFeedback(), and ilUtil\prepareFormOutput().

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

References $ok, $pass, assQuestionGUI\getAnswerFeedbackOutput(), getChoiceKeys(), ilUtil\getHtmlPath(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), populateInlineFeedback(), and ilUtil\prepareFormOutput().

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

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

621  {
622  // No return value, this question type supports inline specific feedback.
623  $output = "";
624  return $this->object->prepareTextareaOutput($output, TRUE);
625  }

◆ getTestOutput()

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

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

References $pass, ilObjTest\_getPass(), ilObjTest\_getUsePreviousAnswers(), getChoiceKeys(), ilUtil\getImagePath(), assQuestionGUI\outQuestionPage(), and ilUtil\prepareFormOutput().

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

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

Referenced by editQuestion().

747  {
748  $isSingleline = ($this->object->lastChange == 0 && !array_key_exists('types', $_POST)) ? (($this->object->getMultilineAnswerSetting()) ? false : true) : $this->object->isSingleline;
749 
750  // Choices
751  include_once "./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php";
752  $choices = new ilSingleChoiceWizardInputGUI($this->lng->txt( "answers" ), "choice");
753  $choices->setRequired( true );
754  $choices->setQuestionObject( $this->object );
755  $choices->setSingleline( $isSingleline );
756  $choices->setAllowMove( false );
757  if ($this->object->getSelfAssessmentEditingMode())
758  {
759  $choices->setSize( 40 );
760  $choices->setMaxLength( 800 );
761  }
762  if ($this->object->getAnswerCount() == 0)
763  $this->object->addAnswer( "", 0, 0 );
764  $choices->setValues( $this->object->getAnswers() );
765  $form->addItem( $choices );
766  }
$_POST['username']
Definition: cron.php:12
This class represents a single choice wizard property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateInlineFeedback()

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

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

Referenced by getPreview(), and getSolutionOutput().

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

◆ populateQuestionSpecificFormPart()

assSingleChoiceGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

644  {
645  $isSingleline = ($this->object->lastChange == 0 && !array_key_exists( 'types',$_POST)) ? (($this->object->getMultilineAnswerSetting()) ? false : true) : $this->object->isSingleline;
646  // shuffle
647  $shuffle = new ilCheckboxInputGUI($this->lng->txt( "shuffle_answers" ), "shuffle");
648  $shuffle->setValue( 1 );
649  $shuffle->setChecked( $this->object->getShuffle() );
650  $shuffle->setRequired( FALSE );
651  $form->addItem( $shuffle );
652 
653  if ($this->object->getId())
654  {
655  $hidden = new ilHiddenInputGUI("", "ID");
656  $hidden->setValue( $this->object->getId() );
657  $form->addItem( $hidden );
658  }
659 
660  if (!$this->object->getSelfAssessmentEditingMode())
661  {
662  // Answer types
663  $types = new ilSelectInputGUI($this->lng->txt( "answer_types" ), "types");
664  $types->setRequired( false );
665  $types->setValue( ($isSingleline) ? 0 : 1 );
666  $types->setOptions( array(
667  0 => $this->lng->txt( 'answers_singleline' ),
668  1 => $this->lng->txt( 'answers_multiline' ),
669  )
670  );
671  $form->addItem( $types );
672  }
673 
674  if ($isSingleline)
675  {
676  // thumb size
677  $thumb_size = new ilNumberInputGUI($this->lng->txt( "thumb_size" ), "thumb_size");
678  $thumb_size->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
679  $thumb_size->setMinValue( 20 );
680  $thumb_size->setDecimals( 0 );
681  $thumb_size->setSize( 6 );
682  $thumb_size->setInfo( $this->lng->txt( 'thumb_size_info' ) );
683  $thumb_size->setValue( $this->object->getThumbSize() );
684  $thumb_size->setRequired( false );
685  $form->addItem( $thumb_size );
686  }
687  return $form;
688  }
$_POST['username']
Definition: cron.php:12
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.
This class represents a number property in a property form.
setValue($a_value)
Set Value.
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 151 of file class.assSingleChoiceGUI.php.

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

152  {
153  $this->writePostData(true);
154  $position = key($_POST['cmd']['removechoice']);
155  $this->object->deleteAnswer($position);
156  $this->editQuestion();
157  }
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
$_POST['username']
Definition: cron.php:12
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
+ Here is the call graph for this function:

◆ removeimagechoice()

assSingleChoiceGUI::removeimagechoice ( )

Remove an image.

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

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

129  {
130  $this->writePostData(true);
131  $position = key($_POST['cmd']['removeimagechoice']);
132  $filename = $_POST['choice']['imagename'][$position];
133  $this->object->removeAnswerImage($position);
134  $this->editQuestion();
135  }
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
$_POST['username']
Definition: cron.php:12
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

◆ renderAggregateView()

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

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

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

827  {
828  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
829 
830  foreach ($aggregate as $line_data)
831  {
832  $tpl->setCurrentBlock( 'aggregaterow' );
833  $tpl->setVariable( 'OPTION', $line_data['answertext'] );
834  $tpl->setVariable( 'COUNT', $line_data['count_checked'] );
835  $tpl->parseCurrentBlock();
836  }
837  return $tpl;
838  }
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 533 of file class.assSingleChoiceGUI.php.

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

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

◆ uploadchoice()

assSingleChoiceGUI::uploadchoice ( )

Upload an image.

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

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

119  {
120  $this->writePostData(true);
121  $position = key($_POST['cmd']['uploadchoice']);
122  $this->editQuestion();
123  }
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
$_POST['username']
Definition: cron.php:12
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
+ 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 704 of file class.assSingleChoiceGUI.php.

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

Referenced by writePostData().

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

◆ writePostData()

assSingleChoiceGUI::writePostData (   $always = false)

Evaluates a posted edit form and writes the form data in the question object.

Parameters
bool$always
Returns
integer A positive value, if one of the required fields wasn't set, else 0

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

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

52  {
53  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
54  if (!$hasErrors)
55  {
56  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
60  $this->saveTaxonomyAssignments();
61  return 0;
62  }
63  return 1;
64  }
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:

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

References $_POST, and ilUtil\sendInfo().

Referenced by writePostData().

628  {
629  $this->object->setShuffle( $_POST["shuffle"] );
630  $this->object->setMultilineAnswerSetting( $_POST["types"] );
631  if (is_array( $_POST['choice']['imagename'] ) && $_POST["types"] == 1)
632  {
633  $this->object->isSingleline = true;
634  ilUtil::sendInfo( $this->lng->txt( 'info_answer_type_change' ), true );
635  }
636  else
637  {
638  $this->object->isSingleline = ($_POST["types"] == 0) ? true : false;
639  }
640  $this->object->setThumbSize( (strlen( $_POST["thumb_size"] )) ? $_POST["thumb_size"] : "" );
641  }
$_POST['username']
Definition: cron.php:12
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $choiceKeys

assSingleChoiceGUI::$choiceKeys

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

Referenced by getChoiceKeys().


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