ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 
 uploadchoice ()
 Upload an image. More...
 
 removeimagechoice ()
 Remove an image. More...
 
 addchoice ()
 Add a new answer. More...
 
 removechoice ()
 Remove an answer. More...
 
 outQuestionForTest ( $formaction, $active_id, $pass=NULL, $is_question_postponed=FALSE, $user_post_solutions=FALSE, $show_specific_inline_feedback=FALSE)
 
 getSolutionOutput ( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
 Get the question solution output. More...
 
 getPreview ($show_question_only=FALSE)
 
 getTestOutput ( $active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
 
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type. More...
 
 getChoiceKeys ()
 Create the key index numbers for the array of choices. More...
 
 getSpecificFeedbackOutput ($active_id, $pass)
 
 writeQuestionSpecificPostData ($always=false)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 writeAnswerSpecificPostData ($always=false)
 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)
 
 aggregateAnswerVariants ($relevant_answers_chosen)
 
 renderAggregateView ($aggregate)
 
 renderVariantsView ($aggregate, $answers)
 
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor More...
 
executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 
 getType ()
 needed for page editor compliance More...
 
 setTaxonomyIds ($taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui (ilTestPlayerAbstractGUI $linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 assessment ()
 output assessment More...
 
_getQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls. More...
 
 _getGUIClassNameForId ($a_q_id)
 
 _getClassNameForQType ($q_type)
 
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation. More...
 
 getQuestionTemplate ()
 get question template More...
 
 getILIASPage ($html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="")
 output question page More...
 
 cancel ()
 cancel action More...
 
 originalSyncForm ($return_to="", $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 save question More...
 
 save ()
 save question More...
 
 saveReturn ()
 save question More...
 
 apply ()
 apply changes More...
 
 getContextPath ($cont_obj, $a_endnode_id, $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber ($nr)
 
 getSequenceNumber ()
 
 setQuestionCount ($a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage ($errormessage)
 
 addErrorMessage ($errormessage)
 
 outAdditionalOutput ()
 
 getQuestionType ()
 Returns the question type string. More...
 
 getAsValueAttribute ($a_value)
 Returns a HTML value attribute. More...
 
 addNewIdListener (&$a_object, $a_method, $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners ($a_new_id)
 Call the new id listeners. More...
 
 addQuestionFormCommandButtons ($form)
 Add the command buttons of a question properties form. More...
 
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time. More...
 
 getSelfAssessmentTags ()
 Get tags allowed in question tags in self assessment mode. More...
 
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question. More...
 
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 getSpecificFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 showSuggestedSolution ()
 
 suggestedsolution ()
 Allows to add suggested solutions for questions. More...
 
 outSolutionExplorer ()
 
 saveSuggestedSolution ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 getSolutionOutput ( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
 
 isAutosaveable ()
 
 showHints ()
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 

Data Fields

 $choiceKeys
 
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
 $object
 
 $tpl
 
 $lng
 
 $error
 
 $errormessage
 
 $sequence_no
 sequence number in test More...
 
 $question_count
 question count in test More...
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static getCommandsFromClassConstants ($guiClassName, $cmdConstantNameBegin='CMD_')
 extracts values of all constants of given class with given prefix as array can be used to get all possible commands in case of these commands are defined as constants More...
 
- Protected Member Functions inherited from assQuestionGUI
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI More...
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI More...
 
 writeQuestionGenericPostData ()
 

Detailed Description

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

◆ addchoice()

assMultipleChoiceGUI::addchoice ( )

Add a new answer.

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

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

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

Referenced by getAggregatedAnswersView().

993  {
994  $aggregate = array();
995  foreach ($answers_defined_on_question as $answer)
996  {
997  $aggregated_info_for_answer = array();
998  $aggregated_info_for_answer['answertext'] = $answer->getAnswerText();
999  $aggregated_info_for_answer['count_checked'] = 0;
1000 
1001  foreach ($relevant_answers_chosen as $relevant_answer)
1002  {
1003  if ($relevant_answer['value1'] == $answer->getOrder())
1004  {
1005  $aggregated_info_for_answer['count_checked']++;
1006  }
1007  }
1008  $aggregated_info_for_answer['count_unchecked'] =
1009  ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
1010  - $aggregated_info_for_answer['count_checked'];
1011 
1012  $aggregate[] = $aggregated_info_for_answer;
1013  }
1014  return $aggregate;
1015  }
+ Here is the caller graph for this function:

◆ aggregateAnswerVariants()

assMultipleChoiceGUI::aggregateAnswerVariants (   $relevant_answers_chosen)

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

Referenced by getAggregatedAnswersView().

1018  {
1019  $variants = array();
1020  $passdata = array();
1021  foreach ($relevant_answers_chosen as $relevant_answer)
1022  {
1023  $pass_ident = $relevant_answer['active_fi'].$relevant_answer['pass'];
1024  $answer = $passdata[$pass_ident];
1025  if (strlen($answer))
1026  {
1027  $answer_elements = explode(',', $answer);
1028  } else {
1029  $answer_elements = array();
1030  }
1031  $answer_elements[] = $relevant_answer['value1'];
1032  $passdata[$pass_ident] = implode(',',$answer_elements);
1033  }
1034  foreach($passdata as $passident => $behaviour)
1035  {
1036  $variants[$behaviour]++;
1037  }
1038  arsort($variants);
1039  return $variants;
1040  }
+ 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 74 of file class.assMultipleChoiceGUI.php.

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

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

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

◆ getAfterParticipationSuppressionAnswerPostVars()

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

921  {
922  return array();
923  }

◆ 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 934 of file class.assMultipleChoiceGUI.php.

References ilPropertyFormGUI\getItemByPostVar().

935  {
936  return array('shuffle','types','thumb_size');
937  }
+ Here is the call graph for this function:

◆ 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 957 of file class.assMultipleChoiceGUI.php.

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

958  {
959  $actives = array();
960  foreach($relevant_answers as $answer)
961  {
962  $actives[$answer['active_fi']] = max($answer['pass'], $actives[$answer['pass']]);
963  }
964  $usercount = count($actives);
965  $passcount = 0;
966  foreach($actives as $active)
967  {
968  $passcount += $active;
969  }
970  $passcount = $passcount + $usercount; // Add pass 0
971 
972  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_header.html', true, true, "Modules/TestQuestionPool");
973  $tpl->setVariable('HEADERTEXT', $this->lng->txt('overview'));
974  $tpl->setVariable('NUMBER_OF_USERS_INFO', $this->lng->txt('number_of_users'));
975  $tpl->setVariable('NUMBER_OF_USERS', $usercount);
976  $tpl->setVariable('NUMBER_OF_PASSES_INFO', $this->lng->txt('number_of_passes'));
977  $tpl->setVariable('NUMBER_OF_PASSES', $passcount);
978 
979  $header = $tpl->get();
980  $overview = $this->renderAggregateView(
981  $this->aggregateAnswers( $relevant_answers, $this->object->getAnswers() )
982  )->get();
983 
984  $variants = $this->renderVariantsView(
985  $this->aggregateAnswerVariants($relevant_answers, $this->object->getAnswers()),
986  $this->object->getAnswers()
987  )->get();
988 
989  return $header . $overview . $variants ;
990  }
renderVariantsView($aggregate, $answers)
special template class to simplify handling of ITX/PEAR
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
aggregateAnswerVariants($relevant_answers_chosen)
+ 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 746 of file class.assMultipleChoiceGUI.php.

References $_GET, $_SESSION, and $choiceKeys.

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

747  {
748  if (strcmp($_GET["activecommand"], "directfeedback") == 0)
749  {
750  if (is_array($_SESSION["choicekeys"])) $this->choiceKeys = $_SESSION["choicekeys"];
751  }
752  if (!is_array($this->choiceKeys))
753  {
754  $this->choiceKeys = array_keys($this->object->answers);
755  if ($this->object->getShuffle())
756  {
757  $this->choiceKeys = $this->object->pcArrayShuffle($this->choiceKeys);
758  }
759  }
760  $_SESSION["choicekeys"] = $this->choiceKeys;
761  return $this->choiceKeys;
762  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
$_GET["client_id"]
+ Here is the caller graph for this function:

◆ getPreview()

assMultipleChoiceGUI::getPreview (   $show_question_only = FALSE)

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

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

430  {
431  // shuffle output
432  $keys = $this->getChoiceKeys();
433 
434  // generate the question output
435  include_once "./Services/UICore/classes/class.ilTemplate.php";
436  $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
437  foreach ($keys as $answer_id)
438  {
439  $answer = $this->object->answers[$answer_id];
440  if (strlen($answer->getImage()))
441  {
442  if ($this->object->getThumbSize())
443  {
444  $template->setCurrentBlock("preview");
445  $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
446  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
447  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
448  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
449  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
450  $alt = $answer->getImage();
451  if (strlen($answer->getAnswertext()))
452  {
453  $alt = $answer->getAnswertext();
454  }
455  $alt = preg_replace("/<[^>]*?>/", "", $alt);
456  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
457  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
458  $template->parseCurrentBlock();
459  }
460  else
461  {
462  $template->setCurrentBlock("answer_image");
463  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
464  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
465  $alt = $answer->getImage();
466  if (strlen($answer->getAnswertext()))
467  {
468  $alt = $answer->getAnswertext();
469  }
470  $alt = preg_replace("/<[^>]*?>/", "", $alt);
471  $template->setVariable("ATTR", $attr);
472  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
473  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
474  $template->parseCurrentBlock();
475  }
476  }
477  $template->setCurrentBlock("answer_row");
478  $template->setVariable("ANSWER_ID", $answer_id);
479  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
480  $template->parseCurrentBlock();
481  }
482  $questiontext = $this->object->getQuestion();
483  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
484  $questionoutput = $template->get();
485  if (!$show_question_only)
486  {
487  // get page object output
488  $questionoutput = $this->getILIASPage($questionoutput);
489  }
490  return $questionoutput;
491  }
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
+ 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 205 of file class.assMultipleChoiceGUI.php.

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

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

765  {
766  // No return value, this question type supports inline specific feedback.
767  $output = "";
768  return $this->object->prepareTextareaOutput($output, TRUE);
769  }

◆ getTestOutput()

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

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

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

Referenced by outQuestionForTest().

509  {
510  // shuffle output
511  $keys = $this->getChoiceKeys();
512 
513  // get the solution of the user for the active pass or from the last pass if allowed
514  $user_solution = array();
515  if ($active_id)
516  {
517  $solutions = NULL;
518  include_once "./Modules/Test/classes/class.ilObjTest.php";
519  if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
520  {
521  if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
522  }
523  $solutions =& $this->object->getSolutionValues($active_id, $pass);
524  foreach ($solutions as $idx => $solution_value)
525  {
526  array_push($user_solution, $solution_value["value1"]);
527  }
528  }
529  // generate the question output
530  include_once "./Services/UICore/classes/class.ilTemplate.php";
531  $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
532  foreach ($keys as $answer_id)
533  {
534  $answer = $this->object->answers[$answer_id];
535  if (strlen($answer->getImage()))
536  {
537  if ($this->object->getThumbSize())
538  {
539  $template->setCurrentBlock("preview");
540  $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
541  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
542  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
543  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage());
544  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
545  $alt = $answer->getImage();
546  if (strlen($answer->getAnswertext()))
547  {
548  $alt = $answer->getAnswertext();
549  }
550  $alt = preg_replace("/<[^>]*?>/", "", $alt);
551  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
552  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
553  $template->parseCurrentBlock();
554  }
555  else
556  {
557  $template->setCurrentBlock("answer_image");
558  $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
559  list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
560  $alt = $answer->getImage();
561  if (strlen($answer->getAnswertext()))
562  {
563  $alt = $answer->getAnswertext();
564  }
565  $alt = preg_replace("/<[^>]*?>/", "", $alt);
566  $template->setVariable("ATTR", $attr);
567  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
568  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
569  $template->parseCurrentBlock();
570  }
571  }
572  if ($show_feedback && $this->object->getSpecificFeedbackSetting() == 2)
573  {
574  foreach ($user_solution as $mc_solution)
575  {
576  if (strcmp($mc_solution, $answer_id) == 0)
577  {
578  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
579  $this->object->getId(), $answer_id
580  );
581  if (strlen($fb))
582  {
583  $template->setCurrentBlock("feedback");
584  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $fb, true ));
585  $template->parseCurrentBlock();
586  }
587  }
588  }
589  }
590 
591  if ($show_feedback && $this->object->getSpecificFeedbackSetting() == 1)
592  {
593  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
594  $this->object->getId(), $answer_id
595  );
596  if (strlen($fb))
597  {
598  $template->setCurrentBlock("feedback");
599  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $fb, true ));
600  $template->parseCurrentBlock();
601  }
602  }
603 
604  if ($show_feedback && $this->object->getSpecificFeedbackSetting() == 3)
605  {
606  $answer = $this->object->getAnswer($answer_id);
607 
608  if ($answer->getPoints() > 0)
609  {
610  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
611  $this->object->getId(), $answer_id
612  );
613  if (strlen($fb))
614  {
615  $template->setCurrentBlock("feedback");
616  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $fb, true ));
617  $template->parseCurrentBlock();
618  }
619  }
620 
621  }
622 
623 
624  $template->setCurrentBlock("answer_row");
625  $template->setVariable("ANSWER_ID", $answer_id);
626  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
627  foreach ($user_solution as $mc_solution)
628  {
629  if (strcmp($mc_solution, $answer_id) == 0)
630  {
631  $template->setVariable("CHECKED_ANSWER", " checked=\"checked\"");
632  }
633  }
634  $template->parseCurrentBlock();
635  }
636  $questiontext = $this->object->getQuestion();
637  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
638  $questionoutput = $template->get();
639  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
640  return $pageoutput;
641  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
getChoiceKeys()
Create the key index numbers for the array of choices.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
_getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ outQuestionForTest()

assMultipleChoiceGUI::outQuestionForTest (   $formaction,
  $active_id,
  $pass = NULL,
  $is_question_postponed = FALSE,
  $user_post_solutions = FALSE,
  $show_specific_inline_feedback = FALSE 
)
Parameters
string$formaction
integer$active_id
integer | null$pass
bool$is_question_postponed
bool$user_post_solutions
bool$show_specific_inline_feedback

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

References $pass, and getTestOutput().

177  {
178  $test_output = $this->getTestOutput(
179  $active_id,
180  $pass,
181  $is_question_postponed,
182  $user_post_solutions,
183  $show_specific_inline_feedback
184  );
185 
186  $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
187  $this->tpl->setVariable("FORMACTION", $formaction);
188  }
getTestOutput( $active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assMultipleChoiceGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

889  {
890  // Choices
891  include_once "./Modules/TestQuestionPool/classes/class.ilMultipleChoiceWizardInputGUI.php";
892  $choices = new ilMultipleChoiceWizardInputGUI($this->lng->txt( "answers" ), "choice");
893  $choices->setRequired( true );
894  $choices->setQuestionObject( $this->object );
895  $isSingleline = ($this->object->lastChange == 0 && !array_key_exists( 'types',
896  $_POST
897  )) ? (($this->object->getMultilineAnswerSetting()) ? false : true) : $this->object->isSingleline;
898  $choices->setSingleline( $isSingleline );
899  $choices->setAllowMove( false );
900  if ($this->object->getSelfAssessmentEditingMode())
901  {
902  $choices->setSize( 40 );
903  $choices->setMaxLength( 800 );
904  }
905  if ($this->object->getAnswerCount() == 0)
906  $this->object->addAnswer( "", 0, 0, 0 );
907  $choices->setValues( $this->object->getAnswers() );
908  $form->addItem( $choices );
909  }
$_POST['username']
Definition: cron.php:12
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 838 of file class.assMultipleChoiceGUI.php.

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

Referenced by editQuestion().

839  {
840  // shuffle
841  $shuffle = new ilCheckboxInputGUI($this->lng->txt( "shuffle_answers" ), "shuffle");
842  $shuffle->setValue( 1 );
843  $shuffle->setChecked( $this->object->getShuffle() );
844  $shuffle->setRequired( FALSE );
845  $form->addItem( $shuffle );
846 
847  if ($this->object->getId())
848  {
849  $hidden = new ilHiddenInputGUI("", "ID");
850  $hidden->setValue( $this->object->getId() );
851  $form->addItem( $hidden );
852  }
853 
854  if (!$this->object->getSelfAssessmentEditingMode())
855  {
856  $isSingleline = ($this->object->lastChange == 0 && !array_key_exists( 'types',
857  $_POST
858  )) ? (($this->object->getMultilineAnswerSetting()) ? false : true) : $this->object->isSingleline;
859  // Answer types
860  $types = new ilSelectInputGUI($this->lng->txt( "answer_types" ), "types");
861  $types->setRequired( false );
862  $types->setValue( ($isSingleline) ? 0 : 1 );
863  $types->setOptions( array(
864  0 => $this->lng->txt( 'answers_singleline' ),
865  1 => $this->lng->txt( 'answers_multiline' ),
866  )
867  );
868  $form->addItem( $types );
869  }
870 
871  if ($isSingleline)
872  {
873  // thumb size
874  $thumb_size = new ilNumberInputGUI($this->lng->txt( "thumb_size" ), "thumb_size");
875  $thumb_size->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
876  $thumb_size->setMinValue( 20 );
877  $thumb_size->setDecimals( 0 );
878  $thumb_size->setSize( 6 );
879  $thumb_size->setInfo( $this->lng->txt( 'thumb_size_info' ) );
880  $thumb_size->setValue( $this->object->getThumbSize() );
881  $thumb_size->setRequired( false );
882  $form->addItem( $thumb_size );
883  return $isSingleline;
884  }
885  return $isSingleline;
886  }
$_POST['username']
Definition: cron.php:12
This class represents a selection list property in a property form.
This class represents a checkbox property in a property form.
This class represents a hidden form property in a property form.
setSuffix($a_value)
Set suffix.
This class represents a number property in a property form.
setValue($a_value)
Set Value.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removechoice()

assMultipleChoiceGUI::removechoice ( )

Remove an answer.

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

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

154  {
155  $this->writePostData(true);
156  $position = key($_POST['cmd']['removechoice']);
157  $this->object->deleteAnswer($position);
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:

◆ removeimagechoice()

assMultipleChoiceGUI::removeimagechoice ( )

Remove an image.

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

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

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

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

1048  {
1049  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
1050  $tpl->setVariable( 'OPTION_HEADER', $this->lng->txt('option') );
1051  $tpl->setVariable( 'COUNT_HEADER', $this->lng->txt('count') );
1052  $tpl->setVariable( 'AGGREGATION_HEADER', $this->lng->txt('aggregated_answers_header') );
1053  foreach ($aggregate as $line_data)
1054  {
1055  $tpl->setCurrentBlock( 'aggregaterow' );
1056  $tpl->setVariable( 'OPTION', $line_data['answertext'] );
1057  $tpl->setVariable( 'COUNT', $line_data['count_checked'] );
1058  $tpl->parseCurrentBlock();
1059  }
1060  return $tpl;
1061  }
special template class to simplify handling of ITX/PEAR
+ Here is the caller graph for this function:

◆ renderVariantsView()

assMultipleChoiceGUI::renderVariantsView (   $aggregate,
  $answers 
)

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

References $options, and assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

1064  {
1065  $tpl = new ilTemplate( 'tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool" );
1066  $tpl->setVariable( 'OPTION_HEADER', $this->lng->txt( 'answer_variant' ) );
1067  $tpl->setVariable( 'COUNT_HEADER', $this->lng->txt( 'count' ) );
1068  $tpl->setVariable( 'AGGREGATION_HEADER', $this->lng->txt( 'aggregated_answers_variants' ) );
1069  foreach ($aggregate as $options => $count)
1070  {
1071  $tpl->setCurrentBlock( 'aggregaterow' );
1072  $optionstext = array();
1073  foreach (explode( ',', $options ) as $option)
1074  {
1075  $answer = $answers[$option];
1076  $optionstext[] = $answer->getAnswerText();
1077  }
1078  $tpl->setVariable( 'OPTION', implode( ',&nbsp;', $optionstext ) );
1079  $tpl->setVariable( 'COUNT', $count );
1080  $tpl->parseCurrentBlock();
1081  }
1082 
1083  return $tpl;
1084  }
if(!is_array($argv)) $options
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 648 of file class.assMultipleChoiceGUI.php.

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

649  {
650  global $rbacsystem, $ilTabs;
651 
652  $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
653  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
654  $q_type = $this->object->getQuestionType();
655 
656  if (strlen($q_type))
657  {
658  $classname = $q_type . "GUI";
659  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
660  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
661  }
662 
663  if ($_GET["q_id"])
664  {
665  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
666  {
667  // edit page
668  $ilTabs->addTarget("edit_page",
669  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
670  array("edit", "insert", "exec_pg"),
671  "", "", $force_active);
672  }
673 
674  // edit page
675  $ilTabs->addTarget("preview",
676  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "preview"),
677  array("preview"),
678  "ilAssQuestionPageGUI", "", $force_active);
679  }
680  $force_active = false;
681  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
682  {
683  $url = "";
684  if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
685  $force_active = false;
686  // edit question properties
687  $ilTabs->addTarget("edit_question",
688  $url,
689  array("editQuestion", "save", "saveEdit", "addchoice", "removechoice", "removeimagechoice", "uploadchoice", "originalSyncForm"),
690  $classname, "", $force_active);
691  }
692 
693  // add tab for question feedback within common class assQuestionGUI
694  $this->addTab_QuestionFeedback($ilTabs);
695 
696  // add tab for question hint within common class assQuestionGUI
697  $this->addTab_QuestionHints($ilTabs);
698 
699  if ($_GET["q_id"])
700  {
701  $ilTabs->addTarget("solution_hint",
702  $this->ctrl->getLinkTargetByClass($classname, "suggestedsolution"),
703  array("suggestedsolution", "saveSuggestedSolution", "outSolutionExplorer", "cancel",
704  "addSuggestedSolution","cancelExplorer", "linkChilds", "removeSuggestedSolution"
705  ),
706  $classname,
707  ""
708  );
709  }
710 
711  // Assessment of questions sub menu entry
712  if ($_GET["q_id"])
713  {
714  $ilTabs->addTarget("statistics",
715  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
716  array("assessment"),
717  $classname, "");
718  }
719 
720  if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
721  {
722  $ref_id = $_GET["calling_test"];
723  if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
724 
725  global $___test_express_mode;
726 
727  if (!$_GET['test_express_mode'] && !$___test_express_mode) {
728  $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
729  }
730  else {
732  $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), $link);
733  }
734  }
735  else
736  {
737  $ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
738  }
739  }
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
$_GET["client_id"]
static getReturnToPageLink($q_id=null)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:

◆ uploadchoice()

assMultipleChoiceGUI::uploadchoice ( )

Upload an image.

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

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

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

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

References $_POST, and $filename.

Referenced by writePostData().

791  {
792  // Delete all existing answers and create new answers from the form data
793  $this->object->flushAnswers();
794  if ($this->object->isSingleline)
795  {
796  foreach ($_POST['choice']['answer'] as $index => $answertext)
797  {
798  $picturefile = $_POST['choice']['imagename'][$index];
799  $file_org_name = $_FILES['choice']['name']['image'][$index];
800  $file_temp_name = $_FILES['choice']['tmp_name']['image'][$index];
801 
802  if (strlen( $file_temp_name ))
803  {
804  // check suffix
805  $suffix = strtolower( array_pop( explode( ".", $file_org_name ) ) );
806  if (in_array( $suffix, array( "jpg", "jpeg", "png", "gif" ) ))
807  {
808  // upload image
809  $filename = $this->object->createNewImageFileName( $file_org_name );
810  if ($this->object->setImageFile( $filename, $file_temp_name ) == 0)
811  {
812  $picturefile = $filename;
813  }
814  }
815  }
816  $this->object->addAnswer( $answertext,
817  $_POST['choice']['points'][$index],
818  $_POST['choice']['points_unchecked'][$index],
819  $index,
820  $picturefile
821  );
822  }
823  }
824  else
825  {
826  foreach ($_POST['choice']['answer'] as $index => $answer)
827  {
828  $answertext = $answer;
829  $this->object->addAnswer( $answertext,
830  $_POST['choice']['points'][$index],
831  $_POST['choice']['points_unchecked'][$index],
832  $index
833  );
834  }
835  }
836  }
$_POST['username']
Definition: cron.php:12
$filename
Definition: buildRTE.php:89
+ 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  {
61  $this->saveTaxonomyAssignments();
62  return 0;
63  }
64  return 1;
65  }
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
writeQuestionSpecificPostData($always=false)
Extracts the question specific values from $_POST and applies them to the data object.
writeAnswerSpecificPostData($always=false)
Extracts the answer specific values from $_POST and applies them to the data object.
+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assMultipleChoiceGUI::writeQuestionSpecificPostData (   $always = false)

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

References $_POST, and ilUtil\sendInfo().

Referenced by writePostData().

772  {
773  $this->object->setShuffle( $_POST["shuffle"] );
774 
775  $this->object->setSpecificFeedbackSetting( $_POST['feedback_setting'] );
776 
777  $this->object->setMultilineAnswerSetting( $_POST["types"] );
778  if (is_array( $_POST['choice']['imagename'] ) && $_POST["types"] == 1)
779  {
780  $this->object->isSingleline = true;
781  ilUtil::sendInfo( $this->lng->txt( 'info_answer_type_change' ), true );
782  }
783  else
784  {
785  $this->object->isSingleline = ($_POST["types"] == 0) ? true : false;
786  }
787  $this->object->setThumbSize( (strlen( $_POST["thumb_size"] )) ? $_POST["thumb_size"] : "" );
788  }
$_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: