ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 the request and applies them to the data object. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from the request and applies them to the data object. More...
 
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 Creates an output of the edit form for the question. More...
 
 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 ()
 
 addgap ()
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getGenericFeedbackOutput (int $active_id, $pass)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 getSpecificFeedbackOutput (array $user_solution)
 
 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
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getObject ()
 
 setObject (assQuestion $question)
 
 setCopyToExistingPoolOnSave (?int $pool_ref_id)
 
 getCopyToExistingPoolOnSave ()
 
 setCopyToNewPoolOnSave (?string $pool_title)
 
 getCopyToNewPoolOnSave ()
 
 setMoveAfterQuestionId (?int $question_id)
 
 getMoveAfterQuestionId ()
 
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getCommentsPanelHTML ()
 
 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 (string $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)
 
 syncQuestion ()
 
 saveReturn ()
 
 saveQuestion ()
 
 setAdditionalContentEditingModeFromPost ()
 
 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)
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 outQuestionType ()
 
 saveSuggestedSolution ()
 
 cancelSuggestedSolution ()
 
 suggestedsolution (bool $save=false)
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $classname)
 
 getEditQuestionTabCommands ()
 
 isAutosaveable ()
 
 outQuestionForTest (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 getPreviewSession ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 
 cmdNeedsExistingQuestion (string $cmd)
 
 setContextAllowsSyncToPool (bool $sync_allowed)
 
 needsSyncQuery ()
 
 getQuestionSyncModal (string $cmd, string $cmd_class='')
 
 getAutoSavedSolutionOutput (int $active_id, int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false)
 

Data Fields

const JS_INSERT_GAP_CODE_AT_CARET
 
 JS
 
- Data Fields inherited from assQuestionGUI
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'
 
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 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'
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const CMD_SYNC_QUESTION_AND_RETURN = 'syncQuestionReturn'
 

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 ()
 
 setTestSpecificProperties ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (string $feedback_correct, string $feedback_incorrect, int $active_id, ?int $pass)
 
 getTypeOptions ()
 
 createSuggestedSolutionLinkingTo (string $type, string $target)
 
 setDefaultTabs (ilTabsGUI $tabs_gui)
 
 setQuestionSpecificTabs (ilTabsGUI $tabs_gui)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabs_gui)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction (string $form_action, int $active_id, int $pass)
 
 addBackTab (ilTabsGUI $tabs_gui)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 getSuggestedSolutionsRepo ()
 
 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

 hasErrorInGapCombinationPoints (array $gap_combinations)
 
 getAddGapButtonClickClosure (string $gap_type)
 
 populateSolutiontextToGapTpl ($gaptemplate, $gap, $solutiontext)
 

Private Attributes

 $gapIndex
 A temporary variable to store gap indexes of ilCtrl commands in the getCommand method. More...
 
RandomGroup $randomGroup
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 
ilDBInterface $db
 

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 getCommandsFromClassConstants (string $guiClassName, string $cmdConstantNameBegin='CMD_')
 
static prepareTextareaOutput (?string $txt_output, bool $prepare_for_latex_output=false, bool $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 HAS_SPECIAL_QUESTION_COMMANDS = false
 
const SUGGESTED_SOLUTION_COMMANDS_CANCEL = 'cancelSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_SAVE = 'saveSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_DEFAULT = 'suggestedsolution'
 
const QUESTION_SAVE_CMDS
 
const ADDITIONAL_CMDS_NEEDING_EXISTING_QST
 There are functions that need an existing question. More...
 
ilLogger $logger
 
GeneralQuestionPropertiesRepository $questionrepository
 
GUIService $notes_gui
 
ilCtrl $ctrl
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
Refinery $refinery
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $question_count
 question count in test More...
 
ilPropertyFormGUI $editForm = null
 
readonly ilTestLegacyFormsHelper $forms_helper
 
readonly RequestDataCollector $request_data_collector
 
bool $parent_type_is_lm = false
 
SuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

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 39 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 96 of file class.assClozeTestGUI.php.

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

97  {
99  global $DIC;
100  $this->ui_factory = $DIC['ui.factory'];
101  $this->ui_renderer = $DIC['ui.renderer'];
102  $this->db = $DIC['ilDB'];
103 
104  $this->object = new assClozeTest();
105  if ($id >= 0) {
106  $this->object->loadFromDb($id);
107  }
108 
109  $this->randomGroup = $this->refinery->random();
110  }
Class for cloze tests.
global $DIC
Definition: shib_login.php:22
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addgap()

assClozeTestGUI::addgap ( )

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

References editQuestion(), assQuestionGUI\setAdditionalContentEditingModeFromPost(), and writePostData().

715  : void
716  {
718  $this->writePostData(true);
719  $this->object->addGapAnswer(
720  $this->gapIndex,
721  $this->request_data_collector->getCmdIndex('addgap_' . $this->gapIndex) + 1,
722  ''
723  );
724  $this->editQuestion();
725  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
Creates an output of the edit form for the question.
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ applyIndizesToGapText()

assClozeTestGUI::applyIndizesToGapText (   $question_text)

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

References $parts.

Referenced by populateQuestionSpecificFormPart().

1312  : string
1313  {
1314  $parts = explode('[gap', $question_text);
1315  $i = 0;
1316  $question_text = '';
1317  foreach ($parts as $part) {
1318  if ($i == 0) {
1319  $question_text .= $part;
1320  } else {
1321  $question_text .= '[gap ' . $i . $part;
1322  }
1323  $i++;
1324  }
1325  return $question_text;
1326  }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
+ Here is the caller graph for this function:

◆ completeAddAnswerAction()

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

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

References assClozeGap\TYPE_TEXT.

Referenced by getAnswersFrequency().

1419  : array
1420  {
1421  $gap = $this->object->getGap($gap_index);
1422 
1423  if ($gap->type != assClozeGap::TYPE_TEXT ||
1424  $this->isUsedInCombinations($gap_index)) {
1425  return $answers;
1426  }
1427 
1428  foreach ($answers as $key => $ans) {
1429  $found = false;
1430 
1431  foreach ($gap->getItems($this->randomGroup->dontShuffle()) as $item) {
1432  if ($ans['answer'] !== $item->getAnswerText()) {
1433  continue;
1434  }
1435 
1436  $found = true;
1437  break;
1438  }
1439 
1440  if (!$found) {
1441  $answers[$key]['addable'] = true;
1442  }
1443  }
1444 
1445  return $answers;
1446  }
+ Here is the caller graph for this function:

◆ createGaps()

assClozeTestGUI::createGaps ( )

Create gaps from cloze text.

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

References editQuestion(), assQuestionGUI\setAdditionalContentEditingModeFromPost(), and writePostData().

696  : void
697  {
699  $this->writePostData(true);
700  $this->object->saveToDb();
701  $this->editQuestion();
702  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
Creates an output of the edit form for the question.
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ editQuestion()

assClozeTestGUI::editQuestion ( bool  $checkonly = false,
?bool  $is_save_cmd = null 
)

Creates an output of the edit form for the question.

public

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

References assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), ILIAS\Repository\ctrl(), hasErrorInGapCombinationPoints(), assQuestionGUI\isSaveCommand(), ILIAS\Repository\lng(), assQuestionGUI\outQuestionType(), populateAnswerSpecificFormPart(), populateQuestionSpecificFormPart(), assQuestionGUI\populateTaxonomyFormSection(), and assQuestionGUI\renderEditForm().

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

264  : bool {
265  $save = $is_save_cmd ?? $this->isSaveCommand();
266 
267  $form = new ilPropertyFormGUI();
268  $this->editForm = $form;
269 
270  $form->setFormAction($this->ctrl->getFormAction($this));
271  $form->setTitle($this->outQuestionType());
272  $form->setMultipart(false);
273  $form->setTableWidth("100%");
274  $form->setId("assclozetest");
275 
276  $this->addBasicQuestionFormProperties($form);
277  $this->populateQuestionSpecificFormPart($form);
278  $this->populateAnswerSpecificFormPart($form);
279  $this->populateTaxonomyFormSection($form);
280 
281  $this->addQuestionFormCommandButtons($form);
282 
283  $errors = false;
284 
285  if ($save) {
286  $form->setValuesByPost();
287  $errors = !$form->checkInput();
288  $form->setValuesByPost();
289 
290  $gap_combinations = $this->request_data_collector->raw('gap_combination');
291  if (is_array($gap_combinations)
292  && $gap_combinations !== []
293  && $this->hasErrorInGapCombinationPoints($gap_combinations)) {
294  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('points_non_numeric_or_negative_msg'));
295  $errors = true;
296  }
297 
298  if ($errors) {
299  $checkonly = false;
300  }
301  }
302 
303  if (!$checkonly) {
304  $this->renderEditForm($form);
305  }
306  return $errors;
307  }
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
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.
hasErrorInGapCombinationPoints(array $gap_combinations)
renderEditForm(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAddGapButtonClickClosure()

assClozeTestGUI::getAddGapButtonClickClosure ( string  $gap_type)
private

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

References $id.

Referenced by populateQuestionSpecificFormPart().

412  : Closure
413  {
414  return fn($id) => "var el = document.getElementById('{$id}').addEventListener('click', "
415  . '(e) => {'
416  . ' e.preventDefault();'
417  . " ClozeQuestionGapBuilder.addGapClickFunction('{$gap_type}');"
418  . '});';
419  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ 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 1211 of file class.assClozeTestGUI.php.

1211  : array
1212  {
1213  return [];
1214  }

◆ 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 1225 of file class.assClozeTestGUI.php.

References ILIAS\Repository\object(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

1225  : array
1226  {
1227  return [];
1228  }
+ Here is the call graph for this function:

◆ getAnswerFrequencyTableGUI()

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

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

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

1376  {
1377  $table = parent::getAnswerFrequencyTableGUI(
1378  $parentGui,
1379  $parentCmd,
1380  $relevantAnswers,
1381  $questionIndex
1382  );
1383 
1384  $table->setTitle(
1385  sprintf(
1386  $this->lng->txt('tst_corrections_answers_tbl_subindex'),
1387  $this->lng->txt('gap') . ' ' . ($questionIndex + 1)
1388  )
1389  );
1390 
1391  if ($this->hasAddAnswerAction($relevantAnswers, $questionIndex)) {
1392  $table->addColumn('', '', '200');
1393  }
1394 
1395  return $table;
1396  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
hasAddAnswerAction($relevantAnswers, $questionIndex)
+ Here is the call graph for this function:

◆ getAnswersFrequency()

assClozeTestGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

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

References completeAddAnswerAction(), and getAnswerTextLabel().

Referenced by hasAddAnswerAction().

1448  : array
1449  {
1450  $answers = [];
1451 
1452  foreach ($relevantAnswers as $row) {
1453  if ($row['value1'] != $questionIndex) {
1454  continue;
1455  }
1456 
1457  if (!isset($answers[$row['value2']])) {
1458  $label = $this->getAnswerTextLabel($row['value1'], $row['value2']);
1459 
1460  $answers[$row['value2']] = [
1461  'answer' => $label, 'frequency' => 0
1462  ];
1463  }
1464 
1465  $answers[$row['value2']]['frequency']++;
1466  }
1467 
1468  $answers = $this->completeAddAnswerAction($answers, $questionIndex);
1469 
1470  return $answers;
1471  }
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 1403 of file class.assClozeTestGUI.php.

References $gapIndex, assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

Referenced by getAnswersFrequency().

1404  {
1405  $gap = $this->object->getGap($gapIndex);
1406 
1407  switch ($gap->type) {
1410  return $answer;
1411 
1413  default:
1414  $items = $gap->getItems($this->randomGroup->dontShuffle());
1415  return $items[$answer]->getAnswertext();
1416  }
1417  }
$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 1040 of file class.assClozeTestGUI.php.

References null, and ilLegacyFormElementsUtil\prepareFormOutput().

Referenced by renderSolutionOutput().

1040  : string
1041  {
1042  $combination = null;
1043  foreach ((array) $gap_combinations as $combiGapSolRow) {
1044  if ($combiGapSolRow['gap_fi'] == $gap_index && $combiGapSolRow['best_solution']) {
1045  $combination = $combiGapSolRow;
1046  break;
1047  }
1048  }
1049  $best_solution_text = ilLegacyFormElementsUtil::prepareFormOutput(
1050  $gap->getBestSolutionOutput(
1051  $this->object->getShuffler(),
1052  $combination
1053  )
1054  );
1055  return $best_solution_text;
1056  }
static prepareFormOutput($a_str, bool $a_strip=false)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCommand()

assClozeTestGUI::getCommand (   $cmd)

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

113  {
114  if (preg_match("/^(removegap|addgap)_(\d+)$/", $cmd, $matches)) {
115  $cmd = $matches[1];
116  $this->gapIndex = $matches[2];
117  }
118  return $cmd;
119  }

◆ getGapCombinations()

assClozeTestGUI::getGapCombinations ( )
protected

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

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

Referenced by populateCorrectionsFormProperties(), and saveGapCombinationCorrectionFormProperties().

1486  : array
1487  {
1488  $combinations = [];
1489 
1490  foreach ($this->object->getGapCombinations() as $c) {
1491  if (!isset($combinations[$c['cid']])) {
1492  $combinations[$c['cid']] = [];
1493  }
1494 
1495  if (!isset($combinations[$c['cid']][$c['row_id']])) {
1496  $combinations[$c['cid']][$c['row_id']] = [
1497  'gaps' => [], 'points' => $c['points'],
1498  ];
1499  }
1500 
1501  if (!isset($combinations[$c['cid']][$c['row_id']]['gaps'][$c['gap_fi']])) {
1502  $combinations[$c['cid']][$c['row_id']]['gaps'][$c['gap_fi']] = [];
1503  }
1504 
1505  $combinations[$c['cid']][$c['row_id']]['gaps'][$c['gap_fi']] = $c['answer'];
1506  }
1507 
1508  return $combinations;
1509  }
$c
Definition: deliver.php:25
+ 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 1058 of file class.assClozeTestGUI.php.

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

Referenced by renderSolutionOutput().

1058  : string
1059  {
1060  $manual_feedback = ilObjTest::getManualFeedback($active_id, $this->object->getId(), $pass);
1061  if (strlen($manual_feedback)) {
1062  return $manual_feedback;
1063  }
1064  $correct_feedback = $this->object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(), true);
1065  $incorrect_feedback = $this->object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(), false);
1066 
1067  $output = '';
1068  if ($correct_feedback . $incorrect_feedback !== '') {
1069  $output = $this->genericFeedbackOutputBuilder($correct_feedback, $incorrect_feedback, $active_id, $pass);
1070  }
1071  //$test = new ilObjTest($this->object->active_id);
1073  }
genericFeedbackOutputBuilder(string $feedback_correct, string $feedback_incorrect, int $active_id, ?int $pass)
static getManualFeedback(int $active_id, int $question_id, ?int $pass)
Retrieves the feedback comment for a question in a test if it is finalized.
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPreview()

assClozeTestGUI::getPreview ( bool  $show_question_only = false,
bool  $show_inline_feedback = false 
)

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

References assQuestionGUI\getILIASPage(), assQuestionGUI\getPreviewSession(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilLegacyFormElementsUtil\prepareFormOutput(), ilLegacyFormElementsUtil\prepareTextareaOutput(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

730  : string {
731  $user_solution = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : [];
732 
733  $template = new ilTemplate("tpl.il_as_qpl_cloze_question_output.html", true, true, "components/ILIAS/TestQuestionPool");
734  $output = $this->object->getClozeTextForHTMLOutput();
735  foreach ($this->object->getGaps() as $gap_index => $gap) {
736  switch ($gap->getType()) {
738  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_text.html", true, true, "components/ILIAS/TestQuestionPool");
739 
740  $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->object->getFixedTextLength();
741  if ($gap_size > 0) {
742  $gaptemplate->setCurrentBlock('size_and_maxlength');
743  $gaptemplate->setVariable("TEXT_GAP_SIZE", $gap_size);
744  $gaptemplate->parseCurrentBlock();
745  }
746  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
747  foreach ($user_solution as $val1 => $val2) {
748  if (strcmp($val1, $gap_index) == 0) {
749  $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput(
750  $val2
751  ) . "\"");
752  }
753  }
754  // fau: fixGapReplace - use replace function
755  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
756  // fau.
757  break;
759  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_select.html", true, true, "components/ILIAS/TestQuestionPool");
760  foreach ($gap->getItems($this->object->getShuffler(), $gap_index) as $item) {
761  $gaptemplate->setCurrentBlock("select_gap_option");
762  $gaptemplate->setVariable("SELECT_GAP_VALUE", $item->getOrder());
763  $gaptemplate->setVariable(
764  "SELECT_GAP_TEXT",
765  ilLegacyFormElementsUtil::prepareFormOutput($item->getAnswerText())
766  );
767  foreach ($user_solution as $val1 => $val2) {
768  if (strcmp($val1, $gap_index) == 0) {
769  if (strcmp($val2, $item->getOrder()) == 0) {
770  $gaptemplate->setVariable("SELECT_GAP_SELECTED", " selected=\"selected\"");
771  }
772  }
773  }
774  $gaptemplate->parseCurrentBlock();
775  }
776  $gaptemplate->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
777  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);// fau: fixGapReplace - use replace function
778  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
779  // fau.
780  break;
782  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_numeric.html", true, true, "components/ILIAS/TestQuestionPool");
783  $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->object->getFixedTextLength();
784  if ($gap_size > 0) {
785  $gaptemplate->setCurrentBlock('size_and_maxlength');
786  $gaptemplate->setVariable("TEXT_GAP_SIZE", $gap_size);
787  $gaptemplate->parseCurrentBlock();
788  }
789  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
790  foreach ($user_solution as $val1 => $val2) {
791  if (strcmp($val1, $gap_index) == 0) {
792  $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput(
793  $val2
794  ) . "\"");
795  }
796  }
797  // fau: fixGapReplace - use replace function
798  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
799  // fau.
800  break;
801  }
802  }
803  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
804  $template->setVariable("CLOZETEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($output, true));
805  $questionoutput = $template->get();
806  if (!$show_question_only) {
807  // get page object output
808  $questionoutput = $this->getILIASPage($questionoutput);
809  }
810  return $questionoutput;
811  }
static prepareFormOutput($a_str, bool $a_strip=false)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:

◆ getSolutionOutput()

assClozeTestGUI::getSolutionOutput ( int  $active_id,
?int  $pass = null,
bool  $graphical_output = false,
bool  $result_output = false,
bool  $show_question_only = true,
bool  $show_feedback = false,
bool  $show_correct_solution = false,
bool  $show_manual_scoring = false,
bool  $show_question_text = true,
bool  $show_inline_feedback = true 
)

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

References renderSolutionOutput().

824  : string {
825  $user_solution = [];
826  if (($active_id > 0) && (!$show_correct_solution)) {
827  $user_solution = $this->object->getSolutionValues($active_id, $pass);
828  if (!is_array($user_solution)) {
829  $user_solution = [];
830  }
831  }
832 
833  return $this->renderSolutionOutput(
834  $user_solution,
835  $active_id,
836  $pass,
837  $graphical_output,
838  $result_output,
839  $show_question_only,
840  $show_feedback,
841  $show_correct_solution,
842  $show_manual_scoring,
843  $show_question_text,
844  false,
845  false
846  );
847  }
renderSolutionOutput(mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assClozeTestGUI::getSpecificFeedbackOutput ( array  $user_solution)

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

References ILIAS\Repository\lng(), ILIAS\Repository\object(), ilLegacyFormElementsUtil\prepareTextareaOutput(), and assClozeGap\TYPE_TEXT.

Referenced by renderSolutionOutput().

1175  : string
1176  {
1177  if (!$this->object->feedbackOBJ->isSpecificAnswerFeedbackAvailable($this->object->getId())) {
1178  return '';
1179  }
1180 
1181  $feedback = '<table class="test_specific_feedback"><tbody>';
1182 
1183  foreach ($this->object->gaps as $gap_index => $gap) {
1184  $answer_value = $this->object->fetchAnswerValueForGap($user_solution, $gap_index);
1185  if ($gap->getType() !== assClozeGap::TYPE_TEXT
1186  && $answer_value === '') {
1187  continue;
1188  }
1189  $answer_index = $this->object->feedbackOBJ->determineAnswerIndexForAnswerValue($gap, $answer_value);
1190  $fb = $this->object->feedbackOBJ->determineTestOutputGapFeedback($gap_index, $answer_index);
1191 
1192  $caption = $this->lng->txt('gap') . ' ' . ($gap_index + 1) . ': ';
1193  $feedback .= '<tr><td>';
1194  $feedback .= $caption . '</td><td>';
1195  $feedback .= $fb . '</td> </tr>';
1196  }
1197  $feedback .= '</tbody></table>';
1198 
1199  return ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true);
1200  }
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubQuestionsIndex()

assClozeTestGUI::getSubQuestionsIndex ( )

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

References ILIAS\Repository\object().

1398  : array
1399  {
1400  return array_keys($this->object->getGaps());
1401  }
+ Here is the call graph for this function:

◆ getTestOutput()

assClozeTestGUI::getTestOutput ( int  $active_id,
int  $pass,
bool  $is_question_postponed = false,
array|bool  $user_post_solutions = false,
bool  $show_specific_inline_feedback = false 
)

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

References ILIAS\Repository\lng(), ILIAS\Repository\object(), assQuestionGUI\outQuestionPage(), ilLegacyFormElementsUtil\prepareFormOutput(), ilLegacyFormElementsUtil\prepareTextareaOutput(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

1081  : string {
1082  // get the solution of the user for the active pass or from the last pass if allowed
1083  $user_solution = [];
1084  if ($user_post_solutions !== false) {
1085  $indexedSolution = $this->object->fetchSolutionSubmit();
1086  $user_solution = $this->object->fetchValuePairsFromIndexedValues($indexedSolution);
1087  } elseif ($active_id) {
1088  $user_solution = $this->object->getTestOutputSolutions($active_id, $pass);
1089  // hey.
1090  if (!is_array($user_solution)) {
1091  $user_solution = [];
1092  }
1093  }
1094 
1095  $template = new ilTemplate("tpl.il_as_qpl_cloze_question_output.html", true, true, "components/ILIAS/TestQuestionPool");
1096  $output = $this->object->getClozeTextForHTMLOutput();
1097  foreach ($this->object->getGaps() as $gap_index => $gap) {
1098  switch ($gap->getType()) {
1100  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_text.html", true, true, "components/ILIAS/TestQuestionPool");
1101  $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->object->getFixedTextLength();
1102 
1103  if ($gap_size > 0) {
1104  $gaptemplate->setCurrentBlock('size_and_maxlength');
1105  $gaptemplate->setVariable("TEXT_GAP_SIZE", $gap_size);
1106  $gaptemplate->parseCurrentBlock();
1107  }
1108 
1109  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
1110  foreach ($user_solution as $solution) {
1111  if (strcmp($solution["value1"], $gap_index) == 0) {
1112  $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput(
1113  $solution["value2"]
1114  ) . "\"");
1115  }
1116  }
1117  // fau: fixGapReplace - use replace function
1118  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
1119  // fau.
1120  break;
1122  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_select.html", true, true, "components/ILIAS/TestQuestionPool");
1123  foreach ($gap->getItems($this->object->getShuffler(), $gap_index) as $item) {
1124  $gaptemplate->setCurrentBlock("select_gap_option");
1125  $gaptemplate->setVariable("SELECT_GAP_VALUE", $item->getOrder());
1126  $gaptemplate->setVariable(
1127  "SELECT_GAP_TEXT",
1128  ilLegacyFormElementsUtil::prepareFormOutput($item->getAnswerText())
1129  );
1130  foreach ($user_solution as $solution) {
1131  if (strcmp($solution["value1"], $gap_index) == 0) {
1132  if (strcmp($solution["value2"], $item->getOrder()) == 0) {
1133  $gaptemplate->setVariable("SELECT_GAP_SELECTED", " selected=\"selected\"");
1134  }
1135  }
1136  }
1137  $gaptemplate->parseCurrentBlock();
1138  }
1139  $gaptemplate->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
1140  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);// fau: fixGapReplace - use replace function
1141  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
1142  // fau.
1143  break;
1145  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_numeric.html", true, true, "components/ILIAS/TestQuestionPool");
1146  $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->object->getFixedTextLength();
1147  if ($gap_size > 0) {
1148  $gaptemplate->setCurrentBlock('size_and_maxlength');
1149  $gaptemplate->setVariable("TEXT_GAP_SIZE", $gap_size);
1150  $gaptemplate->parseCurrentBlock();
1151  }
1152 
1153  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
1154  foreach ($user_solution as $solution) {
1155  if (strcmp($solution["value1"], $gap_index) == 0) {
1156  $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput(
1157  $solution["value2"]
1158  ) . "\"");
1159  }
1160  }
1161  // fau: fixGapReplace - use replace function
1162  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
1163  // fau.
1164  break;
1165  }
1166  }
1167 
1168  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
1169  $template->setVariable("CLOZETEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($output, true));
1170  $questionoutput = $template->get();
1171  $pageoutput = $this->outQuestionPage("", $is_question_postponed, $active_id, $questionoutput);
1172  return $pageoutput;
1173  }
static prepareFormOutput($a_str, bool $a_strip=false)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:

◆ hasAddAnswerAction()

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

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

References getAnswersFrequency().

Referenced by getAnswerFrequencyTableGUI().

1364  : bool
1365  {
1366  foreach ($this->getAnswersFrequency($relevantAnswers, $questionIndex) as $answer) {
1367  if (isset($answer['actions'])) {
1368  return true;
1369  }
1370  }
1371 
1372  return false;
1373  }
getAnswersFrequency($relevantAnswers, $questionIndex)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasErrorInGapCombinationPoints()

assClozeTestGUI::hasErrorInGapCombinationPoints ( array  $gap_combinations)
private

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

Referenced by editQuestion().

309  : bool
310  {
311  foreach ($gap_combinations['points'] as $gaps_points) {
312  foreach ($gaps_points as $points) {
313  $points_standardized = str_replace(',', '.', $points);
314  if (!is_numeric($points_standardized)
315  || (float) $points_standardized < 0) {
316  return true;
317  }
318  }
319  }
320 
321  return false;
322  }
+ Here is the caller graph for this function:

◆ isUsedInCombinations()

assClozeTestGUI::isUsedInCombinations (   $gapIndex)
protected

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

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

Referenced by populateCorrectionsFormProperties(), and saveCorrectionsFormProperties().

1473  : bool
1474  {
1475  foreach ($this->object->getGapCombinations() as $combination) {
1476  if ($combination['gap_fi'] != $gapIndex) {
1477  continue;
1478  }
1479 
1480  return true;
1481  }
1482 
1483  return false;
1484  }
$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 421 of file class.assClozeTestGUI.php.

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

Referenced by editQuestion().

422  {
423  $json = $this->populateJSON();
424  $assClozeGapCombinationObject = new assClozeGapCombination($this->db);
425  $combination_exists = $assClozeGapCombinationObject->combinationExistsForQid($this->object->getId());
426  $combinations = [];
427  if ($combination_exists) {
428  $combinations = $assClozeGapCombinationObject->loadFromDb($this->object->getId());
429  }
430  $new_builder = new ilClozeGapInputBuilderGUI();
431  $header = new ilFormSectionHeaderGUI();
432  $form->addItem($header);
433  $new_builder->setValueByArray($json);
434  $new_builder->setValueCombinationFromDb($combinations);
435  $form->addItem($new_builder);
436  return $form;
437  }
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 1511 of file class.assClozeTestGUI.php.

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

1511  : void
1512  {
1513  foreach ($this->object->getGaps() as $gapIndex => $gap) {
1515  $form,
1516  $gap,
1517  $gapIndex,
1518  $this->isUsedInCombinations($gapIndex)
1519  );
1520  }
1521 
1522  if ($this->object->getGapCombinationsExists()) {
1523  foreach ($this->getGapCombinations() as $combiIndex => $gapCombination) {
1524  $this->populateGapCombinationCorrectionFormProperty($form, $gapCombination, $combiIndex);
1525  }
1526  }
1527  }
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 1529 of file class.assClozeTestGUI.php.

References ilPropertyFormGUI\addItem().

Referenced by populateCorrectionsFormProperties().

1529  : void
1530  {
1531  $header = new ilFormSectionHeaderGUI();
1532  $header->setTitle("Gap Combination " . ($combiIndex + 1));
1533  $form->addItem($header);
1534 
1535  $inp = new ilAssClozeTestCombinationVariantsInputGUI('Answers', 'combination_' . $combiIndex);
1536  $inp->setValues($gapCombi);
1537  $form->addItem($inp);
1538  }
+ 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 1545 of file class.assClozeTestGUI.php.

References $gapIndex, ILIAS\Repository\lng(), populateNumericGapCorrectionFormProperty(), populateTextOrSelectGapCorrectionFormProperty(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

Referenced by populateCorrectionsFormProperties().

1545  : void
1546  {
1547  $header = new ilFormSectionHeaderGUI();
1548  $header->setTitle($this->lng->txt("gap") . " " . ($gapIndex + 1));
1549  $form->addItem($header);
1550 
1551  if ($gap->getType() == assClozeGap::TYPE_TEXT || $gap->getType() == assClozeGap::TYPE_SELECT) {
1552  $this->populateTextOrSelectGapCorrectionFormProperty($form, $gap, $gapIndex, $hidePoints);
1553  } elseif ($gap->getType() == assClozeGap::TYPE_NUMERIC) {
1554  foreach ($gap->getItemsRaw() as $item) {
1555  $this->populateNumericGapCorrectionFormProperty($form, $item, $gapIndex, $hidePoints);
1556  }
1557  }
1558  }
populateNumericGapCorrectionFormProperty($form, $item, $gapIndex, $hidePoints)
populateTextOrSelectGapCorrectionFormProperty($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:
+ 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 494 of file class.assClozeTestGUI.php.

References ILIAS\Repository\lng(), null, populateGapSizeFormPart(), populateNumericGapFormPart(), populateSelectGapFormPart(), populateTextGapFormPart(), ilSelectInputGUI\setOptions(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

495  {
496  $gap = $this->object->getGap($gapCounter);
497 
498  if ($gap == null) {
499  return $form;
500  }
501 
502  $header = new ilFormSectionHeaderGUI();
503  $header->setTitle($this->lng->txt("gap") . " " . ($gapCounter + 1));
504  $form->addItem($header);
505 
506  $gapcounter = new ilHiddenInputGUI("gap[$gapCounter]");
507  $gapcounter->setValue($gapCounter);
508  $form->addItem($gapcounter);
509 
510  $gaptype = new ilSelectInputGUI($this->lng->txt('type'), "clozetype_$gapCounter");
511  $options = [
512  0 => $this->lng->txt("text_gap"),
513  1 => $this->lng->txt("select_gap"),
514  2 => $this->lng->txt("numeric_gap")
515  ];
516  $gaptype->setOptions($options);
517  $gaptype->setValue($gap->getType());
518  $form->addItem($gaptype);
519 
520  if ($gap->getType() == assClozeGap::TYPE_TEXT) {
521  $this->populateGapSizeFormPart($form, $gap, $gapCounter);
522 
523  if (count($gap->getItemsRaw()) == 0) {
524  $gap->addItem(new assAnswerCloze("", 0, 0));
525  }
526  $this->populateTextGapFormPart($form, $gap, $gapCounter);
527  } elseif ($gap->getType() == assClozeGap::TYPE_SELECT) {
528  if (count($gap->getItemsRaw()) == 0) {
529  $gap->addItem(new assAnswerCloze("", 0, 0));
530  }
531  $this->populateSelectGapFormPart($form, $gap, $gapCounter);
532  } elseif ($gap->getType() == assClozeGap::TYPE_NUMERIC) {
533  $this->populateGapSizeFormPart($form, $gap, $gapCounter);
534 
535  if (count($gap->getItemsRaw()) == 0) {
536  $gap->addItem(new assAnswerCloze("", 0, 0));
537  }
538  foreach ($gap->getItemsRaw() as $item) {
539  $this->populateNumericGapFormPart($form, $item, $gapCounter);
540  }
541  }
542  return $form;
543  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
setOptions(array $a_options)
populateTextGapFormPart($form, $gap, $gapCounter)
Populates the form-part for a text gap.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This class represents a hidden form property in a property form.
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.
+ Here is the call 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 550 of file class.assClozeTestGUI.php.

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

Referenced by populateGapFormPart().

551  {
552  $gapSizeFormItem = new ilNumberInputGUI($this->lng->txt('cloze_fixed_textlength'), "gap_" . $gapCounter . '_gapsize');
553 
554  $gapSizeFormItem->allowDecimals(false);
555  $gapSizeFormItem->setMinValue(0);
556  $gapSizeFormItem->setSize(3);
557  $gapSizeFormItem->setMaxLength(6);
558  $gapSizeFormItem->setInfo($this->lng->txt('cloze_gap_size_info'));
559  $gapSizeFormItem->setValue($gap->getGapSize());
560  $form->addItem($gapSizeFormItem);
561 
562  return $form;
563  }
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 439 of file class.assClozeTestGUI.php.

References assQuestionGUI\escapeTemplatePlaceholders(), and null.

Referenced by populateAnswerSpecificFormPart().

439  : array
440  {
441  $gap = $this->object->getGaps();
442  $array = [];
443  if ($gap == null) {
444  return $array;
445  }
446  $translate_type = ['text','select','numeric'];
447  $i = 0;
448  foreach ($gap as $content) {
449  $shuffle = false;
450  $value = $content->getItemsRaw();
451  $items = [];
452  for ($j = 0, $jMax = count($value); $j < $jMax; $j++) {
453  if ($content->isNumericGap()) {
454  $items[$j] = [
455  'answer' => $value[$j]->getAnswerText(),
456  'lower' => $value[$j]->getLowerBound(),
457  'upper' => $value[$j]->getUpperBound(),
458  'points' => $value[$j]->getPoints(),
459  'error' => false
460  ];
461  } else {
462  $items[$j] = [
463  'answer' => $this->escapeTemplatePlaceholders($value[$j]->getAnswerText()),
464  'points' => $value[$j]->getPoints(),
465  'error' => false
466  ];
467 
468  if ($content->isSelectGap()) {
469  $shuffle = $content->getShuffle();
470  }
471  }
472  }
473  $answers[$i] = [
474  'type' => $translate_type[$content->getType()] ,
475  'values' => $items ,
476  'shuffle' => $shuffle,
477  'text_field_length' => $content->getGapSize() > 0 ? $content->getGapSize() : '',
478  'used_in_gap_combination' => true];
479  $i++;
480  }
481  return $answers;
482  }
escapeTemplatePlaceholders(string $text)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 1570 of file class.assClozeTestGUI.php.

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

Referenced by populateGapCorrectionFormProperties().

1570  : void
1571  {
1572  $value = new ilNumberInputGUI($this->lng->txt('value'), "gap_" . $gapIndex . "_numeric");
1573  $value->allowDecimals(true);
1574  $value->setSize(10);
1575  $value->setValue(ilLegacyFormElementsUtil::prepareFormOutput($item->getAnswertext()));
1576  $value->setRequired(true);
1577  $form->addItem($value);
1578 
1579  $lowerbound = new ilNumberInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $gapIndex . "_numeric_lower");
1580  $lowerbound->allowDecimals(true);
1581  $lowerbound->setSize(10);
1582  $lowerbound->setRequired(true);
1583  $lowerbound->setValue(ilLegacyFormElementsUtil::prepareFormOutput($item->getLowerBound()));
1584  $form->addItem($lowerbound);
1585 
1586  $upperbound = new ilNumberInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $gapIndex . "_numeric_upper");
1587  $upperbound->allowDecimals(true);
1588  $upperbound->setSize(10);
1589  $upperbound->setRequired(true);
1590  $upperbound->setValue(ilLegacyFormElementsUtil::prepareFormOutput($item->getUpperBound()));
1591  $form->addItem($upperbound);
1592 
1593  if (!$hidePoints) {
1594  $points = new ilNumberInputGUI($this->lng->txt('points'), "gap_" . $gapIndex . "_numeric_points");
1595  $points->allowDecimals(true);
1596  $points->setSize(3);
1597  $points->setRequired(true);
1598  $points->setValue(ilLegacyFormElementsUtil::prepareFormOutput($item->getPoints()));
1599  $form->addItem($points);
1600  }
1601  }
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 637 of file class.assClozeTestGUI.php.

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

Referenced by populateGapFormPart().

638  {
639  // #8944: the js-based ouput in self-assessment cannot support formulas
640  if (!$this->object->getSelfAssessmentEditingMode()) {
641  $value = new ilFormulaInputGUI($this->lng->txt('value'), "gap_" . $gapCounter . "_numeric");
642  $value->setInlineStyle('text-align: right;');
643 
644  $lowerbound = new ilFormulaInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $gapCounter . "_numeric_lower");
645  $lowerbound->setInlineStyle('text-align: right;');
646 
647  $upperbound = new ilFormulaInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $gapCounter . "_numeric_upper");
648  $upperbound->setInlineStyle('text-align: right;');
649  } else {
650  $value = new ilNumberInputGUI($this->lng->txt('value'), "gap_" . $gapCounter . "_numeric");
651  $value->allowDecimals(true);
652 
653  $lowerbound = new ilNumberInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $gapCounter . "_numeric_lower");
654  $lowerbound->allowDecimals(true);
655 
656  $upperbound = new ilNumberInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $gapCounter . "_numeric_upper");
657  $upperbound->allowDecimals(true);
658  }
659 
660  $value->setSize(10);
661  $value->setValue(ilLegacyFormElementsUtil::prepareFormOutput($gap->getAnswertext()));
662  $value->setRequired(true);
663  $form->addItem($value);
664 
665  $lowerbound->setSize(10);
666  $lowerbound->setRequired(true);
667  $lowerbound->setValue(ilLegacyFormElementsUtil::prepareFormOutput($gap->getLowerBound()));
668  $form->addItem($lowerbound);
669 
670  $upperbound->setSize(10);
671  $upperbound->setRequired(true);
672  $upperbound->setValue(ilLegacyFormElementsUtil::prepareFormOutput($gap->getUpperBound()));
673  $form->addItem($upperbound);
674 
675  if ($this->object->getFixedTextLength() > 0) {
676  $value->setSize($this->object->getFixedTextLength());
677  $value->setMaxLength($this->object->getFixedTextLength());
678  $lowerbound->setSize($this->object->getFixedTextLength());
679  $lowerbound->setMaxLength($this->object->getFixedTextLength());
680  $upperbound->setSize($this->object->getFixedTextLength());
681  $upperbound->setMaxLength($this->object->getFixedTextLength());
682  }
683 
684  $points = new ilNumberInputGUI($this->lng->txt('points'), "gap_" . $gapCounter . "_numeric_points");
685  $points->allowDecimals(true);
686  $points->setSize(3);
687  $points->setRequired(true);
688  $points->setValue(ilLegacyFormElementsUtil::prepareFormOutput($gap->getPoints()));
689  $form->addItem($points);
690  return $form;
691  }
This class represents a formula text property in a property form.
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 324 of file class.assClozeTestGUI.php.

