ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
assKprimChoiceGUI Class Reference
+ Inheritance diagram for assKprimChoiceGUI:
+ Collaboration diagram for assKprimChoiceGUI:

Public Member Functions

 __construct ($qId=-1)
 
 hasInlineFeedback ()
 
 removeImage ()
 
 downkprim_answers ()
 
 upkprim_answers ()
 
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 
 getSpecificFeedbackOutput ($userSolution)
 
 getTestOutput ( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $showInlineFeedback=false)
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() 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)
 
 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...
 
 renderAggregateView ($aggregate)
 
 aggregateAnswers ($rawSolutionData, $answers)
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor More...
 
 hasInlineFeedback ()
 this method can be overwritten per question type More...
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getNotesHTML ()
 
 executeCommand ()
 execute command More...
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext ($presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled ($previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose ($renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext ($editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI ($navigationGUI)
 
 setTaxonomyIds ($taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd ($questionActionCmd)
 
 getQuestionActionCmd ()
 
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation. More...
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 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="", $inlineFeedbackEnabled=false)
 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 ($userSolution)
 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)
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() More...
 
 hasIntermediateSolution ($activeId, $passIndex)
 Check if the question has an intermediate solution. More...
 
 setUseIntermediateSolution ($use)
 
 getUseIntermediateSolution ()
 Get if intermediate solution should be used for solution output. More...
 
 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 ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFreuqencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 

Data Fields

 $object
 
- 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
 
 $request
 
 $sequence_no
 sequence number in test More...
 
 $question_count
 question count in test More...
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 

Protected Member Functions

 getAdditionalEditQuestionCommands ()
 
 editQuestion (ilPropertyFormGUI $form=null)
 
 uploadImage ()
 
 writePostData ($upload=false)
 {} More...
 
 buildEditForm ()
 
 getParticipantsAnswerKeySequence ()
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm ($form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 setDefaultTabs (ilTabsGUI $ilTabs)
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 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_Question (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 addSaveOnEnterOnLoadCode ()
 

Private Member Functions

 handleAnswerTextsSubmit ($answers)
 
 populateSpecificFeedbackInline ($user_solution, $answer_id, $template)
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants ($guiClassName, $cmdConstantNameBegin='CMD_')
 extracts values of all constants of given class with given prefix as array can be used to get all possible commands in case of these commands are defined as constants More...
 
- Protected Attributes inherited from assQuestionGUI
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
 $ctrl
 
 $editForm
 
 $use_intermediate_solution = false
 

Detailed Description

Definition at line 16 of file class.assKprimChoiceGUI.php.

Constructor & Destructor Documentation

◆ __construct()

assKprimChoiceGUI::__construct (   $qId = -1)
Parameters
$qId

Definition at line 26 of file class.assKprimChoiceGUI.php.

References ILIAS\GlobalScreen\Provider\__construct().

27  {
29 
30  require_once 'Modules/TestQuestionPool/classes/class.assKprimChoice.php';
31  $this->object = new assKprimChoice();
32 
33  if ($qId > 0) {
34  $this->object->loadFromDb($qId);
35  }
36  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ aggregateAnswers()

assKprimChoiceGUI::aggregateAnswers (   $rawSolutionData,
  $answers 
)

Definition at line 835 of file class.assKprimChoiceGUI.php.

Referenced by getAggregatedAnswersView(), and getAnswersFrequency().

836  {
837  $aggregate = array();
838 
839  foreach ($answers as $answer) {
840  $answerAgg = array(
841  'answertext' => $answer->getAnswerText(), 'count_true' => 0, 'count_false' => 0
842  );
843 
844  foreach ($rawSolutionData as $solutionRecord) {
845  if ($solutionRecord['value1'] == $answer->getPosition()) {
846  if ($solutionRecord['value2']) {
847  $answerAgg['count_true']++;
848  } else {
849  $answerAgg['count_false']++;
850  }
851  }
852  }
853 
854  $aggregate[] = $answerAgg;
855  }
856 
857  return $aggregate;
858  }
+ Here is the caller graph for this function:

◆ buildEditForm()

assKprimChoiceGUI::buildEditForm ( )
protected
Returns
ilPropertyFormGUI

Definition at line 138 of file class.assKprimChoiceGUI.php.

References assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), assQuestionGUI\buildBasicEditFormObject(), populateAnswerSpecificFormPart(), populateQuestionSpecificFormPart(), and assQuestionGUI\populateTaxonomyFormSection().

Referenced by editQuestion(), and writePostData().

139  {
140  $form = $this->buildBasicEditFormObject();
141 
142  $this->addQuestionFormCommandButtons($form);
143 
144  $this->addBasicQuestionFormProperties($form);
145 
146  $this->populateQuestionSpecificFormPart($form);
147  $this->populateAnswerSpecificFormPart($form);
148 
149  $this->populateTaxonomyFormSection($form);
150 
151  return $form;
152  }
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ downkprim_answers()

assKprimChoiceGUI::downkprim_answers ( )

Definition at line 81 of file class.assKprimChoiceGUI.php.

References $_POST, and editQuestion().

82  {
83  if (isset($_POST['cmd'][__FUNCTION__]) && count($_POST['cmd'][__FUNCTION__])) {
84  $this->object->moveAnswerDown(key($_POST['cmd'][__FUNCTION__]));
85  $this->object->saveToDb();
86  }
87 
88  $this->editQuestion();
89  }
editQuestion(ilPropertyFormGUI $form=null)
$_POST["username"]
+ Here is the call graph for this function:

◆ editQuestion()

assKprimChoiceGUI::editQuestion ( ilPropertyFormGUI  $form = null)
protected

Definition at line 51 of file class.assKprimChoiceGUI.php.

References buildEditForm(), and assQuestionGUI\getQuestionTemplate().

Referenced by downkprim_answers(), removeImage(), upkprim_answers(), uploadImage(), and writePostData().

52  {
53  if ($form === null) {
54  $form = $this->buildEditForm();
55  }
56 
57  $this->getQuestionTemplate();
58 
59  $this->tpl->setVariable("QUESTION_DATA", $this->ctrl->getHTML($form));
60  }
getQuestionTemplate()
get question template
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdditionalEditQuestionCommands()

assKprimChoiceGUI::getAdditionalEditQuestionCommands ( )
protected

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

47  {
48  return array('uploadImage', 'removeImage');
49  }

◆ getAfterParticipationSuppressionAnswerPostVars()

assKprimChoiceGUI::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 777 of file class.assKprimChoiceGUI.php.

778  {
779  return array();
780  }

◆ getAfterParticipationSuppressionQuestionPostVars()

assKprimChoiceGUI::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 791 of file class.assKprimChoiceGUI.php.

792  {
793  return array();
794  }

◆ getAggregatedAnswersView()

assKprimChoiceGUI::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 804 of file class.assKprimChoiceGUI.php.

References aggregateAnswers(), and renderAggregateView().

805  {
806  return $this->renderAggregateView(
807  $this->aggregateAnswers($relevant_answers, $this->object->getAnswers())
808  )->get();
809 
810  return '<pre>' . print_r($relevant_answers, 1) . '</pre>';
811  }
aggregateAnswers($rawSolutionData, $answers)
+ Here is the call graph for this function:

◆ getAnswerFrequencyTableGUI()

assKprimChoiceGUI::getAnswerFrequencyTableGUI (   $parentGui,
  $parentCmd,
  $relevantAnswers,
  $questionIndex 
)
Parameters
$parentGui
$parentCmd
$relevantAnswers
$questionIndex
Returns
ilKprimChoiceAnswerFreqStatTableGUI

Definition at line 884 of file class.assKprimChoiceGUI.php.

References getAnswersFrequency().

885  {
886  require_once 'Modules/TestQuestionPool/classes/tables/class.ilKprimChoiceAnswerFreqStatTableGUI.php';
887 
888  $table = new ilKprimChoiceAnswerFreqStatTableGUI($parentGui, $parentCmd, $this->object);
889  $table->setQuestionIndex($questionIndex);
890  $table->setData($this->getAnswersFrequency($relevantAnswers, $questionIndex));
891  $table->initColumns();
892 
893  return $table;
894  }
getAnswersFrequency($relevantAnswers, $questionIndex)
+ Here is the call graph for this function:

◆ getAnswersFrequency()

assKprimChoiceGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Definition at line 860 of file class.assKprimChoiceGUI.php.

References aggregateAnswers().

Referenced by getAnswerFrequencyTableGUI().

861  {
862  $agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());
863 
864  $answers = array();
865 
866  foreach ($agg as $ans) {
867  $answers[] = array(
868  'answer' => $ans['answertext'],
869  'frequency_true' => $ans['count_true'],
870  'frequency_false' => $ans['count_false']
871  );
872  }
873 
874  return $answers;
875  }
aggregateAnswers($rawSolutionData, $answers)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParticipantsAnswerKeySequence()

assKprimChoiceGUI::getParticipantsAnswerKeySequence ( )
protected

Definition at line 719 of file class.assKprimChoiceGUI.php.

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

720  {
721  $choiceKeys = array_keys($this->object->getAnswers());
722 
723  if ($this->object->isShuffleAnswersEnabled()) {
724  $choiceKeys = $this->object->getShuffler()->shuffle($choiceKeys);
725  }
726 
727  return $choiceKeys;
728  }
+ Here is the caller graph for this function:

◆ getPreview()

assKprimChoiceGUI::getPreview (   $show_question_only = false,
  $showInlineFeedback = false 
)
Parameters
bool$show_question_only
bool$showInlineFeedback

Definition at line 447 of file class.assKprimChoiceGUI.php.

References $keys, $type, assQuestionGUI\buildFocusAnchorHtml(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), getParticipantsAnswerKeySequence(), assQuestionGUI\getPreviewSession(), hasInlineFeedback(), populateSpecificFeedbackInline(), and ilUtil\prepareFormOutput().

448  {
449  $user_solution = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : array();
450  // shuffle output
452 
453  // generate the question output
454  include_once "./Services/UICore/classes/class.ilTemplate.php";
455  $template = new ilTemplate("tpl.il_as_qpl_mc_kprim_output.html", true, true, "Modules/TestQuestionPool");
456 
457  foreach ($keys as $answer_id) {
458  $answer = $this->object->getAnswer($answer_id);
459  if (strlen($answer->getImageFile())) {
460  if ($this->object->getThumbSize()) {
461  $template->setCurrentBlock("preview");
462  $template->setVariable("URL_PREVIEW", $answer->getImageWebPath());
463  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
464  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
465  $template->setVariable("ANSWER_IMAGE_URL", $answer->getThumbWebPath());
466  list($width, $height, $type, $attr) = getimagesize($answer->getImageFsPath());
467  $alt = $answer->getImageFile();
468  if (strlen($answer->getAnswertext())) {
469  $alt = $answer->getAnswertext();
470  }
471  $alt = preg_replace("/<[^>]*?>/", "", $alt);
472  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
473  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
474  $template->parseCurrentBlock();
475  } else {
476  $template->setCurrentBlock("answer_image");
477  $template->setVariable("ANSWER_IMAGE_URL", $answer->getImageWebPath());
478  list($width, $height, $type, $attr) = getimagesize($answer->getImageFsPath());
479  $alt = $answer->getImageFile();
480  if (strlen($answer->getAnswertext())) {
481  $alt = $answer->getAnswertext();
482  }
483  $alt = preg_replace("/<[^>]*?>/", "", $alt);
484  $template->setVariable("ATTR", $attr);
485  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
486  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
487  $template->parseCurrentBlock();
488  }
489  }
490 
491  if ($showInlineFeedback) {
492  $this->populateSpecificFeedbackInline($user_solution, $answer_id, $template);
493  }
494 
495  $template->setCurrentBlock("answer_row");
496  $template->setVariable("ANSWER_ID", $answer_id);
497  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), true));
498  $template->setVariable('VALUE_TRUE', 1);
499  $template->setVariable('VALUE_FALSE', 0);
500 
501  if (isset($user_solution[$answer->getPosition()])) {
502  $tplVar = $user_solution[$answer->getPosition()] ? 'CHECKED_ANSWER_TRUE' : 'CHECKED_ANSWER_FALSE';
503  $template->setVariable($tplVar, " checked=\"checked\"");
504  }
505 
506  $template->parseCurrentBlock();
507  }
508  $questiontext = $this->object->getQuestionForHTMLOutput();
509  if ($showInlineFeedback && $this->hasInlineFeedback()) {
510  $questiontext .= $this->buildFocusAnchorHtml();
511  }
512  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
513 
514  $template->setVariable("INSTRUCTIONTEXT", $this->object->getInstructionTextTranslation(
515  $this->lng,
516  $this->object->getOptionLabel()
517  ));
518 
519  $template->setVariable("OPTION_LABEL_TRUE", $this->object->getTrueOptionLabelTranslation(
520  $this->lng,
521  $this->object->getOptionLabel()
522  ));
523 
524  $template->setVariable("OPTION_LABEL_FALSE", $this->object->getFalseOptionLabelTranslation(
525  $this->lng,
526  $this->object->getOptionLabel()
527  ));
528 
529  $questionoutput = $template->get();
530  if (!$show_question_only) {
531  // get page object output
532  $questionoutput = $this->getILIASPage($questionoutput);
533  }
534  return $questionoutput;
535  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$type
$keys
Definition: metadata.php:187
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)
populateSpecificFeedbackInline($user_solution, $answer_id, $template)
+ Here is the call graph for this function:

◆ getSolutionOutput()

assKprimChoiceGUI::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 
)
Parameters
$active_id
null$pass
bool$graphicalOutput
bool$result_output
bool$show_question_only
bool$show_feedback
bool$show_correct_solution
bool$show_manual_scoring
bool$show_question_text

Definition at line 559 of file class.assKprimChoiceGUI.php.

References $keys, $pass, assQuestionGUI\buildFocusAnchorHtml(), ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, assQuestionGUI\getGenericFeedbackOutput(), ilUtil\getHtmlPath(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), getParticipantsAnswerKeySequence(), assQuestionGUI\getUseIntermediateSolution(), assQuestionGUI\hasCorrectSolution(), hasInlineFeedback(), assQuestionGUI\isRenderPurposePrintPdf(), assQuestionGUI\isTestPresentationContext(), populateSpecificFeedbackInline(), ilUtil\prepareFormOutput(), and assQuestionGUI\renderPurposeSupportsFormHtml().

569  {
570  // shuffle output
572 
573  // get the solution of the user for the active pass or from the last pass if allowed
574  $user_solution = array();
575  if (($active_id > 0) && (!$show_correct_solution)) {
576  $solutions = $this->object->getSolutionValues($active_id, $pass, !$this->getUseIntermediateSolution());
577  foreach ($solutions as $idx => $solution_value) {
578  $user_solution[$solution_value['value1']] = $solution_value['value2'];
579  }
580  } else {
581  // take the correct solution instead of the user solution
582  foreach ($this->object->getAnswers() as $answer) {
583  $user_solution[$answer->getPosition()] = $answer->getCorrectness();
584  }
585  }
586 
587  // generate the question output
588  $template = new ilTemplate("tpl.il_as_qpl_mc_kprim_output_solution.html", true, true, "Modules/TestQuestionPool");
589 
590  foreach ($keys as $answer_id) {
591  $answer = $this->object->getAnswer($answer_id);
592 
593  if (($active_id > 0) && (!$show_correct_solution)) {
594  if ($graphicalOutput) {
595  // output of ok/not ok icons for user entered solutions
596 
597  if ($user_solution[$answer->getPosition()] == $answer->getCorrectness()) {
598  $template->setCurrentBlock("icon_ok");
599  $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
600  $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
601  $template->parseCurrentBlock();
602  } else {
603  $template->setCurrentBlock("icon_ok");
604  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
605  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
606  $template->parseCurrentBlock();
607  }
608  }
609  }
610  if (strlen($answer->getImageFile())) {
611  $template->setCurrentBlock("answer_image");
612  if ($this->object->getThumbSize()) {
613  $template->setVariable("ANSWER_IMAGE_URL", $answer->getThumbWebPath());
614  } else {
615  $template->setVariable("ANSWER_IMAGE_URL", $answer->getImageWebPath());
616  }
617 
618  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($answer->getImageFile()));
619  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($answer->getImageFile()));
620  $template->parseCurrentBlock();
621  }
622 
623  if ($show_feedback) {
624  $this->populateSpecificFeedbackInline($user_solution, $answer_id, $template);
625  }
626 
627  $template->setCurrentBlock("answer_row");
628  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), true));
629 
630  if ($this->renderPurposeSupportsFormHtml() || $this->isRenderPurposePrintPdf()) {
631  if (isset($user_solution[$answer->getPosition()])) {
632  if ($user_solution[$answer->getPosition()]) {
633  $template->setVariable("SOLUTION_IMAGE_TRUE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_checked.png")));
634  $template->setVariable("SOLUTION_ALT_TRUE", $this->lng->txt("checked"));
635  $template->setVariable("SOLUTION_IMAGE_FALSE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png")));
636  $template->setVariable("SOLUTION_ALT_FALSE", $this->lng->txt("unchecked"));
637  } else {
638  $template->setVariable("SOLUTION_IMAGE_TRUE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png")));
639  $template->setVariable("SOLUTION_ALT_TRUE", $this->lng->txt("unchecked"));
640  $template->setVariable("SOLUTION_IMAGE_FALSE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_checked.png")));
641  $template->setVariable("SOLUTION_ALT_FALSE", $this->lng->txt("checked"));
642  }
643  } else {
644  $template->setVariable("SOLUTION_IMAGE_TRUE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png")));
645  $template->setVariable("SOLUTION_ALT_TRUE", $this->lng->txt("unchecked"));
646  $template->setVariable("SOLUTION_IMAGE_FALSE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png")));
647  $template->setVariable("SOLUTION_ALT_FALSE", $this->lng->txt("unchecked"));
648  }
649  } else {
650  $template->setVariable('SOL_QID', $this->object->getId());
651  $template->setVariable('SOL_SUFFIX', $show_correct_solution ? 'bestsolution' : 'usersolution');
652  $template->setVariable('SOL_POSITION', $answer->getPosition());
653 
654  $template->setVariable('SOL_TRUE_VALUE', 1);
655  $template->setVariable('SOL_FALSE_VALUE', 0);
656 
657  if (isset($user_solution[$answer->getPosition()])) {
658  if ($user_solution[$answer->getPosition()]) {
659  $template->setVariable('SOL_TRUE_CHECKED', 'checked');
660  } else {
661  $template->setVariable('SOL_FALSE_CHECKED', 'checked');
662  }
663  }
664  }
665 
666  $template->parseCurrentBlock();
667  }
668 
669  if ($show_question_text == true) {
670  $questiontext = $this->object->getQuestionForHTMLOutput();
671  if ($show_feedback && $this->hasInlineFeedback()) {
672  $questiontext .= $this->buildFocusAnchorHtml();
673  }
674  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
675 
676  $template->setVariable("INSTRUCTIONTEXT", $this->object->getInstructionTextTranslation(
677  $this->lng,
678  $this->object->getOptionLabel()
679  ));
680  }
681 
682  $template->setVariable("OPTION_LABEL_TRUE", $this->object->getTrueOptionLabelTranslation(
683  $this->lng,
684  $this->object->getOptionLabel()
685  ));
686 
687  $template->setVariable("OPTION_LABEL_FALSE", $this->object->getFalseOptionLabelTranslation(
688  $this->lng,
689  $this->object->getOptionLabel()
690  ));
691 
692 
693  $questionoutput = $template->get();
694  $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput($active_id, $pass) : "";
695 
696  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
697 
698  if (strlen($feedback)) {
699  $cssClass = (
700  $this->hasCorrectSolution($active_id, $pass) ?
702  );
703 
704  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
705  $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
706  }
707 
708  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
709 
710  $solutionoutput = $solutiontemplate->get();
711 
712  if (!$show_question_only) {
713  // get page object output
714  $solutionoutput = $this->getILIASPage($solutionoutput);
715  }
716  return $solutionoutput;
717  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
hasCorrectSolution($activeId, $passIndex)
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
$keys
Definition: metadata.php:187
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)
static getHtmlPath($relative_path)
get url of path
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
populateSpecificFeedbackInline($user_solution, $answer_id, $template)
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assKprimChoiceGUI::getSpecificFeedbackOutput (   $userSolution)
Parameters
integer$active_id
integer$pass
Returns
string

Definition at line 324 of file class.assKprimChoiceGUI.php.

325  {
326  return ''; // question type supports inline answer specific feedback
327  }

◆ getTestOutput()

assKprimChoiceGUI::getTestOutput (   $active_id,
  $pass,
  $is_postponed = false,
  $use_post_solutions = false,
  $showInlineFeedback = false 
)
Parameters
integer$active_id
integer | null$pass
bool$is_postponed
bool$use_post_solutions
bool$show_feedback
Returns
string

Definition at line 338 of file class.assKprimChoiceGUI.php.

References $keys, $pass, $type, ilUtil\getImagePath(), getParticipantsAnswerKeySequence(), assQuestionGUI\outQuestionPage(), populateSpecificFeedbackInline(), and ilUtil\prepareFormOutput().

346  {
347  // shuffle output
349 
350  // get the solution of the user for the active pass or from the last pass if allowed
351  $user_solution = array();
352  if ($active_id) {
353  // hey: prevPassSolutions - obsolete due to central check
354  #$solutions = NULL;
355  #include_once "./Modules/Test/classes/class.ilObjTest.php";
356  #if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
357  #{
358  # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
359  #}
360  $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
361  // hey.
362  foreach ($solutions as $idx => $solution_value) {
363  $user_solution[$solution_value["value1"]] = $solution_value["value2"];
364  }
365  }
366 
367  // generate the question output
368  include_once "./Services/UICore/classes/class.ilTemplate.php";
369  $template = new ilTemplate("tpl.il_as_qpl_mc_kprim_output.html", true, true, "Modules/TestQuestionPool");
370 
371  foreach ($keys as $answer_id) {
372  $answer = $this->object->getAnswer($answer_id);
373  if (strlen($answer->getImageFile())) {
374  if ($this->object->getThumbSize()) {
375  $template->setCurrentBlock("preview");
376  $template->setVariable("URL_PREVIEW", $answer->getImageWebPath());
377  $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
378  $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
379  $template->setVariable("ANSWER_IMAGE_URL", $answer->getThumbWebPath());
380  list($width, $height, $type, $attr) = getimagesize($answer->getImageFsPath());
381  $alt = $answer->getImageFile();
382  if (strlen($answer->getAnswertext())) {
383  $alt = $answer->getAnswertext();
384  }
385  $alt = preg_replace("/<[^>]*?>/", "", $alt);
386  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
387  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
388  $template->parseCurrentBlock();
389  } else {
390  $template->setCurrentBlock("answer_image");
391  $template->setVariable("ANSWER_IMAGE_URL", $answer->getImageWebPath());
392  list($width, $height, $type, $attr) = getimagesize($answer->getImageFsPath());
393  $alt = $answer->getImageFile();
394  if (strlen($answer->getAnswertext())) {
395  $alt = $answer->getAnswertext();
396  }
397  $alt = preg_replace("/<[^>]*?>/", "", $alt);
398  $template->setVariable("ATTR", $attr);
399  $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
400  $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
401  $template->parseCurrentBlock();
402  }
403  }
404 
405  if ($showInlineFeedback) {
406  $this->populateSpecificFeedbackInline($user_solution, $answer_id, $template);
407  }
408 
409  $template->setCurrentBlock("answer_row");
410  $template->setVariable("ANSWER_ID", $answer_id);
411  $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), true));
412  $template->setVariable('VALUE_TRUE', 1);
413  $template->setVariable('VALUE_FALSE', 0);
414 
415  if (isset($user_solution[$answer->getPosition()])) {
416  $tplVar = $user_solution[$answer->getPosition()] ? 'CHECKED_ANSWER_TRUE' : 'CHECKED_ANSWER_FALSE';
417  $template->setVariable($tplVar, " checked=\"checked\"");
418  }
419 
420  $template->parseCurrentBlock();
421  }
422  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
423  $template->setVariable("INSTRUCTIONTEXT", $this->object->getInstructionTextTranslation(
424  $this->lng,
425  $this->object->getOptionLabel()
426  ));
427 
428  $template->setVariable("OPTION_LABEL_TRUE", $this->object->getTrueOptionLabelTranslation(
429  $this->lng,
430  $this->object->getOptionLabel()
431  ));
432 
433  $template->setVariable("OPTION_LABEL_FALSE", $this->object->getFalseOptionLabelTranslation(
434  $this->lng,
435  $this->object->getOptionLabel()
436  ));
437 
438  $questionoutput = $template->get();
439  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput, $showInlineFeedback);
440  return $pageoutput;
441  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$type
$keys
Definition: metadata.php:187
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
populateSpecificFeedbackInline($user_solution, $answer_id, $template)
+ Here is the call graph for this function:

