ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
assMultipleChoiceGUI Class Reference

Multiple choice question GUI representation. More...

+ Inheritance diagram for assMultipleChoiceGUI:
+ Collaboration diagram for assMultipleChoiceGUI:

Public Member Functions

 __construct ($id=-1)
 assMultipleChoiceGUI constructor More...
 
 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...
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 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 ()
 Create the key index numbers for the array of choices. More...
 
 getSpecificFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 
 populateAnswerSpecificFormPart (\ilPropertyFormGUI $form)
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAggregatedAnswersView ($relevant_answers)
 Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface. More...
 
 aggregateAnswers ($relevant_answers_chosen, $answers_defined_on_question)
 
 renderAggregateView ($aggregate)
 
- 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...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAggregatedAnswersView ($relevant_answers)
 Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface. More...
 
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. 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

 populateSpecificFeedbackInline ($user_solution, $answer_id, $template)
 

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

Multiple choice question GUI representation.

The assMultipleChoiceGUI class encapsulates the GUI representation for multiple choice questions.

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

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

Constructor & Destructor Documentation

◆ __construct()

assMultipleChoiceGUI::__construct (   $id = -1)

assMultipleChoiceGUI constructor

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

Parameters
integer$idThe database id of a multiple choice question object @access public

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

36 {
37 parent::__construct();
38 include_once "./Modules/TestQuestionPool/classes/class.assMultipleChoice.php";
39 $this->object = new assMultipleChoice();
40 if ($id >= 0)
41 {
42 $this->object->loadFromDb($id);
43 }
44 }
Class for multiple choice tests.

Member Function Documentation

◆ addBasicQuestionFormProperties()

assMultipleChoiceGUI::addBasicQuestionFormProperties ( ilPropertyFormGUI  $form)

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

119 {
120 parent::addBasicQuestionFormProperties($form);
121 $form->getItemByPostVar('question')->setInitialRteWidth('100');
122 }
getItemByPostVar($a_post_var)
Get Item by POST variable.

References ilPropertyFormGUI\getItemByPostVar().

Referenced by editQuestion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addchoice()

assMultipleChoiceGUI::addchoice ( )

Add a new answer.

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

150 {
151 $this->writePostData(true);
152 $position = key($_POST['cmd']['addchoice']);
153 $this->object->addAnswer("", 0, 0, $position+1);
154 $this->editQuestion();
155 }
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
$_POST['username']
Definition: cron.php:12

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

+ Here is the call graph for this function:

◆ aggregateAnswers()

assMultipleChoiceGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)

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

873 {
874 $aggregate = array();
875 foreach ($answers_defined_on_question as $answer)
876 {
877 $aggregated_info_for_answer = array();
878 $aggregated_info_for_answer['answertext'] = $answer->getAnswerText();
879 $aggregated_info_for_answer['count_checked'] = 0;
880
881 foreach ($relevant_answers_chosen as $relevant_answer)
882 {
883 if ($relevant_answer['value1'] == $answer->getOrder())
884 {
885 $aggregated_info_for_answer['count_checked']++;
886 }
887 }
888 $aggregated_info_for_answer['count_unchecked'] =
889 ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
890 - $aggregated_info_for_answer['count_checked'];
891
892 $aggregate[] = $aggregated_info_for_answer;
893 }
894 return $aggregate;
895 }

Referenced by getAggregatedAnswersView().

+ Here is the caller graph for this function:

◆ editQuestion()

assMultipleChoiceGUI::editQuestion (   $checkonly = FALSE)

Creates an output of the edit form for the question.

Parameters
bool$checkonly
Returns
bool

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

76 {
77 $save = $this->isSaveCommand();
78 $this->getQuestionTemplate();
79
80 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
81 $form = new ilPropertyFormGUI();
82 $form->setFormAction($this->ctrl->getFormAction($this));
83 $form->setTitle($this->outQuestionType());
84 $isSingleline = ($this->object->lastChange == 0 && !array_key_exists('types', $_POST)) ? (($this->object->getMultilineAnswerSetting()) ? false : true) : $this->object->isSingleline;
85 if ($checkonly) $isSingleline = ($_POST['types'] == 0) ? true : false;
86 if ($isSingleline)
87 {
88 $form->setMultipart(TRUE);
89 }
90 else
91 {
92 $form->setMultipart(FALSE);
93 }
94 $form->setTableWidth("100%");
95 $form->setId("assmultiplechoice");
96
97 // title, author, description, question, working time (assessment mode)
98 $this->addBasicQuestionFormProperties( $form );
100 $this->populateAnswerSpecificFormPart( $form );
101 $this->populateTaxonomyFormSection($form);
102 $this->addQuestionFormCommandButtons($form);
103
104 $errors = false;
105
106 if ($save)
107 {
108 $form->setValuesByPost();
109 $errors = !$form->checkInput();
110 $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
111 if ($errors) $checkonly = false;
112 }
113
114 if (!$checkonly) $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
115 return $errors;
116 }
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
getQuestionTemplate()
get question template
This class represents a property form user interface.
if(!file_exists(getcwd().'/ilias.ini.php')) if(isset( $_GET["client_id"]))
registration confirmation script for ilias
Definition: confirmReg.php:20
$errors

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAfterParticipationSuppressionAnswerPostVars()

assMultipleChoiceGUI::getAfterParticipationSuppressionAnswerPostVars ( )

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

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

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

Returns
string[]

Implements ilGuiAnswerScoringAdjustable.

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

840 {
841 return array();
842 }

◆ getAfterParticipationSuppressionQuestionPostVars()

assMultipleChoiceGUI::getAfterParticipationSuppressionQuestionPostVars ( )

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

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

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

Returns
string[]

Implements ilGuiQuestionScoringAdjustable.

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

854 {
855 return array();
856 }

◆ getAggregatedAnswersView()

assMultipleChoiceGUI::getAggregatedAnswersView (   $relevant_answers)

Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface.

Parameters
array$relevant_answers
Returns
string

Implements ilGuiQuestionScoringAdjustable.

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

867 {
868 return $this->renderAggregateView(
869 $this->aggregateAnswers( $relevant_answers, $this->object->getAnswers() ) )->get();
870 }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)

References aggregateAnswers(), and renderAggregateView().

+ Here is the call graph for this function:

◆ getChoiceKeys()

assMultipleChoiceGUI::getChoiceKeys ( )

Create the key index numbers for the array of choices.

Returns
array

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

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

References $_GET, $_SESSION, and $choiceKeys.

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

+ Here is the caller graph for this function:

◆ getPreview()

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

Reimplemented from assQuestionGUI.

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

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

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

+ Here is the call graph for this function:

◆ getSolutionOutput()

assMultipleChoiceGUI::getSolutionOutput (   $active_id,
  $pass = NULL,
  $graphicalOutput = FALSE,
  $result_output = FALSE,
  $show_question_only = TRUE,
  $show_feedback = FALSE,
  $show_correct_solution = FALSE,
  $show_manual_scoring = FALSE,
  $show_question_text = TRUE 
)

Get the question solution output.

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

Reimplemented from assQuestionGUI.

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

194 {
195 // shuffle output
196 $keys = $this->getChoiceKeys();
197
198 // get the solution of the user for the active pass or from the last pass if allowed
199 $user_solution = array();
200 if (($active_id > 0) && (!$show_correct_solution))
201 {
202 $solutions =& $this->object->getSolutionValues($active_id, $pass);
203 foreach ($solutions as $idx => $solution_value)
204 {
205 array_push($user_solution, $solution_value["value1"]);
206 }
207 }
208 else
209 {
210 // take the correct solution instead of the user solution
211 foreach ($this->object->answers as $index => $answer)
212 {
213 $points_checked = $answer->getPointsChecked();
214 $points_unchecked = $answer->getPointsUnchecked();
215 if ($points_checked > $points_unchecked)
216 {
217 if ($points_checked > 0)
218 {
219 array_push($user_solution, $index);
220 }
221 }
222 }
223 }
224
225 // generate the question output
226 include_once "./Services/UICore/classes/class.ilTemplate.php";
227 $template = new ilTemplate("tpl.il_as_qpl_mc_mr_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 $checked = FALSE;
239 foreach ($user_solution as $mc_solution)
240 {
241 if (strcmp($mc_solution, $answer_id) == 0)
242 {
243 $checked = TRUE;
244 }
245 }
246 if ($checked)
247 {
248 if ($answer->getPointsChecked() > $answer->getPointsUnchecked())
249 {
250 $ok = TRUE;
251 }
252 else
253 {
254 $ok = FALSE;
255 }
256 }
257 else
258 {
259 if ($answer->getPointsChecked() > $answer->getPointsUnchecked())
260 {
261 $ok = FALSE;
262 }
263 else
264 {
265 $ok = TRUE;
266 }
267 }
268 if ($ok)
269 {
270 $template->setCurrentBlock("icon_ok");
271 $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
272 $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
273 $template->parseCurrentBlock();
274 }
275 else
276 {
277 $template->setCurrentBlock("icon_ok");
278 $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
279 $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
280 $template->parseCurrentBlock();
281 }
282 }
283 }
284 if (strlen($answer->getImage()))
285 {
286 $template->setCurrentBlock("answer_image");
287 if ($this->object->getThumbSize())
288 {
289 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
290 }
291 else
292 {
293 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
294 }
295 $alt = $answer->getImage();
296 if (strlen($answer->getAnswertext()))
297 {
298 $alt = $answer->getAnswertext();
299 }
300 $alt = preg_replace("/<[^>]*?>/", "", $alt);
301 $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
302 $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
303 $template->parseCurrentBlock();
304 }
305
306 if ($show_feedback)
307 {
308
309 if ($this->object->getSpecificFeedbackSetting() == 2)
310 {
311 foreach ($user_solution as $mc_solution)
312 {
313 if (strcmp($mc_solution, $answer_id) == 0)
314 {
315 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
316 $this->object->getId(), $answer_id
317 );
318 if (strlen($fb))
319 {
320 $template->setCurrentBlock("feedback");
321 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $fb, true ));
322 $template->parseCurrentBlock();
323 }
324 }
325 }
326 }
327
328 if ($this->object->getSpecificFeedbackSetting() == 1)
329 {
330 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
331 $this->object->getId(), $answer_id
332 );
333 if (strlen($fb))
334 {
335 $template->setCurrentBlock("feedback");
336 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $fb, true ));
337 $template->parseCurrentBlock();
338 }
339 }
340
341 if ($this->object->getSpecificFeedbackSetting() == 3)
342 {
343 $answer = $this->object->getAnswer($answer_id);
344
345 if ($answer->getPoints() > 0)
346 {
347 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
348 $this->object->getId(), $answer_id
349 );
350 if (strlen($fb))
351 {
352 $template->setCurrentBlock("feedback");
353 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $fb, true ));
354 $template->parseCurrentBlock();
355 }
356 }
357
358 }
359 }
360 $template->setCurrentBlock("answer_row");
361 $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
362 $checked = FALSE;
363 if ($result_output)
364 {
365 $pointschecked = $this->object->answers[$answer_id]->getPointsChecked();
366 $pointsunchecked = $this->object->answers[$answer_id]->getPointsUnchecked();
367 $resulttextchecked = ($pointschecked == 1) || ($pointschecked == -1) ? "%s " . $this->lng->txt("point") : "%s " . $this->lng->txt("points");
368 $resulttextunchecked = ($pointsunchecked == 1) || ($pointsunchecked == -1) ? "%s " . $this->lng->txt("point") : "%s " . $this->lng->txt("points");
369 $template->setVariable("RESULT_OUTPUT", sprintf("(" . $this->lng->txt("checkbox_checked") . " = $resulttextchecked, " . $this->lng->txt("checkbox_unchecked") . " = $resulttextunchecked)", $pointschecked, $pointsunchecked));
370 }
371 foreach ($user_solution as $mc_solution)
372 {
373 if (strcmp($mc_solution, $answer_id) == 0)
374 {
375 $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_checked.png")));
376 $template->setVariable("SOLUTION_ALT", $this->lng->txt("checked"));
377 $checked = TRUE;
378 }
379 }
380 if (!$checked)
381 {
382 $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.png")));
383 $template->setVariable("SOLUTION_ALT", $this->lng->txt("unchecked"));
384 }
385 $template->parseCurrentBlock();
386 }
387 $questiontext = $this->object->getQuestion();
388 if ($show_question_text==true)
389 {
390 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
391 }
392 $questionoutput = $template->get();
393 $feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
394
395 if (strlen($feedback)) $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $feedback , true ));
396 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
397
398 $solutionoutput = $solutiontemplate->get();
399 if (!$show_question_only)
400 {
401 // get page object output
402 $solutionoutput = $this->getILIASPage($solutionoutput);
403 }
404 return $solutionoutput;
405 }
getAnswerFeedbackOutput($active_id, $pass)
Returns the answer generic feedback depending on the results of the question.
static getHtmlPath($relative_path)
get url of path

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

+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assMultipleChoiceGUI::getSpecificFeedbackOutput (   $active_id,
  $pass 
)

Returns the answer specific feedback for the question.

This method should be overwritten by the actual question.