References assQuestionGUI\$tpl, ilObjAdvancedEditing\_getUsedHTMLTags(), ilPropertyFormGUI\addItem(), assQuestion\ADDITIONAL_CONTENT_EDITING_MODE_IPE, applyIndizesToGapText(), ilGlobalPageTemplate\get(), getAddGapButtonClickClosure(), ilAssSelfAssessmentQuestionFormatter\getSelfAssessmentTags(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilGlobalPageTemplate\parseCurrentBlock(), ilSelectInputGUI\setOptions(), ilFormPropertyGUI\setRequired(), ilNumberInputGUI\setValue(), ilGlobalPageTemplate\setVariable(), and ILIAS\UI\Implementation\Component\withAdditionalOnLoadCode().

Referenced by editQuestion().

325  {
326  // cloze text
327  $cloze_text = new ilTextAreaInputGUI($this->lng->txt("cloze_text"), 'cloze_text');
328  $cloze_text->setRequired(true);
329  $cloze_text->setValue($this->applyIndizesToGapText($this->object->getClozeText()));
330  $cloze_text->setInfo($this->lng->txt("close_text_hint"));
331  $cloze_text->setRows(10);
332  $cloze_text->setCols(80);
333  if (!$this->object->getSelfAssessmentEditingMode()) {
334  if ($this->object->getAdditionalContentEditingMode() !== assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_IPE) {
335  $cloze_text->setUseRte(true);
336  $cloze_text->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
337  }
338  } else {
340  $cloze_text->setUseTagsForRteOnly(false);
341  }
342  $cloze_text->setRTESupport($this->object->getId(), "qpl", "assessment");
343  $form->addItem($cloze_text);
344 
345  $tpl = new ilTemplate("tpl.il_as_qpl_cloze_gap_button_code.html", true, true, "components/ILIAS/TestQuestionPool");
346 
347  $button = new ilCustomInputGUI('&nbsp;', '');
348 
349  $button_text_gap = $this->ui_factory->button()->standard($this->lng->txt('text_gap'), '')
351  $this->getAddGapButtonClickClosure('text')
352  );
353  $button_select_gap = $this->ui_factory->button()->standard($this->lng->txt('select_gap'), '')
355  $this->getAddGapButtonClickClosure('select')
356  );
357  $button_numeric_gap = $this->ui_factory->button()->standard($this->lng->txt('numeric_gap'), '')
359  $this->getAddGapButtonClickClosure('numeric')
360  );
361 
362  $tpl->setVariable('BUTTON', $this->ui_renderer->render([
363  $button_text_gap,
364  $button_select_gap,
365  $button_numeric_gap
366  ]));
368 
369  $button->setHtml($tpl->get());
370  $this->tpl->addOnloadCode(self::JS_INSERT_GAP_CODE_AT_CARET);
371  $form->addItem($button);
372 
373  // text rating
374  if (!$this->object->getSelfAssessmentEditingMode()) {
375  $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "textgap_rating");
376  $text_options = [
377  "ci" => $this->lng->txt("cloze_textgap_case_insensitive"),
378  "cs" => $this->lng->txt("cloze_textgap_case_sensitive"),
379  "l1" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1"),
380  "l2" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2"),
381  "l3" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3"),
382  "l4" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4"),
383  "l5" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5")
384  ];
385  $textrating->setOptions($text_options);
386  $textrating->setValue($this->object->getTextgapRating());
387  $form->addItem($textrating);
388 
389  // text field length
390  $fixedTextLength = new ilNumberInputGUI($this->lng->txt("cloze_fixed_textlength"), "fixedTextLength");
391  $ftl = $this->object->getFixedTextLength();
392 
393  $fixedTextLength->setValue($ftl > 0 ? $ftl : '');
394  $fixedTextLength->setMinValue(0);
395  $fixedTextLength->setSize(3);
396  $fixedTextLength->setMaxLength(6);
397  $fixedTextLength->setInfo($this->lng->txt('cloze_fixed_textlength_description'));
398  $fixedTextLength->setRequired(false);
399  $form->addItem($fixedTextLength);
400 
401  // identical scoring
402  $identical_scoring = new ilCheckboxInputGUI($this->lng->txt("identical_scoring"), "identical_scoring");
403  $identical_scoring->setValue(1);
404  $identical_scoring->setChecked($this->object->getIdenticalScoring());
405  $identical_scoring->setInfo($this->lng->txt('identical_scoring_desc'));
406  $identical_scoring->setRequired(false);
407  $form->addItem($identical_scoring);
408  }
409  return $form;
410  }
const ADDITIONAL_CONTENT_EDITING_MODE_IPE
static getSelfAssessmentTags()
Get tags allowed in question tags in self assessment mode.
This class represents a selection list property in a property form.
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
setOptions(array $a_options)
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)
applyIndizesToGapText($question_text)
This class represents a text area property in a property form.
getAddGapButtonClickClosure(string $gap_type)
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 577 of file class.assClozeTestGUI.php.

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

Referenced by populateGapFormPart().

578  {
579  $values = new ilAnswerWizardInputGUI($this->lng->txt("values"), "gap_" . $gapCounter . "");
580  $values->setRequired(true);
581  $values->setQuestionObject($this->object);
582  $values->setSingleline(true);
583  $values->setAllowMove(false);
584 
585  $values->setValues($gap->getItemsRaw());
586  $form->addItem($values);
587 
588  // shuffle
589  $shuffle = new ilCheckboxInputGUI($this->lng->txt("shuffle_answers"), "shuffle_" . $gapCounter . "");
590  $shuffle->setValue(1);
591  $shuffle->setChecked($gap->getShuffle());
592  $shuffle->setRequired(false);
593  $form->addItem($shuffle);
594  return $form;
595  }
This class represents a single choice wizard property in a property form.
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 1339 of file class.assClozeTestGUI.php.

References assQuestionGUI\isRenderPurposePrintPdf(), and assClozeGap\TYPE_SELECT.

Referenced by renderSolutionOutput().

1339  : void
1340  {
1341  if ($this->isRenderPurposePrintPdf()) {
1342  $gaptemplate->setCurrentBlock('gap_span');
1343  $gaptemplate->setVariable('SPAN_SOLUTION', $solutiontext);
1344  } elseif ($gap->getType() == assClozeGap::TYPE_SELECT) {
1345  $gaptemplate->setCurrentBlock('gap_select');
1346  $gaptemplate->setVariable('SELECT_SOLUTION', $solutiontext);
1347  } else {
1348  $gap_size = $gap->getGapSize() > 0 ? $gap->getGapSize() : $this->object->getFixedTextLength();
1349 
1350  if ($gap_size > 0) {
1351  $gaptemplate->setCurrentBlock('gap_size');
1352  $gaptemplate->setVariable("GAP_SIZE", $gap_size);
1353  $gaptemplate->parseCurrentBlock();
1354  }
1355 
1356  $gaptemplate->setCurrentBlock('gap_input');
1357  $gaptemplate->setVariable('INPUT_SOLUTION', $solutiontext);
1358  }
1359 
1360 
1361  $gaptemplate->parseCurrentBlock();
1362  }
+ 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 608 of file class.assClozeTestGUI.php.

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

Referenced by populateGapFormPart().

609  {
610  $values = new ilAnswerWizardInputGUI($this->lng->txt("values"), "gap_" . $gapCounter . "");
611  $values->setRequired(true);
612  $values->setQuestionObject($this->object);
613  $values->setSingleline(true);
614  $values->setAllowMove(false);
615  $values->setValues($gap->getItemsRaw());
616  $form->addItem($values);
617 
618  if ($this->object->getFixedTextLength() > 0) {
619  $values->setSize($this->object->getFixedTextLength());
620  $values->setMaxLength($this->object->getFixedTextLength());
621  }
622 
623  return $form;
624  }
This class represents a single choice wizard property in a property form.
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 1560 of file class.assClozeTestGUI.php.

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

Referenced by populateGapCorrectionFormProperties().

1560  : void
1561  {
1562  $values = new ilAssAnswerCorrectionsInputGUI($this->lng->txt("values"), "gap_" . $gapIndex);
1563  $values->setHidePointsEnabled($hidePoints);
1564  $values->setRequired(true);
1565  $values->setQuestionObject($this->object);
1566  $values->setValues($gap->getItemsRaw());
1567  $form->addItem($values);
1568  }
$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 ( )

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

References editQuestion(), assQuestionGUI\setAdditionalContentEditingModeFromPost(), and writePostData().

704  : void
705  {
707  $this->writePostData(true);
708  $this->object->deleteAnswerText(
709  $this->gapIndex,
710  $this->request_data_collector->getCmdIndex('removegap_' . $this->gapIndex)
711  );
712  $this->editQuestion();
713  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
Creates an output of the edit form for the question.
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ removeIndizesFromGapText()

assClozeTestGUI::removeIndizesFromGapText (   $question_text)

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

References $parts.

Referenced by writePostData().

1328  : string
1329  {
1330  $parts = preg_split('/\[gap \d*\]/', $question_text);
1331  $question_text = implode('[gap]', $parts);
1332  return $question_text;
1333  }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
+ Here is the caller graph for this function:

◆ renderSolutionOutput()

assClozeTestGUI::renderSolutionOutput ( mixed  $user_solutions,
int  $active_id,
?int  $pass,
bool  $graphical_output = false,
bool  $result_output = false,
bool  $show_question_only = true,
bool  $show_feedback = false,
bool  $show_correct_solution = false,
bool  $show_manual_scoring = false,
bool  $show_question_text = true,
bool  $show_autosave_title = false,
bool  $show_inline_feedback = false 
)

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

References Vendor\Package\$a, $check, 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(), ilLegacyFormElementsUtil\prepareFormOutput(), ilLegacyFormElementsUtil\prepareTextareaOutput(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

Referenced by getSolutionOutput().

862  : ?string {
863  $template = new ilTemplate("tpl.il_as_qpl_cloze_question_output_solution.html", true, true, "components/ILIAS/TestQuestionPool");
864  $output = $this->object->getClozeTextForHTMLOutput();
865  $assClozeGapCombinationObject = new assClozeGapCombination($this->db);
866  $check_for_gap_combinations = $assClozeGapCombinationObject->loadFromDb($this->object->getId());
867 
868  foreach ($this->object->getGaps() as $gap_index => $gap) {
869  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_output_solution_gap.html", true, true, "components/ILIAS/TestQuestionPool");
870  $found = [];
871  foreach ($user_solutions as $solutionarray) {
872  if ($solutionarray["value1"] == $gap_index) {
873  $found = $solutionarray;
874  }
875  }
876 
877  if ($active_id
878  && $graphical_output) {
879  // output of ok/not ok icons for user entered solutions
880  $details = $this->object->getUserResultDetails($active_id, $pass);
881  $check = $details[$gap_index] ?? [];
882 
883  if (count($check_for_gap_combinations) != 0) {
884  $gaps_used_in_combination = $assClozeGapCombinationObject->getGapsWhichAreUsedInCombination($this->object->getId());
885  $custom_user_solution = [];
886  if (array_key_exists($gap_index, $gaps_used_in_combination)) {
887  $combination_id = $gaps_used_in_combination[$gap_index];
888  foreach ($gaps_used_in_combination as $key => $value) {
889  $a = 0;
890  if ($value == $combination_id) {
891  foreach ($user_solutions as $solution_key => $solution_value) {
892  if ($solution_value['value1'] == $key) {
893  $result_row = [];
894  $result_row['gap_id'] = $solution_value['value1'];
895  $result_row['value'] = $solution_value['value2'];
896  array_push($custom_user_solution, $result_row);
897  }
898  }
899  }
900  }
901  $points_array = $this->object->calculateCombinationResult($custom_user_solution);
902  $max_combination_points = $assClozeGapCombinationObject->getMaxPointsForCombination($this->object->getId(), $combination_id);
903  if ($points_array[0] == $max_combination_points) {
904  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK));
905  } elseif ($points_array[0] > 0) {
906  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_MOSTLY_OK));
907  } else {
908  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK));
909  }
910  } else {
911  if (array_key_exists('best', $check) && $check["best"]) {
912  $gaptemplate->setCurrentBlock("icon_ok");
913  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK));
914  $gaptemplate->parseCurrentBlock();
915  } else {
916  $gaptemplate->setCurrentBlock("icon_ok");
917  if (array_key_exists('positive', $check) && $check["positive"]) {
918  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_MOSTLY_OK));
919  } else {
920  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK));
921  }
922  $gaptemplate->parseCurrentBlock();
923  }
924  }
925  } else {
926  if (array_key_exists('best', $check) && $check["best"]) {
927  $gaptemplate->setCurrentBlock("icon_ok");
928  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK));
929  $gaptemplate->parseCurrentBlock();
930  } else {
931  $gaptemplate->setCurrentBlock("icon_ok");
932  if (array_key_exists('positive', $check) && $check["positive"]) {
933  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_MOSTLY_OK));
934  } else {
935  $gaptemplate->setVariable("ICON_OK", $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK));
936  }
937  $gaptemplate->parseCurrentBlock();
938  }
939  }
940  }
941 
942  switch ($gap->getType()) {
945  $solutiontext = "";
946  if (($active_id > 0) && (!$show_correct_solution)) {
947  if ((count($found) == 0) || (strlen(trim($found["value2"])) == 0)) {
948  for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
949  $solutiontext .= "&nbsp;";
950  }
951  } else {
952  $solutiontext = ilLegacyFormElementsUtil::prepareFormOutput($found["value2"]);
953  }
954  } else {
955  $solutiontext = $this-> getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
956  }
957  $this->populateSolutiontextToGapTpl($gaptemplate, $gap, $solutiontext);
958  // fau: fixGapReplace - use replace function
959  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
960  // fau.
961  break;
963  $solutiontext = "";
964  if (($active_id > 0) && (!$show_correct_solution)) {
965  if ((count($found) == 0) || (strlen(trim($found["value2"])) == 0)) {
966  for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
967  $solutiontext .= "&nbsp;";
968  }
969  } else {
970  $item = $gap->getItem($found["value2"]);
971  if (is_object($item)) {
972  $solutiontext = ilLegacyFormElementsUtil::prepareFormOutput($item->getAnswertext());
973  } else {
974  for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) {
975  $solutiontext .= "&nbsp;";
976  }
977  }
978  }
979  } else {
980  $solutiontext = $this-> getBestSolutionText($gap, $gap_index, $check_for_gap_combinations);
981  }
982  $this->populateSolutiontextToGapTpl($gaptemplate, $gap, $solutiontext);
983  // fau: fixGapReplace - use replace function
984  $output = $this->object->replaceFirstGap($output, $gaptemplate->get());
985  // fau.
986  break;
987  }
988  }
989 
990  if ($show_question_text) {
991  $template->setVariable(
992  "QUESTIONTEXT",
993  $this->object->getQuestionForHTMLOutput()
994  );
995  }
996 
997  $template->setVariable("CLOZETEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($output, true));
998  // generate the question output
999  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "components/ILIAS/TestQuestionPool");
1000  $questionoutput = $template->get();
1001 
1002  $feedback = '';
1003  if ($show_feedback) {
1004  if (!$this->isTestPresentationContext()) {
1005  $feedback = $this->getGenericFeedbackOutput((int) $active_id, $pass);
1006  }
1007 
1008  $feedback = $this->getSpecificFeedbackOutput(
1009  $this->object->fetchIndexedValuesFromValuePairs($user_solutions)
1010  );
1011  }
1012  if ($feedback !== '') {
1013  $cssClass = (
1014  $this->hasCorrectSolution($active_id, $pass) ?
1016  );
1017 
1018  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
1019  $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
1020  }
1021 
1022  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
1023 
1024  $solutionoutput = $solutiontemplate->get();
1025 
1026  if (!$show_question_only) {
1027  // get page object output
1028  $solutionoutput = $this->getILIASPage($solutionoutput);
1029  }
1030 
1031  return $solutionoutput;
1032  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
populateSolutiontextToGapTpl($gaptemplate, $gap, $solutiontext)
static prepareFormOutput($a_str, bool $a_strip=false)
getBestSolutionText($gap, $gap_index, $gap_combinations)
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
getSpecificFeedbackOutput(array $user_solution)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

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

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

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

1606  : void
1607  {
1608  foreach ($this->object->getGaps() as $gapIndex => $gap) {
1609  if ($this->isUsedInCombinations($gapIndex)) {
1610  continue;
1611  }
1612 
1613  $this->saveGapCorrectionFormProperty($form, $gap, $gapIndex);
1614  }
1615 
1616  if ($this->object->getGapCombinationsExists()) {
1618  }
1619  }
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 1649 of file class.assClozeTestGUI.php.

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

Referenced by saveCorrectionsFormProperties().

1649  : void
1650  {
1651  // please dont ask (!) -.-
1652 
1653  $combinationPoints = ['points' => [], 'select' => []];
1654  $combinationValues = [];
1655 
1656  foreach ($this->getGapCombinations() as $combiId => $combi) {
1657  $values = $form->getItemByPostVar('combination_' . $combiId)->getValues();
1658 
1659  if (!isset($combinationPoints['points'][$combiId])) {
1660  $combinationPoints['points'][$combiId] = [];
1661  $combinationPoints['select'][$combiId] = [];
1662  $combinationValues[$combiId] = [];
1663  }
1664 
1665  foreach ($combi as $varId => $variant) {
1666  $combinationPoints['points'][$combiId][$varId] = (float) str_replace(',', '.', $values[$varId]['points']);
1667  $combinationPoints['select'][$combiId] = array_keys($values[$varId]['gaps']);
1668  $combinationValues[$combiId][$varId] = array_values($values[$varId]['gaps']);
1669  }
1670  }
1671 
1672  $assClozeGapCombinationObject = new assClozeGapCombination($this->db);
1673  $assClozeGapCombinationObject->clearGapCombinationsFromDb($this->object->getId());
1674 
1675  $assClozeGapCombinationObject->saveGapCombinationToDb(
1676  $this->object->getId(),
1677  $combinationPoints,
1678  $combinationValues
1679  );
1680  $this->object->setGapCombinationsExists(true);
1681  }
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 1621 of file class.assClozeTestGUI.php.

References $gapIndex, assClozeGap\getItemsRaw(), assClozeGap\getType(), saveNumericGapCorrectionFormProperty(), saveTextOrSelectGapCorrectionFormProperty(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

Referenced by saveCorrectionsFormProperties().

1621  : void
1622  {
1623  if ($gap->getType() == assClozeGap::TYPE_TEXT || $gap->getType() == assClozeGap::TYPE_SELECT) {
1625  } elseif ($gap->getType() == assClozeGap::TYPE_NUMERIC) {
1626  foreach ($gap->getItemsRaw() as $item) {
1627  $this->saveNumericGapCorrectionFormProperty($form, $item, $gapIndex);
1628  }
1629  }
1630  }
getItemsRaw()
Gets the items of a cloze gap.
saveTextOrSelectGapCorrectionFormProperty(ilPropertyFormGUI $form, assClozeGap $gap, $gapIndex)
saveNumericGapCorrectionFormProperty(ilPropertyFormGUI $form, assAnswerCloze $item, $gapIndex)
$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 1641 of file class.assClozeTestGUI.php.

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

Referenced by saveGapCorrectionFormProperty().

1641  : void
1642  {
1643  $item->setAnswertext($form->getInput('gap_' . $gapIndex . '_numeric'));
1644  $item->setLowerBound($form->getInput('gap_' . $gapIndex . '_numeric_lower'));
1645  $item->setUpperBound($form->getInput('gap_' . $gapIndex . '_numeric_upper'));
1646  $item->setPoints((float) str_replace(',', '.', $form->getInput('gap_' . $gapIndex . '_numeric_points')));
1647  }
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 1632 of file class.assClozeTestGUI.php.

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

Referenced by saveGapCorrectionFormProperty().

1632  : void
1633  {
1634  $answers = $form->getItemByPostVar('gap_' . $gapIndex)->getValues();
1635 
1636  foreach ($gap->getItemsRaw() as $index => $item) {
1637  $item->setPoints((float) str_replace(',', '.', $answers[$index]->getPoints()));
1638  }
1639  }
getItemByPostVar(string $a_post_var)
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 the request and applies them to the data object.

Implements ilGuiAnswerScoringAdjustable.

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

References ILIAS\Repository\ctrl(), null, ILIAS\Repository\object(), ILIAS\Repository\refinery(), assClozeGap\TYPE_NUMERIC, assClozeGap\TYPE_SELECT, and assClozeGap\TYPE_TEXT.

Referenced by writePostData().

149  : void
150  {
151  $gaps = $this->request_data_collector->strArray('gap');
152  if (empty($gaps)) {
153  return;
154  }
155 
156  if ($this->ctrl->getCmd() !== 'createGaps') {
157  $this->object->clearGapAnswers();
158  }
159 
160  $answer_trafo = $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string());
161  $points_trafo = $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->float());
162 
163  foreach (array_keys($gaps) as $idx) {
164  $cloze_type = $this->request_data_collector->int('clozetype_' . $idx);
165  $this->object->setGapType($idx, $cloze_type);
166 
167  $gap_idx = $this->request_data_collector->raw('gap_' . $idx);
168 
169  if ($cloze_type === assClozeGap::TYPE_TEXT || $cloze_type === assClozeGap::TYPE_SELECT) {
170  $answer = $answer_trafo->transform($gap_idx['answer'] ?? []);
171  if ($this->ctrl->getCmd() !== 'createGaps') {
172  if (!empty($answer)) {
173  foreach ($answer as $order => $value) {
174  $this->object->addGapAnswer($idx, $order, $value);
175  }
176  } else {
177  $this->object->addGapAnswer($idx, 0, '');
178  }
179  }
180 
181  $points = $points_trafo->transform($gap_idx['points'] ?? []);
182  foreach ($points as $order => $value) {
183  $this->object->setGapAnswerPoints($idx, $order, $value);
184  }
185  }
186 
187  if ($cloze_type === assClozeGap::TYPE_TEXT || $cloze_type === assClozeGap::TYPE_NUMERIC) {
188  $this->object->setGapShuffle(0);
189 
190  $gap_size = $this->request_data_collector->int('gap_' . $idx . '_gapsize');
191  if ($gap_size !== 0) {
192  $this->object->setGapSize($idx, $gap_size);
193  }
194  } else {
195  $this->object->setGapShuffle($idx, $this->request_data_collector->int('shuffle_' . $idx));
196  }
197 
198  if ($cloze_type === assClozeGap::TYPE_NUMERIC && $this->object->getGap($idx) !== null) {
199  $this->object->getGap($idx)->clearItems();
200 
201  $gap_idx_numeric = $this->request_data_collector->float('gap_' . $idx . '_numeric');
202  if ($gap_idx_numeric !== 0.0) {
203  $this->object->addGapAnswer($idx, 0, (string) $gap_idx_numeric);
204  $this->object->setGapAnswerLowerBound(
205  $idx,
206  0,
207  (string) $this->request_data_collector->float('gap_' . $idx . '_numeric_lower')
208  );
209  $this->object->setGapAnswerUpperBound(
210  $idx,
211  0,
212  (string) $this->request_data_collector->float('gap_' . $idx . '_numeric_upper')
213  );
214  $this->object->setGapAnswerPoints(
215  $idx,
216  0,
217  $this->request_data_collector->float('gap_' . $idx . '_numeric_points')
218  );
219  } else {
220  if ($this->ctrl->getCmd() !== 'createGaps') {
221  $this->object->addGapAnswer($idx, 0, '');
222  }
223 
224  $this->object->setGapAnswerLowerBound($idx, 0, '');
225  $this->object->setGapAnswerUpperBound($idx, 0, '');
226  }
227  }
228 
229  $ass_cloze_gab_combination = new assClozeGapCombination($this->db);
230  $ass_cloze_gab_combination->clearGapCombinationsFromDb($this->object->getId());
231 
232  $gap_combination = $this->request_data_collector->rawArray('gap_combination', 4);
233  if ($gap_combination !== []) {
234  $ass_cloze_gab_combination->saveGapCombinationToDb(
235  $this->object->getId(),
236  $gap_combination,
237  $this->request_data_collector->rawArray('gap_combination_values')
238  );
239  $this->object->setGapCombinationsExists(true);
240  }
241  }
242 
243  if ($this->ctrl->getCmd() !== 'createGaps') {
244  $this->object->updateClozeTextFromGaps();
245  }
246  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 124 of file class.assClozeTestGUI.php.

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

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

124  : int
125  {
126  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
127  if ($hasErrors) {
128  return 1;
129  }
130 
131  $cloze_text = $this->removeIndizesFromGapText(
132  $this->request_data_collector->raw('cloze_text')
133  );
134 
135  $this->object->setQuestion(
136  $this->request_data_collector->raw('question')
137  );
138 
140  $this->object->setClozeText($cloze_text);
141  $this->object->setTextgapRating($this->request_data_collector->raw('textgap_rating'));
142  $this->object->setIdenticalScoring($this->request_data_collector->bool('identical_scoring') ?? false);
143  $this->object->setFixedTextLength($this->request_data_collector->int('fixedTextLength') ?? 0);
145  $this->saveTaxonomyAssignments();
146  return 0;
147  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
Creates an output of the edit form for the question.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from the request and applies them to the data object...
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 the request and applies them to the data object.

Implements ilGuiQuestionScoringAdjustable.

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

248  : void
249  {
250  $this->object->setClozeText($this->request_data_collector->string('cloze_quest'));
251  $this->object->setTextgapRating($this->request_data_collector->string('textgap_rating'));
252  $this->object->setIdenticalScoring($this->request_data_collector->bool('textgap_rating') ?? true);
253  $this->object->setFixedTextLength($this->request_data_collector->int('fixedTextLength'));
254  }

Field Documentation

◆ $db

ilDBInterface assClozeTestGUI::$db
private

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

◆ $gapIndex

◆ $randomGroup

RandomGroup assClozeTestGUI::$randomGroup
private

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

◆ $ui_factory

UIFactory assClozeTestGUI::$ui_factory
private

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

◆ $ui_renderer

UIRenderer assClozeTestGUI::$ui_renderer
private

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

◆ JS

assClozeTestGUI::JS

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

◆ JS_INSERT_GAP_CODE_AT_CARET

const assClozeTestGUI::JS_INSERT_GAP_CODE_AT_CARET

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


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