ILIAS  release_4-4 Revision
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...
 
 outQuestionForTest ($formaction, $active_id, $pass=NULL, $is_question_postponed=FALSE, $user_post_solutions=FALSE, $show_inline_specific_feedback=FALSE)
 
 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)
 
 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 ($always=true)
 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 ($always=true)
 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 (ilTestPlayerAbstractGUI $linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 assessment ()
 output assessment More...
 
_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...
 
 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 ()
 
 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 ()
 
 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'
 
 $object
 
 $tpl
 
 $lng
 
 $error
 
 $errormessage
 
 $sequence_no
 sequence number in test More...
 
 $question_count
 question count in test More...
 

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
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI More...
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI More...
 
 writeQuestionGenericPostData ()
 

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

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

140  {
141  $this->writePostData(true);
142  $position = key($_POST['cmd']['addchoice']);
143  $this->object->addAnswer("", 0, $position+1);
144  $this->editQuestion();
145  }
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 880 of file class.assSingleChoiceGUI.php.

Referenced by getAggregatedAnswersView().

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

70  {
71  $save = $this->isSaveCommand();
72  $this->getQuestionTemplate();
73 
74  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
75  $form = new ilPropertyFormGUI();
76  $form->setFormAction($this->ctrl->getFormAction($this));
77  $form->setTitle($this->outQuestionType());
78  $isSingleline = ($this->object->lastChange == 0 && !array_key_exists('types', $_POST)) ? (($this->object->getMultilineAnswerSetting()) ? false : true) : $this->object->isSingleline;
79  if ($checkonly) $isSingleline = ($_POST['types'] == 0) ? true : false;
80  if ($isSingleline)
81  {
82  $form->setMultipart(TRUE);
83  }
84  else
85  {
86  $form->setMultipart(FALSE);
87  }
88  $form->setTableWidth("100%");
89  $form->setId("asssinglechoice");
90 
91  $this->addBasicQuestionFormProperties( $form );
92  $this->populateQuestionSpecificFormPart( $form );
93  $this->populateAnswerSpecificFormPart( $form );
94 
95 
96  $this->populateTaxonomyFormSection($form);
97 
98  $this->addQuestionFormCommandButtons($form);
99 
100  $errors = false;
101 
102  if ($save)
103  {
104  $form->setValuesByPost();
105  $errors = !$form->checkInput();
106  $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
107  if ($errors) $checkonly = false;
108  }
109 
110  if (!$checkonly) $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
111  return $errors;
112  }
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.
$errors
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 838 of file class.assSingleChoiceGUI.php.

References ilPropertyFormGUI\getItemByPostVar().

839  {
840  return array();
841  }
+ Here is the call graph for this function:

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

763  {
764  return array('shuffle','types','thumb_size');
765  }

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

References $pass, assQuestionGUI\$tpl, aggregateAnswers(), and renderAggregateView().

862  {
863  $passcount = count($relevant_answers);
864  foreach($relevant_answers as $pass)
865  {
866  $actives[$pass['active_fi']] = $pass['active_fi'];
867  }
868  $usercount = count($actives);
869  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_header.html', true, true, "Modules/TestQuestionPool");
870  $tpl->setVariable('HEADERTEXT', $this->lng->txt('overview'));
871  $tpl->setVariable('NUMBER_OF_USERS_INFO', $this->lng->txt('number_of_users'));
872  $tpl->setVariable('NUMBER_OF_USERS', $usercount);
873  $tpl->setVariable('NUMBER_OF_PASSES_INFO', $this->lng->txt('number_of_passes'));
874  $tpl->setVariable('NUMBER_OF_PASSES', $passcount);
875 
876  return $tpl->get() . $this->renderAggregateView(
877  $this->aggregateAnswers( $relevant_answers, $this->object->getAnswers() ) )->get();
878  }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:

◆ getChoiceKeys()

assSingleChoiceGUI::getChoiceKeys ( )

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

References $_GET, $_SESSION, and $choiceKeys.

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

666  {
667  if (strcmp($_GET["activecommand"], "directfeedback") == 0)
668  {
669  if (is_array($_SESSION["choicekeys"])) $this->choiceKeys = $_SESSION["choicekeys"];
670  }
671  if (!is_array($this->choiceKeys))
672  {
673  $this->choiceKeys = array_keys($this->object->answers);
674  if ($this->object->getShuffle())
675  {
676  $this->choiceKeys = $this->object->pcArrayShuffle($this->choiceKeys);
677  }
678  }
679  $_SESSION["choicekeys"] = $this->choiceKeys;
680  return $this->choiceKeys;
681  }
< 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)

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

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