◆ handleAnswerTextsSubmit()

assKprimChoiceGUI::handleAnswerTextsSubmit (   $answers)
private

Definition at line 306 of file class.assKprimChoiceGUI.php.

References assKprimChoice\ANSWER_TYPE_MULTI_LINE, and ilUtil\secureString().

Referenced by writeAnswerSpecificPostData().

307  {
308  if ($this->object->getAnswerType() == assKprimChoice::ANSWER_TYPE_MULTI_LINE) {
309  return $answers;
310  }
311 
312  foreach ($answers as $key => $answer) {
313  $answer->setAnswerText(ilUtil::secureString(htmlspecialchars($answer->getAnswerText())));
314  }
315 
316  return $answers;
317  }
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:

◆ hasInlineFeedback()

assKprimChoiceGUI::hasInlineFeedback ( )
Returns
bool

Definition at line 41 of file class.assKprimChoiceGUI.php.

Referenced by getPreview(), and getSolutionOutput().

42  {
43  return $this->object->feedbackOBJ->isSpecificAnswerFeedbackAvailable($this->object->getId());
44  }
+ Here is the caller graph for this function:

◆ populateAnswerSpecificFormPart()

assKprimChoiceGUI::populateAnswerSpecificFormPart ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form
Returns
ilPropertyFormGUI

Implements ilGuiAnswerScoringAdjustable.

Definition at line 272 of file class.assKprimChoiceGUI.php.

References ilPropertyFormGUI\addItem(), and ilFormPropertyGUI\setInfo().

Referenced by buildEditForm().

273  {
274  require_once 'Modules/TestQuestionPool/classes/class.ilKprimChoiceWizardInputGUI.php';
275  $kprimAnswers = new ilKprimChoiceWizardInputGUI($this->lng->txt('answers'), 'kprim_answers');
276  $kprimAnswers->setInfo($this->lng->txt('kprim_answers_info'));
277  $kprimAnswers->setSize(64);
278  $kprimAnswers->setMaxLength(1000);
279  $kprimAnswers->setRequired(true);
280  $kprimAnswers->setAllowMove(true);
281  $kprimAnswers->setQuestionObject($this->object);
282  if (!$this->object->getSelfAssessmentEditingMode()) {
283  $kprimAnswers->setSingleline($this->object->isSingleLineAnswerType($this->object->getAnswerType()));
284  } else {
285  $kprimAnswers->setSingleline(false);
286  }
287  $kprimAnswers->setValues($this->object->getAnswers());
288  $form->addItem($kprimAnswers);
289 
290  return $form;
291  }
addItem($a_item)
Add Item (Property, SectionHeader).
setInfo($a_info)
Set Information Text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateCorrectionsFormProperties()

assKprimChoiceGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Definition at line 896 of file class.assKprimChoiceGUI.php.

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

897  {
898  // points
899  $points = new ilNumberInputGUI($this->lng->txt('points'), 'points');
900  $points->setRequired(true);
901  $points->setSize(3);
902  $points->allowDecimals(true);
903  $points->setMinValue(0);
904  $points->setMinvalueShouldBeGreater(true);
905  $points->setValue($this->object->getPoints());
906  $form->addItem($points);
907 
908  // score partial solution
909  $scorePartialSolution = new ilCheckboxInputGUI($this->lng->txt('score_partsol_enabled'), 'score_partsol_enabled');
910  $scorePartialSolution->setInfo($this->lng->txt('score_partsol_enabled_info'));
911  $scorePartialSolution->setChecked($this->object->isScorePartialSolutionEnabled());
912  $form->addItem($scorePartialSolution);
913 
914  // answers
915  require_once 'Modules/TestQuestionPool/classes/forms/class.ilKprimChoiceCorrectionsInputGUI.php';
916  $kprimAnswers = new ilKprimChoiceCorrectionsInputGUI($this->lng->txt('answers'), 'kprim_answers');
917  $kprimAnswers->setInfo($this->lng->txt('kprim_answers_info'));
918  $kprimAnswers->setSize(64);
919  $kprimAnswers->setMaxLength(1000);
920  $kprimAnswers->setRequired(true);
921  $kprimAnswers->setQuestionObject($this->object);
922  $kprimAnswers->setValues($this->object->getAnswers());
923  $form->addItem($kprimAnswers);
924 
925  return $form;
926  }
This class represents a checkbox property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
setInfo($a_info)
Set Information Text.
This class represents a number property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assKprimChoiceGUI::populateQuestionSpecificFormPart ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form
Returns
ilPropertyFormGUI

Implements ilGuiQuestionScoringAdjustable.

Definition at line 158 of file class.assKprimChoiceGUI.php.

References ilPropertyFormGUI\addItem(), ilCheckboxInputGUI\setChecked(), ilFormPropertyGUI\setInfo(), ilFormPropertyGUI\setRequired(), and ilNumberInputGUI\setSuffix().

Referenced by buildEditForm().

159  {
160  // shuffle answers
161  $shuffleAnswers = new ilCheckboxInputGUI($this->lng->txt("shuffle_answers"), "shuffle_answers_enabled");
162  $shuffleAnswers->setChecked($this->object->isShuffleAnswersEnabled());
163  $form->addItem($shuffleAnswers);
164 
165  if (!$this->object->getSelfAssessmentEditingMode()) {
166  // answer mode (single-/multi-line)
167  $answerType = new ilSelectInputGUI($this->lng->txt('answer_types'), 'answer_type');
168  $answerType->setOptions($this->object->getAnswerTypeSelectOptions($this->lng));
169  $answerType->setValue($this->object->getAnswerType());
170  $form->addItem($answerType);
171  }
172 
173  if (!$this->object->getSelfAssessmentEditingMode() && $this->object->isSingleLineAnswerType($this->object->getAnswerType())) {
174  // thumb size
175  $thumbSize = new ilNumberInputGUI($this->lng->txt('thumb_size'), 'thumb_size');
176  $thumbSize->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
177  $thumbSize->setInfo($this->lng->txt('thumb_size_info'));
178  $thumbSize->setDecimals(false);
179  $thumbSize->setMinValue(20);
180  $thumbSize->setSize(6);
181  if ($this->object->getThumbSize() > 0) {
182  $thumbSize->setValue($this->object->getThumbSize());
183  }
184  $form->addItem($thumbSize);
185  }
186 
187  // option label
188  $optionLabel = new ilRadioGroupInputGUI($this->lng->txt('option_label'), 'option_label');
189  $optionLabel->setInfo($this->lng->txt('option_label_info'));
190  $optionLabel->setRequired(true);
191  $optionLabel->setValue($this->object->getOptionLabel());
192  foreach ($this->object->getValidOptionLabelsTranslated($this->lng) as $labelValue => $labelText) {
193  $option = new ilRadioOption($labelText, $labelValue);
194  $optionLabel->addOption($option);
195 
196  if ($this->object->isCustomOptionLabel($labelValue)) {
197  $customLabelTrue = new ilTextInputGUI(
198  $this->lng->txt('option_label_custom_true'),
199  'option_label_custom_true'
200  );
201  $customLabelTrue->setValue($this->object->getCustomTrueOptionLabel());
202  $option->addSubItem($customLabelTrue);
203 
204  $customLabelFalse = new ilTextInputGUI(
205  $this->lng->txt('option_label_custom_false'),
206  'option_label_custom_false'
207  );
208  $customLabelFalse->setValue($this->object->getCustomFalseOptionLabel());
209  $option->addSubItem($customLabelFalse);
210  }
211  }
212  $form->addItem($optionLabel);
213 
214  // points
215  $points = new ilNumberInputGUI($this->lng->txt('points'), 'points');
216  $points->setRequired(true);
217  $points->setSize(3);
218  $points->allowDecimals(true);
219  $points->setMinValue(0);
220  $points->setMinvalueShouldBeGreater(true);
221  $points->setValue($this->object->getPoints());
222  $form->addItem($points);
223 
224  // score partial solution
225  $scorePartialSolution = new ilCheckboxInputGUI($this->lng->txt('score_partsol_enabled'), 'score_partsol_enabled');
226  $scorePartialSolution->setInfo($this->lng->txt('score_partsol_enabled_info'));
227  $scorePartialSolution->setChecked($this->object->isScorePartialSolutionEnabled());
228  $form->addItem($scorePartialSolution);
229 
230  return $form;
231  }
This class represents an option in a radio group.
This class represents a checkbox property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
setInfo($a_info)
Set Information Text.
setChecked($a_checked)
Set Checked.
This class represents a property in a property form.
setSuffix($a_value)
Set suffix.
This class represents a number 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:

◆ populateSpecificFeedbackInline()

assKprimChoiceGUI::populateSpecificFeedbackInline (   $user_solution,
  $answer_id,
  $template 
)
private

Definition at line 730 of file class.assKprimChoiceGUI.php.

References ilAssConfigurableMultiOptionQuestionFeedback\FEEDBACK_SETTING_ALL, ilAssConfigurableMultiOptionQuestionFeedback\FEEDBACK_SETTING_CHECKED, and ilAssConfigurableMultiOptionQuestionFeedback\FEEDBACK_SETTING_CORRECT.

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

731  {
732  require_once 'Modules/TestQuestionPool/classes/feedback/class.ilAssConfigurableMultiOptionQuestionFeedback.php';
733 
734  if ($this->object->getSpecificFeedbackSetting() == ilAssConfigurableMultiOptionQuestionFeedback::FEEDBACK_SETTING_CHECKED) {
735  if ($user_solution[$answer_id]) {
736  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
737  if (strlen($fb)) {
738  $template->setCurrentBlock("feedback");
739  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
740  $template->parseCurrentBlock();
741  }
742  }
743  }
744 
745  if ($this->object->getSpecificFeedbackSetting() == ilAssConfigurableMultiOptionQuestionFeedback::FEEDBACK_SETTING_ALL) {
746  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
747  if (strlen($fb)) {
748  $template->setCurrentBlock("feedback");
749  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
750  $template->parseCurrentBlock();
751  }
752  }
753 
754  if ($this->object->getSpecificFeedbackSetting() == ilAssConfigurableMultiOptionQuestionFeedback::FEEDBACK_SETTING_CORRECT) {
755  $answer = $this->object->getAnswer($answer_id);
756 
757  if ($answer->getCorrectness()) {
758  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, $answer_id);
759  if (strlen($fb)) {
760  $template->setCurrentBlock("feedback");
761  $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
762  $template->parseCurrentBlock();
763  }
764  }
765  }
766  }
+ Here is the caller graph for this function:

◆ removeImage()

assKprimChoiceGUI::removeImage ( )

Definition at line 72 of file class.assKprimChoiceGUI.php.

References $_POST, and editQuestion().

73  {
74  $position = key($_POST['cmd']['removeImage']);
75  $this->object->removeAnswerImage($position);
76 
77  $this->object->saveToDb();
78  $this->editQuestion();
79  }
editQuestion(ilPropertyFormGUI $form=null)
$_POST["username"]
+ Here is the call graph for this function:

◆ renderAggregateView()

assKprimChoiceGUI::renderAggregateView (   $aggregate)

Definition at line 813 of file class.assKprimChoiceGUI.php.

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

814  {
815  $trueOptionLabel = $this->object->getTrueOptionLabelTranslation($this->lng, $this->object->getOptionLabel());
816  $falseOptionLabel = $this->object->getFalseOptionLabelTranslation($this->lng, $this->object->getOptionLabel());
817 
818  $tpl = new ilTemplate('tpl.il_as_aggregated_kprim_answers_table.html', true, true, "Modules/TestQuestionPool");
819 
820  foreach ($aggregate as $lineData) {
821  $tpl->setCurrentBlock('aggregaterow');
822  $tpl->setVariable('OPTION', $lineData['answertext']);
823  $tpl->setVariable('COUNT_TRUE', $lineData['count_true']);
824  $tpl->setVariable('COUNT_FALSE', $lineData['count_false']);
825  $tpl->parseCurrentBlock();
826  }
827 
828  $tpl->setVariable('OPTION_HEAD', $this->lng->txt('answers'));
829  $tpl->setVariable('COUNT_TRUE_HEAD', $trueOptionLabel);
830  $tpl->setVariable('COUNT_FALSE_HEAD', $falseOptionLabel);
831 
832  return $tpl;
833  }
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

assKprimChoiceGUI::saveCorrectionsFormProperties ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form

Definition at line 931 of file class.assKprimChoiceGUI.php.

References ilPropertyFormGUI\getInput(), and ilPropertyFormGUI\getItemByPostVar().

932  {
933  $this->object->setPoints(
934  (float) $form->getInput('points')
935  );
936 
937  $this->object->setScorePartialSolutionEnabled(
938  (bool) $form->getInput('score_partsol_enabled')
939  );
940 
941  $this->object->setAnswers(
942  $form->getItemByPostVar('kprim_answers')->getValues()
943  );
944  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
+ Here is the call graph for this function:

◆ supportsIntermediateSolutionOutput()

assKprimChoiceGUI::supportsIntermediateSolutionOutput ( )

Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution()

Returns
bool

Definition at line 542 of file class.assKprimChoiceGUI.php.

543  {
544  return true;
545  }

◆ upkprim_answers()

assKprimChoiceGUI::upkprim_answers ( )

Definition at line 91 of file class.assKprimChoiceGUI.php.

References $_POST, and editQuestion().

92  {
93  if (isset($_POST['cmd'][__FUNCTION__]) && count($_POST['cmd'][__FUNCTION__])) {
94  $this->object->moveAnswerUp(key($_POST['cmd'][__FUNCTION__]));
95  $this->object->saveToDb();
96  }
97 
98  $this->editQuestion();
99  }
editQuestion(ilPropertyFormGUI $form=null)
$_POST["username"]
+ Here is the call graph for this function:

◆ uploadImage()

assKprimChoiceGUI::uploadImage ( )
protected

Definition at line 62 of file class.assKprimChoiceGUI.php.

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

63  {
64  $result = $this->writePostData(true);
65 
66  if ($result == 0) {
67  $this->object->saveToDb();
68  $this->editQuestion();
69  }
70  }
$result
writePostData($upload=false)
{}
editQuestion(ilPropertyFormGUI $form=null)
+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assKprimChoiceGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form

Implements ilGuiAnswerScoringAdjustable.

Definition at line 296 of file class.assKprimChoiceGUI.php.

References ilPropertyFormGUI\getItemByPostVar(), and handleAnswerTextsSubmit().

Referenced by writePostData().

297  {
298  $answers = $form->getItemByPostVar('kprim_answers')->getValues();
299  $answers = $this->handleAnswerTextsSubmit($answers);
300  $files = $form->getItemByPostVar('kprim_answers')->getFiles();
301 
302  $this->object->handleFileUploads($answers, $files);
303  $this->object->setAnswers($answers);
304  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

assKprimChoiceGUI::writePostData (   $upload = false)
protected

{}

Definition at line 104 of file class.assKprimChoiceGUI.php.

References $_POST, $errors, buildEditForm(), editQuestion(), assQuestionGUI\saveTaxonomyAssignments(), ilUtil\sendFailure(), writeAnswerSpecificPostData(), assQuestionGUI\writeQuestionGenericPostData(), and writeQuestionSpecificPostData().

Referenced by uploadImage().

105  {
106  $form = $this->buildEditForm();
107  $form->setValuesByPost();
108  $errors = !$form->checkInput();
109  $form->setValuesByPost();
110 
111  if ($upload) {
112  $answersInput = $form->getItemByPostVar('kprim_answers');
113  $answersInput->setIgnoreMissingUploadsEnabled(true);
114 
115  if (!$answersInput->checkUploads($_POST[$answersInput->getPostVar()])) {
116  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"));
117  $this->editQuestion($form);
118  return 1;
119  }
120 
121  $answersInput->collectValidFiles();
122  } elseif ($errors) {
123  $this->editQuestion($form);
124  return 1;
125  }
126 
128  $this->writeQuestionSpecificPostData($form);
129  $this->writeAnswerSpecificPostData($form);
130  $this->saveTaxonomyAssignments();
131 
132  return 0;
133  }
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
$errors
Definition: imgupload.php:49
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
editQuestion(ilPropertyFormGUI $form=null)
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeQuestionSpecificPostData()

assKprimChoiceGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form

Implements ilGuiQuestionScoringAdjustable.

Definition at line 236 of file class.assKprimChoiceGUI.php.

References assKprimChoice\ANSWER_TYPE_MULTI_LINE, and ilPropertyFormGUI\getItemByPostVar().

Referenced by writePostData().

237  {
238  $oldAnswerType = $this->object->getAnswerType();
239 
240  $this->object->setShuffleAnswersEnabled($form->getItemByPostVar('shuffle_answers_enabled')->getChecked());
241 
242  if (!$this->object->getSelfAssessmentEditingMode()) {
243  $this->object->setAnswerType($form->getItemByPostVar('answer_type')->getValue());
244  } else {
245  $this->object->setAnswerType(assKprimChoice::ANSWER_TYPE_MULTI_LINE);
246  }
247 
248  if (!$this->object->getSelfAssessmentEditingMode() && $this->object->isSingleLineAnswerType($oldAnswerType)) {
249  $this->object->setThumbSize($form->getItemByPostVar('thumb_size')->getValue());
250  }
251 
252  $this->object->setOptionLabel($form->getItemByPostVar('option_label')->getValue());
253 
254  if ($this->object->isCustomOptionLabel($this->object->getOptionLabel())) {
255  $this->object->setCustomTrueOptionLabel(strip_tags(
256  $form->getItemByPostVar('option_label_custom_true')->getValue()
257  ));
258  $this->object->setCustomFalseOptionLabel(strip_tags(
259  $form->getItemByPostVar('option_label_custom_false')->getValue()
260  ));
261  }
262 
263  $this->object->setPoints($form->getItemByPostVar('points')->getValue());
264 
265  $this->object->setScorePartialSolutionEnabled($form->getItemByPostVar('score_partsol_enabled')->getChecked());
266  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $object

assKprimChoiceGUI::$object

Definition at line 21 of file class.assKprimChoiceGUI.php.


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