ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 
 solutionValuesToText (array $solution_values)
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
- 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, array $solutionhints=[])
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 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 ()
 
static 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)
 
 duplicate (bool $for_test=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 ()
 
 deductHintPointsFromReachedPoints (ilAssQuestionPreviewSession $preview_session, $reached_points)
 
 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 ()
 
 cloneHints (int $source_question_id, int $target_question_id)
 
 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)
 
 ensureHintPageObjectExists ($pageObjectId)
 
 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)
 

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)
 
- 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)
 
 duplicateQuestionHints (int $original_question_id, int $duplicate_question_id)
 
 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
 
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 _setReachedPoints (int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. 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 25 of file class.assLongMenu.php.

Member Function Documentation

◆ assertDirExists()

assLongMenu::assertDirExists ( )
private

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

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

Referenced by buildFileName().

344  : void
345  {
346  $folder_name = $this->buildFolderName();
347  if (!ilFileUtils::makeDirParents($folder_name)) {
348  throw new ilException('Cannot create export directory');
349  }
350 
351  if (
352  !is_dir($folder_name) ||
353  !is_readable($folder_name) ||
354  !is_writable($folder_name)
355  ) {
356  throw new ilException('Cannot create export directory');
357  }
358  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ 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 80 of file class.assLongMenu.php.

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

Referenced by createFileFromArray().

80  : ?string
81  {
82  try {
83  $this->assertDirExists();
84  return $this->buildFolderName() . $gap_id . '.txt';
85  } catch (ilException $e) {
86  }
87  return null;
88  }
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:

◆ buildFolderName()

assLongMenu::buildFolderName ( )
private

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

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

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

70  : string
71  {
72  return ilFileUtils::getDataDir() . '/assessment/longMenuQuestion/' . $this->getId() . '/' ;
73  }
static getDataDir()
get data directory (outside webspace)
+ 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 
)

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

References $data, calculateReachedPointsForSolution(), assQuestion\getCurrentSolutionResultSet(), assQuestion\getSolutionMaxPass(), and ILIAS\Repository\int().

Referenced by getUserQuestionResult().

484  : float {
485  $found_values = [];
486  if (is_null($pass)) {
487  $pass = $this->getSolutionMaxPass($active_id);
488  }
489  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
490  while ($data = $this->db->fetchAssoc($result)) {
491  $found_values[(int) $data['value1']] = $data['value2'];
492  }
493 
494  return $this->calculateReachedPointsForSolution($found_values, $active_id);
495  }
calculateReachedPointsForSolution(?array $found_values, int $active_id=0)
getSolutionMaxPass(int $active_id)
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsForSolution()

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

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

References assQuestion\$points, getCorrectAnswersForGap(), getIdenticalScoring(), getPointsForGap(), and null.

Referenced by calculateReachedPoints().

497  : float
498  {
499  if ($found_values == null) {
500  $found_values = [];
501  }
502  $points = 0.0;
503  $solution_values_text = [];
504  foreach ($found_values as $key => $answer) {
505  if ($answer === '') {
506  continue;
507  }
508 
509  $correct_answers = $this->getCorrectAnswersForGap($this->id, $key);
510  if (!in_array($answer, $correct_answers)) {
511  continue;
512  }
513 
514  $points_gap = $this->getPointsForGap($this->id, $key);
515  if (!$this->getIdenticalScoring()
516  && in_array($answer, $solution_values_text)
517  && ($points > 0)) {
518  $points_gap = 0;
519  }
520 
521  $points += $points_gap;
522  array_push($solution_values_text, $answer);
523  }
524 
525  return $points;
526  }
getCorrectAnswersForGap($question_id, $gap_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getPointsForGap($question_id, $gap_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkQuestionCustomPart()

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

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

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

172  : bool
173  {
174  $hidden_text_files = $this->getAnswers();
176  $points = [];
177  if ($correct_answers === null
178  || $correct_answers === []
179  || $hidden_text_files === null
180  || $hidden_text_files === []) {
181  return false;
182  }
183  if (sizeof($correct_answers) != sizeof($hidden_text_files)) {
184  return false;
185  }
186  foreach ($correct_answers as $key => $correct_answers_row) {
187  if ($this->correctAnswerDoesNotExistInAnswerOptions($correct_answers_row, $hidden_text_files[$key])) {
188  return false;
189  }
190  if (!is_array($correct_answers_row[0]) || $correct_answers_row[0] === []) {
191  return false;
192  }
193  if ($correct_answers_row[1] > 0) {
194  array_push($points, $correct_answers_row[1]);
195  }
196  }
197  if (sizeof($correct_answers) != sizeof($points)) {
198  return false;
199  }
200 
201  foreach ($points as $row) {
202  if ($row <= 0) {
203  return false;
204  }
205  }
206  return true;
207  }
correctAnswerDoesNotExistInAnswerOptions($answers, $answer_options)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ clearAnswerSpecificDataFromDb()

assLongMenu::clearAnswerSpecificDataFromDb ( int  $question_id)

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

References getAnswerTableName().

Referenced by saveAnswerSpecificDataToDb().

674  : void
675  {
676  $this->db->manipulateF(
677  'DELETE FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s',
678  [ 'integer' ],
679  [ $question_id ]
680  );
681  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearFolder()

assLongMenu::clearFolder (   $let_folder_exists = true)
private

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

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

Referenced by createFileFromArray(), and delete().

339  : void
340  {
341  ilFileUtils::delDir($this->buildFolderName(), $let_folder_exists);
342  }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ 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 214 of file class.assLongMenu.php.

Referenced by checkQuestionCustomPart().

214  : bool
215  {
216  foreach ($answers[0] as $key => $answer) {
217  if (!in_array($answer, $answer_options)) {
218  return true;
219  }
220  }
221  return false;
222  }
+ Here is the caller graph for this function:

◆ createArrayFromFile()

assLongMenu::createArrayFromFile ( )
private

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

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

Referenced by getAnswersObject(), getAvailableAnswerOptions(), and loadFromDb().

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

◆ createFileFromArray()

assLongMenu::createFileFromArray ( )
private

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

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

Referenced by saveAdditionalQuestionDataToDb().

298  : void
299  {
300  $array = $this->getAnswers();
301  $this->clearFolder();
302  foreach ($array as $gap => $values) {
303  $file_content = '';
304  if (is_array($values)) {
305  foreach ($values as $key => $value) {
306  $file_content .= $value . "\n";
307  }
308  $file_content = rtrim($file_content, "\n");
309  $file = fopen($this->buildFileName($gap), "w");
310  fwrite($file, $file_content);
311  fclose($file);
312  }
313  }
314  }
clearFolder($let_folder_exists=true)
buildFileName($gap_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

assLongMenu::delete ( int  $question_id)

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

References clearFolder().

683  : void
684  {
685  parent::delete($question_id);
686  $this->clearFolder(false);
687  }
clearFolder($let_folder_exists=true)
+ Here is the call graph for this function:

◆ getAdditionalTableName()

assLongMenu::getAdditionalTableName ( )

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

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

622  : string
623  {
624  return 'qpl_qst_lome';
625  }
+ Here is the caller graph for this function:

◆ getAnswers()

assLongMenu::getAnswers ( )

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

References $answers.

Referenced by checkQuestionCustomPart(), createFileFromArray(), getAnswersForLog(), and toJSON().

105  : array
106  {
107  return $this->answers;
108  }
+ Here is the caller graph for this function:

◆ getAnswersForLog()

assLongMenu::getAnswersForLog ( AdditionalInformationGenerator  $additional_info)
private

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

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

Referenced by toLog().

751  : string
752  {
753  $i = 1;
754  return array_reduce(
755  $this->getAnswers(),
756  static function (string $c, array $v) use ($additional_info, &$i): string {
757  return $c . $additional_info->getTagForLangVar('gap')
758  . ' ' . $i++ . ': ' . implode(',', $v) . '; ';
759  },
760  ''
761  );
762  }
$c
Definition: deliver.php:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAnswersObject()

assLongMenu::getAnswersObject ( )

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

References createArrayFromFile().

470  {
471  return json_encode($this->createArrayFromFile());
472  }
+ Here is the call graph for this function:

◆ getAnswerTableName()

assLongMenu::getAnswerTableName ( )

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

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

75  : string
76  {
77  return "qpl_a_lome";
78  }
+ Here is the caller graph for this function:

◆ getAnswerType()

assLongMenu::getAnswerType ( )

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

References $answerType.

Referenced by saveAnswerSpecificDataToDb().

46  : ?array
47  {
48  return $this->answerType;
49  }
+ 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 664 of file class.assLongMenu.php.

References createArrayFromFile().

665  {
666  return $this->createArrayFromFile();
667  }
+ Here is the call graph for this function:

◆ getCorrectAnswers()

assLongMenu::getCorrectAnswers ( )
Returns
mixed

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

References $correct_answers.

Referenced by checkQuestionCustomPart(), getCorrectAnswersForLog(), getCorrectSolutionForTextOutput(), getMaximumPoints(), saveAnswerSpecificDataToDb(), solutionValuesToLog(), solutionValuesToText(), and toJSON().

60  {
62  }
+ Here is the caller graph for this function:

◆ getCorrectAnswersAsJson()

assLongMenu::getCorrectAnswersAsJson ( )

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

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

475  {
476  $this->loadCorrectAnswerData($this->getId());
477  return $this->getJsonStructure();
478  }
loadCorrectAnswerData($question_id)
+ Here is the call graph for this function:

◆ getCorrectAnswersForGap()

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

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

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

Referenced by calculateReachedPointsForSolution().

440  : array
441  {
442  $correct_answers = [];
443  $res = $this->db->queryF(
444  'SELECT answer_text FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s AND gap_number = %s',
445  ['integer', 'integer'],
446  [$question_id, $gap_id]
447  );
448  while ($data = $this->db->fetchAssoc($res)) {
449  $correct_answers[] = rtrim($data['answer_text']);
450  }
451  return $correct_answers;
452  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCorrectAnswersForLog()

assLongMenu::getCorrectAnswersForLog ( AdditionalInformationGenerator  $additional_info)
private

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

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

Referenced by toLog().

764  : string
765  {
766  $answer_types = [
767  self::ANSWER_TYPE_SELECT_VAL => $additional_info->getTagForLangVar('answers_select'),
768  self::ANSWER_TYPE_TEXT_VAL => $additional_info->getTagForLangVar('answers_text_box')
769  ];
770 
771  $i = 1;
772  return array_reduce(
773  $this->getCorrectAnswers(),
774  static function (string $c, array $v) use ($additional_info, $answer_types, &$i): string {
775  return $c . $additional_info->getTagForLangVar('gap')
776  . ' ' . $i++ . ': ' . implode(',', $v[0]) . ', '
777  . $additional_info->getTagForLangVar('points') . ': ' . $v[1] . ', '
778  . $additional_info->getTagForLangVar('type') . ': ' . $answer_types[$v[2]] . '; ';
779  },
780  ''
781  );
782  }
$c
Definition: deliver.php:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCorrectAnswersForQuestionSolution()

assLongMenu::getCorrectAnswersForQuestionSolution (   $question_id)

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

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

421  : array
422  {
423  $correct_answers = [];
424  $res = $this->db->queryF(
425  'SELECT gap_number, answer_text FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s',
426  ['integer'],
427  [$question_id]
428  );
429  while ($data = $this->db->fetchAssoc($res)) {
430  if (array_key_exists($data['gap_number'], $correct_answers)) {
431  $correct_answers[$data['gap_number']] .= ' ' . $this->lng->txt("or") . ' ';
432  $correct_answers[$data['gap_number']] .= rtrim($data['answer_text']);
433  } else {
434  $correct_answers[$data['gap_number']] = rtrim($data['answer_text']);
435  }
436  }
437  return $correct_answers;
438  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

◆ getCorrectSolutionForTextOutput()

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

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

References $correct_answers, getCorrectAnswers(), and ILIAS\Repository\lng().

827  : array
828  {
829  $correct_answers = [];
830  foreach ($this->getCorrectAnswers() as $gap_index => $gap) {
831  $correct_answers[] = $this->lng->txt('gap')
832  . ' ' . $gap_index . ': ' . implode(',', $gap[0]);
833  }
834  return $correct_answers;
835  }
+ Here is the call graph for this function:

◆ getIdenticalScoring()

assLongMenu::getIdenticalScoring ( )

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

References $identical_scoring.

Referenced by calculateReachedPointsForSolution(), and saveAdditionalQuestionDataToDb().

723  : bool
724  {
726  }
+ Here is the caller graph for this function:

◆ getJsonStructure()

assLongMenu::getJsonStructure ( )
Returns
mixed

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

References $json_structure.

Referenced by getCorrectAnswersAsJson().

113  : string
114  {
115  return $this->json_structure;
116  }
string $json_structure
+ Here is the caller graph for this function:

◆ getLongMenuTextValue()

assLongMenu::getLongMenuTextValue ( )

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

References $long_menu_text.

Referenced by getRTETextWithMediaObjects(), saveAdditionalQuestionDataToDb(), toJSON(), and toLog().

95  : string
96  {
97  return $this->long_menu_text;
98  }
string $long_menu_text
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assLongMenu::getMaximumPoints ( )

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

public

See also
$points

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

References assQuestion\$points, and getCorrectAnswers().

Referenced by getUserQuestionResult().

231  : float
232  {
233  $sum = 0;
234  $points = $this->getCorrectAnswers();
235  if ($points) {
236  foreach ($points as $add) {
237  $sum += (float) $add[1];
238  }
239  }
240  return $sum;
241  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMinAutoComplete()

assLongMenu::getMinAutoComplete ( )

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

References $minAutoComplete.

Referenced by saveAdditionalQuestionDataToDb().

141  : int
142  {
143  return $this->minAutoComplete;
144  }
+ Here is the caller graph for this function:

◆ getPointsForGap()

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

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

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

Referenced by calculateReachedPointsForSolution().

454  : float
455  {
456  $points = 0.0;
457  $res = $this->db->queryF(
458  'SELECT points FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s AND gap_number = %s GROUP BY gap_number, points',
459  ['integer', 'integer'],
460  [$question_id, $gap_id]
461  );
462  while ($data = $this->db->fetchAssoc($res)) {
463  $points = (float) $data['points'];
464  }
465  return $points;
466  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionType()

assLongMenu::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

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

Referenced by toJSON(), and toLog().

617  : string
618  {
619  return "assLongMenu";
620  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assLongMenu::getRTETextWithMediaObjects ( )

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

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

References getLongMenuTextValue().

631  : string
632  {
633  return parent::getRTETextWithMediaObjects() . $this->getLongMenuTextValue();
634  }
+ Here is the call graph for this function:

◆ getSolutionSubmit()

assLongMenu::getSolutionSubmit ( )
protected

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

Referenced by saveWorkingData().

597  : array
598  {
599  $solution_submit = [];
600  foreach ($this->questionpool_request->strArray('answer') as $key => $value) {
601  $solution_submit[$key] = $value;
602  }
603  return $solution_submit;
604  }
+ Here is the caller graph for this function:

◆ getSpecificFeedbackSetting()

assLongMenu::getSpecificFeedbackSetting ( )

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

References $specificFeedbackSetting.

Referenced by saveAdditionalQuestionDataToDb().

131  : int
132  {
134  }
int $specificFeedbackSetting
+ 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 644 of file class.assLongMenu.php.

References assQuestion\$points, calculateReachedPoints(), and getMaximumPoints().

645  {
646  $result = new ilUserQuestionResult($this, $active_id, $pass);
647 
648  $points = $this->calculateReachedPoints($active_id, $pass);
649  $max_points = $this->getMaximumPoints();
650 
651  $result->setReachedPercentage(($points / $max_points) * 100);
652 
653  return $result;
654  }
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
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:

◆ isComplete()

assLongMenu::isComplete ( )

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

References assQuestion\getPoints().

146  : bool
147  {
148  if (strlen($this->title)
149  && $this->author
150  && $this->long_menu_text
151  && sizeof($this->answers) > 0
152  && sizeof($this->correct_answers) > 0
153  && $this->getPoints() > 0
154  ) {
155  return true;
156  }
157  return false;
158  }
+ Here is the call graph for this function:

◆ isShuffleAnswersEnabled()

assLongMenu::isShuffleAnswersEnabled ( )

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

669  : bool
670  {
671  return false;
672  }

◆ lmMigrateQuestionTypeSpecificContent()

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

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

References ilAssSelfAssessmentMigrator\migrateToLmContent(), and setLongMenuTextValue().

692  : void
693  {
694  $this->setLongMenuTextValue($migrator->migrateToLmContent($this->getLongMenuTextValue()));
695  }
setLongMenuTextValue(string $long_menu_text='')
+ Here is the call graph for this function:

◆ loadCorrectAnswerData()

assLongMenu::loadCorrectAnswerData (   $question_id)
private

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

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

Referenced by getCorrectAnswersAsJson(), and loadFromDb().

403  : void
404  {
405  $res = $this->db->queryF(
406  "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY gap_number, position ASC",
407  ['integer'],
408  [$question_id]
409  );
410 
411  $correct_answers = [];
412  while ($data = $this->db->fetchAssoc($res)) {
413  $correct_answers[$data['gap_number']][0][$data['position']] = rtrim($data['answer_text']);
414  $correct_answers[$data['gap_number']][1] = $data['points'];
415  $correct_answers[$data['gap_number']][2] = $data['type'];
416  }
417  $this->setJsonStructure(json_encode($correct_answers));
419  }
$res
Definition: ltiservices.php:66
setCorrectAnswers(array $correct_answers)
setJsonStructure(string $json_structure)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadFromDb()

assLongMenu::loadFromDb (   $question_id)

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

References $data, Vendor\Package\$e, ilRTE\_replaceMediaObjectImageSrc(), createArrayFromFile(), getAdditionalTableName(), ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), 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().

360  : void
361  {
362  $result = $this->db->queryF(
363  "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",
364  ["integer"],
365  [$question_id]
366  );
367  if ($result->numRows() == 1) {
368  $data = $this->db->fetchAssoc($result);
369  $this->setId($question_id);
370  $this->setObjId($data['obj_fi']);
371  $this->setNrOfTries($data['nr_of_tries']);
372  $this->setTitle((string) $data['title']);
373  $this->setComment((string) $data['description']);
374  $this->setOriginalId($data['original_id']);
375  $this->setAuthor($data['author']);
376  $this->setPoints($data['points']);
377  $this->setIdenticalScoring((bool) $data['identical_scoring']);
378  $this->setOwner($data['owner']);
379  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data['question_text'], 1));
380  $this->setLongMenuTextValue(ilRTE::_replaceMediaObjectImageSrc((string) $data['long_menu_text'], 1));
381  $this->setMinAutoComplete($data['min_auto_complete'] ?? self::MIN_LENGTH_AUTOCOMPLETE);
382  if (isset($data['feedback_setting'])) {
383  $this->setSpecificFeedbackSetting((int) $data['feedback_setting']);
384  }
385 
386  try {
390  }
391 
392  try {
393  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
394  } catch (ilTestQuestionPoolException $e) {
395  }
396  }
397 
398  $this->loadCorrectAnswerData($question_id);
399  $this->createArrayFromFile();
400  parent::loadFromDb($question_id);
401  }
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...
setNrOfTries(int $a_nr_of_tries)
setOwner(int $owner=-1)
setSpecificFeedbackSetting($specificFeedbackSetting)
loadCorrectAnswerData($question_id)
setComment(string $comment="")
setLongMenuTextValue(string $long_menu_text='')
setMinAutoComplete(int $min_auto_complete)
setPoints(float $points)
setObjId(int $obj_id=0)
setId(int $id=-1)
setOriginalId(?int $original_id)
setTitle(string $title="")
setIdenticalScoring(bool $identical_scoring)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setAuthor(string $author="")
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
+ 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]

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

References assQuestion\getId(), assQuestion\getStep(), and null.

559  : array
560  {
561  $return = [
562  'authorized' => false,
563  'intermediate' => false
564  ];
565 
566  $query = "
567  SELECT authorized, COUNT(*) cnt
568  FROM tst_solutions
569  WHERE active_fi = " . $this->db->quote($activeId, 'integer') . "
570  AND question_fi = " . $this->db->quote($this->getId(), 'integer') . "
571  AND pass = " . $this->db->quote($pass, 'integer') . "
572  AND value2 <> '-1'
573  ";
574 
575  if ($this->getStep() !== null) {
576  $query .= " AND step = " . $this->db->quote((int) $this->getStep(), 'integer') . " ";
577  }
578 
579  $query .= "
580  GROUP BY authorized
581  ";
582 
583  $result = $this->db->query($query);
584 
585  while ($row = $this->db->fetchAssoc($result)) {
586  if ($row['authorized']) {
587  $return['authorized'] = $row['cnt'] > 0;
588  } else {
589  $return['intermediate'] = $row['cnt'] > 0;
590  }
591  }
592  return $return;
593  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 243 of file class.assLongMenu.php.

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

Referenced by saveToDb().

244  {
245  // save additional data
246  $this->db->manipulateF(
247  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
248  [ "integer" ],
249  [ $this->getId() ]
250  );
251  $this->db->manipulateF(
252  "INSERT INTO " . $this->getAdditionalTableName(
253  ) . " (question_fi, long_menu_text, feedback_setting, min_auto_complete, identical_scoring) VALUES (%s, %s, %s, %s, %s)",
254  [ "integer", "text", "integer", "integer", "integer"],
255  [
256  $this->getId(),
257  $this->getLongMenuTextValue(),
259  $this->getMinAutoComplete(),
260  $this->getIdenticalScoring()
261  ]
262  );
263 
264  $this->createFileFromArray();
265  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAnswerSpecificDataToDb()

assLongMenu::saveAnswerSpecificDataToDb ( )

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

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

Referenced by saveToDb().

267  : void
268  {
269  $this->clearAnswerSpecificDataFromDb($this->getId());
270  $type_array = $this->getAnswerType();
271  $points = 0;
272  foreach ($this->getCorrectAnswers() as $gap_number => $gap) {
273  foreach ($gap[0] as $position => $answer) {
274  if ($type_array == null) {
275  $type = $gap[2];
276  } else {
277  $type = $type_array[$gap_number];
278  }
279  $this->db->replace(
280  $this->getAnswerTableName(),
281  [
282  'question_fi' => ['integer', $this->getId()],
283  'gap_number' => ['integer', (int) $gap_number],
284  'position' => ['integer', (int) $position]
285  ],
286  [
287  'answer_text' => ['text', $answer],
288  'points' => ['float', $gap[1]],
289  'type' => ['integer', (int) $type]
290  ]
291  );
292  }
293  $points += $gap[1];
294  }
295  $this->setPoints($points);
296  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setPoints(float $points)
clearAnswerSpecificDataFromDb(int $question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePreviewData()

assLongMenu::savePreviewData ( ilAssQuestionPreviewSession  $preview_session)
protected

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

References ilAssQuestionPreviewSession\setParticipantsSolution().

606  : void
607  {
608  $answer = $this->questionpool_request->strArray('answer');
609  $preview_session->setParticipantsSolution(array_map(static fn($value) => trim($value), $answer));
610  }
+ Here is the call graph for this function:

◆ saveToDb()

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

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

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

160  : void
161  {
165  parent::saveToDb();
166  }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb(?int $original_id=null)
+ Here is the call graph for this function:

◆ saveWorkingData()

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

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

References ilObjTest\_getPass(), assQuestion\getProcessLocker(), getSolutionSubmit(), assQuestion\removeCurrentSolution(), and assQuestion\saveCurrentSolution().

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

◆ setAnswers()

assLongMenu::setAnswers ( array  $answers)

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

References $answers.

Referenced by createArrayFromFile().

100  : void
101  {
102  $this->answers = $answers;
103  }
+ Here is the caller graph for this function:

◆ setAnswerType()

assLongMenu::setAnswerType ( array  $answerType)

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

References $answerType.

51  : void
52  {
53  $this->answerType = $answerType;
54  }

◆ setCorrectAnswers()

assLongMenu::setCorrectAnswers ( array  $correct_answers)

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

References $correct_answers.

Referenced by loadCorrectAnswerData().

65  : void
66  {
67  $this->correct_answers = $correct_answers;
68  }
+ Here is the caller graph for this function:

◆ setIdenticalScoring()

assLongMenu::setIdenticalScoring ( bool  $identical_scoring)

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

References $identical_scoring.

Referenced by loadFromDb().

728  : void
729  {
730  $this->identical_scoring = $identical_scoring;
731  }
+ Here is the caller graph for this function:

◆ setJsonStructure()

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

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

References $json_structure.

Referenced by loadCorrectAnswerData().

121  : void
122  {
123  $this->json_structure = $json_structure;
124  }
string $json_structure
+ Here is the caller graph for this function:

◆ setLongMenuTextValue()

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

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

References assQuestion\getHtmlQuestionContentPurifier().

Referenced by lmMigrateQuestionTypeSpecificContent(), and loadFromDb().

90  : void
91  {
92  $this->long_menu_text = $this->getHtmlQuestionContentPurifier()->purify($long_menu_text);
93  }
string $long_menu_text
+ 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 136 of file class.assLongMenu.php.

Referenced by loadFromDb().

136  : void
137  {
138  $this->minAutoComplete = $min_auto_complete;
139  }
+ Here is the caller graph for this function:

◆ setSpecificFeedbackSetting()

assLongMenu::setSpecificFeedbackSetting (   $specificFeedbackSetting)

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

References $specificFeedbackSetting.

Referenced by loadFromDb().

126  : void
127  {
128  $this->specificFeedbackSetting = $specificFeedbackSetting;
129  }
int $specificFeedbackSetting
+ Here is the caller graph for this function:

◆ solutionValuesToLog()

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

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

References getCorrectAnswers().

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

◆ solutionValuesToText()

assLongMenu::solutionValuesToText ( array  $solution_values)

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

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

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

◆ toJSON()

assLongMenu::toJSON ( )

Returns a JSON representation of the question.

Implements ILIAS\TestQuestionPool\Questions\QuestionLMExportable.

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

References ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getAnswers(), getCorrectAnswers(), assQuestion\getId(), getLongMenuTextValue(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), and assQuestion\getTitleForHTMLOutput().

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

◆ toLog()

assLongMenu::toLog ( AdditionalInformationGenerator  $additional_info)

Implements ILIAS\TestQuestionPool\Questions\Question.

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

References assQuestion\formatSAQuestion(), getAnswersForLog(), getCorrectAnswersForLog(), getLongMenuTextValue(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), assQuestion\getTitleForHTMLOutput(), and ILIAS\Test\Logging\AdditionalInformationGenerator\getTrueFalseTagForBool().

733  : array
734  {
735  return [
736  AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
737  AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
738  AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
739  AdditionalInformationGenerator::KEY_QUESTION_LONGMENU_TEXT => $this->formatSAQuestion($this->getLongMenuTextValue()),
740  AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS => $additional_info
742  AdditionalInformationGenerator::KEY_FEEDBACK => [
743  AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
744  AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
745  ],
746  AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTIONS => $this->getAnswersForLog($additional_info),
747  AdditionalInformationGenerator::KEY_QUESTION_CORRECT_ANSWER_OPTIONS => $this->getCorrectAnswersForLog($additional_info)
748  ];
749  }
getCorrectAnswersForLog(AdditionalInformationGenerator $additional_info)
getAnswersForLog(AdditionalInformationGenerator $additional_info)
getQuestionType()
Returns the question type of the question.
+ Here is the call graph for this function:

Field Documentation

◆ $answers

array assLongMenu::$answers = []
private

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

Referenced by createArrayFromFile(), getAnswers(), and setAnswers().

◆ $answerType

array assLongMenu::$answerType = null
private

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

Referenced by getAnswerType(), and setAnswerType().

◆ $correct_answers

array assLongMenu::$correct_answers = []
private

◆ $identical_scoring

bool assLongMenu::$identical_scoring = true
private

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

Referenced by getIdenticalScoring(), and setIdenticalScoring().

◆ $json_structure

string assLongMenu::$json_structure = ''
private

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

Referenced by getJsonStructure(), and setJsonStructure().

◆ $long_menu_text

string assLongMenu::$long_menu_text = ''
private

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

Referenced by getLongMenuTextValue().

◆ $minAutoComplete

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

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

Referenced by getMinAutoComplete().

◆ $specificFeedbackSetting

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

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

Referenced by getSpecificFeedbackSetting(), and setSpecificFeedbackSetting().

◆ ANSWER_TYPE_SELECT_VAL

const assLongMenu::ANSWER_TYPE_SELECT_VAL = 0

◆ ANSWER_TYPE_TEXT_VAL

const assLongMenu::ANSWER_TYPE_TEXT_VAL = 1

◆ GAP_PLACEHOLDER

◆ HAS_SPECIFIC_FEEDBACK

const assLongMenu::HAS_SPECIFIC_FEEDBACK = false
protected

Definition at line 33 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: