ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
assSingleChoiceGUI Class Reference

Single choice question GUI representation. More...

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

Public Member Functions

 __construct ($id=-1)
 assSingleChoiceGUI constructor More...
 
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 editQuestion ($checkonly=FALSE)
 Creates an output of the edit form for the question. More...
 
 uploadchoice ()
 Upload an image. More...
 
 removeimagechoice ()
 Remove an image. More...
 
 addchoice ()
 Add a new answer. More...
 
 removechoice ()
 Remove an answer. More...
 
 getSolutionOutput ( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
 Get the question solution output. More...
 
 getPreview ($show_question_only=FALSE, $showInlineFeedback=false)
 
 getTestOutput ($active_id, $pass, $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)
 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...
 
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 populateAnswerSpecificFormPart (\ilPropertyFormGUI $form)
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAggregatedAnswersView ($relevant_answers)
 Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface. More...
 
 aggregateAnswers ($relevant_answers_chosen, $answers_defined_on_question)
 
 renderAggregateView ($aggregate)
 
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor More...
 
executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext ($presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled ($previousSolutionPrefilled)
 
 getOutputMode ()
 
 setOutputMode ($outputMode)
 
 isPdfOutputMode ()
 
 isContentEditingOutputMode ()
 
 getNavigationGUI ()
 
 setNavigationGUI ($navigationGUI)
 
 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...
 
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question. More...
 
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 showSuggestedSolution ()
 
 suggestedsolution ()
 Allows to add suggested solutions for questions. More...
 
 outSolutionExplorer ()
 
 saveSuggestedSolution ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, $classname)
 
 getEditQuestionTabCommands ()
 
 getSolutionOutput ( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
 
 isAutosaveable ()
 
 getPreview ($show_question_only=FALSE, $showInlineFeedback=false)
 
 outQuestionForTest ( $formaction, $active_id, $pass, $is_question_postponed=FALSE, $user_post_solutions=FALSE, $show_specific_inline_feedback=FALSE)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession ($previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
 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...
 

Protected Member Functions

 getEditAnswersSingleLine ($checkonly=false)
 Get the single/multiline editing of answers. More...
 
- Protected Member Functions inherited from assQuestionGUI
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 getPreviousSolutionProvidedMessage ()
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 isLastSolutionSubmitAuthorized ($active_id, $pass)
 fetches solutions from database and prefers intermediate solutions, but falls back to authorized solutions. More...
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI More...
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI More...
 
 addTab_QuestionPreview (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 getTestOutputSolutions ($activeId, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 

Private Member Functions

 populateInlineFeedback ($template, $answer_id, $user_solution)
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static getCommandsFromClassConstants ($guiClassName, $cmdConstantNameBegin='CMD_')
 extracts values of all constants of given class with given prefix as array can be used to get all possible commands in case of these commands are defined as constants More...
 
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
 $object
 
 $tpl
 
 $lng
 
 $error
 
 $errormessage
 
 $sequence_no
 sequence number in test More...
 
 $question_count
 question count in test More...
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const OUTPUT_MODE_SCREEN = 'outModeScreen'
 
const OUTPUT_MODE_PDF = 'outModePdf'
 
const OUTPUT_MODE_CONTENT_EDITING = 'outModeUsrSol'
 

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

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

Member Function Documentation

◆ addchoice()

assSingleChoiceGUI::addchoice ( )

Add a new answer.

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

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

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

+ Here is the call graph for this function:

◆ aggregateAnswers()

assSingleChoiceGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)

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

843 {
844 $aggregate = array();
845 foreach ($answers_defined_on_question as $answer)
846 {
847 $aggregated_info_for_answer = array();
848 $aggregated_info_for_answer['answertext'] = $answer->getAnswerText();
849 $aggregated_info_for_answer['count_checked'] = 0;
850
851 foreach ($relevant_answers_chosen as $relevant_answer)
852 {
853 if ($relevant_answer['value1'] == $answer->getOrder())
854 {
855 $aggregated_info_for_answer['count_checked']++;
856 }
857 }
858 $aggregated_info_for_answer['count_unchecked'] =
859 ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
860 - $aggregated_info_for_answer['count_checked'];
861
862 $aggregate[] = $aggregated_info_for_answer;
863 }
864 return $aggregate;
865 }

Referenced by getAggregatedAnswersView().

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

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

References $errors, assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), getEditAnswersSingleLine(), assQuestionGUI\getQuestionTemplate(), 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()

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

824 {
825 return array();
826 }

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

746 {
747 return array();
748 }

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

837 {
838 return $this->renderAggregateView(
839 $this->aggregateAnswers( $relevant_answers, $this->object->getAnswers() ) )->get();
840 }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)

References aggregateAnswers(), and renderAggregateView().

+ Here is the call graph for this function:

◆ getChoiceKeys()

assSingleChoiceGUI::getChoiceKeys ( )

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

655 {
656 $choiceKeys = array_keys($this->object->answers);
657
658 if( $this->object->getShuffle() )
659 {
660 $choiceKeys = $this->object->getShuffler()->shuffle($choiceKeys);
661 }
662
663 return $choiceKeys;
664 }

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

+ Here is the caller graph for this function:

◆ getEditAnswersSingleLine()

assSingleChoiceGUI::getEditAnswersSingleLine (   $checkonly = false)
protected

Get the single/multiline editing of answers.

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

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

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

References $_POST.

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

+ Here is the caller graph for this function:

◆ getPreview()

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

Reimplemented from assQuestionGUI.

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

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.svg'));
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 if( $showInlineFeedback && is_object($this->getPreviewSession()) )
426 {
427 $this->populateInlineFeedback($template, $answer_id, $this->getPreviewSession()->getParticipantsSolution());
428 }
429 $template->setCurrentBlock("answer_row");
430 $template->setVariable("QID", $this->object->getId().'ID');
431 $template->setVariable("ANSWER_ID", $answer_id);
432 $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
433
434 if( is_object($this->getPreviewSession()) )
435 {
436 $user_solution = $this->getPreviewSession()->getParticipantsSolution();
437 if (strcmp($user_solution, $answer_id) == 0)
438 {
439 $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
440 }
441 }
442
443 $template->parseCurrentBlock();
444 }
445 $questiontext = $this->object->getQuestion();
446 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
447 $questionoutput = $template->get();
448 if (!$show_question_only)
449 {
450 // get page object output
451 $questionoutput = $this->getILIASPage($questionoutput);
452 }
453 return $questionoutput;
454 }
getILIASPage($html="")
Returns the ILIAS Page around a question.
populateInlineFeedback($template, $answer_id, $user_solution)
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(), populateInlineFeedback(), and ilUtil\prepareFormOutput().

+ 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

Reimplemented from assQuestionGUI.

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

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

+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

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

667 {
668 // No return value, this question type supports inline specific feedback.
669 $output = "";
670 return $this->object->prepareTextareaOutput($output, TRUE);
671 }

◆ getTestOutput()

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

Reimplemented from assQuestionGUI.

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

459 {
460 $keys = $this->getChoiceKeys();
461
462 // get the solution of the user for the active pass or from the last pass if allowed
463 $user_solution = "";
464 if ($active_id)
465 {
466 // hey: prevPassSolutions - obsolete due to central check
467 #$solutions = NULL;
468 #include_once "./Modules/Test/classes/class.ilObjTest.php";
469 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
470 #{
471 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
472 #}
473 // hey.
474 $solutions = $this->getTestOutputSolutions($active_id, $pass);
475 foreach ($solutions as $idx => $solution_value)
476 {
477 $user_solution = $solution_value["value1"];
478 }
479 }
480
481 // generate the question output
482 include_once "./Services/UICore/classes/class.ilTemplate.php";
483 $template = new ilTemplate("tpl.il_as_qpl_mc_sr_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
484 foreach ($keys as $answer_id)
485 {
486 $answer = $this->object->answers[$answer_id];
487 if (strlen($answer->getImage()))
488 {
489 if ($this->object->getThumbSize())
490 {
491 $template->setCurrentBlock("preview");
492 $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
493 $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
494 $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
495 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
496 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
497 $alt = $answer->getImage();
498 if (strlen($answer->getAnswertext()))
499 {
500 $alt = $answer->getAnswertext();
501 }
502 $alt = preg_replace("/<[^>]*?>/", "", $alt);
503 $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
504 $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
505 $template->parseCurrentBlock();
506 }
507 else
508 {
509 $template->setCurrentBlock("answer_image");
510 $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
511 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
512 $alt = $answer->getImage();
513 if (strlen($answer->getAnswertext()))
514 {
515 $alt = $answer->getAnswertext();
516 }
517 $alt = preg_replace("/<[^>]*?>/", "", $alt);
518 $template->setVariable("ATTR", $attr);
519 $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
520 $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
521 $template->parseCurrentBlock();
522 }
523 }
524 if ($show_feedback)
525 {
526 $feedbackOutputRequired = false;
527
528 switch( $this->object->getSpecificFeedbackSetting() )
529 {
530 case 1:
531 $feedbackOutputRequired = true;
532 break;
533
534 case 2:
535 if (strcmp($user_solution, $answer_id) == 0)
536 {
537 $feedbackOutputRequired = true;
538 }
539 break;
540
541 case 3:
542 if ($this->object->getAnswer($answer_id)->getPoints() > 0)
543 {
544 $feedbackOutputRequired = true;
545 }
546 break;
547 }
548
549 if($feedbackOutputRequired)
550 {
551 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
552 $this->object->getId(), $answer_id
553 );
554 if (strlen($fb))
555 {
556 $template->setCurrentBlock("feedback");
557 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $fb, true ));
558 $template->parseCurrentBlock();
559 }
560 }
561 }
562 $template->setCurrentBlock("answer_row");
563 $template->setVariable("ANSWER_ID", $answer_id);
564 $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
565 if (strcmp($user_solution, $answer_id) == 0)
566 {
567 $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
568 }
569 $template->parseCurrentBlock();
570 }
571 $questiontext = $this->object->getQuestion();
572 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
573 $questionoutput = $template->get();
574 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
575 return $pageoutput;
576 }
getTestOutputSolutions($activeId, $pass)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page

