ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
assClozeTestGUI Class Reference

Cloze test question GUI representation. More...

+ Inheritance diagram for assClozeTestGUI:
+ Collaboration diagram for assClozeTestGUI:

Public Member Functions

 __construct (int $id=-1)
 assClozeTestGUI constructor More...
 
 getCommand ($cmd)
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 editQuestion ($checkonly=false)
 Creates an output of the edit form for the question. More...
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 
 createGaps ()
 Create gaps from cloze text. More...
 
 removegap ()
 Remove a gap answer. More...
 
 addgap ()
 Add a gap answer. More...
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 Creates a preview output of the question. More...
 
 getSolutionOutput ( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
 Get the question solution output. More...
 
 getGenericFeedbackOutput (int $active_id, $pass)
 
 getTestOutput ( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
 
 getSpecificFeedbackOutput (array $userSolution)
 
 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...
 
 applyIndizesToGapText ($question_text)
 
 removeIndizesFromGapText ($question_text)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from assQuestionGUI
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getNotesHTML ()
 
 executeCommand ()
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext (string $presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled (bool $previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose (string $renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext (string $editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI (?ilTestQuestionNavigationGUI $navigationGUI)
 
 setTaxonomyIds (array $taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder (\ilQuestionHeaderBlockBuilder $questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd (string $questionActionCmd)
 
 getQuestionActionCmd ()
 
 assessment ()
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 
 getILIASPage (string $html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
 cancel ()
 
 originalSyncForm (string $return_to="", string $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 
 save ()
 
 saveReturn ()
 
 apply ()
 
 getContextPath ($cont_obj, int $a_endnode_id, int $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber (int $nr)
 
 getSequenceNumber ()
 
 setQuestionCount (int $a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage (string $errormessage)
 
 addErrorMessage (string $errormessage)
 
 outAdditionalOutput ()
 Why are you here? Some magic for plugins? More...
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addNewIdListener ($a_object, string $a_method, string $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners (int $a_new_id)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 suggestedsolution ()
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $classname)
 
 getEditQuestionTabCommands ()
 
 getSolutionOutput ( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
 
 isAutosaveable ()
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 outQuestionForTest (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 getAggregatedAnswersView (array $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...
 

Data Fields

const OLD_CLOZE_TEST_UI = false
 
const JS_INSERT_GAP_CODE_AT_CARET
 
 JS
 
- 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 CORRECTNESS_NOT_OK = 0
 
const CORRECTNESS_MOSTLY_OK = 1
 
const CORRECTNESS_OK = 2
 
const ALLOWED_PLAIN_TEXT_TAGS = "<em>, <strong>"
 sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI. More...
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $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

 writePostData (bool $always=false)
 {} More...
 
 populateJSON ()
 
 populateGapFormPart ($form, $gapCounter)
 Populates a gap form-part. More...
 
 populateGapSizeFormPart ($form, $gap, $gapCounter)
 
 populateSelectGapFormPart ($form, $gap, $gapCounter)
 Populates the form-part for a select gap. More...
 
 populateTextGapFormPart ($form, $gap, $gapCounter)
 Populates the form-part for a text gap. More...
 
 populateNumericGapFormPart ($form, $gap, $gapCounter)
 Populates the form-part for a numeric gap. More...
 
 getBestSolutionText ($gap, $gap_index, $gap_combinations)
 
 hasAddAnswerAction ($relevantAnswers, $questionIndex)
 
 getAnswerTextLabel ($gapIndex, $answer)
 
 completeAddAnswerAction ($answers, $gap_index)
 
 isUsedInCombinations ($gapIndex)
 
 getGapCombinations ()
 
 populateGapCombinationCorrectionFormProperty (ilPropertyFormGUI $form, $gapCombi, $combiIndex)
 
 populateGapCorrectionFormProperties ($form, $gap, $gapIndex, $hidePoints)
 
 populateTextOrSelectGapCorrectionFormProperty ($form, $gap, $gapIndex, $hidePoints)
 
 populateNumericGapCorrectionFormProperty ($form, $item, $gapIndex, $hidePoints)
 
 saveGapCorrectionFormProperty (ilPropertyFormGUI $form, assClozeGap $gap, $gapIndex)
 
 saveTextOrSelectGapCorrectionFormProperty (ilPropertyFormGUI $form, assClozeGap $gap, $gapIndex)
 
 saveNumericGapCorrectionFormProperty (ilPropertyFormGUI $form, assAnswerCloze $item, $gapIndex)
 
 saveGapCombinationCorrectionFormProperties (ilPropertyFormGUI $form)
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 writePostData (bool $always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm (ilPropertyFormGUI $form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (string $feedback_correct, string $feedback_incorrect, int $active_id, ?int $pass)
 
 setDefaultTabs (ilTabsGUI $ilTabs)
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 cleanupAnswerText (array $answer_text, bool $is_rte)
 sk - 12.05.2023: This is one more of those that we need, but don't want. More...
 
 addSaveOnEnterOnLoadCode ()
 

Private Member Functions

 populateSolutiontextToGapTpl ($gaptemplate, $gap, $solutiontext)
 

Private Attributes

 $gapIndex
 A temporary variable to store gap indexes of ilCtrl commands in the getCommand method. More...
 
RandomGroup $randomGroup
 
Container $dic
 
Factory $refinery
 
ArrayBasedRequestWrapper $post
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI (string $question_type='', int $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants (string $guiClassName, string $cmdConstantNameBegin='CMD_')
 
static prepareTextareaOutput ($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output where latex code may be in it If the text is HTML-free, CHR(13) will be converted to a line break. More...
 
- Protected Attributes inherited from assQuestionGUI
const SUGGESTED_SOLUTION_COMMANDS
 
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
ILIAS Notes GUIService $notes_gui
 
ilCtrl $ctrl
 
ilPropertyFormGUI $editForm
 
ILIAS TestQuestionPool InternalRequestService $request
 

Detailed Description

Cloze test question GUI representation.

The assClozeTestGUI class encapsulates the GUI representation for cloze test 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$

assClozeTestGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

assClozeTestGUI::__construct ( int  $id = -1)

assClozeTestGUI constructor

Parameters
integer$idThe database id of a image map question object

Definition at line 101 of file class.assClozeTestGUI.php.

References $DIC, $id, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\refinery().

102  {
104  global $DIC;
105  $this->dic = $DIC;
106  $this->refinery = $this->dic->refinery();
107  $this->post = $this->dic->http()->wrapper()->post();
108 
109  $this->object = new assClozeTest();
110  if ($id >= 0) {
111  $this->object->loadFromDb($id);
112  }
113 
114  $this->randomGroup = $this->refinery->random();
115  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

Member Function Documentation

◆ addBasicQuestionFormProperties()

assClozeTestGUI::addBasicQuestionFormProperties ( ilPropertyFormGUI  $form)

Definition at line 347 of file class.assClozeTestGUI.php.

References ilObjAdvancedEditing\_getUsedHTMLTags(), ilPropertyFormGUI\addItem(), assQuestion\ADDITIONAL_CONTENT_EDITING_MODE_RTE, assQuestionGUI\addNumberOfTriesToFormIfNecessary(), ilAssSelfAssessmentQuestionFormatter\getSelfAssessmentTags(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilLegacyFormElementsUtil\prepareFormOutput(), and ilTextAreaInputGUI\setValue().

Referenced by editQuestion().

347  : void
348  {
349  // title
350  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
351  $title->setMaxLength(100);
352  $title->setValue($this->object->getTitle());
353  $title->setRequired(true);
354  $form->addItem($title);
355 
356  if (!$this->object->getSelfAssessmentEditingMode()) {
357  // author
358  $author = new ilTextInputGUI($this->lng->txt("author"), "author");
359  $author->setValue($this->object->getAuthor());
360  $author->setRequired(true);
361  $form->addItem($author);
362 
363  // description
364  $description = new ilTextInputGUI($this->lng->txt("description"), "comment");
365  $description->setValue($this->object->getComment());
366  $description->setRequired(false);
367  $form->addItem($description);
368  } else {
369  // author as hidden field
370  $hi = new ilHiddenInputGUI("author");
371  $author = ilLegacyFormElementsUtil::prepareFormOutput($this->object->getAuthor());
372  if (trim($author) == "") {
373  $author = "-";
374  }
375  $hi->setValue($author);
376  $form->addItem($hi);
377  }
378 
379  // lifecycle
380  $lifecycle = new ilSelectInputGUI($this->lng->txt('qst_lifecycle'), 'lifecycle');
381  $lifecycle->setOptions($this->object->getLifecycle()->getSelectOptions($this->lng));
382  $lifecycle->setValue($this->object->getLifecycle()->getIdentifier());
383  $form->addItem($lifecycle);
384 
385  // questiontext
386  $question = new ilTextAreaInputGUI($this->lng->txt("question"), "question");
387  $question->setValue($this->object->getQuestion());
388  $question->setRequired(true);
389  $question->setRows(10);
390  $question->setCols(80);
391  if (!$this->object->getSelfAssessmentEditingMode()) {
392  if ($this->object->getAdditionalContentEditingMode() == assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_RTE) {
393  $question->setUseRte(true);
394  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
395  $question->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
396  $question->addPlugin("latex");
397  $question->addButton("latex");
398  $question->addButton("pastelatex");
399  $question->setRTESupport($this->object->getId(), "qpl", "assessment");
400  }
401  } else {
402  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
404  $question->setUseTagsForRteOnly(false);
405  }
406  $form->addItem($question);
407  $this->addNumberOfTriesToFormIfNecessary($form);
408  }
static getSelfAssessmentTags()
Get tags allowed in question tags in self assessment mode.
static prepareFormOutput($a_str, bool $a_strip=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
addNumberOfTriesToFormIfNecessary(ilPropertyFormGUI $form)
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addgap()

assClozeTestGUI::addgap ( )

Add a gap answer.

Definition at line 816 of file class.assClozeTestGUI.php.

References editQuestion(), and writePostData().

816  : void
817  {
818  $this->writePostData(true);
819  $this->object->addGapAnswer($this->gapIndex, key($_POST['cmd']['addgap_' . $this->gapIndex]) + 1, "");
820  $this->editQuestion();
821  }
writePostData(bool $always=false)
{}
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
+ Here is the call graph for this function:

◆ applyIndizesToGapText()

assClozeTestGUI::applyIndizesToGapText (   $question_text)

Definition at line 1409 of file class.assClozeTestGUI.php.

References $i, and $parts.

Referenced by populateQuestionSpecificFormPart().

1409  : string
1410  {
1411  $parts = explode('[gap', $question_text);
1412  $i = 0;
1413  $question_text = '';
1414  foreach ($parts as $part) {
1415  if ($i == 0) {
1416  $question_text .= $part;
1417  } else {
1418  $question_text .= '[gap ' . $i . $part;
1419  }
1420  $i++;
1421  }
1422  return $question_text;
1423  }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
$i
Definition: metadata.php:41
+ Here is the caller graph for this function:

◆ completeAddAnswerAction()

assClozeTestGUI::completeAddAnswerAction (   $answers,
  $gap_index 
)
protected

Definition at line 1516 of file class.assClozeTestGUI.php.

References ILIAS\LTI\ToolProvider\$key, and CLOZE_TEXT.

Referenced by getAnswersFrequency().

1516  : array
1517  {
1518  $gap = $this->object->getGap($gap_index);
1519 
1520  if ($gap->type != CLOZE_TEXT ||
1521  $this->isUsedInCombinations($gap_index)) {
1522  return $answers;
1523  }
1524 
1525  foreach ($answers as $key => $ans) {
1526  $found = false;
1527 
1528  foreach ($gap->getItems($this->randomGroup->dontShuffle()) as $item) {
1529  if ($ans['answer'] !== $item->getAnswerText()) {
1530  continue;
1531  }
1532 
1533  $found = true;
1534  break;
1535  }
1536 
1537  if (!$found) {
1538  $answers[$key]['addable'] = true;
1539  }
1540  }
1541 
1542  return $answers;
1543  }
const CLOZE_TEXT
Cloze question constants.
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the caller graph for this function:

◆ createGaps()

assClozeTestGUI::createGaps ( )

Create gaps from cloze text.

Definition at line 796 of file class.assClozeTestGUI.php.

References editQuestion(), and writePostData().

796  : void
797  {
798  $this->writePostData(true);
799  $this->object->saveToDb();
800  $this->editQuestion();
801  }
writePostData(bool $always=false)
{}
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
+ Here is the call graph for this function:

◆ editQuestion()

assClozeTestGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

public

Definition at line 307 of file class.assClozeTestGUI.php.

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

Referenced by addgap(), createGaps(), removegap(), and writePostData().

307  : bool
308  {
309  $save = $this->isSaveCommand();
310  $this->getQuestionTemplate();
311 
312  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
313  $form = new ilPropertyFormGUI();
314  $this->editForm = $form;
315 
316  $form->setFormAction($this->ctrl->getFormAction($this));
317  $form->setTitle($this->outQuestionType());
318  $form->setMultipart(false);
319  $form->setTableWidth("100%");
320  $form->setId("assclozetest");
321 
322  $this->addBasicQuestionFormProperties($form);
323  $this->populateQuestionSpecificFormPart($form);
324  $this->populateAnswerSpecificFormPart($form);
325  $this->populateTaxonomyFormSection($form);
326 
327  $this->addQuestionFormCommandButtons($form);
328 
329  $errors = false;
330 
331  if ($save) {
332  $form->setValuesByPost();
333  $errors = !$form->checkInput();
334  $form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we
335  // need this if we don't want to have duplication of backslashes
336  if ($errors) {
337  $checkonly = false;
338  }
339  }
340 
341  if (!$checkonly) {
342  $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
343  }
344  return $errors;
345  }
$errors
Definition: imgupload.php:65
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
Adds the question specific forms parts to a question property form gui.
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
Adds the answer specific form parts to a question property form gui.
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAfterParticipationSuppressionAnswerPostVars()

assClozeTestGUI::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 1308 of file class.assClozeTestGUI.php.

1308  : array
1309  {
1310  return array();
1311  }

◆ getAfterParticipationSuppressionQuestionPostVars()

assClozeTestGUI::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 1322 of file class.assClozeTestGUI.php.

References $i, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, ilGuiQuestionScoringAdjustable\getAggregatedAnswersView(), and ILIAS\Repository\object().

1322  : array
1323  {
1324  return array();
1325  }
+ Here is the call graph for this function:

◆ getAnswerFrequencyTableGUI()

assClozeTestGUI::getAnswerFrequencyTableGUI (   $parentGui,
  $parentCmd,
  $relevantAnswers,
  $questionIndex 
)

Definition at line 1472 of file class.assClozeTestGUI.php.

References hasAddAnswerAction(), and ILIAS\Repository\lng().

1473  {
1474  $table = parent::getAnswerFrequencyTableGUI(
1475  $parentGui,
1476  $parentCmd,
1477  $relevantAnswers,
1478  $questionIndex
1479  );
1480 
1481  $table->setTitle(
1482  sprintf(
1483  $this->lng->txt('tst_corrections_answers_tbl_subindex'),
1484  $this->lng->txt('gap') . ' ' . ($questionIndex + 1)
1485  )
1486  );
1487 
1488  if ($this->hasAddAnswerAction($relevantAnswers, $questionIndex)) {
1489  $table->addColumn('', '', '200');
1490  }
1491 
1492  return $table;
1493  }
hasAddAnswerAction($relevantAnswers, $questionIndex)
+ Here is the call graph for this function:

◆ getAnswersFrequency()

assClozeTestGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Definition at line 1545 of file class.assClozeTestGUI.php.

References completeAddAnswerAction(), and getAnswerTextLabel().

Referenced by hasAddAnswerAction().

1545  : array
1546  {
1547  $answers = array();
1548 
1549  foreach ($relevantAnswers as $row) {
1550  if ($row['value1'] != $questionIndex) {
1551  continue;
1552  }
1553 
1554  if (!isset($answers[$row['value2']])) {
1555  $label = $this->getAnswerTextLabel($row['value1'], $row['value2']);
1556 
1557  $answers[$row['value2']] = array(
1558  'answer' => $label, 'frequency' => 0
1559  );
1560  }
1561 
1562  $answers[$row['value2']]['frequency']++;
1563  }
1564 
1565  $answers = $this->completeAddAnswerAction($answers, $questionIndex);
1566 
1567  return $answers;
1568  }
completeAddAnswerAction($answers, $gap_index)
getAnswerTextLabel($gapIndex, $answer)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAnswerTextLabel()

assClozeTestGUI::getAnswerTextLabel (   $gapIndex,
  $answer 
)
protected

Definition at line 1500 of file class.assClozeTestGUI.php.

References $gapIndex, CLOZE_NUMERIC, CLOZE_SELECT, and CLOZE_TEXT.

Referenced by getAnswersFrequency().

1501  {
1502  $gap = $this->object->getGap($gapIndex);
1503 
1504  switch ($gap->type) {
1505  case CLOZE_NUMERIC:
1506  case CLOZE_TEXT:
1507  return $answer;
1508 
1509  case CLOZE_SELECT:
1510  default:
1511  $items = $gap->getItems($this->randomGroup->dontShuffle());
1512  return $items[$answer]->getAnswertext();
1513  }
1514  }
const CLOZE_TEXT
Cloze question constants.
const CLOZE_SELECT
const CLOZE_NUMERIC
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
+ Here is the caller graph for this function:

◆ getBestSolutionText()

assClozeTestGUI::getBestSolutionText (   $gap,
  $gap_index,
  $gap_combinations 
)
protected
Parameters
assClozeGap$gap
$gap_index
$gap_combinations
Returns
string

Definition at line 1132 of file class.assClozeTestGUI.php.

References ilLegacyFormElementsUtil\prepareFormOutput().

Referenced by getSolutionOutput().

1132  : string
1133  {
1134  $combination = null;
1135  foreach ((array) $gap_combinations as $combiGapSolRow) {
1136  if ($combiGapSolRow['gap_fi'] == $gap_index && $combiGapSolRow['best_solution']) {
1137  $combination = $combiGapSolRow;
1138  break;
1139  }
1140  }
1141  $best_solution_text = ilLegacyFormElementsUtil::prepareFormOutput(
1142  $gap->getBestSolutionOutput(
1143  $this->object->getShuffler(),
1144  $combination
1145  )
1146  );
1147  return $best_solution_text;
1148  }
static prepareFormOutput($a_str, bool $a_strip=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCommand()

assClozeTestGUI::getCommand (   $cmd)

Definition at line 117 of file class.assClozeTestGUI.php.

118  {
119  if (preg_match("/^(removegap|addgap)_(\d+)$/", $cmd, $matches)) {
120  $cmd = $matches[1];
121  $this->gapIndex = $matches[2];
122  }
123  return $cmd;
124  }

◆ getGapCombinations()

assClozeTestGUI::getGapCombinations ( )
protected

Definition at line 1583 of file class.assClozeTestGUI.php.

References $c, and ILIAS\Repository\object().

Referenced by populateCorrectionsFormProperties(), and saveGapCombinationCorrectionFormProperties().

1583  : array
1584  {
1585  $combinations = array();
1586 
1587  foreach ($this->object->getGapCombinations() as $c) {
1588  if (!isset($combinations[$c['cid']])) {
1589  $combinations[$c['cid']] = array();
1590  }
1591 
1592  if (!isset($combinations[$c['cid']][$c['row_id']])) {
1593  $combinations[$c['cid']][$c['row_id']] = array(
1594  'gaps' => array(), 'points' => $c['points'],
1595  );
1596  }
1597 
1598  if (!isset($combinations[$c['cid']][$c['row_id']]['gaps'][$c['gap_fi']])) {
1599  $combinations[$c['cid']][$c['row_id']]['gaps'][$c['gap_fi']] = array();
1600  }
1601 
1602  $combinations[$c['cid']][$c['row_id']]['gaps'][$c['gap_fi']] = $c['answer'];
1603  }
1604 
1605  return $combinations;
1606  }
$c
Definition: cli.php:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGenericFeedbackOutput()

assClozeTestGUI::getGenericFeedbackOutput ( int  $active_id,
  $pass 
)

Definition at line 1150 of file class.assClozeTestGUI.php.

References assQuestionGUI\genericFeedbackOutputBuilder(), ilObjTest\getManualFeedback(), and ILIAS\Repository\object().

Referenced by getSolutionOutput().

1150  : string
1151  {
1152  include_once "./Modules/Test/classes/class.ilObjTest.php";
1153  $manual_feedback = ilObjTest::getManualFeedback($active_id, $this->object->getId(), $pass);
1154  if (strlen($manual_feedback)) {
1155  return $manual_feedback;
1156  }
1157  $correct_feedback = $this->object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(), true);
1158  $incorrect_feedback = $this->object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(), false);
1159 
1160  $output = '';
1161  if ($correct_feedback . $incorrect_feedback !== '') {
1162  $output = $this->genericFeedbackOutputBuilder($correct_feedback, $incorrect_feedback, $active_id, $pass);
1163  }
1164  //$test = new ilObjTest($this->object->active_id);
1165  return $this->object->prepareTextareaOutput($output, true);
1166  }
genericFeedbackOutputBuilder(string $feedback_correct, string $feedback_incorrect, int $active_id, ?int $pass)
static getManualFeedback($active_id, $question_id, $pass)
Retrieves the feedback comment for a question in a test if it is finalized.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPreview()

assClozeTestGUI::getPreview (   $show_question_only = false,
  $showInlineFeedback = false 
)

Creates a preview output of the question.

Parameters
bool$show_question_only
Returns
string HTML code which contains the preview output of the question public

Definition at line 831 of file class.assClozeTestGUI.php.

References CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, assQuestionGUI\getILIASPage(), assQuestionGUI\getPreviewSession(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareFormOutput().

831  : string
832  {
833  $user_solution = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : array();
834 
835  // generate the question output
836  include_once "./Services/UICore/classes/class.ilTemplate.php";
837  $template = new ilTemplate("tpl.il_as_qpl_cloze_question_output.html", true, true, "Modules/TestQuestionPool");
838  $output = $this->object->getClozeTextForHTMLOutput();
839  foreach ($this->object->getGaps() as $gap_index => $gap) {
840  switch ($gap->getType()) {
841  case CLOZE_TEXT:
842  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_text.html", true, true, "Modules/TestQuestionPool");
843 
844  $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->object->getFixedTextLength();
845  if ($gap_size > 0) {
846  $gaptemplate->setCurrentBlock('size_and_maxlength');
847  $gaptemplate->setVariable("TEXT_GAP_SIZE", $gap_size);
848  $gaptemplate->parseCurrentBlock();
849  }
850  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
851  foreach ($user_solution as $val1 => $val2) {
852  if (strcmp($val1, $gap_index) == 0) {
853  $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput(
854  $val2
855  ) . "\"");
856  }
857  }
858  // fau: fixGapReplace - use replace function
859  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
860  // fau.
861  break;
862  case CLOZE_SELECT:
863  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_select.html", true, true, "Modules/TestQuestionPool");
864  foreach ($gap->getItems($this->object->getShuffler(), $gap_index) as $item) {
865  $gaptemplate->setCurrentBlock("select_gap_option");
866  $gaptemplate->setVariable("SELECT_GAP_VALUE", $item->getOrder());
867  $gaptemplate->setVariable(
868  "SELECT_GAP_TEXT",
869  ilLegacyFormElementsUtil::prepareFormOutput($item->getAnswerText())
870  );
871  foreach ($user_solution as $val1 => $val2) {
872  if (strcmp($val1, $gap_index) == 0) {
873  if (strcmp($val2, $item->getOrder()) == 0) {
874  $gaptemplate->setVariable("SELECT_GAP_SELECTED", " selected=\"selected\"");
875  }
876  }
877  }
878  $gaptemplate->parseCurrentBlock();
879  }
880  $gaptemplate->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
881  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);// fau: fixGapReplace - use replace function
882  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
883  // fau.
884  break;
885  case CLOZE_NUMERIC:
886  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_numeric.html", true, true, "Modules/TestQuestionPool");
887  $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->object->getFixedTextLength();
888  if ($gap_size > 0) {
889  $gaptemplate->setCurrentBlock('size_and_maxlength');
890  $gaptemplate->setVariable("TEXT_GAP_SIZE", $gap_size);
891  $gaptemplate->parseCurrentBlock();
892  }
893  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
894  foreach ($user_solution as $val1 => $val2) {
895  if (strcmp($val1, $gap_index) == 0) {
896  $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput(
897  $val2
898  ) . "\"");
899  }
900  }
901  // fau: fixGapReplace - use replace function
902  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
903  // fau.
904  break;
905  }
906  }
907  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
908  $template->setVariable("CLOZETEXT", $this->object->prepareTextareaOutput($output, true));
909  $questionoutput = $template->get();
910  if (!$show_question_only) {
911  // get page object output
912  $questionoutput = $this->getILIASPage($questionoutput);
913  }
914  return $questionoutput;
915  }
const CLOZE_TEXT
Cloze question constants.
static prepareFormOutput($a_str, bool $a_strip=false)
const CLOZE_SELECT
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
const CLOZE_NUMERIC
+ Here is the call graph for this function:

◆ getSolutionOutput()

assClozeTestGUI::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 930 of file class.assClozeTestGUI.php.

References Vendor\Package\$a, $check, ILIAS\LTI\ToolProvider\$details, ILIAS\LTI\ToolProvider\$key, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, assQuestionGUI\generateCorrectnessIconsForCorrectness(), getBestSolutionText(), getGenericFeedbackOutput(), assQuestionGUI\getILIASPage(), getSpecificFeedbackOutput(), assQuestionGUI\hasCorrectSolution(), assQuestionGUI\isTestPresentationContext(), ILIAS\Repository\object(), populateSolutiontextToGapTpl(), and ilLegacyFormElementsUtil\prepareFormOutput().

940  : string {
941  // get the solution of the user for the active pass or from the last pass if allowed
942  $user_solution = array();
943  if (($active_id > 0) && (!$show_correct_solution)) {
944  // get the solutions of a user
945  $user_solution = $this->object->getSolutionValues($active_id, $pass);
946  if (!is_array($user_solution)) {
947  $user_solution = array();
948  }
949  }
950 
951  include_once "./Services/UICore/classes/class.ilTemplate.php";
952  $template = new ilTemplate("tpl.il_as_qpl_cloze_question_output_solution.html", true, true, "Modules/TestQuestionPool");
953  $output = $this->object->getClozeTextForHTMLOutput();
954  $assClozeGapCombinationObject = new assClozeGapCombination();
955  $check_for_gap_combinations = $assClozeGapCombinationObject->loadFromDb($this->object->getId());
956 
957  foreach ($this->object->getGaps() as $gap_index => $gap) {
958  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_output_solution_gap.html", true, true, "Modules/TestQuestionPool");
959  $found = array();
960  foreach ($user_solution as $solutionarray) {
961  if ($solutionarray["value1"] == $gap_index) {
962  $found = $solutionarray;
963  }
964  }
965 
966  if ($active_id) {
967  if ($graphicalOutput) {
968  // output of ok/not ok icons for user entered solutions
969  $details = $this->object->calculateReachedPoints($active_id, $pass, true, true);
970  $check = $details[$gap_index] ?? [];
971 
972  if (count($check_for_gap_combinations) != 0) {
973  $gaps_used_in_combination = $assClozeGapCombinationObject->getGapsWhichAreUsedInCombination($this->object->getId());
974  $custom_user_solution = array();
975  if (array_key_exists($gap_index, $gaps_used_in_combination)) {
976  $combination_id = $gaps_used_in_combination[$gap_index];
977  foreach ($gaps_used_in_combination as $key => $value) {
978  $a = 0;
979  if ($value == $combination_id) {
980  foreach ($user_solution as $solution_key => $solution_value) {
981  if ($solution_value['value1'] == $key) {
982  $result_row = array();
983  $result_row['gap_id'] = $solution_value['value1'];
984  $result_row['value'] = $solution_value['value2'];
985  array_push($custom_user_solution, $result_row);
986  }
987  }
988  }
989  }
990  $points_array = $this->object->calculateCombinationResult($custom_user_solution);
991  $max_combination_points = $assClozeGapCombinationObject->getMaxPointsForCombination($this->object->getId(), $combination_id);
992  if ($points_array[0] == $max_combination_points) {
993  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK));
994  } elseif ($points_array[0] > 0) {
995  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_MOSTLY_OK));
996  } else {
997  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK));
998  }
999  } else {
1000  if (array_key_exists('best', $check) && $check["best"]) {
1001  $gaptemplate->setCurrentBlock("icon_ok");
1002  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK));
1003  $gaptemplate->parseCurrentBlock();
1004  } else {
1005  $gaptemplate->setCurrentBlock("icon_ok");
1006  if (array_key_exists('positive', $check) && $check["positive"]) {
1007  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_MOSTLY_OK));
1008  } else {
1009  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK));
1010  }
1011  $gaptemplate->parseCurrentBlock();
1012  }
1013  }
1014  } else {
1015  if (array_key_exists('best', $check) && $check["best"]) {
1016  $gaptemplate->setCurrentBlock("icon_ok");
1017  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK));
1018  $gaptemplate->parseCurrentBlock();
1019  } else {
1020  $gaptemplate->setCurrentBlock("icon_ok");
1021  if (array_key_exists('positive', $check) && $check["positive"]) {
1022  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_MOSTLY_OK));
1023  } else {
1024  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK));
1025  }
1026  $gaptemplate->parseCurrentBlock();
1027  }
1028  }
1029  }
1030  }
1031  $combination = null;
1032  switch ($gap->getType()) {
1033  case CLOZE_NUMERIC:
1034  case CLOZE_TEXT:
1035  $solutiontext = "";
1036  if (($active_id > 0) && (!$show_correct_solution)) {
1037  if ((count($found) == 0) || (strlen(trim($found["value2"])) == 0)) {
1038  for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
1039  $solutiontext .= "&nbsp;";
1040  }
1041  } else {
1042  $solutiontext = ilLegacyFormElementsUtil::prepareFormOutput($found["value2"]);
1043  }
1044  } else {
1045  $solutiontext = $this-> getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
1046  }
1047  $this->populateSolutiontextToGapTpl($gaptemplate, $gap, $solutiontext);
1048  // fau: fixGapReplace - use replace function
1049  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
1050  // fau.
1051  break;
1052  case CLOZE_SELECT:
1053  $solutiontext = "";
1054  if (($active_id > 0) && (!$show_correct_solution)) {
1055  if ((count($found) == 0) || (strlen(trim($found["value2"])) == 0)) {
1056  for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
1057  $solutiontext .= "&nbsp;";
1058  }
1059  } else {
1060  $item = $gap->getItem($found["value2"]);
1061  if (is_object($item)) {
1062  $solutiontext = ilLegacyFormElementsUtil::prepareFormOutput($item->getAnswertext());
1063  } else {
1064  for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
1065  $solutiontext .= "&nbsp;";
1066  }
1067  }
1068  }
1069  } else {
1070  $solutiontext = $this-> getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
1071  }
1072  $this->populateSolutiontextToGapTpl($gaptemplate, $gap, $solutiontext);
1073  // fau: fixGapReplace - use replace function
1074  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
1075  // fau.
1076  break;
1077  }
1078  }
1079 
1080  if ($show_question_text) {
1081  $template->setVariable(
1082  "QUESTIONTEXT",
1083  $this->object->getQuestionForHTMLOutput()
1084  );
1085  }
1086 
1087  $template->setVariable("CLOZETEXT", $this->object->prepareTextareaOutput($output, true));
1088  // generate the question output
1089  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
1090  $questionoutput = $template->get();
1091 
1092  $feedback = '';
1093  if ($show_feedback) {
1094  if (!$this->isTestPresentationContext()) {
1095  $fb = $this->getGenericFeedbackOutput((int) $active_id, $pass);
1096  $feedback .= strlen($fb) ? $fb : '';
1097  }
1098 
1099  $fb = $this->getSpecificFeedbackOutput(
1100  $this->object->fetchIndexedValuesFromValuePairs($user_solution)
1101  );
1102  $feedback .= strlen($fb) ? $fb : '';
1103  }
1104  if (strlen($feedback)) {
1105  $cssClass = (
1106  $this->hasCorrectSolution($active_id, $pass) ?
1108  );
1109 
1110  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
1111  $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
1112  }
1113 
1114  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
1115 
1116  $solutionoutput = $solutiontemplate->get();
1117 
1118  if (!$show_question_only) {
1119  // get page object output
1120  $solutionoutput = $this->getILIASPage($solutionoutput);
1121  }
1122 
1123  return $solutionoutput;
1124  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
const CLOZE_TEXT
Cloze question constants.
populateSolutiontextToGapTpl($gaptemplate, $gap, $solutiontext)
static prepareFormOutput($a_str, bool $a_strip=false)
getSpecificFeedbackOutput(array $userSolution)
getBestSolutionText($gap, $gap_index, $gap_combinations)
array $details
Details for error message relating to last request processed.
Definition: System.php:109
const CLOZE_SELECT
string $key
Consumer key/client ID value.
Definition: System.php:193
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
getGenericFeedbackOutput(int $active_id, $pass)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$check
Definition: buildRTE.php:81
const CLOZE_NUMERIC
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assClozeTestGUI::getSpecificFeedbackOutput ( array  $userSolution)

