ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
assMultipleChoiceGUI Class Reference

Multiple choice question GUI representation. More...

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

Public Member Functions

 __construct ($id=-1)
 assMultipleChoiceGUI constructor More...
 
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 editQuestion ($checkonly=FALSE)
 Creates an output of the edit form for the question. More...
 
 addBasicQuestionFormProperties ($form)
 
 uploadchoice ()
 Upload an image. More...
 
 removeimagechoice ()
 Remove an image. More...
 
 addchoice ()
 Add a new answer. More...
 
 removechoice ()
 Remove an answer. More...
 
 getSolutionOutput ( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
 Get the question solution output. More...
 
 getPreview ($show_question_only=FALSE, $showInlineFeedback=false)
 
 getTestOutput ( $active_id, $pass, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
 
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type. More...
 
 getChoiceKeys ()
 Create the key index numbers for the array of choices. More...
 
 getSpecificFeedbackOutput ($active_id, $pass)
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 
 populateAnswerSpecificFormPart (\ilPropertyFormGUI $form)
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAggregatedAnswersView ($relevant_answers)
 Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface. More...
 
 aggregateAnswers ($relevant_answers_chosen, $answers_defined_on_question)
 
 renderAggregateView ($aggregate)
 
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor More...
 
executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 
 getType ()
 needed for page editor compliance More...
 
 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...
 
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 

Data Fields

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

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

 populateSpecificFeedbackInline ($user_solution, $answer_id, $template)
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static getCommandsFromClassConstants ($guiClassName, $cmdConstantNameBegin='CMD_')
 extracts values of all constants of given class with given prefix as array can be used to get all possible commands in case of these commands are defined as constants More...
 

Detailed Description

Multiple choice question GUI representation.

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

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

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

Constructor & Destructor Documentation

◆ __construct()

assMultipleChoiceGUI::__construct (   $id = -1)

assMultipleChoiceGUI constructor

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

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

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

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

Member Function Documentation

◆ addBasicQuestionFormProperties()

assMultipleChoiceGUI::addBasicQuestionFormProperties (   $form)

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

Referenced by editQuestion().

146  {
147  parent::addBasicQuestionFormProperties($form);
148  $form->getItemByPostVar('question')->setInitialRteWidth('100');
149  }
+ Here is the caller graph for this function:

◆ addchoice()

assMultipleChoiceGUI::addchoice ( )

Add a new answer.

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

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

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

◆ aggregateAnswers()

assMultipleChoiceGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)

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

Referenced by getAggregatedAnswersView().

922  {
923  $aggregate = array();
924  foreach ($answers_defined_on_question as $answer)
925  {
926  $aggregated_info_for_answer = array();
927  $aggregated_info_for_answer['answertext'] = $answer->getAnswerText();
928  $aggregated_info_for_answer['count_checked'] = 0;
929 
930  foreach ($relevant_answers_chosen as $relevant_answer)
931  {
932  if ($relevant_answer['value1'] == $answer->getOrder())
933  {
934  $aggregated_info_for_answer['count_checked']++;
935  }
936  }
937  $aggregated_info_for_answer['count_unchecked'] =
938  ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
939  - $aggregated_info_for_answer['count_checked'];
940 
941  $aggregate[] = $aggregated_info_for_answer;
942  }
943  return $aggregate;
944  }
+ Here is the caller graph for this function:

◆ editQuestion()

assMultipleChoiceGUI::editQuestion (   $checkonly = FALSE)

Creates an output of the edit form for the question.

Parameters
bool$checkonly
Returns
bool

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

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

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

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

◆ getAfterParticipationSuppressionAnswerPostVars()

assMultipleChoiceGUI::getAfterParticipationSuppressionAnswerPostVars ( )

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

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

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

Returns
string[]

Implements ilGuiAnswerScoringAdjustable.

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

889  {
890  return array();
891  }

◆ getAfterParticipationSuppressionQuestionPostVars()

assMultipleChoiceGUI::getAfterParticipationSuppressionQuestionPostVars ( )

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

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

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

Returns
string[]

Implements ilGuiQuestionScoringAdjustable.

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

903  {
904  return array();
905  }

◆ getAggregatedAnswersView()

assMultipleChoiceGUI::getAggregatedAnswersView (   $relevant_answers)

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

Parameters
array$relevant_answers
Returns
string

Implements ilGuiQuestionScoringAdjustable.

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

References aggregateAnswers(), and renderAggregateView().

916  {
917  return $this->renderAggregateView(
918  $this->aggregateAnswers( $relevant_answers, $this->object->getAnswers() ) )->get();
919  }
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
+ Here is the call graph for this function:

◆ getChoiceKeys()

assMultipleChoiceGUI::getChoiceKeys ( )

Create the key index numbers for the array of choices.

Returns
array

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

References $choiceKeys.

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

722  {
723  $choiceKeys = array_keys($this->object->answers);
724 
725  if( $this->object->getShuffle() )
726  {
727  $choiceKeys = $this->object->getShuffler()->shuffle($choiceKeys);
728  }
729 
730  return $choiceKeys;
731  }
+ Here is the caller graph for this function:

◆ getEditAnswersSingleLine()

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

References $_POST.

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

76  {
77  if ($checkonly)
78  {
79  // form posting is checked
80  return ($_POST['types'] == 0) ? true : false;
81  }
82 
83  $lastChange = $this->object->getLastChange();
84  if (empty($lastChange) && !isset($_POST['types']))
85  {
86  // a new question is edited
87  return $this->object->getMultilineAnswerSetting() ? false : true;
88  }
89  else
90  {
91  // a saved question is edited
92  return $this->object->isSingleline;
93  }
94  }
$_POST['username']
Definition: cron.php:12
+ Here is the caller graph for this function:

◆ getPreview()

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

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

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

462  {
463  $user_solution = is_object($this->getPreviewSession()) ? (array)$this->getPreviewSession()->getParticipantsSolution() : array();
464  // shuffle output
465  $keys = $this->getChoiceKeys();
466 
467  // generate the question output
468  include_once "./Services/UICore/classes/class.ilTemplate.php";
469  $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
470  foreach ($keys as $answer_id)
471  {
472  $answer = $this->object->answers[$answer_id];
473  if (strlen($answer->getImage()))
474  {
475  if ($this->object->getThumbSize())
476  {
477  $template->setCurrentBlock("preview");
478  $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
479  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
480  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
481  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
482  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
483  $alt = $answer->getImage();
484  if (strlen($answer->getAnswertext()))
485  {
486  $alt = $answer->getAnswertext();
487  }
488  $alt = preg_replace("/<[^>]*?>/", "", $alt);
489  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
490  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
491  $template->parseCurrentBlock();
492  }
493  else
494  {
495  $template->setCurrentBlock("answer_image");
496  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
497  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
498  $alt = $answer->getImage();
499  if (strlen($answer->getAnswertext()))
500  {
501  $alt = $answer->getAnswertext();
502  }
503  $alt = preg_replace("/<[^>]*?>/", "", $alt);
504  $template->setVariable("ATTR", $attr);
505  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
506  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
507  $template->parseCurrentBlock();
508  }
509  }
510 
511  if( $showInlineFeedback )
512  {
513  $this->populateSpecificFeedbackInline($user_solution, $answer_id, $template);
514  }
515 
516  $template->setCurrentBlock("answer_row");
517  $template->setVariable("ANSWER_ID", $answer_id);
518  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
519  foreach ($user_solution as $mc_solution)
520  {
521  if (strcmp($mc_solution, $answer_id) == 0)
522  {
523  $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
524  }
525  }
526  $template->parseCurrentBlock();
527  }
528  $questiontext = $this->object->getQuestion();
529  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
530  $questionoutput = $template->get();
531  if (!$show_question_only)
532  {
533  // get page object output
534  $questionoutput = $this->getILIASPage($questionoutput);
535  }
536  return $questionoutput;
537  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getChoiceKeys()
Create the key index numbers for the array of choices.
getILIASPage($html="")
Returns the ILIAS Page around a question.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
populateSpecificFeedbackInline($user_solution, $answer_id, $template)
+ Here is the call graph for this function:

◆ getSolutionOutput()

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

Get the question solution output.

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

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

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(), and ilUtil\prepareFormOutput().

221  {
222  // shuffle output
223  $keys = $this->getChoiceKeys();
224 
225  // get the solution of the user for the active pass or from the last pass if allowed
226  $user_solution = array();
227  if (($active_id > 0) && (!$show_correct_solution))
228  {
229  $solutions =& $this->object->getSolutionValues($active_id, $pass);
230  foreach ($solutions as $idx => $solution_value)
231  {
232  array_push($user_solution, $solution_value["value1"]);
233  }
234  }
235  else
236  {
237  // take the correct solution instead of the user solution
238  foreach ($this->object->answers as $index => $answer)
239  {
240  $points_checked = $answer->getPointsChecked();
241  $points_unchecked = $answer->getPointsUnchecked();
242  if ($points_checked > $points_unchecked)
243  {
244  if ($points_checked > 0)
245  {
246  array_push($user_solution, $index);
247  }
248  }
249  }
250  }
251 
252  // generate the question output
253  include_once "./Services/UICore/classes/class.ilTemplate.php";
254  $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
255  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
256  foreach ($keys as $answer_id)
257  {
258  $answer = $this->object->answers[$answer_id];
259  if (($active_id > 0) && (!$show_correct_solution))
260  {
261  if ($graphicalOutput)
262  {
263  // output of ok/not ok icons for user entered solutions
264  $ok = FALSE;
265  $checked = FALSE;
266  foreach ($user_solution as $mc_solution)
267  {
268  if (strcmp($mc_solution, $answer_id) == 0)
269  {
270  $checked = TRUE;
271  }
272  }
273  if ($checked)
274  {
275  if ($answer->getPointsChecked() > $answer->getPointsUnchecked())
276  {
277  $ok = TRUE;
278  }
279  else
280  {
281  $ok = FALSE;
282  }
283  }
284  else
285  {
286  if ($answer->getPointsChecked() > $answer->getPointsUnchecked())
287  {
288  $ok = FALSE;
289  }
290  else
291  {
292  $ok = TRUE;
293  }
294  }
295  if ($ok)
296  {
297  $template->setCurrentBlock("icon_ok");
298  $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
299  $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
300  $template->parseCurrentBlock();
301  }
302  else
303  {
304  $template->setCurrentBlock("icon_ok");
305  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
306  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
307  $template->parseCurrentBlock();
308  }
309  }
310  }
311  if (strlen($answer->getImage()))
312  {
313  $template->setCurrentBlock("answer_image");
314  if ($this->object->getThumbSize())
315  {
316  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
317  }
318  else
319  {
320  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
321  }
322  $alt = $answer->getImage();
323  if (strlen($answer->getAnswertext()))
324  {
325  $alt = $answer->getAnswertext();
326  }
327  $alt = preg_replace("/<[^>]*?>/", "", $alt);
328  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
329  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
330  $template->parseCurrentBlock();
331  }
332 
333  if ($show_feedback)
334  {
335 
336  if ($this->object->getSpecificFeedbackSetting() == 2)
337  {
338  foreach ($user_solution as $mc_solution)
339  {
340  if (strcmp($mc_solution, $answer_id) == 0)
341  {
342  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
343  $this->object->getId(), $answer_id
344  );
345  if (strlen($fb))
346  {
347  $template->setCurrentBlock("feedback");
348  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $fb, true ));
349  $template->parseCurrentBlock();
350  }
351  }
352  }
353  }
354 
355  if ($this->object->getSpecificFeedbackSetting() == 1)
356  {
357  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
358  $this->object->getId(), $answer_id
359  );
360  if (strlen($fb))
361  {
362  $template->setCurrentBlock("feedback");
363  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $fb, true ));
364  $template->parseCurrentBlock();
365  }
366  }
367 
368  if ($this->object->getSpecificFeedbackSetting() == 3)
369  {
370  $answer = $this->object->getAnswer($answer_id);
371 
372  if ($answer->getPoints() > 0)
373  {
374  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
375  $this->object->getId(), $answer_id
376  );
377  if (strlen($fb))
378  {
379  $template->setCurrentBlock("feedback");
380  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $fb, true ));
381  $template->parseCurrentBlock();
382  }
383  }
384 
385  }
386  }
387  $template->setCurrentBlock("answer_row");
388  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
389  $checked = FALSE;
390  if ($result_output)
391  {
392  $pointschecked = $this->object->answers[$answer_id]->getPointsChecked();
393  $pointsunchecked = $this->object->answers[$answer_id]->getPointsUnchecked();
394  $resulttextchecked = ($pointschecked == 1) || ($pointschecked == -1) ? "%s " . $this->lng->txt("point") : "%s " . $this->lng->txt("points");
395  $resulttextunchecked = ($pointsunchecked == 1) || ($pointsunchecked == -1) ? "%s " . $this->lng->txt("point") : "%s " . $this->lng->txt("points");
396  $template->setVariable("RESULT_OUTPUT", sprintf("(" . $this->lng->txt("checkbox_checked") . " = $resulttextchecked, " . $this->lng->txt("checkbox_unchecked") . " = $resulttextunchecked)", $pointschecked, $pointsunchecked));
397  }
398  foreach ($user_solution as $mc_solution)
399  {
400  if (strcmp($mc_solution, $answer_id) == 0)
401  {
402  if( $this->isPdfOutputMode() || $this->isContentEditingOutputMode() )
403  {
404  $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_checked.png")));
405  $template->setVariable("SOLUTION_ALT", $this->lng->txt("checked"));
406  }
407  else
408  {
409  $template->setVariable('QID', $this->object->getId());
410  $template->setVariable('SUFFIX', $show_correct_solution ? 'bestsolution' : 'usersolution');
411  $template->setVariable('SOLUTION_VALUE', $answer_id);
412  $template->setVariable('SOLUTION_CHECKED', 'checked');
413  }
414  $checked = TRUE;
415  }
416  }
417  if (!$checked)
418  {
419  if( $this->isPdfOutputMode() || $this->isContentEditingOutputMode() )
420  {
421  $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.png")));
422  $template->setVariable("SOLUTION_ALT", $this->lng->txt("unchecked"));
423  }
424  else
425  {
426  $template->setVariable('QID', $this->object->getId());
427  $template->setVariable('SUFFIX', $show_correct_solution ? 'bestsolution' : 'usersolution');
428  $template->setVariable('SOLUTION_VALUE', $answer_id);
429  }
430  }
431  $template->parseCurrentBlock();
432  }
433  $questiontext = $this->object->getQuestion();
434  if ($show_question_text==true)
435  {
436  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
437  }
438  $questionoutput = $template->get();
439  $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
440 
441  if (strlen($feedback))
442  {
443  $cssClass = ( $this->hasCorrectSolution($active_id, $pass) ?
445  );
446 
447  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
448  $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $feedback , true ));
449  }
450  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
451 
452  $solutionoutput = $solutiontemplate->get();
453  if (!$show_question_only)
454  {
455  // get page object output
456  $solutionoutput = $this->getILIASPage($solutionoutput);
457  }
458  return $solutionoutput;
459  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
hasCorrectSolution($activeId, $passIndex)
getChoiceKeys()
Create the key index numbers for the array of choices.
getILIASPage($html="")
Returns the ILIAS Page around a question.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
static getHtmlPath($relative_path)
get url of path
getAnswerFeedbackOutput($active_id, $pass)
Returns the answer generic feedback depending on the results of the question.
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assMultipleChoiceGUI::getSpecificFeedbackOutput (   $active_id,
  $pass 
)

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

734  {
735  // No return value, this question type supports inline specific feedback.
736  $output = "";
737  return $this->object->prepareTextareaOutput($output, TRUE);
738  }

◆ getTestOutput()

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

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

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

557  {
558  // shuffle output
559  $keys = $this->getChoiceKeys();
560 
561  // get the solution of the user for the active pass or from the last pass if allowed
562  $user_solution = array();
563  if ($active_id)
564  {
565  // hey: prevPassSolutions - obsolete due to central check
566  #$solutions = NULL;
567  #include_once "./Modules/Test/classes/class.ilObjTest.php";
568  #if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
569  #{
570  # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
571  #}
572  $solutions = $this->getTestOutputSolutions($active_id, $pass);
573  // hey.
574  foreach ($solutions as $idx => $solution_value)
575  {
576  array_push($user_solution, $solution_value["value1"]);
577  }
578  }
579  // generate the question output
580  include_once "./Services/UICore/classes/class.ilTemplate.php";
581  $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
582  foreach ($keys as $answer_id)
583  {
584  $answer = $this->object->answers[$answer_id];
585  if (strlen($answer->getImage()))
586  {
587  if ($this->object->getThumbSize())
588  {
589  $template->setCurrentBlock("preview");
590  $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
591  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
592  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
593  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
594  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
595  $alt = $answer->getImage();
596  if (strlen($answer->getAnswertext()))
597  {
598  $alt = $answer->getAnswertext();
599  }
600  $alt = preg_replace("/<[^>]*?>/", "", $alt);
601  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
602  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
603  $template->parseCurrentBlock();
604  }
605  else
606  {
607  $template->setCurrentBlock("answer_image");
608  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
609  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
610  $alt = $answer->getImage();
611  if (strlen($answer->getAnswertext()))
612  {
613  $alt = $answer->getAnswertext();
614  }
615  $alt = preg_replace("/<[^>]*?>/", "", $alt);
616  $template->setVariable("ATTR", $attr);
617  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
618  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
619  $template->parseCurrentBlock();
620  }
621  }
622 
623  if( $show_feedback )
624  {
625  $this->populateSpecificFeedbackInline($user_solution, $answer_id, $template);
626  }
627 
628  $template->setCurrentBlock("answer_row");
629  $template->setVariable("ANSWER_ID", $answer_id);
630  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
631  foreach ($user_solution as $mc_solution)
632  {
633  if (strcmp($mc_solution, $answer_id) == 0)
634  {
635  $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
636  }
637  }
638  $template->parseCurrentBlock();
639  }
640  $questiontext = $this->object->getQuestion();
641  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
642  $questionoutput = $template->get();
643  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
644  return $pageoutput;
645  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getChoiceKeys()
Create the key index numbers for the array of choices.
getTestOutputSolutions($activeId, $pass)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
populateSpecificFeedbackInline($user_solution, $answer_id, $template)
+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assMultipleChoiceGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

859  {
860  // Choices
861  include_once "./Modules/TestQuestionPool/classes/class.ilMultipleChoiceWizardInputGUI.php";
862  $choices = new ilMultipleChoiceWizardInputGUI($this->lng->txt( "answers" ), "choice");
863  $choices->setRequired( true );
864  $choices->setQuestionObject( $this->object );
865  $isSingleline = $this->getEditAnswersSingleLine();
866  $choices->setSingleline( $isSingleline );
867  $choices->setAllowMove( false );
868  if ($this->object->getSelfAssessmentEditingMode())
869  {
870  $choices->setSize( 40 );
871  $choices->setMaxLength( 800 );
872  }
873  if ($this->object->getAnswerCount() == 0)
874  $this->object->addAnswer( "", 0, 0, 0 );
875  $choices->setValues( $this->object->getAnswers() );
876  $form->addItem( $choices );
877  }
getEditAnswersSingleLine($checkonly=false)
Get the single/multiline editing of answers.
This class represents a multiple choice wizard property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateQuestionSpecificFormPart()

assMultipleChoiceGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

810  {
811  // shuffle
812  $shuffle = new ilCheckboxInputGUI($this->lng->txt( "shuffle_answers" ), "shuffle");
813  $shuffle->setValue( 1 );
814  $shuffle->setChecked( $this->object->getShuffle() );
815  $shuffle->setRequired( FALSE );
816  $form->addItem( $shuffle );
817 
818  if ($this->object->getId())
819  {
820  $hidden = new ilHiddenInputGUI("", "ID");
821  $hidden->setValue( $this->object->getId() );
822  $form->addItem( $hidden );
823  }
824 
825  $isSingleline = $this->getEditAnswersSingleLine();
826 
827  if (!$this->object->getSelfAssessmentEditingMode())
828  {
829  // Answer types
830  $types = new ilSelectInputGUI($this->lng->txt( "answer_types" ), "types");
831  $types->setRequired( false );
832  $types->setValue( ($isSingleline) ? 0 : 1 );
833  $types->setOptions( array(
834  0 => $this->lng->txt( 'answers_singleline' ),
835  1 => $this->lng->txt( 'answers_multiline' ),
836  )
837  );
838  $form->addItem( $types );
839  }
840 
841  if ($isSingleline)
842  {
843  // thumb size
844  $thumb_size = new ilNumberInputGUI($this->lng->txt( "thumb_size" ), "thumb_size");
845  $thumb_size->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
846  $thumb_size->setMinValue( 20 );
847  $thumb_size->setDecimals( 0 );
848  $thumb_size->setSize( 6 );
849  $thumb_size->setInfo( $this->lng->txt( 'thumb_size_info' ) );
850  $thumb_size->setValue( $this->object->getThumbSize() );
851  $thumb_size->setRequired( false );
852  $form->addItem( $thumb_size );
853  return $isSingleline;
854  }
855  return $isSingleline;
856  }
This class represents a selection list property in a property form.
This class represents a checkbox property in a property form.
This class represents a hidden form property in a property form.
setSuffix($a_value)
Set suffix.
This class represents a number property in a property form.
setValue($a_value)
Set Value.
getEditAnswersSingleLine($checkonly=false)
Get the single/multiline editing of answers.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateSpecificFeedbackInline()

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

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

Referenced by getPreview(), and getTestOutput().

980  {
981  if($this->object->getSpecificFeedbackSetting() == 2)
982  {
983  foreach($user_solution as $mc_solution)
984  {
985  if(strcmp($mc_solution, $answer_id) == 0)
986  {
987  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id);
988  if(strlen($fb))
989  {
990  $template->setCurrentBlock("feedback");
991  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
992  $template->parseCurrentBlock();
993  }
994  }
995  }
996  }
997 
998  if($this->object->getSpecificFeedbackSetting() == 1)
999  {
1000  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id);
1001  if(strlen($fb))
1002  {
1003  $template->setCurrentBlock("feedback");
1004  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
1005  $template->parseCurrentBlock();
1006  }
1007  }
1008 
1009  if($this->object->getSpecificFeedbackSetting() == 3)
1010  {
1011  $answer = $this->object->getAnswer($answer_id);
1012 
1013  if($answer->getPoints() > 0)
1014  {
1015  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id);
1016  if(strlen($fb))
1017  {
1018  $template->setCurrentBlock("feedback");
1019  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
1020  $template->parseCurrentBlock();
1021  }
1022  }
1023  }
1024  }
+ Here is the caller graph for this function:

◆ removechoice()

assMultipleChoiceGUI::removechoice ( )

Remove an answer.

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

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

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

◆ removeimagechoice()

assMultipleChoiceGUI::removeimagechoice ( )

Remove an image.

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

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

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

◆ renderAggregateView()

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

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

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

952  {
953  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
954 
955  $tpl->setCurrentBlock('headercell');
956  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
957  $tpl->parseCurrentBlock();
958 
959  $tpl->setCurrentBlock('headercell');
960  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
961  $tpl->parseCurrentBlock();
962 
963  foreach ($aggregate as $line_data)
964  {
965  $tpl->setCurrentBlock( 'aggregaterow' );
966  $tpl->setVariable( 'OPTION', $line_data['answertext'] );
967  $tpl->setVariable( 'COUNT', $line_data['count_checked'] );
968  $tpl->parseCurrentBlock();
969  }
970  return $tpl;
971  }
special template class to simplify handling of ITX/PEAR
+ Here is the caller graph for this function:

◆ setQuestionTabs()

assMultipleChoiceGUI::setQuestionTabs ( )

Sets the ILIAS tabs for this question type.

Todo:
: MOVE THIS STEPS TO COMMON QUESTION CLASS assQuestionGUI

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

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

653  {
654  global $rbacsystem, $ilTabs;
655 
656  $ilTabs->clearTargets();
657 
658  $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
659  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
660  $q_type = $this->object->getQuestionType();
661 
662  if (strlen($q_type))
663  {
664  $classname = $q_type . "GUI";
665  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
666  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
667  }
668 
669  if ($_GET["q_id"])
670  {
671  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
672  {
673  // edit page
674  $ilTabs->addTarget("edit_page",
675  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
676  array("edit", "insert", "exec_pg"),
677  "", "", $force_active);
678  }
679 
680  $this->addTab_QuestionPreview($ilTabs);
681  }
682  $force_active = false;
683  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
684  {
685  $url = "";
686  if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
687  $force_active = false;
688  // edit question properties
689  $ilTabs->addTarget("edit_question",
690  $url,
691  array("editQuestion", "save", "saveEdit", "addchoice", "removechoice", "removeimagechoice", "uploadchoice", "originalSyncForm"),
692  $classname, "", $force_active);
693  }
694 
695  // add tab for question feedback within common class assQuestionGUI
696  $this->addTab_QuestionFeedback($ilTabs);
697 
698  // add tab for question hint within common class assQuestionGUI
699  $this->addTab_QuestionHints($ilTabs);
700 
701  // add tab for question's suggested solution within common class assQuestionGUI
702  $this->addTab_SuggestedSolution($ilTabs, $classname);
703 
704  // Assessment of questions sub menu entry
705  if ($_GET["q_id"])
706  {
707  $ilTabs->addTarget("statistics",
708  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
709  array("assessment"),
710  $classname, "");
711  }
712 
713  $this->addBackTab($ilTabs);
714  }
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
$_GET["client_id"]
$url
Definition: shib_logout.php:72
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBackTab(ilTabsGUI $ilTabs)
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
+ Here is the call graph for this function:

◆ uploadchoice()

assMultipleChoiceGUI::uploadchoice ( )

Upload an image.

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

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

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

◆ writeAnswerSpecificPostData()

assMultipleChoiceGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

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

Implements ilGuiAnswerScoringAdjustable.

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

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

Referenced by writePostData().

760  {
761  // Delete all existing answers and create new answers from the form data
762  $this->object->flushAnswers();
763  if ($this->object->isSingleline)
764  {
765  foreach ($_POST['choice']['answer'] as $index => $answertext)
766  {
767  $answertext = ilUtil::secureString($answertext);
768 
769  $picturefile = $_POST['choice']['imagename'][$index];
770  $file_org_name = $_FILES['choice']['name']['image'][$index];
771  $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index];
772 
773  if (strlen( $file_temp_name ))
774  {
775  // check suffix
776  $suffix = strtolower( array_pop( explode( ".", $file_org_name ) ) );
777  if (in_array( $suffix, array( "jpg", "jpeg", "png", "gif" ) ))
778  {
779  // upload image
780  $filename = $this->object->createNewImageFileName( $file_org_name );
781  if ($this->object->setImageFile( $filename, $file_temp_name ) == 0)
782  {
783  $picturefile = $filename;
784  }
785  }
786  }
787  $this->object->addAnswer( $answertext,
788  $_POST['choice']['points'][$index],
789  $_POST['choice']['points_unchecked'][$index],
790  $index,
791  $picturefile
792  );
793  }
794  }
795  else
796  {
797  foreach ($_POST['choice']['answer'] as $index => $answer)
798  {
799  $answertext = $answer;
800  $this->object->addAnswer( $answertext,
801  $_POST['choice']['points'][$index],
802  $_POST['choice']['points_unchecked'][$index],
803  $index
804  );
805  }
806  }
807  }
$_POST['username']
Definition: cron.php:12
$filename
Definition: buildRTE.php:89
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

assMultipleChoiceGUI::writePostData (   $always = false)

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

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

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

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

54  {
55  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
56  if (!$hasErrors)
57  {
58  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
62  $this->saveTaxonomyAssignments();
63  return 0;
64  }
65  return 1;
66  }
This class represents a property form user interface.
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
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.
+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assMultipleChoiceGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

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

Implements ilGuiQuestionScoringAdjustable.

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

References $_POST, and ilUtil\sendInfo().

Referenced by writePostData().

741  {
742  $this->object->setShuffle( $_POST["shuffle"] );
743 
744  $this->object->setSpecificFeedbackSetting( $_POST['feedback_setting'] );
745 
746  $this->object->setMultilineAnswerSetting( $_POST["types"] );
747  if (is_array( $_POST['choice']['imagename'] ) && $_POST["types"] == 1)
748  {
749  $this->object->isSingleline = true;
750  ilUtil::sendInfo( $this->lng->txt( 'info_answer_type_change' ), true );
751  }
752  else
753  {
754  $this->object->isSingleline = ($_POST["types"] == 0) ? true : false;
755  }
756  $this->object->setThumbSize( (strlen( $_POST["thumb_size"] )) ? $_POST["thumb_size"] : "" );
757  }
$_POST['username']
Definition: cron.php:12
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $choiceKeys

assMultipleChoiceGUI::$choiceKeys

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

Referenced by getChoiceKeys().


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