References $pass, getChoiceKeys(), ilUtil\getImagePath(), assQuestionGUI\getTestOutputSolutions(), assQuestionGUI\outQuestionPage(), and ilUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assSingleChoiceGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

793 {
794 $isSingleline = $this->getEditAnswersSingleLine();
795
796 // Choices
797 include_once "./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php";
798 $choices = new ilSingleChoiceWizardInputGUI($this->lng->txt( "answers" ), "choice");
799 $choices->setRequired( true );
800 $choices->setQuestionObject( $this->object );
801 $choices->setSingleline( $isSingleline );
802 $choices->setAllowMove( false );
803 if ($this->object->getSelfAssessmentEditingMode())
804 {
805 $choices->setSize( 40 );
806 $choices->setMaxLength( 800 );
807 }
808 if ($this->object->getAnswerCount() == 0)
809 $this->object->addAnswer( "", 0, 0 );
810 $choices->setValues( $this->object->getAnswers() );
811 $form->addItem( $choices );
812 }
This class represents a single choice wizard property in a property form.

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

Referenced by editQuestion().

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

◆ populateInlineFeedback()

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

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

895 {
896 $feedbackOutputRequired = false;
897
898 switch($this->object->getSpecificFeedbackSetting())
899 {
900 case 1:
901 $feedbackOutputRequired = true;
902 break;
903
904 case 2:
905 if(strcmp($user_solution, $answer_id) == 0)
906 {
907 $feedbackOutputRequired = true;
908 }
909 break;
910
911 case 3:
912 if($this->object->getAnswer($answer_id)->getPoints() > 0)
913 {
914 $feedbackOutputRequired = true;
915 }
916 break;
917 }
918
919 if($feedbackOutputRequired)
920 {
921 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id);
922 if(strlen($fb))
923 {
924 $template->setCurrentBlock("feedback");
925 $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
926 $template->parseCurrentBlock();
927 }
928 }
929 }

Referenced by getPreview(), and getSolutionOutput().

+ Here is the caller graph for this function:

◆ populateQuestionSpecificFormPart()

assSingleChoiceGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

690 {
691 $isSingleline = $this->getEditAnswersSingleLine();
692 // shuffle
693 $shuffle = new ilCheckboxInputGUI($this->lng->txt( "shuffle_answers" ), "shuffle");
694 $shuffle->setValue( 1 );
695 $shuffle->setChecked( $this->object->getShuffle() );
696 $shuffle->setRequired( FALSE );
697 $form->addItem( $shuffle );
698
699 if ($this->object->getId())
700 {
701 $hidden = new ilHiddenInputGUI("", "ID");
702 $hidden->setValue( $this->object->getId() );
703 $form->addItem( $hidden );
704 }
705
706 if (!$this->object->getSelfAssessmentEditingMode())
707 {
708 // Answer types
709 $types = new ilSelectInputGUI($this->lng->txt( "answer_types" ), "types");
710 $types->setRequired( false );
711 $types->setValue( ($isSingleline) ? 0 : 1 );
712 $types->setOptions( array(
713 0 => $this->lng->txt( 'answers_singleline' ),
714 1 => $this->lng->txt( 'answers_multiline' ),
715 )
716 );
717 $form->addItem( $types );
718 }
719
720 if ($isSingleline)
721 {
722 // thumb size
723 $thumb_size = new ilNumberInputGUI($this->lng->txt( "thumb_size" ), "thumb_size");
724 $thumb_size->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
725 $thumb_size->setMinValue( 20 );
726 $thumb_size->setDecimals( 0 );
727 $thumb_size->setSize( 6 );
728 $thumb_size->setInfo( $this->lng->txt( 'thumb_size_info' ) );
729 $thumb_size->setValue( $this->object->getThumbSize() );
730 $thumb_size->setRequired( false );
731 $form->addItem( $thumb_size );
732 }
733 return $form;
734 }
This class represents a checkbox property in a property form.
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 ilPropertyFormGUI\addItem(), and getEditAnswersSingleLine().

Referenced by editQuestion().

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

177 {
178 $this->writePostData(true);
179 $position = key($_POST['cmd']['removechoice']);
180 $this->object->deleteAnswer($position);
181 $this->editQuestion();
182 }

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

+ Here is the call graph for this function:

◆ removeimagechoice()

assSingleChoiceGUI::removeimagechoice ( )

Remove an image.

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

154 {
155 $this->writePostData(true);
156 $position = key($_POST['cmd']['removeimagechoice']);
157 $filename = $_POST['choice']['imagename'][$position];
158 $this->object->removeAnswerImage($position);
159 $this->editQuestion();
160 }
$filename
Definition: buildRTE.php:89

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

+ Here is the call graph for this function:

◆ renderAggregateView()

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

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

873 {
874 $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
875
876 $tpl->setCurrentBlock('headercell');
877 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
878 $tpl->parseCurrentBlock();
879
880 $tpl->setCurrentBlock('headercell');
881 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
882 $tpl->parseCurrentBlock();
883
884 foreach ($aggregate as $line_data)
885 {
886 $tpl->setCurrentBlock( 'aggregaterow' );
887 $tpl->setVariable( 'OPTION', $line_data['answertext'] );
888 $tpl->setVariable( 'COUNT', $line_data['count_checked'] );
889 $tpl->parseCurrentBlock();
890 }
891 return $tpl;
892 }

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

+ Here is the caller graph for this function:

◆ setQuestionTabs()

assSingleChoiceGUI::setQuestionTabs ( )

Sets the ILIAS tabs for this question type.

@access public

Todo:
: MOVE THIS STEPS TO COMMON QUESTION CLASS assQuestionGUI

Reimplemented from assQuestionGUI.

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

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

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

+ Here is the call graph for this function:

◆ uploadchoice()

assSingleChoiceGUI::uploadchoice ( )

Upload an image.

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

144 {
145 $this->writePostData(true);
146 $position = key($_POST['cmd']['uploadchoice']);
147 $this->editQuestion();
148 }

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

+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assSingleChoiceGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

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

Implements ilGuiAnswerScoringAdjustable.

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

751 {
752 // Delete all existing answers and create new answers from the form data
753 $this->object->flushAnswers();
754 if ($this->object->isSingleline)
755 {
756 foreach ($_POST['choice']['answer'] as $index => $answertext)
757 {
758 $answertext = ilUtil::secureString($answertext);
759
760 $picturefile = $_POST['choice']['imagename'][$index];
761 $file_org_name = $_FILES['choice']['name']['image'][$index];
762 $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index];
763
764 if (strlen( $file_temp_name ))
765 {
766 // check suffix
767 $suffix = strtolower( array_pop( explode( ".", $file_org_name ) ) );
768 if (in_array( $suffix, array( "jpg", "jpeg", "png", "gif" ) ))
769 {
770 // upload image
771 $filename = $this->object->createNewImageFileName( $file_org_name );
772 if ($this->object->setImageFile( $filename, $file_temp_name ) == 0)
773 {
774 $picturefile = $filename;
775 }
776 }
777 }
778
779 $this->object->addAnswer( $answertext, $_POST['choice']['points'][$index], $index, $picturefile );
780 }
781 }
782 else
783 {
784 foreach ($_POST['choice']['answer'] as $index => $answer)
785 {
786 $answertext = $answer;
787 $this->object->addAnswer( $answertext, $_POST['choice']['points'][$index], $index );
788 }
789 }
790 }
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()

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

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

assSingleChoiceGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

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

Implements ilGuiQuestionScoringAdjustable.

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

674 {
675 $this->object->setShuffle( $_POST["shuffle"] );
676 $this->object->setMultilineAnswerSetting( $_POST["types"] );
677 if (is_array( $_POST['choice']['imagename'] ) && $_POST["types"] == 1)
678 {
679 $this->object->isSingleline = true;
680 ilUtil::sendInfo( $this->lng->txt( 'info_answer_type_change' ), true );
681 }
682 else
683 {
684 $this->object->isSingleline = ($_POST["types"] == 0) ? true : false;
685 }
686 $this->object->setThumbSize( (strlen( $_POST["thumb_size"] )) ? $_POST["thumb_size"] : "" );
687 }
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:

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