379  {
380  $keys = $this->getChoiceKeys();
381 
382  // generate the question output
383  include_once "./Services/UICore/classes/class.ilTemplate.php";
384  $template = new ilTemplate("tpl.il_as_qpl_mc_sr_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
385  foreach ($keys as $answer_id)
386  {
387  $answer = $this->object->answers[$answer_id];
388  if (strlen($answer->getImage()))
389  {
390  if ($this->object->getThumbSize())
391  {
392  $template->setCurrentBlock("preview");
393  $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
394  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
395  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
396  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
397  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
398  $alt = $answer->getImage();
399  if (strlen($answer->getAnswertext()))
400  {
401  $alt = $answer->getAnswertext();
402  }
403  $alt = preg_replace("/<[^>]*?>/", "", $alt);
404  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
405  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
406  $template->parseCurrentBlock();
407  }
408  else
409  {
410  $template->setCurrentBlock("answer_image");
411  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
412  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
413  $alt = $answer->getImage();
414  if (strlen($answer->getAnswertext()))
415  {
416  $alt = $answer->getAnswertext();
417  }
418  $alt = preg_replace("/<[^>]*?>/", "", $alt);
419  $template->setVariable("ATTR", $attr);
420  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
421  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
422  $template->parseCurrentBlock();
423  }
424  }
425  $template->setCurrentBlock("answer_row");
426  $template->setVariable("QID", $this->object->getId().'ID');
427  $template->setVariable("ANSWER_ID", $answer_id);
428  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
429  $template->parseCurrentBlock();
430  }
431  $questiontext = $this->object->getQuestion();
432  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
433  $questionoutput = $template->get();
434  if (!$show_question_only)
435  {
436  // get page object output
437  $questionoutput = $this->getILIASPage($questionoutput);
438  }
439  return $questionoutput;
440  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
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 186 of file class.assSingleChoiceGUI.php.

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

197  {
198  // shuffle output
199  $keys = $this->getChoiceKeys();
200 
201  // get the solution of the user for the active pass or from the last pass if allowed
202  $user_solution = "";
203  if (($active_id > 0) && (!$show_correct_solution))
204  {
205  $solutions =& $this->object->getSolutionValues($active_id, $pass);
206  foreach ($solutions as $idx => $solution_value)
207  {
208  $user_solution = $solution_value["value1"];
209  }
210  }
211  else
212  {
213  $found_index = -1;
214  $max_points = 0;
215  foreach ($this->object->answers as $index => $answer)
216  {
217  if ($answer->getPoints() > $max_points)
218  {
219  $max_points = $answer->getPoints();
220  $found_index = $index;
221  }
222  }
223  $user_solution = $found_index;
224  }
225  // generate the question output
226  include_once "./Services/UICore/classes/class.ilTemplate.php";
227  $template = new ilTemplate("tpl.il_as_qpl_mc_sr_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
228  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
229  foreach ($keys as $answer_id)
230  {
231  $answer = $this->object->answers[$answer_id];
232  if (($active_id > 0) && (!$show_correct_solution))
233  {
234  if ($graphicalOutput)
235  {
236  // output of ok/not ok icons for user entered solutions
237  $ok = FALSE;
238  if (strcmp($user_solution, $answer_id) == 0)
239  {
240  if ($answer->getPoints() == $this->object->getMaximumPoints())
241  {
242  $ok = TRUE;
243  }
244  else
245  {
246  $ok = FALSE;
247  }
248  if ($ok)
249  {
250  $template->setCurrentBlock("icon_ok");
251  $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.png"));
252  $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
253  $template->parseCurrentBlock();
254  }
255  else
256  {
257  $template->setCurrentBlock("icon_not_ok");
258  if ($answer->getPoints() > 0)
259  {
260  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.png"));
261  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive"));
262  }
263  else
264  {
265  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.png"));
266  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
267  }
268  $template->parseCurrentBlock();
269  }
270  }
271  if (strlen($user_solution) == 0)
272  {
273  $template->setCurrentBlock("icon_not_ok");
274  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.png"));
275  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
276  $template->parseCurrentBlock();
277  }
278  }
279  }
280  if (strlen($answer->getImage()))
281  {
282  $template->setCurrentBlock("answer_image");
283  if ($this->object->getThumbSize())
284  {
285  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
286  }
287  else
288  {
289  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
290  }
291  $alt = $answer->getImage();
292  if (strlen($answer->getAnswertext()))
293  {
294  $alt = $answer->getAnswertext();
295  }
296  $alt = preg_replace("/<[^>]*?>/", "", $alt);
297  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
298  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
299  $template->parseCurrentBlock();
300  }
301  if ($show_feedback)
302  {
303  $feedbackOutputRequired = false;
304 
305  switch( $this->object->getSpecificFeedbackSetting() )
306  {
307  case 1:
308  $feedbackOutputRequired = true;
309  break;
310 
311  case 2:
312  if (strcmp($user_solution, $answer_id) == 0)
313  {
314  $feedbackOutputRequired = true;
315  }
316  break;
317 
318  case 3:
319  if ($this->object->getAnswer($answer_id)->getPoints() > 0)
320  {
321  $feedbackOutputRequired = true;
322  }
323  break;
324  }
325 
326  if($feedbackOutputRequired)
327  {
328  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
329  $this->object->getId(), $answer_id
330  );
331  if (strlen($fb))
332  {
333  $template->setCurrentBlock("feedback");
334  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $fb, true ));
335  $template->parseCurrentBlock();
336  }
337  }
338  }
339  $template->setCurrentBlock("answer_row");
340  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
341  if (strcmp($user_solution, $answer_id) == 0)
342  {
343  $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_checked.png")));
344  $template->setVariable("SOLUTION_ALT", $this->lng->txt("checked"));
345  }
346  else
347  {
348  $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png")));
349  $template->setVariable("SOLUTION_ALT", $this->lng->txt("unchecked"));
350  }
351  if ($result_output)
352  {
353  $points = $this->object->answers[$answer_id]->getPoints();
354  $resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
355  $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
356  }
357  $template->parseCurrentBlock();
358  }
359  $questiontext = $this->object->getQuestion();
360  if ($show_question_text==true)
361  {
362  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
363  }
364  $questionoutput = $template->get();
365  $feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
366  if (strlen($feedback)) $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $feedback, true ));
367  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
368 
369  $solutionoutput = $solutiontemplate->get();
370  if (!$show_question_only)
371  {
372  // get page object output
373  $solutionoutput = '<div class="ilc_question_Standard">'.$solutionoutput."</div>";
374  }
375  return $solutionoutput;
376  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
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 683 of file class.assSingleChoiceGUI.php.

