ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
assLongMenu Class Reference
+ Inheritance diagram for assLongMenu:
+ Collaboration diagram for assLongMenu:

Public Member Functions

 getAnswerType ()
 
 setAnswerType (array $answerType)
 
 getCorrectAnswers ()
 
 setCorrectAnswers (array $correct_answers)
 
 getAnswerTableName ()
 
 setLongMenuTextValue (string $long_menu_text='')
 
 getLongMenuTextValue ()
 
 setAnswers (array $answers)
 
 getAnswers ()
 
 getJsonStructure ()
 
 setSpecificFeedbackSetting ($specificFeedbackSetting)
 
 getSpecificFeedbackSetting ()
 
 setMinAutoComplete (int $min_auto_complete)
 
 getMinAutoComplete ()
 
 isComplete ()
 
 saveToDb (?int $original_id=null)
 
 checkQuestionCustomPart ($form=null)
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 saveAnswerSpecificDataToDb ()
 
 loadFromDb ($question_id)
 
 getCorrectAnswersForQuestionSolution ($question_id)
 
 getAnswersObject ()
 
 getCorrectAnswersAsJson ()
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 
 isShuffleAnswersEnabled ()
 
 clearAnswerSpecificDataFromDb (int $question_id)
 
 delete (int $question_id)
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getIdenticalScoring ()
 
 setIdenticalScoring (bool $identical_scoring)
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 solutionValuesToText (array $solution_values)
 MUST convert the given solution values into text. More...
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
 toNormalized (Transformations $transformations, array $context=[])
 
 fromNormalized (array $normalized, Transformations $transformations)
 
- Public Member Functions inherited from assQuestion
 getQuestionType ()
 
 isComplete ()
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 getCurrentUser ()
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML (string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping)
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $force_image_references=false)
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 setShuffle (?bool $shuffle=true)
 
 setAuthor (string $author="")
 
 setOwner (int $owner=-1)
 
 getTitle ()
 
 getTitleForHTMLOutput ()
 
 getTitleFilenameCompliant ()
 
 getId ()
 
 getShuffle ()
 
 getTestId ()
 
 getComment ()
 
 getDescriptionForHTMLOutput ()
 
 getThumbSize ()
 
 setThumbSize (int $a_size)
 
 getMinimumThumbSize ()
 
 getMaximumThumbSize ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorized_solution=true)
 
 calculateResultsFromSolution (int $active_id, int $pass)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $preview_session)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 getSuggestedSolutionPath ()
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 getSuggestedSolutionPathWeb ()
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getTestOutputSolutions (int $activeId, int $pass)
 
 getUserSolutionPreferingIntermediate (int $active_id, ?int $pass=null)
 
 getSolutionValues (int $active_id, ?int $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 cloneXHTMLMediaObjectsOfQuestion (int $source_question_id)
 
 createPageObject ()
 
 clonePageOfQuestion (int $a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
 fixSvgToPng (string $imageFilenameContainingString)
 
 fixUnavailableSkinImageSources (string $html)
 
 loadFromDb (int $question_id)
 
 createNewQuestion (bool $a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb (?int $original_id=null)
 
 updateOriginalId (?int $original_id=null)
 
 duplicate (bool $set_original_id=true, string $title='', string $author='', int $owner=-1, $test_obj_id=null)
 
 copyObject (int $target_parent_id, string $title='')
 
 createNewOriginalFromThisDuplicate (int $target_parent_id, string $target_question_title='')
 
 saveToDb (?int $original_id=null)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 
 resolveInternalLink (string $internal_link)
 
 resolveSuggestedSolutionLinks ()
 
 getInternalLinkHref (string $target)
 
 syncWithOriginal ()
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 isWriteable ()
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $preview_session)
 
 adjustReachedPointsByScoringOptions (float $points, int $active_id)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionTypeID ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 getNrOfTries ()
 
 setNrOfTries (int $a_nr_of_tries)
 
 setExportImagePath (string $path)
 
 formatSAQuestion ($a_q)
 
 setPreventRteUsage (bool $prevent_rte_usage)
 
 getPreventRteUsage ()
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode (bool $selfassessmenteditingmode)
 
 getSelfAssessmentEditingMode ()
 
 setDefaultNrOfTries (int $defaultnroftries)
 
 getDefaultNrOfTries ()
 
 syncSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 isAnswered (int $active_id, int $pass)
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange (int $lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 removeCurrentSolution (int $active_id, int $pass, bool $authorized=true)
 
 saveCurrentSolution (int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
 updateCurrentSolution (int $solutionId, $value1, $value2, bool $authorized=true)
 
 updateCurrentSolutionsAuthorization (int $activeId, int $pass, bool $authorized, bool $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 intermediateSolutionExists (int $active_id, int $pass)
 
 authorizedSolutionExists (int $active_id, ?int $pass)
 
 authorizedOrIntermediateSolutionExists (int $active_id, int $pass)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions (int $activeId, int $pass)
 
 resetUsersAnswer (int $activeId, int $pass)
 
 removeResultRecord (int $activeId, int $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $value_pairs)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
 hasWritableOriginalInQuestionPool ()
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 getSolutionForTextOutput (int $active_id, int $pass)
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
 getVariablesAsTextArray (int $active_id, int $pass)
 
 toNormalized (Transformations $transformations, array $context=[])
 
 fromNormalized (array $normalized, Transformations $transformations)
 
 validateSolutionSubmit ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 toJSON ()
 
 toNormalized (Transformations $transformations, array $context=[])
 Convert the internal state of the implementing object into a language-neutral array structure. More...
 
 fromNormalized (array $normalized, Transformations $transformations)
 Restore the object from its normalized representation. More...
 

Data Fields

const ANSWER_TYPE_SELECT_VAL = 0
 
const ANSWER_TYPE_TEXT_VAL = 1
 
const GAP_PLACEHOLDER = 'Longmenu'
 
const MIN_LENGTH_AUTOCOMPLETE = 3
 
const MAX_INPUT_FIELDS = 500
 
- Data Fields inherited from assQuestion
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
const TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
ilAssQuestionFeedback $feedbackOBJ
 
bool $prevent_rte_usage = false
 
bool $selfassessmenteditingmode = false
 
int $defaultnroftries = 0
 
string $questionActionCmd = 'handleQuestionAction'
 
const KEY_VALUES_IMPLOSION_SEPARATOR = ':'
 

Protected Member Functions

 calculateReachedPointsForSolution (?array $found_values, int $active_id=0)
 
 getSolutionSubmit ()
 
 savePreviewData (ilAssQuestionPreviewSession $preview_session)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 solutionValuesToLog (AdditionalInformationGenerator $additional_info, array $solution_values)
 MUST convert the given solution values into an array or a string that can be stored in the log. More...
 
- Protected Member Functions inherited from assQuestion
 solutionValuesToLog (AdditionalInformationGenerator $additional_info, array $solution_values)
 MUST convert the given solution values into an array or a string that can be stored in the log. More...
 
 solutionValuesToText (array $solution_values)
 MUST convert the given solution values into text. More...
 
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $post_submission_field_name)
 
 savePreviewData (ilAssQuestionPreviewSession $preview_session)
 
 deletePageOfQuestion (int $question_id)
 
 cloneQuestionTypeSpecificProperties (self $target)
 
 removeAllImageFiles (string $image_target_path)
 
 onDuplicate (int $original_parent_id, int $original_question_id, int $duplicate_parent_id, int $duplicate_question_id)
 
 afterSyncWithOriginal (int $original_question_id, int $clone_question_id, int $original_parent_id, int $clone_parent_id)
 
 onCopy (int $sourceParentId, int $sourceQuestionId, int $targetParentId, int $targetQuestionId)
 
 duplicateComments (int $parent_source_id, int $source_id, int $parent_target_id, int $target_id)
 
 deleteComments ()
 
 getNotesManager ()
 
 getNotesDataService ()
 
 getNotesRepo ()
 
 cloneSuggestedSolutions (int $source_question_id, int $target_question_id)
 
 duplicateSuggestedSolutionFiles (int $parent_id, int $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 cloneSuggestedSolutionFiles (int $source_question_id, int $target_question_id)
 
 copySuggestedSolutions (int $target_question_id)
 
 ensureNonNegativePoints (float $points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet (int $active_id, int $pass, bool $authorized=true)
 
 removeSolutionRecordById (int $solutionId)
 
 getSolutionRecordById (int $solutionId)
 
 deleteDummySolutionRecord (int $activeId, int $passIndex)
 
 isDummySolutionRecord (array $solutionRecord)
 
 deleteSolutionRecordByValues (int $activeId, int $passIndex, bool $authorized, array $matchValues)
 
 duplicateIntermediateSolutionAuthorized (int $activeId, int $passIndex)
 
 forceExistingIntermediateSolution (int $activeId, int $passIndex, bool $considerDummyRecordCreation)
 
 lookupMaxStep (int $active_id, int $pass)
 
 buildTestPresentationConfig ()
 
 getSuggestedSolutionsRepo ()
 
 loadSuggestedSolutions ()
 
 answerToLog (AdditionalInformationGenerator $additional_info, int $active_id, int $pass)
 

Protected Attributes

const HAS_SPECIFIC_FEEDBACK = false
 
- Protected Attributes inherited from assQuestion
const HAS_SPECIFIC_FEEDBACK = true
 
GeneralQuestionPropertiesRepository $questionrepository
 
RequestDataCollector $questionpool_request
 
QuestionFiles $question_files
 
ilAssQuestionProcessLocker $processLocker
 
ilTestQuestionConfig $testQuestionConfig
 
SuggestedSolutionsDatabaseRepository $suggestedsolution_repo
 
ILIAS $ilias
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
ilDBInterface $db
 
ilObjUser $current_user
 
SkillUsageService $skillUsageService
 
HTTPServices $http
 
Refinery $refinery
 
Transformation $shuffler
 
LoggingServices $log
 
Container $dic
 
ilAssQuestionLifecycle $lifecycle
 
ilAssQuestionPage $page
 
TestResultRepository $test_result_repository
 
int $id
 
string $title
 
string $comment
 
int $owner
 
string $author
 
int $thumb_size
 
string $question
 
float $points = 0.0
 
bool $shuffle = true
 
int $test_id
 
int $obj_id = 0
 
int $original_id = null
 
int $lastChange = null
 
string $external_id = null
 
int $step = null
 
array $suggested_solutions
 

Private Member Functions

 buildFolderName ()
 
 buildFileName ($gap_id)
 
 setJsonStructure (string $json_structure)
 
 correctAnswerDoesNotExistInAnswerOptions ($answers, $answer_options)
 
 createFileFromArray ()
 
 createArrayFromFile ()
 
 clearFolder ($let_folder_exists=true)
 
 assertDirExists ()
 
 loadCorrectAnswerData ($question_id)
 
 getCorrectAnswersForGap ($question_id, $gap_id)
 
 getPointsForGap ($question_id, $gap_id)
 
 getAnswersForLog (AdditionalInformationGenerator $additional_info)
 
 getCorrectAnswersForLog (AdditionalInformationGenerator $additional_info)
 

Private Attributes

array $answerType = null
 
string $long_menu_text = ''
 
string $json_structure = ''
 
int $specificFeedbackSetting = ilAssConfigurableMultiOptionQuestionFeedback::FEEDBACK_SETTING_ALL
 
int $minAutoComplete = self::MIN_LENGTH_AUTOCOMPLETE
 
bool $identical_scoring = true
 
array $correct_answers = []
 
array $answers = []
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $force_pass_results_update_enabled)
 
static isForcePassResultUpdateEnabled ()
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static isFileAvailable (string $file)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $question_id)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
static extendedTrim (string $value)
 Trim non-printable characters from the beginning and end of a string. More...
 
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 
- Static Protected Attributes inherited from assQuestion
static $force_pass_results_update_enabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

Definition at line 28 of file class.assLongMenu.php.

Member Function Documentation

◆ assertDirExists()

assLongMenu::assertDirExists ( )
private

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

347 : void
348 {
349 $folder_name = $this->buildFolderName();
350 if (!ilFileUtils::makeDirParents($folder_name)) {
351 throw new ilException('Cannot create export directory');
352 }
353
354 if (
355 !is_dir($folder_name) ||
356 !is_readable($folder_name) ||
357 !is_writable($folder_name)
358 ) {
359 throw new ilException('Cannot create export directory');
360 }
361 }
Base class for ILIAS Exception handling.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.

References buildFolderName(), and ilFileUtils\makeDirParents().

Referenced by buildFileName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildFileName()

assLongMenu::buildFileName (   $gap_id)
private

Definition at line 83 of file class.assLongMenu.php.

83 : ?string
84 {
85 try {
86 $this->assertDirExists();
87 return $this->buildFolderName() . $gap_id . '.txt';
88 } catch (ilException $e) {
89 }
90 return null;
91 }

References Vendor\Package\$e, assertDirExists(), and buildFolderName().

Referenced by createFileFromArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildFolderName()

assLongMenu::buildFolderName ( )
private

Definition at line 73 of file class.assLongMenu.php.

73 : string
74 {
75 return ilFileUtils::getDataDir() . '/assessment/longMenuQuestion/' . $this->getId() . '/' ;
76 }
static getDataDir()
get data directory (outside webspace)

References ilFileUtils\getDataDir(), and assQuestion\getId().

Referenced by assertDirExists(), buildFileName(), clearFolder(), and createArrayFromFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPoints()

assLongMenu::calculateReachedPoints ( int  $active_id,
?int  $pass = null,
bool  $authorized_solution = true 
)

Reimplemented from assQuestion.

Definition at line 483 of file class.assLongMenu.php.

487 : float {
488 $found_values = [];
489 if (is_null($pass)) {
490 $pass = $this->getSolutionMaxPass($active_id);
491 }
492 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
493 while ($data = $this->db->fetchAssoc($result)) {
494 $found_values[(int) $data['value1']] = $data['value2'];
495 }
496
497 return $this->calculateReachedPointsForSolution($found_values, $active_id);
498 }
calculateReachedPointsForSolution(?array $found_values, int $active_id=0)
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
getSolutionMaxPass(int $active_id)
$data
Definition: storeScorm.php:45

References assQuestion\getSolutionMaxPass().

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assLongMenu::calculateReachedPointsForSolution ( ?array  $found_values,
int  $active_id = 0 
)
protected

Definition at line 500 of file class.assLongMenu.php.

500 : float
501 {
502 if ($found_values == null) {
503 $found_values = [];
504 }
505 $points = 0.0;
506 $solution_values_text = [];
507 foreach ($found_values as $key => $answer) {
508 if ($answer === '') {
509 continue;
510 }
511
512 $correct_answers = $this->getCorrectAnswersForGap($this->id, $key);
513 if (!in_array($answer, $correct_answers)) {
514 continue;
515 }
516
517 $points_gap = $this->getPointsForGap($this->id, $key);
518 if (!$this->getIdenticalScoring()
519 && in_array($answer, $solution_values_text)
520 && ($points > 0)) {
521 $points_gap = 0;
522 }
523
524 $points += $points_gap;
525 array_push($solution_values_text, $answer);
526 }
527
528 return $points;
529 }
getCorrectAnswersForGap($question_id, $gap_id)
getPointsForGap($question_id, $gap_id)

◆ checkQuestionCustomPart()

assLongMenu::checkQuestionCustomPart (   $form = null)
Parameters
ilPropertyFormGUI | null$form
Returns
bool

Definition at line 175 of file class.assLongMenu.php.

175 : bool
176 {
177 $hidden_text_files = $this->getAnswers();
179 $points = [];
180 if ($correct_answers === null
181 || $correct_answers === []
182 || $hidden_text_files === null
183 || $hidden_text_files === []) {
184 return false;
185 }
186 if (sizeof($correct_answers) != sizeof($hidden_text_files)) {
187 return false;
188 }
189 foreach ($correct_answers as $key => $correct_answers_row) {
190 if ($this->correctAnswerDoesNotExistInAnswerOptions($correct_answers_row, $hidden_text_files[$key])) {
191 return false;
192 }
193 if (!is_array($correct_answers_row[0]) || $correct_answers_row[0] === []) {
194 return false;
195 }
196 if ($correct_answers_row[1] > 0) {
197 array_push($points, $correct_answers_row[1]);
198 }
199 }
200 if (sizeof($correct_answers) != sizeof($points)) {
201 return false;
202 }
203
204 foreach ($points as $row) {
205 if ($row <= 0) {
206 return false;
207 }
208 }
209 return true;
210 }
correctAnswerDoesNotExistInAnswerOptions($answers, $answer_options)

References $correct_answers, assQuestion\$points, correctAnswerDoesNotExistInAnswerOptions(), getAnswers(), and getCorrectAnswers().

+ Here is the call graph for this function:

◆ clearAnswerSpecificDataFromDb()

assLongMenu::clearAnswerSpecificDataFromDb ( int  $question_id)

Definition at line 677 of file class.assLongMenu.php.

677 : void
678 {
679 $this->db->manipulateF(
680 'DELETE FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s',
681 [ 'integer' ],
682 [ $question_id ]
683 );
684 }

Referenced by saveAnswerSpecificDataToDb().

+ Here is the caller graph for this function:

◆ clearFolder()

assLongMenu::clearFolder (   $let_folder_exists = true)
private

Definition at line 342 of file class.assLongMenu.php.

342 : void
343 {
344 ilFileUtils::delDir($this->buildFolderName(), $let_folder_exists);
345 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References buildFolderName(), and ilFileUtils\delDir().

Referenced by createFileFromArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ correctAnswerDoesNotExistInAnswerOptions()

assLongMenu::correctAnswerDoesNotExistInAnswerOptions (   $answers,
  $answer_options 
)
private
Parameters
$answers
$answer_options
Returns
bool

Definition at line 217 of file class.assLongMenu.php.

217 : bool
218 {
219 foreach ($answers[0] as $key => $answer) {
220 if (!in_array($answer, $answer_options)) {
221 return true;
222 }
223 }
224 return false;
225 }

References $answers.

Referenced by checkQuestionCustomPart().

+ Here is the caller graph for this function:

◆ createArrayFromFile()

assLongMenu::createArrayFromFile ( )
private

Definition at line 319 of file class.assLongMenu.php.

319 : array
320 {
321 $files = glob($this->buildFolderName() . '*.txt');
322
323 if ($files === false) {
324 $files = [];
325 }
326
327 $answers = [];
328
329 foreach ($files as $file) {
330 $gap = str_replace('.txt', '', basename($file));
331 $answers[(int) $gap] = explode("\n", file_get_contents($file));
332 }
333 // Sort by gap keys, to ensure the numbers are in ascending order.
334 // Glob will report the keys in files order like 0, 1, 10, 11, 2,...
335 // json_encoding the array with keys in order 0,1,10,11,2,.. will create
336 // a json_object instead of a list when keys are numeric, sorted and start with 0
337 ksort($answers);
338 $this->setAnswers($answers);
339 return $answers;
340 }
setAnswers(array $answers)

References $answers, $files, buildFolderName(), ILIAS\Repository\int(), and setAnswers().

Referenced by getAnswersObject(), and loadFromDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createFileFromArray()

assLongMenu::createFileFromArray ( )
private

Definition at line 301 of file class.assLongMenu.php.

301 : void
302 {
303 $array = $this->getAnswers();
304 $this->clearFolder();
305 foreach ($array as $gap => $values) {
306 $file_content = '';
307 if (is_array($values)) {
308 foreach ($values as $key => $value) {
309 $file_content .= $value . "\n";
310 }
311 $file_content = rtrim($file_content, "\n");
312 $file = fopen($this->buildFileName($gap), "w");
313 fwrite($file, $file_content);
314 fclose($file);
315 }
316 }
317 }
buildFileName($gap_id)
clearFolder($let_folder_exists=true)

References buildFileName(), clearFolder(), and getAnswers().

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

assLongMenu::delete ( int  $question_id)

Reimplemented from assQuestion.

Definition at line 686 of file class.assLongMenu.php.

686 : void
687 {
688 parent::delete($question_id);
689 $this->clearFolder(false);
690 }

◆ fromNormalized()

assLongMenu::fromNormalized ( array  $normalized,
Transformations  $transformations 
)
Parameters
array<array-key,mixed>$normalized

Reimplemented from assQuestion.

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

861 : static
862 {
863 $clone = parent::fromNormalized($normalized, $transformations);
864 $clone->long_menu_text = $transformations->string($normalized['long_menu_text']);
865 $clone->json_structure = $transformations->string($normalized['json_structure']);
866 $clone->minAutoComplete = $transformations->int($normalized['min_auto_complete']);
867 $clone->identical_scoring = $transformations->bool($normalized['identical_scoring']);
868 $clone->correct_answers = $normalized['correct_answers'];
869 $clone->answers = $normalized['answers'];
870
871 return $clone;
872 }

References ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\bool(), ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\int(), and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\string().

+ Here is the call graph for this function:

◆ getAdditionalTableName()

assLongMenu::getAdditionalTableName ( )

Reimplemented from assQuestion.

Definition at line 625 of file class.assLongMenu.php.

625 : string
626 {
627 return 'qpl_qst_lome';
628 }

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAnswers()

assLongMenu::getAnswers ( )

Definition at line 108 of file class.assLongMenu.php.

108 : array
109 {
110 return $this->answers;
111 }

References $answers.

Referenced by checkQuestionCustomPart(), and createFileFromArray().

+ Here is the caller graph for this function:

◆ getAnswersForLog()

assLongMenu::getAnswersForLog ( AdditionalInformationGenerator  $additional_info)
private

Definition at line 754 of file class.assLongMenu.php.

754 : string
755 {
756 $i = 1;
757 return array_reduce(
758 $this->getAnswers(),
759 static function (string $c, array $v) use ($additional_info, &$i): string {
760 return $c . $additional_info->getTagForLangVar('gap')
761 . ' ' . $i++ . ': ' . implode(',', $v) . '; ';
762 },
763 ''
764 );
765 }

References Vendor\Package\$c, and ILIAS\Test\Logging\AdditionalInformationGenerator\getTagForLangVar().

+ Here is the call graph for this function:

◆ getAnswersObject()

assLongMenu::getAnswersObject ( )

Definition at line 472 of file class.assLongMenu.php.

473 {
474 return json_encode($this->createArrayFromFile());
475 }

References createArrayFromFile().

+ Here is the call graph for this function:

◆ getAnswerTableName()

assLongMenu::getAnswerTableName ( )

Reimplemented from assQuestion.

Definition at line 78 of file class.assLongMenu.php.

78 : string
79 {
80 return "qpl_a_lome";
81 }

Referenced by getCorrectAnswersForGap(), getCorrectAnswersForQuestionSolution(), getPointsForGap(), and saveAnswerSpecificDataToDb().

+ Here is the caller graph for this function:

◆ getAnswerType()

assLongMenu::getAnswerType ( )

Definition at line 49 of file class.assLongMenu.php.

49 : ?array
50 {
51 return $this->answerType;
52 }

References $answerType.

Referenced by saveAnswerSpecificDataToDb().

+ Here is the caller graph for this function:

◆ getAvailableAnswerOptions()

assLongMenu::getAvailableAnswerOptions (   $index = null)

If index is null, the function returns an array with all anwser options Else it returns the specific answer option.

Parameters
null | int$index
Returns
array|ASS_AnswerSimple

Definition at line 667 of file class.assLongMenu.php.

668 {
669 return $this->createArrayFromFile();
670 }

◆ getCorrectAnswers()

assLongMenu::getCorrectAnswers ( )
Returns
mixed

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

63 {
65 }

References $correct_answers.

Referenced by checkQuestionCustomPart(), getMaximumPoints(), and saveAnswerSpecificDataToDb().

+ Here is the caller graph for this function:

◆ getCorrectAnswersAsJson()

assLongMenu::getCorrectAnswersAsJson ( )

Definition at line 477 of file class.assLongMenu.php.

478 {
479 $this->loadCorrectAnswerData($this->getId());
480 return $this->getJsonStructure();
481 }
loadCorrectAnswerData($question_id)

References assQuestion\getId(), getJsonStructure(), and loadCorrectAnswerData().

+ Here is the call graph for this function:

◆ getCorrectAnswersForGap()

assLongMenu::getCorrectAnswersForGap (   $question_id,
  $gap_id 
)
private

Definition at line 443 of file class.assLongMenu.php.

443 : array
444 {
445 $correct_answers = [];
446 $res = $this->db->queryF(
447 'SELECT answer_text FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s AND gap_number = %s',
448 ['integer', 'integer'],
449 [$question_id, $gap_id]
450 );
451 while ($data = $this->db->fetchAssoc($res)) {
452 $correct_answers[] = rtrim($data['answer_text']);
453 }
454 return $correct_answers;
455 }
foreach($_POST as $key=> $value) $res

References $correct_answers, $data, $res, and getAnswerTableName().

+ Here is the call graph for this function:

◆ getCorrectAnswersForLog()

assLongMenu::getCorrectAnswersForLog ( AdditionalInformationGenerator  $additional_info)
private

Definition at line 767 of file class.assLongMenu.php.

767 : string
768 {
769 $answer_types = [
770 self::ANSWER_TYPE_SELECT_VAL => $additional_info->getTagForLangVar('answers_select'),
771 self::ANSWER_TYPE_TEXT_VAL => $additional_info->getTagForLangVar('answers_text_box')
772 ];
773
774 $i = 1;
775 return array_reduce(
776 $this->getCorrectAnswers(),
777 static function (string $c, array $v) use ($additional_info, $answer_types, &$i): string {
778 return $c . $additional_info->getTagForLangVar('gap')
779 . ' ' . $i++ . ': ' . implode(',', $v[0]) . ', '
780 . $additional_info->getTagForLangVar('points') . ': ' . $v[1] . ', '
781 . $additional_info->getTagForLangVar('type') . ': ' . $answer_types[$v[2]] . '; ';
782 },
783 ''
784 );
785 }

References Vendor\Package\$c, and ILIAS\Test\Logging\AdditionalInformationGenerator\getTagForLangVar().

+ Here is the call graph for this function:

◆ getCorrectAnswersForQuestionSolution()

assLongMenu::getCorrectAnswersForQuestionSolution (   $question_id)

Definition at line 424 of file class.assLongMenu.php.

424 : array
425 {
426 $correct_answers = [];
427 $res = $this->db->queryF(
428 'SELECT gap_number, answer_text FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s',
429 ['integer'],
430 [$question_id]
431 );
432 while ($data = $this->db->fetchAssoc($res)) {
433 if (array_key_exists($data['gap_number'], $correct_answers)) {
434 $correct_answers[$data['gap_number']] .= ' ' . $this->lng->txt("or") . ' ';
435 $correct_answers[$data['gap_number']] .= rtrim($data['answer_text']);
436 } else {
437 $correct_answers[$data['gap_number']] = rtrim($data['answer_text']);
438 }
439 }
440 return $correct_answers;
441 }

References $correct_answers, $data, $res, getAnswerTableName(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getCorrectSolutionForTextOutput()

assLongMenu::getCorrectSolutionForTextOutput ( int  $active_id,
int  $pass 
)

Reimplemented from assQuestion.

Definition at line 830 of file class.assLongMenu.php.

830 : array
831 {
832 $correct_answers = [];
833 foreach ($this->getCorrectAnswers() as $gap_index => $gap) {
834 $correct_answers[] = $this->lng->txt('gap')
835 . ' ' . $gap_index . ': ' . implode(',', $gap[0]);
836 }
837 return $correct_answers;
838 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getIdenticalScoring()

assLongMenu::getIdenticalScoring ( )

Definition at line 726 of file class.assLongMenu.php.

726 : bool
727 {
729 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getJsonStructure()

assLongMenu::getJsonStructure ( )
Returns
mixed

Definition at line 116 of file class.assLongMenu.php.

116 : string
117 {
119 }
string $json_structure

References $json_structure.

Referenced by getCorrectAnswersAsJson().

+ Here is the caller graph for this function:

◆ getLongMenuTextValue()

assLongMenu::getLongMenuTextValue ( )

Definition at line 98 of file class.assLongMenu.php.

98 : string
99 {
101 }
string $long_menu_text

References $long_menu_text.

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getMaximumPoints()

assLongMenu::getMaximumPoints ( )

Returns the maximum points, a learner can reach answering the question.

@access public

See also
$points

Reimplemented from assQuestion.

Definition at line 234 of file class.assLongMenu.php.

234 : float
235 {
236 $sum = 0;
237 $points = $this->getCorrectAnswers();
238 if ($points) {
239 foreach ($points as $add) {
240 $sum += (float) $add[1];
241 }
242 }
243 return $sum;
244 }

References assQuestion\$points, and getCorrectAnswers().

+ Here is the call graph for this function:

◆ getMinAutoComplete()

assLongMenu::getMinAutoComplete ( )

Definition at line 144 of file class.assLongMenu.php.

144 : int
145 {
147 }

References $minAutoComplete.

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getPointsForGap()

assLongMenu::getPointsForGap (   $question_id,
  $gap_id 
)
private

Definition at line 457 of file class.assLongMenu.php.

457 : float
458 {
459 $points = 0.0;
460 $res = $this->db->queryF(
461 'SELECT points FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s AND gap_number = %s GROUP BY gap_number, points',
462 ['integer', 'integer'],
463 [$question_id, $gap_id]
464 );
465 while ($data = $this->db->fetchAssoc($res)) {
466 $points = (float) $data['points'];
467 }
468 return $points;
469 }

References $data, assQuestion\$points, $res, and getAnswerTableName().

+ Here is the call graph for this function:

◆ getQuestionType()

assLongMenu::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

Reimplemented from assQuestion.

Definition at line 620 of file class.assLongMenu.php.

620 : string
621 {
622 return "assLongMenu";
623 }

◆ getRTETextWithMediaObjects()

assLongMenu::getRTETextWithMediaObjects ( )

Collects all text in the question which could contain media objects which were created with the Rich Text Editor.

Reimplemented from assQuestion.

Definition at line 634 of file class.assLongMenu.php.

634 : string
635 {
636 return parent::getRTETextWithMediaObjects() . $this->getLongMenuTextValue();
637 }

◆ getSolutionSubmit()

assLongMenu::getSolutionSubmit ( )
protected

Definition at line 600 of file class.assLongMenu.php.

600 : array
601 {
602 $solution_submit = [];
603 foreach ($this->questionpool_request->strArray('answer') as $key => $value) {
604 $solution_submit[$key] = $value;
605 }
606 return $solution_submit;
607 }

◆ getSpecificFeedbackSetting()

assLongMenu::getSpecificFeedbackSetting ( )

Definition at line 134 of file class.assLongMenu.php.

134 : int
135 {
137 }
int $specificFeedbackSetting

References $specificFeedbackSetting.

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getUserQuestionResult()

assLongMenu::getUserQuestionResult (   $active_id,
  $pass 
)

Get the user solution for a question by active_id and the test pass.

Parameters
int$active_id
int$pass
Returns
ilUserQuestionResult

Definition at line 647 of file class.assLongMenu.php.

648 {
649 $result = new ilUserQuestionResult($this, $active_id, $pass);
650
651 $points = $this->calculateReachedPoints($active_id, $pass);
652 $max_points = $this->getMaximumPoints();
653
654 $result->setReachedPercentage(($points / $max_points) * 100);
655
656 return $result;
657 }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ isComplete()

assLongMenu::isComplete ( )

Reimplemented from assQuestion.

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

149 : bool
150 {
151 if (strlen($this->title)
152 && $this->author
153 && $this->long_menu_text
154 && sizeof($this->answers) > 0
155 && sizeof($this->correct_answers) > 0
156 && $this->getPoints() > 0
157 ) {
158 return true;
159 }
160 return false;
161 }

References assQuestion\getPoints().

+ Here is the call graph for this function:

◆ isShuffleAnswersEnabled()

assLongMenu::isShuffleAnswersEnabled ( )

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

672 : bool
673 {
674 return false;
675 }

◆ lmMigrateQuestionTypeSpecificContent()

assLongMenu::lmMigrateQuestionTypeSpecificContent ( ilAssSelfAssessmentMigrator  $migrator)
protected
Parameters
ilAssSelfAssessmentMigrator$migrator

Reimplemented from assQuestion.

Definition at line 695 of file class.assLongMenu.php.

695 : void
696 {
697 $this->setLongMenuTextValue($migrator->migrateToLmContent($this->getLongMenuTextValue()));
698 }
setLongMenuTextValue(string $long_menu_text='')

References ilAssSelfAssessmentMigrator\migrateToLmContent().

+ Here is the call graph for this function:

◆ loadCorrectAnswerData()

assLongMenu::loadCorrectAnswerData (   $question_id)
private

Definition at line 406 of file class.assLongMenu.php.

406 : void
407 {
408 $res = $this->db->queryF(
409 "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY gap_number, position ASC",
410 ['integer'],
411 [$question_id]
412 );
413
414 $correct_answers = [];
415 while ($data = $this->db->fetchAssoc($res)) {
416 $correct_answers[$data['gap_number']][0][$data['position']] = rtrim($data['answer_text']);
417 $correct_answers[$data['gap_number']][1] = $data['points'];
418 $correct_answers[$data['gap_number']][2] = $data['type'];
419 }
420 $this->setJsonStructure(json_encode($correct_answers));
422 }
setJsonStructure(string $json_structure)
setCorrectAnswers(array $correct_answers)

References $correct_answers, $data, $res, setCorrectAnswers(), and setJsonStructure().

Referenced by getCorrectAnswersAsJson(), and loadFromDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadFromDb()

assLongMenu::loadFromDb (   $question_id)

Definition at line 363 of file class.assLongMenu.php.

363 : void
364 {
365 $result = $this->db->queryF(
366 "SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s",
367 ["integer"],
368 [$question_id]
369 );
370 if ($result->numRows() == 1) {
371 $data = $this->db->fetchAssoc($result);
372 $this->setId($question_id);
373 $this->setObjId($data['obj_fi']);
374 $this->setNrOfTries($data['nr_of_tries']);
375 $this->setTitle((string) $data['title']);
376 $this->setComment((string) $data['description']);
377 $this->setOriginalId($data['original_id']);
378 $this->setAuthor($data['author']);
379 $this->setPoints($data['points']);
380 $this->setIdenticalScoring((bool) $data['identical_scoring']);
381 $this->setOwner($data['owner']);
382 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data['question_text'], 1));
383 $this->setLongMenuTextValue(ilRTE::_replaceMediaObjectImageSrc((string) $data['long_menu_text'], 1));
384 $this->setMinAutoComplete($data['min_auto_complete'] ?? self::MIN_LENGTH_AUTOCOMPLETE);
385 if (isset($data['feedback_setting'])) {
386 $this->setSpecificFeedbackSetting((int) $data['feedback_setting']);
387 }
388
389 try {
390 $this->setLifecycle(new ilAssQuestionLifecycle($data['lifecycle']));
393 }
394
395 try {
396 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
398 }
399 }
400
401 $this->loadCorrectAnswerData($question_id);
402 $this->createArrayFromFile();
403 parent::loadFromDb($question_id);
404 }
setSpecificFeedbackSetting($specificFeedbackSetting)
setMinAutoComplete(int $min_auto_complete)
setIdenticalScoring(bool $identical_scoring)
setOriginalId(?int $original_id)
setId(int $id=-1)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
setAuthor(string $author="")
setComment(string $comment="")
setObjId(int $obj_id=0)
setOwner(int $owner=-1)
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
setPoints(float $points)
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...

References $data, Vendor\Package\$e, ilRTE\_replaceMediaObjectImageSrc(), createArrayFromFile(), getAdditionalTableName(), loadCorrectAnswerData(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setId(), setIdenticalScoring(), assQuestion\setLifecycle(), setLongMenuTextValue(), setMinAutoComplete(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setSpecificFeedbackSetting(), and assQuestion\setTitle().

+ Here is the call graph for this function:

◆ lookupForExistingSolutions()

assLongMenu::lookupForExistingSolutions ( int  $activeId,
int  $pass 
)

Lookup if an authorized or intermediate solution exists.

Returns
array ['authorized' => bool, 'intermediate' => bool]

Reimplemented from assQuestion.

Definition at line 562 of file class.assLongMenu.php.

562 : array
563 {
564 $return = [
565 'authorized' => false,
566 'intermediate' => false
567 ];
568
569 $query = "
570 SELECT authorized, COUNT(*) cnt
571 FROM tst_solutions
572 WHERE active_fi = " . $this->db->quote($activeId, 'integer') . "
573 AND question_fi = " . $this->db->quote($this->getId(), 'integer') . "
574 AND pass = " . $this->db->quote($pass, 'integer') . "
575 AND value2 <> '-1'
576 ";
577
578 if ($this->getStep() !== null) {
579 $query .= " AND step = " . $this->db->quote((int) $this->getStep(), 'integer') . " ";
580 }
581
582 $query .= "
583 GROUP BY authorized
584 ";
585
586 $result = $this->db->query($query);
587
588 while ($row = $this->db->fetchAssoc($result)) {
589 if ($row['authorized']) {
590 $return['authorized'] = $row['cnt'] > 0;
591 } else {
592 $return['intermediate'] = $row['cnt'] > 0;
593 }
594 }
595 return $return;
596 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assLongMenu::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

Definition at line 246 of file class.assLongMenu.php.

247 {
248 // save additional data
249 $this->db->manipulateF(
250 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
251 [ "integer" ],
252 [ $this->getId() ]
253 );
254 $this->db->manipulateF(
255 "INSERT INTO " . $this->getAdditionalTableName(
256 ) . " (question_fi, long_menu_text, feedback_setting, min_auto_complete, identical_scoring) VALUES (%s, %s, %s, %s, %s)",
257 [ "integer", "text", "integer", "integer", "integer"],
258 [
259 $this->getId(),
260 $this->getLongMenuTextValue(),
262 $this->getMinAutoComplete(),
263 $this->getIdenticalScoring()
264 ]
265 );
266
267 $this->createFileFromArray();
268 }

References createFileFromArray(), getAdditionalTableName(), assQuestion\getId(), getIdenticalScoring(), getLongMenuTextValue(), getMinAutoComplete(), and getSpecificFeedbackSetting().

Referenced by saveToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAnswerSpecificDataToDb()

assLongMenu::saveAnswerSpecificDataToDb ( )

Definition at line 270 of file class.assLongMenu.php.

270 : void
271 {
272 $this->clearAnswerSpecificDataFromDb($this->getId());
273 $type_array = $this->getAnswerType();
274 $points = 0;
275 foreach ($this->getCorrectAnswers() as $gap_number => $gap) {
276 foreach ($gap[0] as $position => $answer) {
277 if ($type_array == null) {
278 $type = $gap[2];
279 } else {
280 $type = $type_array[$gap_number];
281 }
282 $this->db->replace(
283 $this->getAnswerTableName(),
284 [
285 'question_fi' => ['integer', $this->getId()],
286 'gap_number' => ['integer', (int) $gap_number],
287 'position' => ['integer', (int) $position]
288 ],
289 [
290 'answer_text' => ['text', $answer],
291 'points' => ['float', $gap[1]],
292 'type' => ['integer', (int) $type]
293 ]
294 );
295 }
296 $points += $gap[1];
297 }
298 $this->setPoints($points);
299 }
clearAnswerSpecificDataFromDb(int $question_id)

References assQuestion\$points, clearAnswerSpecificDataFromDb(), getAnswerTableName(), getAnswerType(), getCorrectAnswers(), assQuestion\getId(), and assQuestion\setPoints().

Referenced by saveToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePreviewData()

assLongMenu::savePreviewData ( ilAssQuestionPreviewSession  $preview_session)
protected

Reimplemented from assQuestion.

Definition at line 609 of file class.assLongMenu.php.

609 : void
610 {
611 $answer = $this->questionpool_request->strArray('answer');
612 $preview_session->setParticipantsSolution(array_map(static fn($value) => trim($value), $answer));
613 }

References ilAssQuestionPreviewSession\setParticipantsSolution().

+ Here is the call graph for this function:

◆ saveToDb()

assLongMenu::saveToDb ( ?int  $original_id = null)

Reimplemented from assQuestion.

Definition at line 163 of file class.assLongMenu.php.

163 : void
164 {
168 parent::saveToDb();
169 }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb(?int $original_id=null)

References assQuestion\$original_id, saveAdditionalQuestionDataToDb(), saveAnswerSpecificDataToDb(), and assQuestion\saveQuestionDataToDb().

+ Here is the call graph for this function:

◆ saveWorkingData()

assLongMenu::saveWorkingData ( int  $active_id,
?int  $pass = null,
bool  $authorized = true 
)

Reimplemented from assQuestion.

Definition at line 531 of file class.assLongMenu.php.

535 : bool {
536 if (is_null($pass)) {
537 $pass = ilObjTest::_getPass($active_id);
538 }
539
540 $answer = $this->getSolutionSubmit();
541 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
542 function () use ($answer, $active_id, $pass, $authorized) {
543 $this->removeCurrentSolution($active_id, $pass, $authorized);
544
545 foreach ($answer as $key => $value) {
546 if ($value === '') {
547 continue;
548 }
549 $this->saveCurrentSolution($active_id, $pass, $key, $value, $authorized);
550 }
551 }
552 );
553
554 return true;
555 }
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.

References ilObjTest\_getPass().

+ Here is the call graph for this function:

◆ setAnswers()

assLongMenu::setAnswers ( array  $answers)

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

103 : void
104 {
105 $this->answers = $answers;
106 }

References $answers.

Referenced by createArrayFromFile().

+ Here is the caller graph for this function:

◆ setAnswerType()

assLongMenu::setAnswerType ( array  $answerType)

Definition at line 54 of file class.assLongMenu.php.

54 : void
55 {
56 $this->answerType = $answerType;
57 }

References $answerType.

◆ setCorrectAnswers()

assLongMenu::setCorrectAnswers ( array  $correct_answers)

Definition at line 68 of file class.assLongMenu.php.

68 : void
69 {
70 $this->correct_answers = $correct_answers;
71 }

References $correct_answers.

Referenced by loadCorrectAnswerData().

+ Here is the caller graph for this function:

◆ setIdenticalScoring()

assLongMenu::setIdenticalScoring ( bool  $identical_scoring)

Definition at line 731 of file class.assLongMenu.php.

731 : void
732 {
733 $this->identical_scoring = $identical_scoring;
734 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setJsonStructure()

assLongMenu::setJsonStructure ( string  $json_structure)
private
Parameters
mixed$json_structure

Definition at line 124 of file class.assLongMenu.php.

124 : void
125 {
126 $this->json_structure = $json_structure;
127 }

References $json_structure.

Referenced by loadCorrectAnswerData().

+ Here is the caller graph for this function:

◆ setLongMenuTextValue()

assLongMenu::setLongMenuTextValue ( string  $long_menu_text = '')

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

93 : void
94 {
95 $this->long_menu_text = $this->getHtmlQuestionContentPurifier()->purify($long_menu_text);
96 }

References assQuestion\getHtmlQuestionContentPurifier().

Referenced by loadFromDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMinAutoComplete()

assLongMenu::setMinAutoComplete ( int  $min_auto_complete)

Definition at line 139 of file class.assLongMenu.php.

139 : void
140 {
141 $this->minAutoComplete = $min_auto_complete;
142 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setSpecificFeedbackSetting()

assLongMenu::setSpecificFeedbackSetting (   $specificFeedbackSetting)

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

129 : void
130 {
131 $this->specificFeedbackSetting = $specificFeedbackSetting;
132 }

References $specificFeedbackSetting.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ solutionValuesToLog()

assLongMenu::solutionValuesToLog ( AdditionalInformationGenerator  $additional_info,
array  $solution_values 
)
protected

MUST convert the given solution values into an array or a string that can be stored in the log.

Language variables must be generated through the corresponding functions in the AdditionalInformationGenerator. If an array is returned it will be rendered into a line per array entry in the format "key: value". If the key exists as a language variable, it will be translated.

Reimplemented from assQuestion.

Definition at line 787 of file class.assLongMenu.php.

790 : array {
791 $parsed_solution = [];
792 foreach ($this->getCorrectAnswers() as $gap_index => $gap) {
793 foreach ($solution_values as $solution) {
794 if ($gap_index !== (int) $solution['value1']) {
795 continue;
796 }
797 $value = $solution['value2'];
798 if ($gap[2] === self::ANSWER_TYPE_SELECT_VAL
799 && $value === '-1') {
800 $value = '';
801 }
802 $parsed_solution[$gap_index + 1] = $value;
803 break;
804 }
805 }
806 return $parsed_solution;
807 }

◆ solutionValuesToText()

assLongMenu::solutionValuesToText ( array  $solution_values)

MUST convert the given solution values into text.

If the text has multiple lines each line MUST be placed as an entry in an array.

Reimplemented from assQuestion.

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

809 : array
810 {
811 $parsed_solution = [];
812
813 foreach ($this->getCorrectAnswers() as $gap_index => $gap) {
814 foreach ($solution_values as $solution) {
815 if ($gap_index !== (int) $solution['value1']) {
816 continue;
817 }
818 $value = $solution['value2'];
819 if ($gap[2] === self::ANSWER_TYPE_SELECT_VAL
820 && $value === '-1') {
821 $value = '';
822 }
823 $parsed_solution[] = $this->lng->txt('gap') . ' ' . $gap_index + 1 . ': ' . $value;
824 break;
825 }
826 }
827 return $parsed_solution;
828 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ toJSON()

assLongMenu::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

Definition at line 703 of file class.assLongMenu.php.

703 : string
704 {
705 $result = [];
706 $result['id'] = $this->getId();
707 $result['type'] = (string) $this->getQuestionType();
708 $result['title'] = $this->getTitleForHTMLOutput();
709 $result['question'] = $this->formatSAQuestion($this->getQuestion());
710 $replaced_quesiton_text = $this->getLongMenuTextValue();
711 $result['lmtext'] = $this->formatSAQuestion($replaced_quesiton_text);
712 $result['nr_of_tries'] = $this->getNrOfTries();
713 $result['shuffle'] = $this->getShuffle();
714 $result['feedback'] = [
715 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
716 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
717 ];
718
719 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
720 $result['answers'] = $this->getAnswers();
721 $result['correct_answers'] = $this->getCorrectAnswers();
722 $result['mobs'] = $mobs;
723 return json_encode($result);
724 }
getQuestionType()
Returns the question type of the question.
static _getMobsOfObject(string $a_type, int $a_id, int|false $a_usage_hist_nr=0, string $a_lang="-")

References ilObjMediaObject\_getMobsOfObject(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ toLog()

assLongMenu::toLog ( AdditionalInformationGenerator  $additional_info)

MUST return an array of the question settings that can be stored in the log.

Language variables must be generated through the corresponding functions in the AdditionalInformationGenerator. If an array is returned it will be rendered into a line per array entry in the format "key: value". If the key exists as a language variable, it will be translated.

Reimplemented from assQuestion.

Definition at line 736 of file class.assLongMenu.php.

736 : array
737 {
738 return [
739 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
740 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
741 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
742 AdditionalInformationGenerator::KEY_QUESTION_LONGMENU_TEXT => $this->formatSAQuestion($this->getLongMenuTextValue()),
743 AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS => $additional_info
745 AdditionalInformationGenerator::KEY_FEEDBACK => [
746 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
747 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
748 ],
749 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTIONS => $this->getAnswersForLog($additional_info),
750 AdditionalInformationGenerator::KEY_QUESTION_CORRECT_ANSWER_OPTIONS => $this->getCorrectAnswersForLog($additional_info)
751 ];
752 }
getCorrectAnswersForLog(AdditionalInformationGenerator $additional_info)
getAnswersForLog(AdditionalInformationGenerator $additional_info)

References ILIAS\Test\Logging\AdditionalInformationGenerator\getTrueFalseTagForBool().

+ Here is the call graph for this function:

◆ toNormalized()

assLongMenu::toNormalized ( Transformations  $transformations,
array  $context = [] 
)
Parameters
array<string,mixed>$context
Returns
array<array-key, mixed>|float|bool|int|string|null

Reimplemented from assQuestion.

Definition at line 841 of file class.assLongMenu.php.

844 : array|float|bool|int|string|null
845 {
846 return [
847 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
848 'long_menu_text' => $this->long_menu_text,
849 'json_structure' => $this->json_structure,
850 'min_auto_complete' => $this->minAutoComplete,
851 'identical_scoring' => $this->identical_scoring,
852 'correct_answers' => $this->correct_answers,
853 'answers' => $this->answers,
854 ];
855 }

Field Documentation

◆ $answers

array assLongMenu::$answers = []
private

◆ $answerType

array assLongMenu::$answerType = null
private

Definition at line 38 of file class.assLongMenu.php.

Referenced by getAnswerType(), and setAnswerType().

◆ $correct_answers

◆ $identical_scoring

bool assLongMenu::$identical_scoring = true
private

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

◆ $json_structure

string assLongMenu::$json_structure = ''
private

Definition at line 40 of file class.assLongMenu.php.

Referenced by getJsonStructure(), and setJsonStructure().

◆ $long_menu_text

string assLongMenu::$long_menu_text = ''
private

Definition at line 39 of file class.assLongMenu.php.

Referenced by getLongMenuTextValue().

◆ $minAutoComplete

int assLongMenu::$minAutoComplete = self::MIN_LENGTH_AUTOCOMPLETE
private

Definition at line 42 of file class.assLongMenu.php.

Referenced by getMinAutoComplete().

◆ $specificFeedbackSetting

int assLongMenu::$specificFeedbackSetting = ilAssConfigurableMultiOptionQuestionFeedback::FEEDBACK_SETTING_ALL
private

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

Referenced by getSpecificFeedbackSetting(), and setSpecificFeedbackSetting().

◆ ANSWER_TYPE_SELECT_VAL

◆ ANSWER_TYPE_TEXT_VAL

◆ GAP_PLACEHOLDER

◆ HAS_SPECIFIC_FEEDBACK

const assLongMenu::HAS_SPECIFIC_FEEDBACK = false
protected

Definition at line 36 of file class.assLongMenu.php.

◆ MAX_INPUT_FIELDS

const assLongMenu::MAX_INPUT_FIELDS = 500

◆ MIN_LENGTH_AUTOCOMPLETE

const assLongMenu::MIN_LENGTH_AUTOCOMPLETE = 3

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