Definition at line 1272 of file class.assClozeTestGUI.php.

References $gapIndex, ILIAS\Repository\lng(), ILIAS\Repository\object(), and assClozeGap\TYPE_TEXT.

Referenced by getSolutionOutput().

1272  : string
1273  {
1274  if (!$this->object->feedbackOBJ->isSpecificAnswerFeedbackAvailable($this->object->getId())) {
1275  return '';
1276  }
1277 
1278  $feedback = '<table class="test_specific_feedback"><tbody>';
1279 
1280  foreach ($this->object->gaps as $gapIndex => $gap) {
1281  $answerValue = $this->object->fetchAnswerValueForGap($userSolution, $gapIndex);
1282  if ($gap->getType() !== assClozeGap::TYPE_TEXT
1283  && $answerValue === '') {
1284  continue;
1285  }
1286  $answerIndex = $this->object->feedbackOBJ->determineAnswerIndexForAnswerValue($gap, $answerValue);
1287  $fb = $this->object->feedbackOBJ->determineTestOutputGapFeedback($gapIndex, $answerIndex);
1288 
1289  $caption = $this->lng->txt('gap') . ' ' . ($gapIndex + 1) . ': ';
1290  $feedback .= '<tr><td>';
1291  $feedback .= $caption . '</td><td>';
1292  $feedback .= $fb . '</td> </tr>';
1293  }
1294  $feedback .= '</tbody></table>';
1295 
1296  return $this->object->prepareTextareaOutput($feedback, true);
1297  }
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubQuestionsIndex()

assClozeTestGUI::getSubQuestionsIndex ( )

Definition at line 1495 of file class.assClozeTestGUI.php.

References ILIAS\Repository\object().

1495  : array
1496  {
1497  return array_keys($this->object->getGaps());
1498  }
+ Here is the call graph for this function:

◆ getTestOutput()

assClozeTestGUI::getTestOutput (   $active_id,
  $pass,
  $is_postponed = false,
  $use_post_solutions = false,
  $show_feedback = false 
)

Definition at line 1168 of file class.assClozeTestGUI.php.

References CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, ILIAS\Repository\lng(), ILIAS\Repository\object(), assQuestionGUI\outQuestionPage(), and ilLegacyFormElementsUtil\prepareFormOutput().

1176  : string {
1177  // get the solution of the user for the active pass or from the last pass if allowed
1178  $user_solution = array();
1179  if ($use_post_solutions !== false) {
1180  $indexedSolution = $this->object->fetchSolutionSubmit($use_post_solutions);
1181  $user_solution = $this->object->fetchValuePairsFromIndexedValues($indexedSolution);
1182  } elseif ($active_id) {
1183  $user_solution = $this->object->getTestOutputSolutions($active_id, $pass);
1184  // hey.
1185  if (!is_array($user_solution)) {
1186  $user_solution = array();
1187  }
1188  }
1189 
1190  // generate the question output
1191  include_once "./Services/UICore/classes/class.ilTemplate.php";
1192  $template = new ilTemplate("tpl.il_as_qpl_cloze_question_output.html", true, true, "Modules/TestQuestionPool");
1193  $output = $this->object->getClozeTextForHTMLOutput();
1194  foreach ($this->object->getGaps() as $gap_index => $gap) {
1195  switch ($gap->getType()) {
1196  case CLOZE_TEXT:
1197  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_text.html", true, true, "Modules/TestQuestionPool");
1198  $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->object->getFixedTextLength();
1199 
1200  if ($gap_size > 0) {
1201  $gaptemplate->setCurrentBlock('size_and_maxlength');
1202  $gaptemplate->setVariable("TEXT_GAP_SIZE", $gap_size);
1203  $gaptemplate->parseCurrentBlock();
1204  }
1205 
1206  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
1207  foreach ($user_solution as $solution) {
1208  if (strcmp($solution["value1"], $gap_index) == 0) {
1209  $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput(
1210  $solution["value2"]
1211  ) . "\"");
1212  }
1213  }
1214  // fau: fixGapReplace - use replace function
1215  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
1216  // fau.
1217  break;
1218  case CLOZE_SELECT:
1219  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_select.html", true, true, "Modules/TestQuestionPool");
1220  foreach ($gap->getItems($this->object->getShuffler(), $gap_index) as $item) {
1221  $gaptemplate->setCurrentBlock("select_gap_option");
1222  $gaptemplate->setVariable("SELECT_GAP_VALUE", $item->getOrder());
1223  $gaptemplate->setVariable(
1224  "SELECT_GAP_TEXT",
1225  ilLegacyFormElementsUtil::prepareFormOutput($item->getAnswerText())
1226  );
1227  foreach ($user_solution as $solution) {
1228  if (strcmp($solution["value1"], $gap_index) == 0) {
1229  if (strcmp($solution["value2"], $item->getOrder()) == 0) {
1230  $gaptemplate->setVariable("SELECT_GAP_SELECTED", " selected=\"selected\"");
1231  }
1232  }
1233  }
1234  $gaptemplate->parseCurrentBlock();
1235  }
1236  $gaptemplate->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
1237  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);// fau: fixGapReplace - use replace function
1238  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
1239  // fau.
1240  break;
1241  case CLOZE_NUMERIC:
1242  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_numeric.html", true, true, "Modules/TestQuestionPool");
1243  $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->object->getFixedTextLength();
1244  if ($gap_size > 0) {
1245  $gaptemplate->setCurrentBlock('size_and_maxlength');
1246  $gaptemplate->setVariable("TEXT_GAP_SIZE", $gap_size);
1247  $gaptemplate->parseCurrentBlock();
1248  }
1249 
1250  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
1251  foreach ($user_solution as $solution) {
1252  if (strcmp($solution["value1"], $gap_index) == 0) {
1253  $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput(
1254  $solution["value2"]
1255  ) . "\"");
1256  }
1257  }
1258  // fau: fixGapReplace - use replace function
1259  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
1260  // fau.
1261  break;
1262  }
1263  }
1264 
1265  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
1266  $template->setVariable("CLOZETEXT", $this->object->prepareTextareaOutput($output, true));
1267  $questionoutput = $template->get();
1268  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
1269  return $pageoutput;
1270  }
const CLOZE_TEXT
Cloze question constants.
static prepareFormOutput($a_str, bool $a_strip=false)
const CLOZE_SELECT
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
const CLOZE_NUMERIC
+ Here is the call graph for this function:

◆ hasAddAnswerAction()

assClozeTestGUI::hasAddAnswerAction (   $relevantAnswers,
  $questionIndex 
)
protected

Definition at line 1461 of file class.assClozeTestGUI.php.

References getAnswersFrequency().

Referenced by getAnswerFrequencyTableGUI().

1461  : bool
1462  {
1463  foreach ($this->getAnswersFrequency($relevantAnswers, $questionIndex) as $answer) {
1464  if (isset($answer['actions'])) {
1465  return true;
1466  }
1467  }
1468 
1469  return false;
1470  }
getAnswersFrequency($relevantAnswers, $questionIndex)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isUsedInCombinations()

assClozeTestGUI::isUsedInCombinations (   $gapIndex)
protected

Definition at line 1570 of file class.assClozeTestGUI.php.

References $gapIndex, and ILIAS\Repository\object().

Referenced by populateCorrectionsFormProperties(), and saveCorrectionsFormProperties().

1570  : bool
1571  {
1572  foreach ($this->object->getGapCombinations() as $combination) {
1573  if ($combination['gap_fi'] != $gapIndex) {
1574  continue;
1575  }
1576 
1577  return true;
1578  }
1579 
1580  return false;
1581  }
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateAnswerSpecificFormPart()

assClozeTestGUI::populateAnswerSpecificFormPart ( ilPropertyFormGUI  $form)

Adds the answer specific form parts to a question property form gui.

Implements ilGuiAnswerScoringAdjustable.

Definition at line 508 of file class.assClozeTestGUI.php.

References ilPropertyFormGUI\addItem(), ILIAS\Repository\object(), populateGapFormPart(), and populateJSON().

Referenced by editQuestion().

509  {
510  if (self::OLD_CLOZE_TEST_UI) {
511  for ($gapCounter = 0; $gapCounter < $this->object->getGapCount(); $gapCounter++) {
512  $this->populateGapFormPart($form, $gapCounter);
513  }
514  return $form;
515  } else {
516  require_once 'Modules/TestQuestionPool/classes/Form/class.ilClozeGapInputBuilderGUI.php';
517  $json = $this->populateJSON();
518  $assClozeGapCombinationObject = new assClozeGapCombination();
519  $combination_exists = $assClozeGapCombinationObject->combinationExistsForQid($this->object->getId());
520  $combinations = array();
521  if ($combination_exists) {
522  $combinations = $assClozeGapCombinationObject->loadFromDb($this->object->getId());
523  }
524  $new_builder = new ilClozeGapInputBuilderGUI();
525  $header = new ilFormSectionHeaderGUI();
526  $form->addItem($header);
527  $new_builder->setValueByArray($json);
528  $new_builder->setValueCombinationFromDb($combinations);
529  $form->addItem($new_builder);
530  return $form;
531  }
532  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
populateGapFormPart($form, $gapCounter)
Populates a gap form-part.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateCorrectionsFormProperties()

assClozeTestGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Definition at line 1608 of file class.assClozeTestGUI.php.

References $gapIndex, getGapCombinations(), isUsedInCombinations(), ILIAS\Repository\object(), populateGapCombinationCorrectionFormProperty(), and populateGapCorrectionFormProperties().

1608  : void
1609  {
1610  foreach ($this->object->getGaps() as $gapIndex => $gap) {
1612  $form,
1613  $gap,
1614  $gapIndex,
1615  $this->isUsedInCombinations($gapIndex)
1616  );
1617  }
1618 
1619  if ($this->object->getGapCombinationsExists()) {
1620  foreach ($this->getGapCombinations() as $combiIndex => $gapCombination) {
1621  $this->populateGapCombinationCorrectionFormProperty($form, $gapCombination, $combiIndex);
1622  }
1623  }
1624  }
populateGapCombinationCorrectionFormProperty(ilPropertyFormGUI $form, $gapCombi, $combiIndex)
populateGapCorrectionFormProperties($form, $gap, $gapIndex, $hidePoints)
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
+ Here is the call graph for this function:

◆ populateGapCombinationCorrectionFormProperty()

assClozeTestGUI::populateGapCombinationCorrectionFormProperty ( ilPropertyFormGUI  $form,
  $gapCombi,
  $combiIndex 
)
protected

Definition at line 1626 of file class.assClozeTestGUI.php.

References ilPropertyFormGUI\addItem().

Referenced by populateCorrectionsFormProperties().

1626  : void
1627  {
1628  $header = new ilFormSectionHeaderGUI();
1629  $header->setTitle("Gap Combination " . ($combiIndex + 1));
1630  $form->addItem($header);
1631 
1632  require_once 'Modules/TestQuestionPool/classes/forms/class.ilAssClozeTestCombinationVariantsInputGUI.php';
1633  $inp = new ilAssClozeTestCombinationVariantsInputGUI('Answers', 'combination_' . $combiIndex);
1634  $inp->setValues($gapCombi);
1635  $form->addItem($inp);
1636  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateGapCorrectionFormProperties()

assClozeTestGUI::populateGapCorrectionFormProperties (   $form,
  $gap,
  $gapIndex,
  $hidePoints 
)
protected
Parameters
ilPropertyFormGUI$form
assClozeGap$gap
integer$gapIndex

Definition at line 1643 of file class.assClozeTestGUI.php.

References $gapIndex, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, ILIAS\Repository\lng(), populateNumericGapCorrectionFormProperty(), and populateTextOrSelectGapCorrectionFormProperty().

Referenced by populateCorrectionsFormProperties().

1643  : void
1644  {
1645  $header = new ilFormSectionHeaderGUI();
1646  $header->setTitle($this->lng->txt("gap") . " " . ($gapIndex + 1));
1647  $form->addItem($header);
1648 
1649  if ($gap->getType() == CLOZE_TEXT || $gap->getType() == CLOZE_SELECT) {
1650  $this->populateTextOrSelectGapCorrectionFormProperty($form, $gap, $gapIndex, $hidePoints);
1651  } elseif ($gap->getType() == CLOZE_NUMERIC) {
1652  foreach ($gap->getItemsRaw() as $item) {
1653  $this->populateNumericGapCorrectionFormProperty($form, $item, $gapIndex, $hidePoints);
1654  }
1655  }
1656  }
populateNumericGapCorrectionFormProperty($form, $item, $gapIndex, $hidePoints)
const CLOZE_TEXT
Cloze question constants.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CLOZE_SELECT
populateTextOrSelectGapCorrectionFormProperty($form, $gap, $gapIndex, $hidePoints)
const CLOZE_NUMERIC
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateGapFormPart()

assClozeTestGUI::populateGapFormPart (   $form,
  $gapCounter 
)
protected

Populates a gap form-part.

This includes: A section header with the according gap-ordinal, the type select-box. Furthermore, this method calls the gap-type-specific methods for their contents.

Parameters
$formilPropertyFormGUI Reference to the form, that receives the point.
$gapCounterinteger Ordinal number of the gap in the sequence of gaps
Returns
ilPropertyFormGUI

Definition at line 589 of file class.assClozeTestGUI.php.

References CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, ILIAS\Repository\lng(), populateGapSizeFormPart(), populateNumericGapFormPart(), populateSelectGapFormPart(), and populateTextGapFormPart().

Referenced by populateAnswerSpecificFormPart().

590  {
591  $gap = $this->object->getGap($gapCounter);
592 
593  if ($gap == null) {
594  return $form;
595  }
596 
597  $header = new ilFormSectionHeaderGUI();
598  $header->setTitle($this->lng->txt("gap") . " " . ($gapCounter + 1));
599  $form->addItem($header);
600 
601  $gapcounter = new ilHiddenInputGUI("gap[$gapCounter]");
602  $gapcounter->setValue($gapCounter);
603  $form->addItem($gapcounter);
604 
605  $gaptype = new ilSelectInputGUI($this->lng->txt('type'), "clozetype_$gapCounter");
606  $options = array(
607  0 => $this->lng->txt("text_gap"),
608  1 => $this->lng->txt("select_gap"),
609  2 => $this->lng->txt("numeric_gap")
610  );
611  $gaptype->setOptions($options);
612  $gaptype->setValue($gap->getType());
613  $form->addItem($gaptype);
614 
615  if ($gap->getType() == CLOZE_TEXT) {
616  $this->populateGapSizeFormPart($form, $gap, $gapCounter);
617 
618  if (count($gap->getItemsRaw()) == 0) {
619  $gap->addItem(new assAnswerCloze("", 0, 0));
620  }
621  $this->populateTextGapFormPart($form, $gap, $gapCounter);
622  } elseif ($gap->getType() == CLOZE_SELECT) {
623  if (count($gap->getItemsRaw()) == 0) {
624  $gap->addItem(new assAnswerCloze("", 0, 0));
625  }
626  $this->populateSelectGapFormPart($form, $gap, $gapCounter);
627  } elseif ($gap->getType() == CLOZE_NUMERIC) {
628  $this->populateGapSizeFormPart($form, $gap, $gapCounter);
629 
630  if (count($gap->getItemsRaw()) == 0) {
631  $gap->addItem(new assAnswerCloze("", 0, 0));
632  }
633  foreach ($gap->getItemsRaw() as $item) {
634  $this->populateNumericGapFormPart($form, $item, $gapCounter);
635  }
636  }
637  return $form;
638  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CLOZE_TEXT
Cloze question constants.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
populateTextGapFormPart($form, $gap, $gapCounter)
Populates the form-part for a text gap.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CLOZE_SELECT
populateGapSizeFormPart($form, $gap, $gapCounter)
populateNumericGapFormPart($form, $gap, $gapCounter)
Populates the form-part for a numeric gap.
populateSelectGapFormPart($form, $gap, $gapCounter)
Populates the form-part for a select gap.
const CLOZE_NUMERIC
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateGapSizeFormPart()

assClozeTestGUI::populateGapSizeFormPart (   $form,
  $gap,
  $gapCounter 
)
protected
Parameters
$formilPropertyFormGUI Reference to the form, that receives the point.
$gapmixed Raw text gap item.
$gapCounterinteger Ordinal number of the gap in the sequence of gaps

Definition at line 645 of file class.assClozeTestGUI.php.

References ilNumberInputGUI\allowDecimals(), and ILIAS\Repository\lng().

Referenced by populateGapFormPart().

646  {
647  $gapSizeFormItem = new ilNumberInputGUI($this->lng->txt('cloze_fixed_textlength'), "gap_" . $gapCounter . '_gapsize');
648 
649  $gapSizeFormItem->allowDecimals(false);
650  $gapSizeFormItem->setMinValue(0);
651  $gapSizeFormItem->setSize(3);
652  $gapSizeFormItem->setMaxLength(6);
653  $gapSizeFormItem->setInfo($this->lng->txt('cloze_gap_size_info'));
654  $gapSizeFormItem->setValue($gap->getGapSize());
655  $form->addItem($gapSizeFormItem);
656 
657  return $form;
658  }
allowDecimals(bool $a_value)
This class represents a number property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateJSON()

assClozeTestGUI::populateJSON ( )
protected

Definition at line 534 of file class.assClozeTestGUI.php.

References $i, and assQuestionGUI\escapeTemplatePlaceholders().

Referenced by populateAnswerSpecificFormPart().

534  : array
535  {
536  $gap = $this->object->getGaps();
537  $array = array();
538  if ($gap == null) {
539  return $array;
540  }
541  $translate_type = array('text','select','numeric');
542  $i = 0;
543  foreach ($gap as $content) {
544  $shuffle = false;
545  $value = $content->getItemsRaw();
546  $items = array();
547  for ($j = 0, $jMax = count($value); $j < $jMax; $j++) {
548  if ($content->isNumericGap()) {
549  $items[$j] = array(
550  'answer' => $value[$j]->getAnswerText(),
551  'lower' => $value[$j]->getLowerBound(),
552  'upper' => $value[$j]->getUpperBound(),
553  'points' => $value[$j]->getPoints(),
554  'error' => false
555  );
556  } else {
557  $items[$j] = array(
558  'answer' => $this->escapeTemplatePlaceholders($value[$j]->getAnswerText()),
559  'points' => $value[$j]->getPoints(),
560  'error' => false
561  );
562 
563  if ($content->isSelectGap()) {
564  $shuffle = $content->getShuffle();
565  }
566  }
567  }
568  $answers[$i] = array(
569  'type' => $translate_type[$content->getType()] ,
570  'values' => $items ,
571  'shuffle' => $shuffle,
572  'text_field_length' => $content->getGapSize() > 0 ? $content->getGapSize() : '',
573  'used_in_gap_combination' => true);
574  $i++;
575  }
576  return $answers;
577  }
escapeTemplatePlaceholders(string $text)
$i
Definition: metadata.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateNumericGapCorrectionFormProperty()

assClozeTestGUI::populateNumericGapCorrectionFormProperty (   $form,
  $item,
  $gapIndex,
  $hidePoints 
)
protected

Definition at line 1669 of file class.assClozeTestGUI.php.

References $gapIndex, ilNumberInputGUI\allowDecimals(), ILIAS\Repository\lng(), and ilLegacyFormElementsUtil\prepareFormOutput().

Referenced by populateGapCorrectionFormProperties().

1669  : void
1670  {
1671  $value = new ilNumberInputGUI($this->lng->txt('value'), "gap_" . $gapIndex . "_numeric");
1672  $value->allowDecimals(true);
1673  $value->setSize(10);
1674  $value->setValue(ilLegacyFormElementsUtil::prepareFormOutput($item->getAnswertext()));
1675  $value->setRequired(true);
1676  $form->addItem($value);
1677 
1678  $lowerbound = new ilNumberInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $gapIndex . "_numeric_lower");
1679  $lowerbound->allowDecimals(true);
1680  $lowerbound->setSize(10);
1681  $lowerbound->setRequired(true);
1682  $lowerbound->setValue(ilLegacyFormElementsUtil::prepareFormOutput($item->getLowerBound()));
1683  $form->addItem($lowerbound);
1684 
1685  $upperbound = new ilNumberInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $gapIndex . "_numeric_upper");
1686  $upperbound->allowDecimals(true);
1687  $upperbound->setSize(10);
1688  $upperbound->setRequired(true);
1689  $upperbound->setValue(ilLegacyFormElementsUtil::prepareFormOutput($item->getUpperBound()));
1690  $form->addItem($upperbound);
1691 
1692  if (!$hidePoints) {
1693  $points = new ilNumberInputGUI($this->lng->txt('points'), "gap_" . $gapIndex . "_numeric_points");
1694  $points->allowDecimals(true);
1695  $points->setSize(3);
1696  $points->setRequired(true);
1697  $points->setValue(ilLegacyFormElementsUtil::prepareFormOutput($item->getPoints()));
1698  $form->addItem($points);
1699  }
1700  }
static prepareFormOutput($a_str, bool $a_strip=false)
allowDecimals(bool $a_value)
This class represents a number property in a property form.
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateNumericGapFormPart()

assClozeTestGUI::populateNumericGapFormPart (   $form,
  $gap,
  $gapCounter 
)
protected

Populates the form-part for a numeric gap.

This includes: The type selector, value, lower bound, upper bound and points.

Parameters
$formilPropertyFormGUI Reference to the form, that receives the point.
$gapmixed Raw numeric gap item.
$gapCounterinteger Ordinal number of the gap in the sequence of gaps.
Returns
ilPropertyFormGUI

Definition at line 737 of file class.assClozeTestGUI.php.

References ilNumberInputGUI\allowDecimals(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilLegacyFormElementsUtil\prepareFormOutput(), and ilTextInputGUI\setInlineStyle().

Referenced by populateGapFormPart().

738  {
739  // #8944: the js-based ouput in self-assessment cannot support formulas
740  if (!$this->object->getSelfAssessmentEditingMode()) {
741  $value = new ilFormulaInputGUI($this->lng->txt('value'), "gap_" . $gapCounter . "_numeric");
742  $value->setInlineStyle('text-align: right;');
743 
744  $lowerbound = new ilFormulaInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $gapCounter . "_numeric_lower");
745  $lowerbound->setInlineStyle('text-align: right;');
746 
747  $upperbound = new ilFormulaInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $gapCounter . "_numeric_upper");
748  $upperbound->setInlineStyle('text-align: right;');
749  } else {
750  $value = new ilNumberInputGUI($this->lng->txt('value'), "gap_" . $gapCounter . "_numeric");
751  $value->allowDecimals(true);
752 
753  $lowerbound = new ilNumberInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $gapCounter . "_numeric_lower");
754  $lowerbound->allowDecimals(true);
755 
756  $upperbound = new ilNumberInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $gapCounter . "_numeric_upper");
757  $upperbound->allowDecimals(true);
758  }
759 
760  $value->setSize(10);
761  $value->setValue(ilLegacyFormElementsUtil::prepareFormOutput($gap->getAnswertext()));
762  $value->setRequired(true);
763  $form->addItem($value);
764 
765  $lowerbound->setSize(10);
766  $lowerbound->setRequired(true);
767  $lowerbound->setValue(ilLegacyFormElementsUtil::prepareFormOutput($gap->getLowerBound()));
768  $form->addItem($lowerbound);
769 
770  $upperbound->setSize(10);
771  $upperbound->setRequired(true);
772  $upperbound->setValue(ilLegacyFormElementsUtil::prepareFormOutput($gap->getUpperBound()));
773  $form->addItem($upperbound);
774 
775  if ($this->object->getFixedTextLength() > 0) {
776  $value->setSize($this->object->getFixedTextLength());
777  $value->setMaxLength($this->object->getFixedTextLength());
778  $lowerbound->setSize($this->object->getFixedTextLength());
779  $lowerbound->setMaxLength($this->object->getFixedTextLength());
780  $upperbound->setSize($this->object->getFixedTextLength());
781  $upperbound->setMaxLength($this->object->getFixedTextLength());
782  }
783 
784  $points = new ilNumberInputGUI($this->lng->txt('points'), "gap_" . $gapCounter . "_numeric_points");
785  $points->allowDecimals(true);
786  $points->setSize(3);
787  $points->setRequired(true);
788  $points->setValue(ilLegacyFormElementsUtil::prepareFormOutput($gap->getPoints()));
789  $form->addItem($points);
790  return $form;
791  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static prepareFormOutput($a_str, bool $a_strip=false)
allowDecimals(bool $a_value)
This class represents a number property in a property form.
setInlineStyle(string $a_style)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateQuestionSpecificFormPart()

assClozeTestGUI::populateQuestionSpecificFormPart ( ilPropertyFormGUI  $form)

Adds the question specific forms parts to a question property form gui.

Implements ilGuiQuestionScoringAdjustable.

Definition at line 410 of file class.assClozeTestGUI.php.

References assQuestionGUI\$tpl, ilObjAdvancedEditing\_getUsedHTMLTags(), ilPropertyFormGUI\addItem(), assQuestion\ADDITIONAL_CONTENT_EDITING_MODE_RTE, applyIndizesToGapText(), ilGlobalPageTemplate\get(), ilJsLinkButton\getInstance(), ilSplitButtonGUI\getInstance(), ilAssSelfAssessmentQuestionFormatter\getSelfAssessmentTags(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilGlobalPageTemplate\parseCurrentBlock(), ilFormPropertyGUI\setRequired(), ilCheckboxInputGUI\setValue(), ilNumberInputGUI\setValue(), and ilGlobalPageTemplate\setVariable().

Referenced by editQuestion().

411  {
412  // cloze text
413  $cloze_text = new ilTextAreaInputGUI($this->lng->txt("cloze_text"), 'cloze_text');
414  $cloze_text->setRequired(true);
415  $cloze_text->setValue($this->applyIndizesToGapText($this->object->getClozeText()));
416  $cloze_text->setInfo($this->lng->txt("close_text_hint"));
417  $cloze_text->setRows(10);
418  $cloze_text->setCols(80);
419  if (!$this->object->getSelfAssessmentEditingMode()) {
420  if ($this->object->getAdditionalContentEditingMode() == assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_RTE) {
421  $cloze_text->setUseRte(true);
422  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
423  $cloze_text->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
424  $cloze_text->addPlugin("latex");
425  $cloze_text->addButton("latex");
426  $cloze_text->addButton("pastelatex");
427  }
428  } else {
429  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
431  $cloze_text->setUseTagsForRteOnly(false);
432  }
433  $cloze_text->setRTESupport($this->object->getId(), "qpl", "assessment");
434  $form->addItem($cloze_text);
435 
436  $tpl = new ilTemplate("tpl.il_as_qpl_cloze_gap_button_code.html", true, true, "Modules/TestQuestionPool");
437 
438  $button = new ilCustomInputGUI('&nbsp;', '');
439  $action_button = ilSplitButtonGUI::getInstance();
440 
441  $sb_text_gap = ilJsLinkButton::getInstance();
442  $sb_text_gap->setCaption('text_gap');
443  $sb_text_gap->setName('gapbutton');
444  $sb_text_gap->setId('gaptrigger_text');
445  $sb_text_gap->setTarget('');
446  $action_button->setDefaultButton($sb_text_gap);
447 
448  $sb_sel_gap = ilJsLinkButton::getInstance();
449  $sb_sel_gap->setCaption('select_gap');
450  $sb_sel_gap->setName('gapbutton_select');
451  $sb_sel_gap->setId('gaptrigger_select');
452  $sb_sel_gap->setTarget('');
453  $action_button->addMenuItem(new ilButtonToSplitButtonMenuItemAdapter($sb_sel_gap));
454 
455  $sb_num_gap = ilJsLinkButton::getInstance();
456  $sb_num_gap->setCaption('numeric_gap');
457  $sb_num_gap->setName('gapbutton_numeric');
458  $sb_num_gap->setId('gaptrigger_numeric');
459  $sb_num_gap->setTarget('');
460  $action_button->addMenuItem(new ilButtonToSplitButtonMenuItemAdapter($sb_num_gap));
461 
462  $tpl->setVariable('BUTTON', $action_button->render());
464 
465  $button->setHtml($tpl->get());
466  $this->tpl->addOnloadCode(self::JS_INSERT_GAP_CODE_AT_CARET);
467  $form->addItem($button);
468 
469  // text rating
470  if (!$this->object->getSelfAssessmentEditingMode()) {
471  $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "textgap_rating");
472  $text_options = array(
473  "ci" => $this->lng->txt("cloze_textgap_case_insensitive"),
474  "cs" => $this->lng->txt("cloze_textgap_case_sensitive"),
475  "l1" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1"),
476  "l2" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2"),
477  "l3" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3"),
478  "l4" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4"),
479  "l5" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5")
480  );
481  $textrating->setOptions($text_options);
482  $textrating->setValue($this->object->getTextgapRating());
483  $form->addItem($textrating);
484 
485  // text field length
486  $fixedTextLength = new ilNumberInputGUI($this->lng->txt("cloze_fixed_textlength"), "fixedTextLength");
487  $ftl = $this->object->getFixedTextLength();
488 
489  $fixedTextLength->setValue($ftl > 0 ? $ftl : '');
490  $fixedTextLength->setMinValue(0);
491  $fixedTextLength->setSize(3);
492  $fixedTextLength->setMaxLength(6);
493  $fixedTextLength->setInfo($this->lng->txt('cloze_fixed_textlength_description'));
494  $fixedTextLength->setRequired(false);
495  $form->addItem($fixedTextLength);
496 
497  // identical scoring
498  $identical_scoring = new ilCheckboxInputGUI($this->lng->txt("identical_scoring"), "identical_scoring");
499  $identical_scoring->setValue(1);
500  $identical_scoring->setChecked($this->object->getIdenticalScoring());
501  $identical_scoring->setInfo($this->lng->txt('identical_scoring_desc'));
502  $identical_scoring->setRequired(false);
503  $form->addItem($identical_scoring);
504  }
505  return $form;
506  }
static getSelfAssessmentTags()
Get tags allowed in question tags in self assessment mode.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
This class represents a checkbox property in a property form.
ilGlobalPageTemplate $tpl
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
This class represents a number property in a property form.
setValue(?string $a_value)
setRequired(bool $a_required)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
applyIndizesToGapText($question_text)
This class represents a text area property in a property form.
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateSelectGapFormPart()

assClozeTestGUI::populateSelectGapFormPart (   $form,
  $gap,
  $gapCounter 
)
protected

Populates the form-part for a select gap.

This includes: The AnswerWizardGUI for the individual select items and points as well as the the checkbox for the shuffle option.

Parameters
$formilPropertyFormGUI Reference to the form, that receives the point.
$gapmixed Raw text gap item.
$gapCounterinteger Ordinal number of the gap in the sequence of gaps
Returns
ilPropertyFormGUI

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

References ILIAS\Repository\lng(), ilFormPropertyGUI\setRequired(), and ilCheckboxInputGUI\setValue().

Referenced by populateGapFormPart().

673  {
674  include_once "./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
675  include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
676  $values = new ilAnswerWizardInputGUI($this->lng->txt("values"), "gap_" . $gapCounter . "");
677  $values->setRequired(true);
678  $values->setQuestionObject($this->object);
679  $values->setSingleline(true);
680  $values->setAllowMove(false);
681 
682  $values->setValues($gap->getItemsRaw());
683  $form->addItem($values);
684 
685  // shuffle
686  $shuffle = new ilCheckboxInputGUI($this->lng->txt("shuffle_answers"), "shuffle_" . $gapCounter . "");
687  $shuffle->setValue(1);
688  $shuffle->setChecked($gap->getShuffle());
689  $shuffle->setRequired(false);
690  $form->addItem($shuffle);
691  return $form;
692  }
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRequired(bool $a_required)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateSolutiontextToGapTpl()

assClozeTestGUI::populateSolutiontextToGapTpl (   $gaptemplate,
  $gap,
  $solutiontext 
)
private
Parameters
$gaptemplate
$solutiontext

Definition at line 1436 of file class.assClozeTestGUI.php.

References CLOZE_SELECT, and assQuestionGUI\isRenderPurposePrintPdf().

Referenced by getSolutionOutput().

1436  : void
1437  {
1438  if ($this->isRenderPurposePrintPdf()) {
1439  $gaptemplate->setCurrentBlock('gap_span');
1440  $gaptemplate->setVariable('SPAN_SOLUTION', $solutiontext);
1441  } elseif ($gap->getType() == CLOZE_SELECT) {
1442  $gaptemplate->setCurrentBlock('gap_select');
1443  $gaptemplate->setVariable('SELECT_SOLUTION', $solutiontext);
1444  } else {
1445  $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->object->getFixedTextLength();
1446 
1447  if ($gap_size > 0) {
1448  $gaptemplate->setCurrentBlock('gap_size');
1449  $gaptemplate->setVariable("GAP_SIZE", $gap_size);
1450  $gaptemplate->parseCurrentBlock();
1451  }
1452 
1453  $gaptemplate->setCurrentBlock('gap_input');
1454  $gaptemplate->setVariable('INPUT_SOLUTION', $solutiontext);
1455  }
1456 
1457 
1458  $gaptemplate->parseCurrentBlock();
1459  }
const CLOZE_SELECT
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateTextGapFormPart()

assClozeTestGUI::populateTextGapFormPart (   $form,
  $gap,
  $gapCounter 
)
protected

Populates the form-part for a text gap.

This includes: The AnswerWizardGUI for the individual text answers and points.

Parameters
$formilPropertyFormGUI Reference to the form, that receives the point.
$gapmixed Raw text gap item.
$gapCounterinteger Ordinal number of the gap in the sequence of gaps
Returns
ilPropertyFormGUI

Definition at line 705 of file class.assClozeTestGUI.php.

References ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilFormPropertyGUI\setRequired().

Referenced by populateGapFormPart().

706  {
707  // Choices
708  include_once "./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
709  include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
710  $values = new ilAnswerWizardInputGUI($this->lng->txt("values"), "gap_" . $gapCounter . "");
711  $values->setRequired(true);
712  $values->setQuestionObject($this->object);
713  $values->setSingleline(true);
714  $values->setAllowMove(false);
715  $values->setValues($gap->getItemsRaw());
716  $form->addItem($values);
717 
718  if ($this->object->getFixedTextLength() > 0) {
719  $values->setSize($this->object->getFixedTextLength());
720  $values->setMaxLength($this->object->getFixedTextLength());
721  }
722 
723  return $form;
724  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRequired(bool $a_required)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateTextOrSelectGapCorrectionFormProperty()

assClozeTestGUI::populateTextOrSelectGapCorrectionFormProperty (   $form,
  $gap,
  $gapIndex,
  $hidePoints 
)
protected

Definition at line 1658 of file class.assClozeTestGUI.php.

References $gapIndex, ILIAS\Repository\lng(), and ilAssAnswerCorrectionsInputGUI\setHidePointsEnabled().

Referenced by populateGapCorrectionFormProperties().

1658  : void
1659  {
1660  require_once "Modules/TestQuestionPool/classes/forms/class.ilAssAnswerCorrectionsInputGUI.php";
1661  $values = new ilAssAnswerCorrectionsInputGUI($this->lng->txt("values"), "gap_" . $gapIndex);
1662  $values->setHidePointsEnabled($hidePoints);
1663  $values->setRequired(true);
1664  $values->setQuestionObject($this->object);
1665  $values->setValues($gap->getItemsRaw());
1666  $form->addItem($values);
1667  }
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removegap()

assClozeTestGUI::removegap ( )

Remove a gap answer.

Definition at line 806 of file class.assClozeTestGUI.php.

References editQuestion(), and writePostData().

806  : void
807  {
808  $this->writePostData(true);
809  $this->object->deleteAnswerText($this->gapIndex, key($_POST['cmd']['removegap_' . $this->gapIndex]));
810  $this->editQuestion();
811  }
writePostData(bool $always=false)
{}
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
+ Here is the call graph for this function:

◆ removeIndizesFromGapText()

assClozeTestGUI::removeIndizesFromGapText (   $question_text)

Definition at line 1425 of file class.assClozeTestGUI.php.

References $parts.

Referenced by writePostData().

1425  : string
1426  {
1427  $parts = preg_split('/\[gap \d*\]/', $question_text);
1428  $question_text = implode('[gap]', $parts);
1429  return $question_text;
1430  }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

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

Definition at line 1705 of file class.assClozeTestGUI.php.

References $gapIndex, isUsedInCombinations(), ILIAS\Repository\object(), saveGapCombinationCorrectionFormProperties(), and saveGapCorrectionFormProperty().

1705  : void
1706  {
1707  foreach ($this->object->getGaps() as $gapIndex => $gap) {
1708  if ($this->isUsedInCombinations($gapIndex)) {
1709  continue;
1710  }
1711 
1712  $this->saveGapCorrectionFormProperty($form, $gap, $gapIndex);
1713  }
1714 
1715  if ($this->object->getGapCombinationsExists()) {
1717  }
1718  }
saveGapCorrectionFormProperty(ilPropertyFormGUI $form, assClozeGap $gap, $gapIndex)
saveGapCombinationCorrectionFormProperties(ilPropertyFormGUI $form)
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
+ Here is the call graph for this function:

◆ saveGapCombinationCorrectionFormProperties()

assClozeTestGUI::saveGapCombinationCorrectionFormProperties ( ilPropertyFormGUI  $form)
protected

Definition at line 1748 of file class.assClozeTestGUI.php.

References getGapCombinations(), ilPropertyFormGUI\getItemByPostVar(), and ILIAS\Repository\object().

Referenced by saveCorrectionsFormProperties().

1748  : void
1749  {
1750  // please dont ask (!) -.-
1751 
1752  $combinationPoints = array('points' => array(), 'select' => array());
1753  $combinationValues = array();
1754 
1755  foreach ($this->getGapCombinations() as $combiId => $combi) {
1756  $values = $form->getItemByPostVar('combination_' . $combiId)->getValues();
1757 
1758  if (!isset($combinationPoints['points'][$combiId])) {
1759  $combinationPoints['points'][$combiId] = array();
1760  $combinationPoints['select'][$combiId] = array();
1761  $combinationValues[$combiId] = array();
1762  }
1763 
1764  foreach ($combi as $varId => $variant) {
1765  $combinationPoints['points'][$combiId][$varId] = (float) str_replace(',', '.', $values[$varId]['points']);
1766  $combinationPoints['select'][$combiId] = array_keys($values[$varId]['gaps']);
1767  $combinationValues[$combiId][$varId] = array_values($values[$varId]['gaps']);
1768  }
1769  }
1770 
1771  $combinationPoints = $combinationPoints;
1772  $combinationValues = $combinationValues;
1773 
1774  $assClozeGapCombinationObject = new assClozeGapCombination();
1775  $assClozeGapCombinationObject->clearGapCombinationsFromDb($this->object->getId());
1776 
1777  $assClozeGapCombinationObject->saveGapCombinationToDb(
1778  $this->object->getId(),
1779  $combinationPoints,
1780  $combinationValues
1781  );
1782  }
getItemByPostVar(string $a_post_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveGapCorrectionFormProperty()

assClozeTestGUI::saveGapCorrectionFormProperty ( ilPropertyFormGUI  $form,
assClozeGap  $gap,
  $gapIndex 
)
protected

Definition at line 1720 of file class.assClozeTestGUI.php.

References $gapIndex, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, assClozeGap\getItemsRaw(), assClozeGap\getType(), saveNumericGapCorrectionFormProperty(), and saveTextOrSelectGapCorrectionFormProperty().

Referenced by saveCorrectionsFormProperties().

1720  : void
1721  {
1722  if ($gap->getType() == CLOZE_TEXT || $gap->getType() == CLOZE_SELECT) {
1724  } elseif ($gap->getType() == CLOZE_NUMERIC) {
1725  foreach ($gap->getItemsRaw() as $item) {
1726  $this->saveNumericGapCorrectionFormProperty($form, $item, $gapIndex);
1727  }
1728  }
1729  }
const CLOZE_TEXT
Cloze question constants.
getItemsRaw()
Gets the items of a cloze gap.
const CLOZE_SELECT
saveTextOrSelectGapCorrectionFormProperty(ilPropertyFormGUI $form, assClozeGap $gap, $gapIndex)
saveNumericGapCorrectionFormProperty(ilPropertyFormGUI $form, assAnswerCloze $item, $gapIndex)
const CLOZE_NUMERIC
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveNumericGapCorrectionFormProperty()

assClozeTestGUI::saveNumericGapCorrectionFormProperty ( ilPropertyFormGUI  $form,
assAnswerCloze  $item,
  $gapIndex 
)
protected

Definition at line 1740 of file class.assClozeTestGUI.php.

References $gapIndex, ilPropertyFormGUI\getInput(), ASS_AnswerSimple\setAnswertext(), assAnswerCloze\setLowerBound(), ASS_AnswerSimple\setPoints(), and assAnswerCloze\setUpperBound().

Referenced by saveGapCorrectionFormProperty().

1740  : void
1741  {
1742  $item->setAnswertext($form->getInput('gap_' . $gapIndex . '_numeric'));
1743  $item->setLowerBound($form->getInput('gap_' . $gapIndex . '_numeric_lower'));
1744  $item->setUpperBound($form->getInput('gap_' . $gapIndex . '_numeric_upper'));
1745  $item->setPoints((float) str_replace(',', '.', $form->getInput('gap_' . $gapIndex . '_numeric_points')));
1746  }
setPoints($points=0.0)
Sets the points.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
setUpperBound(string $bound)
Sets the upper bound.
setAnswertext($answertext="")
Sets the answer text.
setLowerBound(string $bound)
Sets the lower boind.
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveTextOrSelectGapCorrectionFormProperty()

assClozeTestGUI::saveTextOrSelectGapCorrectionFormProperty ( ilPropertyFormGUI  $form,
assClozeGap  $gap,
  $gapIndex 
)
protected

Definition at line 1731 of file class.assClozeTestGUI.php.

References $gapIndex, $index, ilPropertyFormGUI\getItemByPostVar(), and assClozeGap\getItemsRaw().

Referenced by saveGapCorrectionFormProperty().

1731  : void
1732  {
1733  $answers = $form->getItemByPostVar('gap_' . $gapIndex)->getValues();
1734 
1735  foreach ($gap->getItemsRaw() as $index => $item) {
1736  $item->setPoints((float) str_replace(',', '.', $answers[$index]->getPoints()));
1737  }
1738  }
getItemByPostVar(string $a_post_var)
$index
Definition: metadata.php:145
getItemsRaw()
Gets the items of a cloze gap.
$gapIndex
A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeAnswerSpecificPostData()

assClozeTestGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiAnswerScoringAdjustable.

Definition at line 156 of file class.assClozeTestGUI.php.

References CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, ILIAS\Repository\ctrl(), ILIAS\Repository\object(), and ILIAS\Repository\refinery().

Referenced by writePostData().

156  : void
157  {
158  if (!$this->post->has('gap')) {
159  return;
160  }
161 
162  $gaps = $this->post->retrieve(
163  "gap",
164  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
165  );
166 
167  if ($this->ctrl->getCmd() !== 'createGaps') {
168  $this->object->clearGapAnswers();
169  }
170 
171  foreach ($gaps as $idx => $hidden) {
172  $clozetype = $this->post->retrieve(
173  "clozetype_" . $idx,
174  $this->refinery->kindlyTo()->string()
175  );
176 
177  $this->object->setGapType($idx, $clozetype);
178 
179  switch ($clozetype) {
180  case CLOZE_TEXT:
181 
182  $this->object->setGapShuffle($idx, 0);
183 
184  if ($this->ctrl->getCmd() != 'createGaps') {
185  if (is_array($_POST['gap_' . $idx]['answer'])) {
186  foreach ($_POST['gap_' . $idx]['answer'] as $order => $value) {
187  $this->object->addGapAnswer($idx, $order, $value);
188  }
189  } else {
190  $this->object->addGapAnswer($idx, 0, '');
191  }
192  }
193 
194  if (is_array($_POST['gap_' . $idx]['points'])) {
195  foreach ($_POST['gap_' . $idx]['points'] as $order => $value) {
196  $this->object->setGapAnswerPoints($idx, $order, $value);
197  }
198  }
199 
200  $k_gapsize = 'gap_' . $idx . '_gapsize';
201  if ($this->request->isset($k_gapsize)) {
202  $this->object->setGapSize($idx, $_POST[$k_gapsize]);
203  }
204  break;
205 
206  case CLOZE_SELECT:
207 
208  $this->object->setGapShuffle($idx, (int) (isset($_POST["shuffle_$idx"]) && $_POST["shuffle_$idx"]));
209 
210  if ($this->ctrl->getCmd() != 'createGaps') {
211  if (is_array($_POST['gap_' . $idx]['answer'])) {
212  foreach ($_POST['gap_' . $idx]['answer'] as $order => $value) {
213  $this->object->addGapAnswer($idx, $order, $value);
214  }
215  } else {
216  $this->object->addGapAnswer($idx, 0, '');
217  }
218  }
219 
220  if (is_array($_POST['gap_' . $idx]['points'])) {
221  foreach ($_POST['gap_' . $idx]['points'] as $order => $value) {
222  $this->object->setGapAnswerPoints($idx, $order, $value);
223  }
224  }
225  break;
226 
227  case CLOZE_NUMERIC:
228 
229  $this->object->setGapShuffle($idx, 0);
230 
231  $gap = $this->object->getGap($idx);
232  if (!$gap) {
233  break;
234  }
235 
236  $this->object->getGap($idx)->clearItems();
237 
238  if ($this->post->has('gap_' . $idx . '_numeric')) {
239  if ($this->ctrl->getCmd() !== 'createGaps') {
240  $this->object->addGapAnswer(
241  $idx,
242  0,
243  str_replace(",", ".", $_POST['gap_' . $idx . '_numeric'])
244  );
245  }
246 
247  $this->object->setGapAnswerLowerBound(
248  $idx,
249  0,
250  str_replace(",", ".", $_POST['gap_' . $idx . '_numeric_lower'])
251  );
252 
253  $this->object->setGapAnswerUpperBound(
254  $idx,
255  0,
256  str_replace(",", ".", $_POST['gap_' . $idx . '_numeric_upper'])
257  );
258 
259  $this->object->setGapAnswerPoints($idx, 0, $_POST['gap_' . $idx . '_numeric_points']);
260  } else {
261  if ($this->ctrl->getCmd() != 'createGaps') {
262  $this->object->addGapAnswer($idx, 0, '');
263  }
264 
265  $this->object->setGapAnswerLowerBound($idx, 0, '');
266 
267  $this->object->setGapAnswerUpperBound($idx, 0, '');
268  }
269 
270  if ($this->post->has('gap_' . $idx . '_gapsize')) {
271  $this->object->setGapSize($idx, $_POST['gap_' . $idx . '_gapsize']);
272  }
273  break;
274  }
275  $assClozeGapCombinationObject = new assClozeGapCombination();
276  $assClozeGapCombinationObject->clearGapCombinationsFromDb($this->object->getId());
277  if (
278  isset($_POST['gap_combination']) &&
279  is_array($_POST['gap_combination']) &&
280  count($_POST['gap_combination']) > 0
281  ) {
282  $assClozeGapCombinationObject->saveGapCombinationToDb(
283  $this->object->getId(),
284  $_POST['gap_combination'],
285  $_POST['gap_combination_values']
286  );
287  }
288  }
289  if ($this->ctrl->getCmd() != 'createGaps') {
290  $this->object->updateClozeTextFromGaps();
291  }
292  }
const CLOZE_TEXT
Cloze question constants.
const CLOZE_SELECT
const CLOZE_NUMERIC
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

assClozeTestGUI::writePostData ( bool  $always = false)
protected

{}

Definition at line 129 of file class.assClozeTestGUI.php.

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

Referenced by addgap(), createGaps(), and removegap().

129  : int
130  {
131  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
132  if (!$hasErrors) {
133  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
134 
135  $cloze_text = $this->removeIndizesFromGapText(
136  $this->request->raw('cloze_text')
137  );
138 
139  $this->object->setQuestion(
140  $this->request->raw('question')
141  );
142 
144  $this->object->setClozeText($cloze_text);
145  $this->object->setTextgapRating($this->request->raw('textgap_rating'));
146  $this->object->setIdenticalScoring((bool) ($this->request->raw('identical_scoring') ?? false));
147  $this->object->setFixedTextLength(($this->request->int('fixedTextLength') ?? 0));
149  $this->saveTaxonomyAssignments();
150  return 0;
151  }
152 
153  return 1;
154  }
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
removeIndizesFromGapText($question_text)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeQuestionSpecificPostData()

assClozeTestGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

Definition at line 294 of file class.assClozeTestGUI.php.

294  : void
295  {
296  $this->object->setClozeText($_POST['cloze_text']);
297  $this->object->setTextgapRating($_POST["textgap_rating"]);
298  $this->object->setIdenticalScoring($_POST["identical_scoring"]);
299  $this->object->setFixedTextLength($_POST["fixedTextLength"]);
300  }

Field Documentation

◆ $dic

Container assClozeTestGUI::$dic
private

Definition at line 92 of file class.assClozeTestGUI.php.

◆ $gapIndex

◆ $post

ArrayBasedRequestWrapper assClozeTestGUI::$post
private

Definition at line 94 of file class.assClozeTestGUI.php.

◆ $randomGroup

RandomGroup assClozeTestGUI::$randomGroup
private

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

◆ $refinery

Factory assClozeTestGUI::$refinery
private

Definition at line 93 of file class.assClozeTestGUI.php.

◆ JS

assClozeTestGUI::JS

Definition at line 84 of file class.assClozeTestGUI.php.

◆ JS_INSERT_GAP_CODE_AT_CARET

const assClozeTestGUI::JS_INSERT_GAP_CODE_AT_CARET

Definition at line 45 of file class.assClozeTestGUI.php.

◆ OLD_CLOZE_TEST_UI

const assClozeTestGUI::OLD_CLOZE_TEST_UI = false

Definition at line 43 of file class.assClozeTestGUI.php.


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