684  {
685  // No return value, this question type supports inline specific feedback.
686  $output = "";
687  return $this->object->prepareTextareaOutput($output, TRUE);
688  }

◆ getTestOutput()

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

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

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

Referenced by outQuestionForTest().

443  {
444  $keys = $this->getChoiceKeys();
445 
446  // get the solution of the user for the active pass or from the last pass if allowed
447  $user_solution = "";
448  if ($active_id)
449  {
450  $solutions = NULL;
451  include_once "./Modules/Test/classes/class.ilObjTest.php";
452  if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
453  {
454  if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
455  }
456  $solutions =& $this->object->getSolutionValues($active_id, $pass);
457  foreach ($solutions as $idx => $solution_value)
458  {
459  $user_solution = $solution_value["value1"];
460  }
461  }
462 
463  // generate the question output
464  include_once "./Services/UICore/classes/class.ilTemplate.php";
465  $template = new ilTemplate("tpl.il_as_qpl_mc_sr_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
466  foreach ($keys as $answer_id)
467  {
468  $answer = $this->object->answers[$answer_id];
469  if (strlen($answer->getImage()))
470  {
471  if ($this->object->getThumbSize())
472  {
473  $template->setCurrentBlock("preview");
474  $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
475  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
476  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
477  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
478  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
479  $alt = $answer->getImage();
480  if (strlen($answer->getAnswertext()))
481  {
482  $alt = $answer->getAnswertext();
483  }
484  $alt = preg_replace("/<[^>]*?>/", "", $alt);
485  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
486  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
487  $template->parseCurrentBlock();
488  }
489  else
490  {
491  $template->setCurrentBlock("answer_image");
492  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
493  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
494  $alt = $answer->getImage();
495  if (strlen($answer->getAnswertext()))
496  {
497  $alt = $answer->getAnswertext();
498  }
499  $alt = preg_replace("/<[^>]*?>/", "", $alt);
500  $template->setVariable("ATTR", $attr);
501  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
502  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
503  $template->parseCurrentBlock();
504  }
505  }
506  if ($show_feedback)
507  {
508  $feedbackOutputRequired = false;
509 
510  switch( $this->object->getSpecificFeedbackSetting() )
511  {
512  case 1:
513  $feedbackOutputRequired = true;
514  break;
515 
516  case 2:
517  if (strcmp($user_solution, $answer_id) == 0)
518  {
519  $feedbackOutputRequired = true;
520  }
521  break;
522 
523  case 3:
524  if ($this->object->getAnswer($answer_id)->getPoints() > 0)
525  {
526  $feedbackOutputRequired = true;
527  }
528  break;
529  }
530 
531  if($feedbackOutputRequired)
532  {
533  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
534  $this->object->getId(), $answer_id
535  );
536  if (strlen($fb))
537  {
538  $template->setCurrentBlock("feedback");
539  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $fb, true ));
540  $template->parseCurrentBlock();
541  }
542  }
543  }
544  $template->setCurrentBlock("answer_row");
545  $template->setVariable("ANSWER_ID", $answer_id);
546  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
547  if (strcmp($user_solution, $answer_id) == 0)
548  {
549  $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
550  }
551  $template->parseCurrentBlock();
552  }
553  $questiontext = $this->object->getQuestion();
554  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
555  $questionoutput = $template->get();
556  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
557  return $pageoutput;
558  }
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:
+ Here is the caller graph for this function:

◆ outQuestionForTest()

assSingleChoiceGUI::outQuestionForTest (   $formaction,
  $active_id,
  $pass = NULL,
  $is_question_postponed = FALSE,
  $user_post_solutions = FALSE,
  $show_inline_specific_feedback = FALSE 
)

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

References $pass, and getTestOutput().

160  {
161  $test_output = $this->getTestOutput(
162  $active_id,
163  $pass,
164  $is_question_postponed,
165  $user_post_solutions,
166  $show_inline_specific_feedback
167  );
168 
169  $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
170  $this->tpl->setVariable("FORMACTION", $formaction);
171  }
getTestOutput($active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assSingleChoiceGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

808  {
809  $isSingleline = ($this->object->lastChange == 0 && !array_key_exists('types', $_POST)) ? (($this->object->getMultilineAnswerSetting()) ? false : true) : $this->object->isSingleline;
810 
811  // Choices
812  include_once "./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php";
813  $choices = new ilSingleChoiceWizardInputGUI($this->lng->txt( "answers" ), "choice");
814  $choices->setRequired( true );
815  $choices->setQuestionObject( $this->object );
816  $choices->setSingleline( $isSingleline );
817  $choices->setAllowMove( false );
818  if ($this->object->getSelfAssessmentEditingMode())
819  {
820  $choices->setSize( 40 );
821  $choices->setMaxLength( 800 );
822  }
823  if ($this->object->getAnswerCount() == 0)
824  $this->object->addAnswer( "", 0, 0 );
825  $choices->setValues( $this->object->getAnswers() );
826  $form->addItem( $choices );
827  }
$_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:

◆ populateQuestionSpecificFormPart()

assSingleChoiceGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

707  {
708  $isSingleline = ($this->object->lastChange == 0 && !array_key_exists( 'types',$_POST)) ? (($this->object->getMultilineAnswerSetting()) ? false : true) : $this->object->isSingleline;
709  // shuffle
710  $shuffle = new ilCheckboxInputGUI($this->lng->txt( "shuffle_answers" ), "shuffle");
711  $shuffle->setValue( 1 );
712  $shuffle->setChecked( $this->object->getShuffle() );
713  $shuffle->setRequired( FALSE );
714  $form->addItem( $shuffle );
715 
716  if ($this->object->getId())
717  {
718  $hidden = new ilHiddenInputGUI("", "ID");
719  $hidden->setValue( $this->object->getId() );
720  $form->addItem( $hidden );
721  }
722 
723  if (!$this->object->getSelfAssessmentEditingMode())
724  {
725  // Answer types
726  $types = new ilSelectInputGUI($this->lng->txt( "answer_types" ), "types");
727  $types->setRequired( false );
728  $types->setValue( ($isSingleline) ? 0 : 1 );
729  $types->setOptions( array(
730  0 => $this->lng->txt( 'answers_singleline' ),
731  1 => $this->lng->txt( 'answers_multiline' ),
732  )
733  );
734  $form->addItem( $types );
735  }
736 
737  if ($isSingleline)
738  {
739  // thumb size
740  $thumb_size = new ilNumberInputGUI($this->lng->txt( "thumb_size" ), "thumb_size");
741  $thumb_size->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
742  $thumb_size->setMinValue( 20 );
743  $thumb_size->setDecimals( 0 );
744  $thumb_size->setSize( 6 );
745  $thumb_size->setInfo( $this->lng->txt( 'thumb_size_info' ) );
746  $thumb_size->setValue( $this->object->getThumbSize() );
747  $thumb_size->setRequired( false );
748  $form->addItem( $thumb_size );
749  }
750  return $form;
751  }
$_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 150 of file class.assSingleChoiceGUI.php.

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

151  {
152  $this->writePostData(true);
153  $position = key($_POST['cmd']['removechoice']);
154  $this->object->deleteAnswer($position);
155  $this->editQuestion();
156  }
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 127 of file class.assSingleChoiceGUI.php.

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

128  {
129  $this->writePostData(true);
130  $position = key($_POST['cmd']['removeimagechoice']);
131  $filename = $_POST['choice']['imagename'][$position];
132  $this->object->removeAnswerImage($position);
133  $this->editQuestion();
134  }
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 910 of file class.assSingleChoiceGUI.php.

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

911  {
912  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
913  $tpl->setVariable( 'OPTION_HEADER', $this->lng->txt('option') );
914  $tpl->setVariable( 'COUNT_HEADER', $this->lng->txt('count') );
915  $tpl->setVariable( 'AGGREGATION_HEADER', $this->lng->txt('aggregated_answers_header') );
916  foreach ($aggregate as $line_data)
917  {
918  $tpl->setCurrentBlock( 'aggregaterow' );
919  $tpl->setVariable( 'OPTION', $line_data['answertext'] );
920  $tpl->setVariable( 'COUNT', $line_data['count_checked'] );
921  $tpl->parseCurrentBlock();
922  }
923  return $tpl;
924  }
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 567 of file class.assSingleChoiceGUI.php.

References $_GET, $ref_id, assQuestionGUI\addTab_QuestionFeedback(), assQuestionGUI\addTab_QuestionHints(), and ilTestExpressPage\getReturnToPageLink().

568  {
569  global $rbacsystem, $ilTabs;
570 
571  $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
572  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
573  $q_type = $this->object->getQuestionType();
574 
575  if (strlen($q_type))
576  {
577  $classname = $q_type . "GUI";
578  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
579  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
580  }
581 
582  if ($_GET["q_id"])
583  {
584  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
585  {
586  // edit page
587  $ilTabs->addTarget("edit_page",
588  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
589  array("edit", "insert", "exec_pg"),
590  "", "", $force_active);
591  }
592 
593  // edit page
594  $ilTabs->addTarget("preview",
595  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "preview"),
596  array("preview"),
597  "ilAssQuestionPageGUI", "", $force_active);
598  }
599 
600  $force_active = false;
601  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
602  {
603  $url = "";
604  if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
605  // edit question properties
606  $ilTabs->addTarget("edit_question",
607  $url,
608  array("editQuestion", "save", "saveEdit", "addchoice", "removechoice", "removeimagechoice", "uploadchoice", "originalSyncForm"),
609  $classname, "", $force_active);
610  }
611 
612  // add tab for question feedback within common class assQuestionGUI
613  $this->addTab_QuestionFeedback($ilTabs);
614 
615  // add tab for question hint within common class assQuestionGUI
616  $this->addTab_QuestionHints($ilTabs);
617 
618  if ($_GET["q_id"])
619  {
620  $ilTabs->addTarget("solution_hint",
621  $this->ctrl->getLinkTargetByClass($classname, "suggestedsolution"),
622  array("suggestedsolution", "saveSuggestedSolution", "outSolutionExplorer", "cancel",
623  "addSuggestedSolution","cancelExplorer", "linkChilds", "removeSuggestedSolution"
624  ),
625  $classname,
626  ""
627  );
628  }
629 
630  // Assessment of questions sub menu entry
631  if ($_GET["q_id"])
632  {
633  $ilTabs->addTarget("statistics",
634  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
635  array("assessment"),
636  $classname, "");
637  }
638 
639  if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
640  {
641  $ref_id = $_GET["calling_test"];
642  if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
643 
644  global $___test_express_mode;
645 
646  if (!$_GET['test_express_mode'] && !$___test_express_mode) {
647  $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
648  }
649  else {
651  $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), $link);
652  }
653  }
654  else
655  {
656  $ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
657  }
658  }
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
$_GET["client_id"]
static getReturnToPageLink($q_id=null)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:

◆ uploadchoice()

assSingleChoiceGUI::uploadchoice ( )

Upload an image.

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

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

118  {
119  $this->writePostData(true);
120  $position = key($_POST['cmd']['uploadchoice']);
121  $this->editQuestion();
122  }
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 (   $always = true)

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

References $_POST, and $filename.

Referenced by writePostData().

768  {
769  // Delete all existing answers and create new answers from the form data
770  $this->object->flushAnswers();
771  if ($this->object->isSingleline)
772  {
773  foreach ($_POST['choice']['answer'] as $index => $answertext)
774  {
775  $picturefile = $_POST['choice']['imagename'][$index];
776  $file_org_name = $_FILES['choice']['name']['image'][$index];
777  $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index];
778 
779  if (strlen( $file_temp_name ))
780  {
781  // check suffix
782  $suffix = strtolower( array_pop( explode( ".", $file_org_name ) ) );
783  if (in_array( $suffix, array( "jpg", "jpeg", "png", "gif" ) ))
784  {
785  // upload image
786  $filename = $this->object->createNewImageFileName( $file_org_name );
787  if ($this->object->setImageFile( $filename, $file_temp_name ) == 0)
788  {
789  $picturefile = $filename;
790  }
791  }
792  }
793 
794  $this->object->addAnswer( $answertext, $_POST['choice']['points'][$index], $index, $picturefile );
795  }
796  }
797  else
798  {
799  foreach ($_POST['choice']['answer'] as $index => $answer)
800  {
801  $answertext = $answer;
802  $this->object->addAnswer( $answertext, $_POST['choice']['points'][$index], $index );
803  }
804  }
805  }
$_POST['username']
Definition: cron.php:12
$filename
Definition: buildRTE.php:89
+ 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  {
59  $this->saveTaxonomyAssignments();
60  return 0;
61  }
62  return 1;
63  }
writeAnswerSpecificPostData($always=true)
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($always=true)
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 (   $always = true)

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

References $_POST, and ilUtil\sendInfo().

Referenced by writePostData().

691  {
692  $this->object->setShuffle( $_POST["shuffle"] );
693  $this->object->setMultilineAnswerSetting( $_POST["types"] );
694  if (is_array( $_POST['choice']['imagename'] ) && $_POST["types"] == 1)
695  {
696  $this->object->isSingleline = true;
697  ilUtil::sendInfo( $this->lng->txt( 'info_answer_type_change' ), true );
698  }
699  else
700  {
701  $this->object->isSingleline = ($_POST["types"] == 0) ? true : false;
702  }
703  $this->object->setThumbSize( (strlen( $_POST["thumb_size"] )) ? $_POST["thumb_size"] : "" );
704  }
$_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: