ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
assSingleChoiceGUI Class Reference

Single choice question GUI representation. More...

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

Public Member Functions

 __construct ($id=-1)
 assSingleChoiceGUI constructor More...
 
 editQuestion ($checkonly=FALSE)
 Creates an output of the edit form for the question. More...
 
 uploadchoice ()
 Upload an image. More...
 
 removeimagechoice ()
 Remove an image. More...
 
 addchoice ()
 Add a new answer. More...
 
 removechoice ()
 Remove an answer. More...
 
 getSolutionOutput ( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
 Get the question solution output. More...
 
 getPreview ($show_question_only=FALSE, $showInlineFeedback=false)
 
 getTestOutput ($active_id, $pass, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
 
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type. More...
 
 getChoiceKeys ()
 
 getSpecificFeedbackOutput ($active_id, $pass)
 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 ()
 
 getRenderPurpose ()
 
 setRenderPurpose ($renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext ($editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI ($navigationGUI)
 
 setTaxonomyIds ($taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd ($questionActionCmd)
 
 getQuestionActionCmd ()
 
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation. More...
 
 populateJavascriptFilesRequiredForWorkForm (ilTemplate $tpl)
 
 getQuestionTemplate ()
 get question template More...
 
 getILIASPage ($html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="")
 output question page More...
 
 cancel ()
 cancel action More...
 
 originalSyncForm ($return_to="", $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 save question More...
 
 save ()
 save question More...
 
 saveReturn ()
 save question More...
 
 apply ()
 apply changes More...
 
 getContextPath ($cont_obj, $a_endnode_id, $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber ($nr)
 
 getSequenceNumber ()
 
 setQuestionCount ($a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage ($errormessage)
 
 addErrorMessage ($errormessage)
 
 outAdditionalOutput ()
 
 getQuestionType ()
 Returns the question type string. More...
 
 getAsValueAttribute ($a_value)
 Returns a HTML value attribute. More...
 
 addNewIdListener (&$a_object, $a_method, $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners ($a_new_id)
 Call the new id listeners. More...
 
 addQuestionFormCommandButtons ($form)
 Add the command buttons of a question properties form. More...
 
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time. More...
 
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question. More...
 
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 showSuggestedSolution ()
 
 suggestedsolution ()
 Allows to add suggested solutions for questions. More...
 
 outSolutionExplorer ()
 
 saveSuggestedSolution ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, $classname)
 
 getEditQuestionTabCommands ()
 
 getSolutionOutput ( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
 
 isAutosaveable ()
 
 getPreview ($show_question_only=FALSE, $showInlineFeedback=false)
 
 outQuestionForTest ( $formaction, $active_id, $pass, $is_question_postponed=FALSE, $user_post_solutions=FALSE, $show_specific_inline_feedback=FALSE)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession ($previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
 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

 writePostData ($always=false)
 {Evaluates a posted edit form and writes the form data in the question object.
Returns
integer A positive value, if one of the required fields wasn't set, else 0
} More...
 
 getEditAnswersSingleLine ($checkonly=false)
 Get the single/multiline editing of answers. More...
 
- Protected Member Functions inherited from assQuestionGUI
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm ($form)
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI More...
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI More...
 
 addTab_QuestionPreview (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 buildEditForm ()
 

Private Member Functions

 populateInlineFeedback ($template, $answer_id, $user_solution)
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants ($guiClassName, $cmdConstantNameBegin='CMD_')
 extracts values of all constants of given class with given prefix as array can be used to get all possible commands in case of these commands are defined as constants More...
 
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
 $object
 
 $tpl
 
 $lng
 
 $error
 
 $errormessage
 
 $sequence_no
 sequence number in test More...
 
 $question_count
 question count in test More...
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 
- Protected Attributes inherited from assQuestionGUI
 $editForm
 

Detailed Description

Single choice question GUI representation.

The assSingleChoiceGUI class encapsulates the GUI representation for single choice questions.

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

@ilCtrl_Calls assSingleChoiceGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

assSingleChoiceGUI::__construct (   $id = -1)

assSingleChoiceGUI constructor

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

Parameters
integer$idThe database id of a single choice question object

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

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

Member Function Documentation

◆ addchoice()

assSingleChoiceGUI::addchoice ( )

Add a new answer.

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

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

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

+ Here is the call graph for this function:

◆ aggregateAnswers()

assSingleChoiceGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)

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

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

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

94 {
95 $save = $this->isSaveCommand();
96 $this->getQuestionTemplate();
97
98 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
99 $form = new ilPropertyFormGUI();
100 $this->editForm = $form;
101
102 $form->setFormAction($this->ctrl->getFormAction($this));
103 $form->setTitle($this->outQuestionType());
104 $isSingleline = $this->getEditAnswersSingleLine($checkonly);
105 if ($isSingleline)
106 {
107 $form->setMultipart(TRUE);
108 }
109 else
110 {
111 $form->setMultipart(FALSE);
112 }
113 $form->setTableWidth("100%");
114 $form->setId("asssinglechoice");
115
116 $this->addBasicQuestionFormProperties( $form );
117 $this->populateQuestionSpecificFormPart( $form );
118 $this->populateAnswerSpecificFormPart( $form );
119
120
121 $this->populateTaxonomyFormSection($form);
122
123 $this->addQuestionFormCommandButtons($form);
124
125 $errors = false;
126
127 if ($save)
128 {
129 $form->setValuesByPost();
130 $errors = !$form->checkInput();
131 $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
132 if ($errors) $checkonly = false;
133 }
134
135 if (!$checkonly) $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
136 return $errors;
137 }
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 822 of file class.assSingleChoiceGUI.php.

823 {
824 return array();
825 }

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

745 {
746 return array();
747 }

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

836 {
837 return $this->renderAggregateView(
838 $this->aggregateAnswers( $relevant_answers, $this->object->getAnswers() ) )->get();
839 }
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 653 of file class.assSingleChoiceGUI.php.

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

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

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

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

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

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

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

666 {
667 // No return value, this question type supports inline specific feedback.
668 $output = "";
669 return $this->object->prepareTextareaOutput($output, TRUE);
670 }
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output

References $output.

◆ getTestOutput()

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

Reimplemented from assQuestionGUI.

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

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

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

+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assSingleChoiceGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

792 {
793 $isSingleline = $this->getEditAnswersSingleLine();
794
795 // Choices
796 include_once "./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php";
797 $choices = new ilSingleChoiceWizardInputGUI($this->lng->txt( "answers" ), "choice");
798 $choices->setRequired( true );
799 $choices->setQuestionObject( $this->object );
800 $choices->setSingleline( $isSingleline );
801 $choices->setAllowMove( false );
802 if ($this->object->getSelfAssessmentEditingMode())
803 {
804 $choices->setSize( 40 );
805 }
806 $choices->setMaxLength( 800 );
807 if ($this->object->getAnswerCount() == 0)
808 $this->object->addAnswer( "", 0, 0 );
809 $choices->setValues( $this->object->getAnswers() );
810 $form->addItem( $choices );
811 }
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 893 of file class.assSingleChoiceGUI.php.

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

Referenced by getPreview(), and getSolutionOutput().

+ Here is the caller graph for this function:

◆ populateQuestionSpecificFormPart()

assSingleChoiceGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

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

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

+ Here is the call graph for this function:

◆ removeimagechoice()

assSingleChoiceGUI::removeimagechoice ( )

Remove an image.

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

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

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

+ Here is the call graph for this function:

◆ renderAggregateView()

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

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

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

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

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

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

References $_POST, editQuestion(), and 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 749 of file class.assSingleChoiceGUI.php.

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

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

Returns
integer A positive value, if one of the required fields wasn't set, else 0
}

Reimplemented from assQuestionGUI.

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

47 {
48 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
49 if (!$hasErrors)
50 {
51 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
56 return 0;
57 }
58 return 1;
59 }
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().

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

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

◆ writeQuestionSpecificPostData()

assSingleChoiceGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

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

Implements ilGuiQuestionScoringAdjustable.

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

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