Todo:
Mark this method abstract!
Parameters
integer$active_idActive ID of the user
integer$passActive pass
Returns
string HTML Code with the answer specific feedback @access public

Reimplemented from assQuestionGUI.

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

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

◆ getTestOutput()

assMultipleChoiceGUI::getTestOutput (   $active_id,
  $pass = NULL,
  $is_postponed = FALSE,
  $use_post_solutions = FALSE,
  $show_feedback = FALSE 
)
Parameters
integer$active_id
integer | null$pass
bool$is_postponed
bool$use_post_solutions
bool$show_feedback
Returns
string

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

501 {
502 // shuffle output
503 $keys = $this->getChoiceKeys();
504
505 // get the solution of the user for the active pass or from the last pass if allowed
506 $user_solution = array();
507 if ($active_id)
508 {
509 $solutions = NULL;
510 include_once "./Modules/Test/classes/class.ilObjTest.php";
511 if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
512 {
513 if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
514 }
515 $solutions =& $this->object->getSolutionValues($active_id, $pass);
516 foreach ($solutions as $idx => $solution_value)
517 {
518 array_push($user_solution, $solution_value["value1"]);
519 }
520 }
521 // generate the question output
522 include_once "./Services/UICore/classes/class.ilTemplate.php";
523 $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
524 foreach ($keys as $answer_id)
525 {
526 $answer = $this->object->answers[$answer_id];
527 if (strlen($answer->getImage()))
528 {
529 if ($this->object->getThumbSize())
530 {
531 $template->setCurrentBlock("preview");
532 $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
533 $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
534 $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
535 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
536 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
537 $alt = $answer->getImage();
538 if (strlen($answer->getAnswertext()))
539 {
540 $alt = $answer->getAnswertext();
541 }
542 $alt = preg_replace("/<[^>]*?>/", "", $alt);
543 $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
544 $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
545 $template->parseCurrentBlock();
546 }
547 else
548 {
549 $template->setCurrentBlock("answer_image");
550 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
551 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
552 $alt = $answer->getImage();
553 if (strlen($answer->getAnswertext()))
554 {
555 $alt = $answer->getAnswertext();
556 }
557 $alt = preg_replace("/<[^>]*?>/", "", $alt);
558 $template->setVariable("ATTR", $attr);
559 $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
560 $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
561 $template->parseCurrentBlock();
562 }
563 }
564
565 if( $show_feedback )
566 {
567 $this->populateSpecificFeedbackInline($user_solution, $answer_id, $template);
568 }
569
570 $template->setCurrentBlock("answer_row");
571 $template->setVariable("ANSWER_ID", $answer_id);
572 $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
573 foreach ($user_solution as $mc_solution)
574 {
575 if (strcmp($mc_solution, $answer_id) == 0)
576 {
577 $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
578 }
579 }
580 $template->parseCurrentBlock();
581 }
582 $questiontext = $this->object->getQuestion();
583 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
584 $questionoutput = $template->get();
585 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
586 return $pageoutput;
587 }
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
_getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.

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

+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assMultipleChoiceGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

References $_POST, and ilPropertyFormGUI\addItem().

Referenced by editQuestion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateQuestionSpecificFormPart()

assMultipleChoiceGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

758 {
759 // shuffle
760 $shuffle = new ilCheckboxInputGUI($this->lng->txt( "shuffle_answers" ), "shuffle");
761 $shuffle->setValue( 1 );
762 $shuffle->setChecked( $this->object->getShuffle() );
763 $shuffle->setRequired( FALSE );
764 $form->addItem( $shuffle );
765
766 if ($this->object->getId())
767 {
768 $hidden = new ilHiddenInputGUI("", "ID");
769 $hidden->setValue( $this->object->getId() );
770 $form->addItem( $hidden );
771 }
772
773 if (!$this->object->getSelfAssessmentEditingMode())
774 {
775 $isSingleline = ($this->object->lastChange == 0 && !array_key_exists( 'types',
776 $_POST
777 )) ? (($this->object->getMultilineAnswerSetting()) ? false : true) : $this->object->isSingleline;
778 // Answer types
779 $types = new ilSelectInputGUI($this->lng->txt( "answer_types" ), "types");
780 $types->setRequired( false );
781 $types->setValue( ($isSingleline) ? 0 : 1 );
782 $types->setOptions( array(
783 0 => $this->lng->txt( 'answers_singleline' ),
784 1 => $this->lng->txt( 'answers_multiline' ),
785 )
786 );
787 $form->addItem( $types );
788 }
789
790 if ($isSingleline)
791 {
792 // thumb size
793 $thumb_size = new ilNumberInputGUI($this->lng->txt( "thumb_size" ), "thumb_size");
794 $thumb_size->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
795 $thumb_size->setMinValue( 20 );
796 $thumb_size->setDecimals( 0 );
797 $thumb_size->setSize( 6 );
798 $thumb_size->setInfo( $this->lng->txt( 'thumb_size_info' ) );
799 $thumb_size->setValue( $this->object->getThumbSize() );
800 $thumb_size->setRequired( false );
801 $form->addItem( $thumb_size );
802 return $isSingleline;
803 }
804 return $isSingleline;
805 }
This class represents a checkbox property in a property form.
setRequired($a_required)
Set Required.
This class represents a hidden form property in a property form.
This class represents a number property in a property form.
This class represents a selection list property in a property form.

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

Referenced by editQuestion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateSpecificFeedbackInline()

assMultipleChoiceGUI::populateSpecificFeedbackInline (   $user_solution,
  $answer_id,
  $template 
)
private
Parameters
$user_solution
$answer_id
$template
Returns
array

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

923 {
924 if($this->object->getSpecificFeedbackSetting() == 2)
925 {
926 foreach($user_solution as $mc_solution)
927 {
928 if(strcmp($mc_solution, $answer_id) == 0)
929 {
930 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id);
931 if(strlen($fb))
932 {
933 $template->setCurrentBlock("feedback");
934 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
935 $template->parseCurrentBlock();
936 }
937 }
938 }
939 }
940
941 if($this->object->getSpecificFeedbackSetting() == 1)
942 {
943 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id);
944 if(strlen($fb))
945 {
946 $template->setCurrentBlock("feedback");
947 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
948 $template->parseCurrentBlock();
949 }
950 }
951
952 if($this->object->getSpecificFeedbackSetting() == 3)
953 {
954 $answer = $this->object->getAnswer($answer_id);
955
956 if($answer->getPoints() > 0)
957 {
958 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id);
959 if(strlen($fb))
960 {
961 $template->setCurrentBlock("feedback");
962 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
963 $template->parseCurrentBlock();
964 }
965 }
966 }
967 }

Referenced by getPreview(), and getTestOutput().

+ Here is the caller graph for this function:

◆ removechoice()

assMultipleChoiceGUI::removechoice ( )

Remove an answer.

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

161 {
162 $this->writePostData(true);
163 $position = key($_POST['cmd']['removechoice']);
164 $this->object->deleteAnswer($position);
165 $this->editQuestion();
166 }

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

+ Here is the call graph for this function:

◆ removeimagechoice()

assMultipleChoiceGUI::removeimagechoice ( )

Remove an image.

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

138 {
139 $this->writePostData(true);
140 $position = key($_POST['cmd']['removeimagechoice']);
141 $filename = $_POST['choice']['imagename'][$position];
142 $this->object->removeAnswerImage($position);
143 $this->editQuestion();
144 }
$filename
Definition: buildRTE.php:89

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

+ Here is the call graph for this function:

◆ renderAggregateView()

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

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

903 {
904 $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
905
906 foreach ($aggregate as $line_data)
907 {
908 $tpl->setCurrentBlock( 'aggregaterow' );
909 $tpl->setVariable( 'OPTION', $line_data['answertext'] );
910 $tpl->setVariable( 'COUNT', $line_data['count_checked'] );
911 $tpl->parseCurrentBlock();
912 }
913 return $tpl;
914 }

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

+ Here is the caller graph for this function:

◆ setQuestionTabs()

assMultipleChoiceGUI::setQuestionTabs ( )

Sets the ILIAS tabs for this question type.

Todo:
: MOVE THIS STEPS TO COMMON QUESTION CLASS assQuestionGUI

Reimplemented from assQuestionGUI.

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

595 {
596 global $rbacsystem, $ilTabs;
597
598 $ilTabs->clearTargets();
599
600 $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
601 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
602 $q_type = $this->object->getQuestionType();
603
604 if (strlen($q_type))
605 {
606 $classname = $q_type . "GUI";
607 $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
608 $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
609 }
610
611 if ($_GET["q_id"])
612 {
613 if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
614 {
615 // edit page
616 $ilTabs->addTarget("edit_page",
617 $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
618 array("edit", "insert", "exec_pg"),
619 "", "", $force_active);
620 }
621
622 $this->addTab_QuestionPreview($ilTabs);
623 }
624 $force_active = false;
625 if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
626 {
627 $url = "";
628 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
629 $force_active = false;
630 // edit question properties
631 $ilTabs->addTarget("edit_question",
632 $url,
633 array("editQuestion", "save", "saveEdit", "addchoice", "removechoice", "removeimagechoice", "uploadchoice", "originalSyncForm"),
634 $classname, "", $force_active);
635 }
636
637 // add tab for question feedback within common class assQuestionGUI
638 $this->addTab_QuestionFeedback($ilTabs);
639
640 // add tab for question hint within common class assQuestionGUI
641 $this->addTab_QuestionHints($ilTabs);
642
643 // add tab for question's suggested solution within common class assQuestionGUI
644 $this->addTab_SuggestedSolution($ilTabs, $classname);
645
646 // Assessment of questions sub menu entry
647 if ($_GET["q_id"])
648 {
649 $ilTabs->addTarget("statistics",
650 $this->ctrl->getLinkTargetByClass($classname, "assessment"),
651 array("assessment"),
652 $classname, "");
653 }
654
655 $this->addBackTab($ilTabs);
656 }
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
addBackTab(ilTabsGUI $ilTabs)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addTab_QuestionPreview(ilTabsGUI $tabsGUI)

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

+ Here is the call graph for this function:

◆ uploadchoice()

assMultipleChoiceGUI::uploadchoice ( )

Upload an image.

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

128 {
129 $this->writePostData(true);
130 $position = key($_POST['cmd']['uploadchoice']);
131 $this->editQuestion();
132 }

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

+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assMultipleChoiceGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

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

Implements ilGuiAnswerScoringAdjustable.

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

708 {
709 // Delete all existing answers and create new answers from the form data
710 $this->object->flushAnswers();
711 if ($this->object->isSingleline)
712 {
713 foreach ($_POST['choice']['answer'] as $index => $answertext)
714 {
715 $answertext = ilUtil::secureString($answertext);
716
717 $picturefile = $_POST['choice']['imagename'][$index];
718 $file_org_name = $_FILES['choice']['name']['image'][$index];
719 $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index];
720
721 if (strlen( $file_temp_name ))
722 {
723 // check suffix
724 $suffix = strtolower( array_pop( explode( ".", $file_org_name ) ) );
725 if (in_array( $suffix, array( "jpg", "jpeg", "png", "gif" ) ))
726 {
727 // upload image
728 $filename = $this->object->createNewImageFileName( $file_org_name );
729 if ($this->object->setImageFile( $filename, $file_temp_name ) == 0)
730 {
731 $picturefile = $filename;
732 }
733 }
734 }
735 $this->object->addAnswer( $answertext,
736 $_POST['choice']['points'][$index],
737 $_POST['choice']['points_unchecked'][$index],
738 $index,
739 $picturefile
740 );
741 }
742 }
743 else
744 {
745 foreach ($_POST['choice']['answer'] as $index => $answer)
746 {
747 $answertext = $answer;
748 $this->object->addAnswer( $answertext,
749 $_POST['choice']['points'][$index],
750 $_POST['choice']['points_unchecked'][$index],
751 $index
752 );
753 }
754 }
755 }
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.

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

Referenced by writePostData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

assMultipleChoiceGUI::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 53 of file class.assMultipleChoiceGUI.php.

54 {
55 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
56 if (!$hasErrors)
57 {
58 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
63 return 0;
64 }
65 return 1;
66 }
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.

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

+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assMultipleChoiceGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

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

Implements ilGuiQuestionScoringAdjustable.

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

689 {
690 $this->object->setShuffle( $_POST["shuffle"] );
691
692 $this->object->setSpecificFeedbackSetting( $_POST['feedback_setting'] );
693
694 $this->object->setMultilineAnswerSetting( $_POST["types"] );
695 if (is_array( $_POST['choice']['imagename'] ) && $_POST["types"] == 1)
696 {
697 $this->object->isSingleline = true;
698 ilUtil::sendInfo( $this->lng->txt( 'info_answer_type_change' ), true );
699 }
700 else
701 {
702 $this->object->isSingleline = ($_POST["types"] == 0) ? true : false;
703 }
704 $this->object->setThumbSize( (strlen( $_POST["thumb_size"] )) ? $_POST["thumb_size"] : "" );
705 }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $_POST, and ilUtil\sendInfo().

Referenced by writePostData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $choiceKeys

assMultipleChoiceGUI::$choiceKeys

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

Referenced by getChoiceKeys().


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