ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
assLongMenu Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for assLongMenu:
+ Collaboration diagram for assLongMenu:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 
 getAnswerType ()
 
 setAnswerType (array $answerType)
 
 getCorrectAnswers ()
 
 setCorrectAnswers ($correct_answers)
 
 getAnswerTableName ()
 
 setLongMenuTextValue ($long_menu_text="")
 
 getLongMenuTextValue ()
 
 setAnswers ($answers)
 
 getAnswers ()
 
 getJsonStructure ()
 
 setJsonStructure ($json_structure)
 
 setSpecificFeedbackSetting ($specificFeedbackSetting)
 
 getSpecificFeedbackSetting ()
 
 setMinAutoComplete ($minAutoComplete)
 
 getMinAutoComplete ()
 
 isComplete ()
 
 saveToDb (int $original_id=-1)
 
 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 ()
 
 duplicate (bool $for_test=true, string $title="", string $author="", int $owner=-1, $testObjId=null)
 
 copyObject ($target_questionpool_id, $title="")
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 saveWorkingData (int $active_id, int $pass=null, bool $authorized=true)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 getSolutionSubmit ()
 
 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...
 
 setExportDetailsXLSX (ilAssExcelFormatHelper $worksheet, int $startrow, int $col, int $active_id, int $pass)
 {} 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 ($question_id)
 
 delete (int $question_id)
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getIdenticalScoring ()
 
 setIdenticalScoring ($a_identical_scoring)
 
- Public Member Functions inherited from assQuestion
 __construct (string $title="", string $comment="", string $author="", int $owner=-1, string $question="")
 assQuestion constructor More...
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML ($item, int $questionpool_id, ?int $tst_id, &$tst_object, int &$question_counter, array $import_mapping, array &$solutionhints=[])
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 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...
 
 isComplete ()
 Returns true, if a question is complete for use. 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 $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution (int $active_id, int $pass, bool $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $obligationsEnabled=false, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 saveWorkingData (int $active_id, int $pass, bool $authorized=true)
 Saves the learners input of the question to the database. More...
 
 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, $pass=null)
 
 getSolutionValues ($active_id, $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 copyXHTMLMediaObjectsOfQuestion (int $a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 
 copyPageOfQuestion (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=-1)
 
 saveToDb ()
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 
 resolveInternalLink (string $internal_link)
 
 resolveSuggestedSolutionLinks ()
 
 syncWithOriginal ()
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 deductHintPointsFromReachedPoints (ilAssQuestionPreviewSession $previewSession, $reachedPoints)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=null)
 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="")
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 
 syncHints ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 setExportDetailsXLSX (ilAssExcelFormatHelper $worksheet, int $startrow, int $col, int $active_id, int $pass)
 
 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 ($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 ()
 
 duplicate (bool $for_test=true, string $title="", string $author="", int $owner=-1, $testObjId=null)
 
 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 $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered (bool $obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
- Public Member Functions inherited from assQuestionInterface
 validateSolutionSubmit ()
 

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 TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
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 ($found_values, $active_id=0)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
- Protected Member Functions inherited from assQuestion
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $postSubmissionFieldname)
 
 log (int $active_id, string $langVar)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 deletePageOfQuestion (int $question_id)
 
 onDuplicate (int $originalParentId, int $originalQuestionId, int $duplicateParentId, int $duplicateQuestionId)
 
 beforeSyncWithOriginal (int $origQuestionId, int $dupQuestionId, int $origParentObjId, int $dupParentObjId)
 
 afterSyncWithOriginal (int $origQuestionId, int $dupQuestionId, int $origParentObjId, int $dupParentObjId)
 
 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 ()
 
 syncSuggestedSolutions (int $target_question_id, int $target_obj_id)
 
 duplicateSuggestedSolutionFiles (int $parent_id, int $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles (int $target_question_id, int $target_obj_id)
 
 copySuggestedSolutionFiles (int $source_questionpool_id, int $source_question_id)
 
 copySuggestedSolutions (int $target_question_id)
 
 ensureNonNegativePoints ($points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints (int $originalQuestionId, int $duplicateQuestionId)
 
 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 ()
 build basic test question configuration instance More...
 
 getSuggestedSolutionsRepo ()
 
 loadSuggestedSolutions ()
 

Protected Attributes

const HAS_SPECIFIC_FEEDBACK = false
 
- Protected Attributes inherited from assQuestion
const HAS_SPECIFIC_FEEDBACK = true
 
ILIAS TestQuestionPool QuestionInfoService $questioninfo
 
ILIAS Test TestParticipantInfoService $testParticipantInfo
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
ILIAS TestQuestionPool QuestionFilesService $questionFilesService
 
ILIAS DI LoggingServices $ilLog
 
int $id
 
string $title
 
string $comment
 
string $owner
 
string $author
 
int $thumb_size
 
string $question
 The question text. More...
 
float $points
 The maximum available points for the question. More...
 
bool $shuffle
 Indicates whether the answers will be shuffled or not. More...
 
int $test_id
 The database id of a test in which the question is contained. More...
 
int $obj_id = 0
 Object id of the container object. More...
 
 $ilias
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
ilDBInterface $db
 
Container $dic
 
array $suggested_solutions
 
int $original_id = null
 
 $page
 
string $external_id = null
 
ilAssQuestionProcessLocker $processLocker
 
 $step
 
 $lastChange
 
Transformation $shuffler
 
ilTestQuestionConfig $testQuestionConfig
 
ilAssQuestionLifecycle $lifecycle
 
ilObjUser $current_user
 
SkillUsageService $skillUsageService
 
assQuestionSuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

Private Member Functions

 buildFolderName ()
 
 buildFileName ($gap_id)
 
 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)
 

Private Attributes

array $answerType = null
 
 $long_menu_text
 
 $json_structure
 
 $ilDB
 
 $specificFeedbackSetting
 
 $minAutoComplete
 
 $identical_scoring
 
 $correct_answers = []
 
 $answers = []
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $forcePassResultsUpdateEnabled)
 
static isForcePassResultUpdateEnabled ()
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static logAction (string $logtext, int $active_id, int $question_id)
 
static isFileAvailable (string $file)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static _getInternalLinkHref (string $target="")
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static _isWriteable (int $question_id, int $user_id)
 
static _setReachedPoints (int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring, bool $obligationsEnabled, ?int $test_id=null)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static _needsManualScoring (int $question_id)
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static instantiateQuestionGUI (int $a_question_id)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $questionId)
 
static isObligationPossible (int $questionId)
 
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 $forcePassResultsUpdateEnabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

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

Constructor & Destructor Documentation

◆ __construct()

assLongMenu::__construct (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $question = "" 
)

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

References assQuestion\$author, assQuestion\$comment, $DIC, assQuestion\$owner, assQuestion\$question, assQuestion\$title, ILIAS\MetaData\Repository\Validation\Data\__construct(), and ilAssConfigurableMultiOptionQuestionFeedback\FEEDBACK_SETTING_ALL.

51  {
52  global $DIC;
54  $this->minAutoComplete = self::MIN_LENGTH_AUTOCOMPLETE;
56  $this->ilDB = $DIC->database();
57  $this->identical_scoring = 1;
58  }
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
string $question
The question text.
+ Here is the call graph for this function:

Member Function Documentation

◆ assertDirExists()

assLongMenu::assertDirExists ( )
private

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

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

Referenced by buildFileName().

355  : void
356  {
357  $folder_name = $this->buildFolderName();
358  if (!ilFileUtils::makeDirParents($folder_name)) {
359  throw new ilException('Cannot create export directory');
360  }
361 
362  if (
363  !is_dir($folder_name) ||
364  !is_readable($folder_name) ||
365  !is_writable($folder_name)
366  ) {
367  throw new ilException('Cannot create export directory');
368  }
369  }
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 94 of file class.assLongMenu.php.

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

Referenced by createFileFromArray().

94  : ?string
95  {
96  try {
97  $this->assertDirExists();
98  return $this->buildFolderName() . $gap_id . '.txt';
99  } catch (ilException $e) {
100  }
101  return null;
102  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildFolderName()

assLongMenu::buildFolderName ( )
private

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

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

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

84  : string
85  {
86  return ilFileUtils::getDataDir() . '/assessment/longMenuQuestion/' . $this->getId() . '/' ;
87  }
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 (   $active_id,
  $pass = null,
  $authorizedSolution = true,
  $returndetails = false 
)

Returns the points, a learner has reached answering the question.

The points are calculated from the given answers.

Parameters
integer$active_id
integer$pass
boolean$returndetails(deprecated !!)
Exceptions
ilTestException
Returns
integer/array $points/$details (array $details is deprecated !!)

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

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

Referenced by getUserQuestionResult().

601  : float
602  {
603  if ($returndetails) {
604  throw new ilTestException('return details not implemented for ' . __METHOD__);
605  }
606 
607  $found_values = array();
608  if (is_null($pass)) {
609  $pass = $this->getSolutionMaxPass($active_id);
610  }
611  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
612  while ($data = $this->ilDB->fetchAssoc($result)) {
613  $found_values[(int) $data['value1']] = $data['value2'];
614  }
615 
616  return $this->calculateReachedPointsForSolution($found_values, $active_id);
617  }
calculateReachedPointsForSolution($found_values, $active_id=0)
Base Exception for all Exceptions relating to Modules/Test.
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 (   $found_values,
  $active_id = 0 
)
protected

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

References $correct_answers, ILIAS\LTI\ToolProvider\$key, assQuestion\$points, getCorrectAnswersForGap(), getIdenticalScoring(), and getPointsForGap().

Referenced by calculateReachedPoints().

619  : float
620  {
621  if ($found_values == null) {
622  $found_values = [];
623  }
624  $points = 0.0;
625  $solution_values_text = array();
626  foreach ($found_values as $key => $answer) {
627  if ($answer != '') {
628  $correct_answers = $this->getCorrectAnswersForGap($this->id, $key);
629  if (in_array($answer, $correct_answers)) {
630  $points_gap = $this->getPointsForGap($this->id, $key);
631  if (!$this->getIdenticalScoring()) {
632  // check if the same solution text was already entered
633  if ((in_array($answer, $solution_values_text)) && ($points > 0)) {
634  $points_gap = 0;
635  }
636  }
637  $points += $points_gap;
638  array_push($solution_values_text, $answer);
639  }
640  }
641  }
642  return $points;
643  }
getCorrectAnswersForGap($question_id, $gap_id)
float $points
The maximum available points for the question.
string $key
Consumer key/client ID value.
Definition: System.php:193
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 186 of file class.assLongMenu.php.

References $correct_answers, ILIAS\LTI\ToolProvider\$key, assQuestion\$points, correctAnswerDoesNotExistInAnswerOptions(), getAnswers(), and getCorrectAnswers().

186  : bool
187  {
188  $hidden_text_files = $this->getAnswers();
190  $points = array();
191  if ($correct_answers === null || sizeof($correct_answers) == 0 || $hidden_text_files === null || sizeof($hidden_text_files) == 0) {
192  return false;
193  }
194  if (sizeof($correct_answers) != sizeof($hidden_text_files)) {
195  return false;
196  }
197  foreach ($correct_answers as $key => $correct_answers_row) {
198  if ($this->correctAnswerDoesNotExistInAnswerOptions($correct_answers_row, $hidden_text_files[$key])) {
199  return false;
200  }
201  if (!is_array($correct_answers_row[0]) || sizeof($correct_answers_row[0]) == 0) {
202  return false;
203  }
204  if ($correct_answers_row[1] > 0) {
205  array_push($points, $correct_answers_row[1]);
206  }
207  }
208  if (sizeof($correct_answers) != sizeof($points)) {
209  return false;
210  }
211 
212  foreach ($points as $row) {
213  if ($row <= 0) {
214  return false;
215  }
216  }
217  return true;
218  }
correctAnswerDoesNotExistInAnswerOptions($answers, $answer_options)
float $points
The maximum available points for the question.
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:

◆ clearAnswerSpecificDataFromDb()

assLongMenu::clearAnswerSpecificDataFromDb (   $question_id)

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

References getAnswerTableName().

Referenced by saveAnswerSpecificDataToDb().

851  : void
852  {
853  $this->ilDB->manipulateF(
854  'DELETE FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s',
855  array( 'integer' ),
856  array( $question_id )
857  );
858  }
+ 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 350 of file class.assLongMenu.php.

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

Referenced by createFileFromArray(), and delete().

350  : void
351  {
352  ilFileUtils::delDir($this->buildFolderName(), $let_folder_exists);
353  }
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:

◆ copyObject()

assLongMenu::copyObject (   $target_questionpool_id,
  $title = "" 
)

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

References assQuestion\$original_id, assQuestion\$title, assQuestion\getId(), and assQuestion\getObjId().

536  : int
537  {
538  if ($this->getId() <= 0) {
539  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
540  }
541  // duplicate the question in database
542  $clone = $this;
543 
544  $original_id = $this->questioninfo->getOriginalId($this->id);
545  $clone->id = -1;
546  $source_questionpool_id = $this->getObjId();
547  $clone->setObjId($target_questionpool_id);
548  if ($title) {
549  $clone->setTitle($title);
550  }
551  $clone->saveToDb();
552 
553  $clone->copyPageOfQuestion($original_id);
554  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
555 
556  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
557 
558  return $clone->id;
559  }
+ Here is the call graph for this function:

◆ correctAnswerDoesNotExistInAnswerOptions()

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

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

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

Referenced by checkQuestionCustomPart().

225  : bool
226  {
227  foreach ($answers[0] as $key => $answer) {
228  if (!in_array($answer, $answer_options)) {
229  return true;
230  }
231  }
232  return false;
233  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the caller graph for this function:

◆ createArrayFromFile()

assLongMenu::createArrayFromFile ( )
private

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

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

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

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

◆ createFileFromArray()

assLongMenu::createFileFromArray ( )
private

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

References ILIAS\LTI\ToolProvider\$key, buildFileName(), clearFolder(), and getAnswers().

Referenced by saveAdditionalQuestionDataToDb().

309  : void
310  {
311  $array = $this->getAnswers();
312  $this->clearFolder();
313  foreach ($array as $gap => $values) {
314  $file_content = '';
315  if (is_array($values)) {
316  foreach ($values as $key => $value) {
317  $file_content .= $value . "\n";
318  }
319  $file_content = rtrim($file_content, "\n");
320  $file = fopen($this->buildFileName($gap), "w");
321  fwrite($file, $file_content);
322  fclose($file);
323  }
324  }
325  }
string $key
Consumer key/client ID value.
Definition: System.php:193
clearFolder($let_folder_exists=true)
buildFileName($gap_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createNewOriginalFromThisDuplicate()

assLongMenu::createNewOriginalFromThisDuplicate (   $targetParentId,
  $targetQuestionTitle = "" 
)

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

References assQuestion\$id, assQuestion\getId(), and assQuestion\getObjId().

561  : int
562  {
563  if ($this->getId() <= 0) {
564  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
565  }
566 
567  $sourceQuestionId = $this->id;
568  $sourceParentId = $this->getObjId();
569 
570  // duplicate the question in database
571  $clone = $this;
572  $clone->id = -1;
573 
574  $clone->setObjId($targetParentId);
575 
576  if ($targetQuestionTitle) {
577  $clone->setTitle($targetQuestionTitle);
578  }
579 
580  $clone->saveToDb();
581  $clone->copyPageOfQuestion($sourceQuestionId);
582  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
583 
584  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
585 
586  return $clone->id;
587  }
+ Here is the call graph for this function:

◆ delete()

assLongMenu::delete ( int  $question_id)

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

References clearFolder().

860  : void
861  {
862  parent::delete($question_id);
863  $this->clearFolder(false);
864  }
clearFolder($let_folder_exists=true)
+ Here is the call graph for this function:

◆ duplicate()

assLongMenu::duplicate ( bool  $for_test = true,
string  $title = "",
string  $author = "",
int  $owner = -1,
  $testObjId = null 
)

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

References assQuestion\$author, assQuestion\$original_id, assQuestion\$owner, assQuestion\$title, assQuestion\getId(), and assQuestion\getObjId().

492  : int
493  {
494  if ($this->id <= 0) {
495  // The question has not been saved. It cannot be duplicated
496  return -1;
497  }
498 
499  // duplicate the question in database
500  $this_id = $this->getId();
501  $thisObjId = $this->getObjId();
502 
503  $clone = $this;
504 
505  $original_id = $this->questioninfo->getOriginalId($this->id);
506  $clone->id = -1;
507 
508  if ((int) $testObjId > 0) {
509  $clone->setObjId($testObjId);
510  }
511 
512  if ($title) {
513  $clone->setTitle($title);
514  }
515 
516  if ($author) {
517  $clone->setAuthor($author);
518  }
519  if ($owner) {
520  $clone->setOwner($owner);
521  }
522 
523  if ($for_test) {
524  $clone->saveToDb($original_id);
525  } else {
526  $clone->saveToDb();
527  }
528 
529  $clone->copyPageOfQuestion($this_id);
530  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
531  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
532 
533  return $clone->id;
534  }
+ Here is the call graph for this function:

◆ getAdditionalTableName()

assLongMenu::getAdditionalTableName ( )

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

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

764  : string
765  {
766  return 'qpl_qst_lome';
767  }
+ Here is the caller graph for this function:

◆ getAnswers()

assLongMenu::getAnswers ( )

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

References $answers.

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

119  : array
120  {
121  return $this->answers;
122  }
+ Here is the caller graph for this function:

◆ getAnswersObject()

assLongMenu::getAnswersObject ( )

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

References createArrayFromFile().

482  {
483  return json_encode($this->createArrayFromFile());
484  }
+ Here is the call graph for this function:

◆ getAnswerTableName()

assLongMenu::getAnswerTableName ( )

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

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

89  : string
90  {
91  return "qpl_a_lome";
92  }
+ Here is the caller graph for this function:

◆ getAnswerType()

assLongMenu::getAnswerType ( )

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

References $answerType.

Referenced by saveAnswerSpecificDataToDb().

60  : ?array
61  {
62  return $this->answerType;
63  }
+ 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 841 of file class.assLongMenu.php.

References createArrayFromFile().

842  {
843  return $this->createArrayFromFile();
844  }
+ Here is the call graph for this function:

◆ getCorrectAnswers()

assLongMenu::getCorrectAnswers ( )
Returns
mixed

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

References $correct_answers.

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

74  {
76  }
+ Here is the caller graph for this function:

◆ getCorrectAnswersAsJson()

assLongMenu::getCorrectAnswersAsJson ( )

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

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

487  {
488  $this->loadCorrectAnswerData($this->getId());
489  return $this->getJsonStructure();
490  }
loadCorrectAnswerData($question_id)
+ Here is the call graph for this function:

◆ getCorrectAnswersForGap()

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

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

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

Referenced by calculateReachedPointsForSolution().

452  : array
453  {
454  $correct_answers = array();
455  $res = $this->db->queryF(
456  'SELECT answer_text FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s AND gap_number = %s',
457  array('integer', 'integer'),
458  array($question_id, $gap_id)
459  );
460  while ($data = $this->ilDB->fetchAssoc($res)) {
461  $correct_answers[] = rtrim($data['answer_text']);
462  }
463  return $correct_answers;
464  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCorrectAnswersForQuestionSolution()

assLongMenu::getCorrectAnswersForQuestionSolution (   $question_id)

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

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

433  : array
434  {
435  $correct_answers = array();
436  $res = $this->db->queryF(
437  'SELECT gap_number, answer_text FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s',
438  array('integer'),
439  array($question_id)
440  );
441  while ($data = $this->ilDB->fetchAssoc($res)) {
442  if (array_key_exists($data['gap_number'], $correct_answers)) {
443  $correct_answers[$data['gap_number']] .= ' ' . $this->lng->txt("or") . ' ';
444  $correct_answers[$data['gap_number']] .= rtrim($data['answer_text']);
445  } else {
446  $correct_answers[$data['gap_number']] = rtrim($data['answer_text']);
447  }
448  }
449  return $correct_answers;
450  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:

◆ getIdenticalScoring()

assLongMenu::getIdenticalScoring ( )

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

Referenced by calculateReachedPointsForSolution(), and saveAdditionalQuestionDataToDb().

900  : int
901  {
902  return ($this->identical_scoring) ? 1 : 0;
903  }
+ Here is the caller graph for this function:

◆ getJsonStructure()

assLongMenu::getJsonStructure ( )
Returns
mixed

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

References $json_structure.

Referenced by getCorrectAnswersAsJson().

128  {
129  return $this->json_structure;
130  }
+ Here is the caller graph for this function:

◆ getLongMenuTextValue()

assLongMenu::getLongMenuTextValue ( )

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

References $long_menu_text.

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

110  {
111  return $this->long_menu_text;
112  }
+ 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 242 of file class.assLongMenu.php.

References assQuestion\$points, and getCorrectAnswers().

Referenced by getUserQuestionResult().

242  : float
243  {
244  $sum = 0;
245  $points = $this->getCorrectAnswers();
246  if ($points) {
247  foreach ($points as $add) {
248  $sum += (float) $add[1];
249  }
250  }
251  return $sum;
252  }
float $points
The maximum available points for the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMinAutoComplete()

assLongMenu::getMinAutoComplete ( )

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

Referenced by saveAdditionalQuestionDataToDb().

155  : int
156  {
157  return $this->minAutoComplete ? $this->minAutoComplete : self::MIN_LENGTH_AUTOCOMPLETE;
158  }
+ Here is the caller graph for this function:

◆ getPointsForGap()

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

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

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

Referenced by calculateReachedPointsForSolution().

466  : float
467  {
468  $points = 0.0;
469  $res = $this->db->queryF(
470  'SELECT points FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s AND gap_number = %s GROUP BY gap_number, points',
471  array('integer', 'integer'),
472  array($question_id, $gap_id)
473  );
474  while ($data = $this->ilDB->fetchAssoc($res)) {
475  $points = (float) $data['points'];
476  }
477  return $points;
478  }
$res
Definition: ltiservices.php:69
float $points
The maximum available points for the question.
+ 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 759 of file class.assLongMenu.php.

Referenced by toJSON().

759  : string
760  {
761  return "assLongMenu";
762  }
+ 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 773 of file class.assLongMenu.php.

References getLongMenuTextValue().

773  : string
774  {
775  return parent::getRTETextWithMediaObjects() . $this->getLongMenuTextValue();
776  }
+ Here is the call graph for this function:

◆ getSolutionSubmit()

assLongMenu::getSolutionSubmit ( )

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

References ILIAS\LTI\ToolProvider\$key, and ilArrayUtil\stripSlashesRecursive().

Referenced by saveWorkingData().

731  : array
732  {
733  $solutionSubmit = array();
734  $answer = ilArrayUtil::stripSlashesRecursive($_POST['answer']);
735 
736  foreach ($answer as $key => $value) {
737  $solutionSubmit[$key] = $value;
738  }
739 
740  return $solutionSubmit;
741  }
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSpecificFeedbackSetting()

assLongMenu::getSpecificFeedbackSetting ( )

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

References $specificFeedbackSetting.

Referenced by saveAdditionalQuestionDataToDb().

145  : int
146  {
148  }
+ 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 821 of file class.assLongMenu.php.

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

822  {
823  $result = new ilUserQuestionResult($this, $active_id, $pass);
824 
825  $points = $this->calculateReachedPoints($active_id, $pass);
826  $max_points = $this->getMaximumPoints();
827 
828  $result->setReachedPercentage(($points / $max_points) * 100);
829 
830  return $result;
831  }
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
float $points
The maximum available points for 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 160 of file class.assLongMenu.php.

References assQuestion\getPoints().

160  : bool
161  {
162  if (strlen($this->title)
163  && $this->author
164  && $this->long_menu_text
165  && sizeof($this->answers) > 0
166  && sizeof($this->correct_answers) > 0
167  && $this->getPoints() > 0
168  ) {
169  return true;
170  }
171  return false;
172  }
+ Here is the call graph for this function:

◆ isShuffleAnswersEnabled()

assLongMenu::isShuffleAnswersEnabled ( )

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

846  : bool
847  {
848  return false;
849  }

◆ lmMigrateQuestionTypeSpecificContent()

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

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

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

869  : void
870  {
871  $this->setLongMenuTextValue($migrator->migrateToLmContent($this->getLongMenuTextValue()));
872  }
setLongMenuTextValue($long_menu_text="")
+ Here is the call graph for this function:

◆ loadCorrectAnswerData()

assLongMenu::loadCorrectAnswerData (   $question_id)
private

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

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

Referenced by getCorrectAnswersAsJson(), and loadFromDb().

415  : void
416  {
417  $res = $this->db->queryF(
418  "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY gap_number, position ASC",
419  array('integer'),
420  array($question_id)
421  );
422 
423  $correct_answers = array();
424  while ($data = $this->ilDB->fetchAssoc($res)) {
425  $correct_answers[$data['gap_number']][0][$data['position']] = rtrim($data['answer_text']);
426  $correct_answers[$data['gap_number']][1] = $data['points'];
427  $correct_answers[$data['gap_number']][2] = $data['type'];
428  }
429  $this->setJsonStructure(json_encode($correct_answers));
431  }
$res
Definition: ltiservices.php:69
setJsonStructure($json_structure)
setCorrectAnswers($correct_answers)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadFromDb()

assLongMenu::loadFromDb (   $question_id)

Definition at line 371 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().

371  : void
372  {
373  $result = $this->ilDB->queryF(
374  "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",
375  array("integer"),
376  array($question_id)
377  );
378  if ($result->numRows() == 1) {
379  $data = $this->ilDB->fetchAssoc($result);
380  $this->setId($question_id);
381  $this->setObjId($data["obj_fi"]);
382  $this->setNrOfTries($data['nr_of_tries']);
383  $this->setTitle((string) $data["title"]);
384  $this->setComment((string) $data["description"]);
385  $this->setOriginalId($data["original_id"]);
386  $this->setAuthor($data["author"]);
387  $this->setPoints($data["points"]);
388  $this->setIdenticalScoring($data["identical_scoring"]);
389  $this->setOwner($data["owner"]);
390  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data['question_text'], 1));
391  $this->setLongMenuTextValue(ilRTE::_replaceMediaObjectImageSrc((string) $data['long_menu_text'], 1));
392  $this->loadCorrectAnswerData($question_id);
393  $this->setMinAutoComplete($data["min_auto_complete"]);
394  if (isset($data['feedback_setting'])) {
395  $this->setSpecificFeedbackSetting((int) $data['feedback_setting']);
396  }
397 
398  try {
402  }
403 
404  try {
405  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
406  } catch (ilTestQuestionPoolException $e) {
407  }
408  }
409 
410  $this->loadCorrectAnswerData($question_id);
411  $this->createArrayFromFile();
412  parent::loadFromDb($question_id);
413  }
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)
setIdenticalScoring($a_identical_scoring)
setMinAutoComplete($minAutoComplete)
setOwner(int $owner=-1)
setSpecificFeedbackSetting($specificFeedbackSetting)
loadCorrectAnswerData($question_id)
setComment(string $comment="")
setLongMenuTextValue($long_menu_text="")
setPoints(float $points)
setObjId(int $obj_id=0)
setId(int $id=-1)
setOriginalId(?int $original_id)
setTitle(string $title="")
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 690 of file class.assLongMenu.php.

References $DIC, $ilDB, assQuestion\getId(), and assQuestion\getStep().

690  : array
691  {
692  global $DIC;
693  $ilDB = $DIC['ilDB'];
694 
695  $return = array(
696  'authorized' => false,
697  'intermediate' => false
698  );
699 
700  $query = "
701  SELECT authorized, COUNT(*) cnt
702  FROM tst_solutions
703  WHERE active_fi = " . $ilDB->quote($activeId, 'integer') . "
704  AND question_fi = " . $ilDB->quote($this->getId(), 'integer') . "
705  AND pass = " . $ilDB->quote($pass, 'integer') . "
706  AND value2 <> '-1'
707  ";
708 
709  if ($this->getStep() !== null) {
710  $query .= " AND step = " . $ilDB->quote((int) $this->getStep(), 'integer') . " ";
711  }
712 
713  $query .= "
714  GROUP BY authorized
715  ";
716 
717  $result = $ilDB->query($query);
718 
719  while ($row = $ilDB->fetchAssoc($result)) {
720  if ($row['authorized']) {
721  $return['authorized'] = $row['cnt'] > 0;
722  } else {
723  $return['intermediate'] = $row['cnt'] > 0;
724  }
725  }
726  return $return;
727  }
global $DIC
Definition: feed.php:28
+ 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 254 of file class.assLongMenu.php.

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

Referenced by saveToDb().

255  {
256  // save additional data
257  $this->ilDB->manipulateF(
258  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
259  array( "integer" ),
260  array( $this->getId() )
261  );
262  $this->ilDB->manipulateF(
263  "INSERT INTO " . $this->getAdditionalTableName(
264  ) . " (question_fi, long_menu_text, feedback_setting, min_auto_complete, identical_scoring) VALUES (%s, %s, %s, %s, %s)",
265  array( "integer", "text", "integer", "integer", "integer"),
266  array(
267  $this->getId(),
268  $this->getLongMenuTextValue(),
270  $this->getMinAutoComplete(),
271  $this->getIdenticalScoring()
272  )
273  );
274 
275  $this->createFileFromArray();
276  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAnswerSpecificDataToDb()

assLongMenu::saveAnswerSpecificDataToDb ( )

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

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

Referenced by saveToDb().

278  : void
279  {
280  $this->clearAnswerSpecificDataFromDb($this->getId());
281  $type_array = $this->getAnswerType();
282  $points = 0;
283  foreach ($this->getCorrectAnswers() as $gap_number => $gap) {
284  foreach ($gap[0] as $position => $answer) {
285  if ($type_array == null) {
286  $type = $gap[2];
287  } else {
288  $type = $type_array[$gap_number];
289  }
290  $this->db->replace(
291  $this->getAnswerTableName(),
292  array(
293  'question_fi' => array('integer', $this->getId()),
294  'gap_number' => array('integer', (int) $gap_number),
295  'position' => array('integer', (int) $position)
296  ),
297  array(
298  'answer_text' => array('text', $answer),
299  'points' => array('float', (float) str_replace(',', '.', $gap[1])),
300  'type' => array('integer', (int) $type)
301  )
302  );
303  }
304  $points += (float) str_replace(',', '.', $gap[1]);
305  }
306  $this->setPoints($points);
307  }
float $points
The maximum available points for the question.
setPoints(float $points)
clearAnswerSpecificDataFromDb($question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePreviewData()

assLongMenu::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

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

References ilAssQuestionPreviewSession\setParticipantsSolution().

743  : void
744  {
745  $answer = $_POST['answer'] ?? null;
746  if (is_array($answer)) {
747  $answer = array_map(function ($value) {
748  return trim($value);
749  }, $answer);
750  }
751  $previewSession->setParticipantsSolution($answer);
752  }
+ Here is the call graph for this function:

◆ saveToDb()

assLongMenu::saveToDb ( int  $original_id = -1)

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

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

174  : void
175  {
179  parent::saveToDb();
180  }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb(int $original_id=-1)
+ Here is the call graph for this function:

◆ saveWorkingData()

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

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

References ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), assQuestion\getId(), assQuestion\getProcessLocker(), getSolutionSubmit(), ILIAS\Repository\lng(), assQuestion\logAction(), assQuestion\removeCurrentSolution(), assQuestion\saveCurrentSolution(), and ilUtil\stripSlashes().

645  : bool
646  {
647  if (is_null($pass)) {
648  $pass = ilObjTest::_getPass($active_id);
649  }
650 
651  $entered_values = 0;
652 
653  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $active_id, $pass, $authorized) {
654  $this->removeCurrentSolution($active_id, $pass, $authorized);
655 
656  foreach ($this->getSolutionSubmit() as $val1 => $val2) {
657  $value = ilUtil::stripSlashes(trim($val2), false);
658  if (strlen($value)) {
659  $this->saveCurrentSolution($active_id, $pass, $val1, $value, $authorized);
660  $entered_values++;
661  }
662  }
663  });
664 
665  if ($entered_values) {
667  assQuestion::logAction($this->lng->txtlng(
668  "assessment",
669  "log_user_entered_values",
671  ), $active_id, $this->getId());
672  }
673  } else {
675  assQuestion::logAction($this->lng->txtlng(
676  "assessment",
677  "log_user_not_entered_values",
679  ), $active_id, $this->getId());
680  }
681  }
682  return true;
683  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
static logAction(string $logtext, int $active_id, int $question_id)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
+ Here is the call graph for this function:

◆ setAnswers()

assLongMenu::setAnswers (   $answers)

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

References $answers.

Referenced by createArrayFromFile().

114  : void
115  {
116  $this->answers = $answers;
117  }
+ Here is the caller graph for this function:

◆ setAnswerType()

assLongMenu::setAnswerType ( array  $answerType)

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

References $answerType.

65  : void
66  {
67  $this->answerType = $answerType;
68  }

◆ setCorrectAnswers()

assLongMenu::setCorrectAnswers (   $correct_answers)

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

References $correct_answers.

Referenced by loadCorrectAnswerData().

79  : void
80  {
81  $this->correct_answers = $correct_answers;
82  }
+ Here is the caller graph for this function:

◆ setExportDetailsXLSX()

assLongMenu::setExportDetailsXLSX ( ilAssExcelFormatHelper  $worksheet,
int  $startrow,
int  $col,
int  $active_id,
int  $pass 
)

{}

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

References ilExcel\getColumnCoord(), getCorrectAnswers(), assQuestion\getSolutionValues(), ILIAS\Repository\lng(), ilExcel\setBold(), and ilAssExcelFormatHelper\setCell().

781  : int
782  {
783  parent::setExportDetailsXLSX($worksheet, $startrow, $col, $active_id, $pass);
784 
785  $solution = $this->getSolutionValues($active_id, $pass);
786 
787  $i = 1;
788  foreach ($this->getCorrectAnswers() as $gap_index => $gap) {
789  $worksheet->setCell($startrow + $i, $col, $this->lng->txt('assLongMenu') . " $i");
790  $worksheet->setBold($worksheet->getColumnCoord($col) . ($startrow + $i));
791  foreach ($solution as $solutionvalue) {
792  if ($gap_index == $solutionvalue["value1"]) {
793  switch ($gap[2]) {
794  case self::ANSWER_TYPE_SELECT_VAL:
795  $value = $solutionvalue["value2"];
796  if ($value == -1) {
797  $value = '';
798  }
799  $worksheet->setCell($startrow + $i, $col + 2, $value);
800  break;
801  case self::ANSWER_TYPE_TEXT_VAL:
802  $worksheet->setCell($startrow + $i, $col + 2, $solutionvalue["value2"]);
803  break;
804  }
805  }
806  }
807  $i++;
808  }
809 
810  return $startrow + $i + 1;
811  }
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
getColumnCoord(int $a_col)
Get column "name" from number.
setCell($a_row, $a_col, $a_value, $datatype=null)
setBold(string $a_coords)
Set cell(s) to bold.
+ Here is the call graph for this function:

◆ setIdenticalScoring()

assLongMenu::setIdenticalScoring (   $a_identical_scoring)
Parameters
$a_identical_scoring

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

Referenced by loadFromDb().

908  : void
909  {
910  $this->identical_scoring = ($a_identical_scoring) ? 1 : 0;
911  }
+ Here is the caller graph for this function:

◆ setJsonStructure()

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

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

References $json_structure.

Referenced by loadCorrectAnswerData().

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

◆ setLongMenuTextValue()

assLongMenu::setLongMenuTextValue (   $long_menu_text = "")

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

References $long_menu_text, and assQuestion\getHtmlQuestionContentPurifier().

Referenced by lmMigrateQuestionTypeSpecificContent(), and loadFromDb().

104  : void
105  {
106  $this->long_menu_text = $this->getHtmlQuestionContentPurifier()->purify($long_menu_text);
107  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMinAutoComplete()

assLongMenu::setMinAutoComplete (   $minAutoComplete)

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

References $minAutoComplete.

Referenced by loadFromDb().

150  : void
151  {
152  $this->minAutoComplete = $minAutoComplete;
153  }
+ Here is the caller graph for this function:

◆ setSpecificFeedbackSetting()

assLongMenu::setSpecificFeedbackSetting (   $specificFeedbackSetting)

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

References $specificFeedbackSetting.

Referenced by loadFromDb().

140  : void
141  {
142  $this->specificFeedbackSetting = $specificFeedbackSetting;
143  }
+ Here is the caller graph for this function:

◆ toJSON()

assLongMenu::toJSON ( )

Returns a JSON representation of the question.

Implements ilAssQuestionLMExportable.

Definition at line 877 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().

877  : string
878  {
879  $result = array();
880  $result['id'] = $this->getId();
881  $result['type'] = (string) $this->getQuestionType();
882  $result['title'] = $this->getTitleForHTMLOutput();
883  $replaced_quesiton_text = $this->getLongMenuTextValue();
884  $result['question'] = $this->formatSAQuestion($this->getQuestion());
885  $result['lmtext'] = $this->formatSAQuestion($replaced_quesiton_text);
886  $result['nr_of_tries'] = $this->getNrOfTries();
887  $result['shuffle'] = $this->getShuffle();
888  $result['feedback'] = array(
889  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
890  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
891  );
892 
893  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
894  $result['answers'] = $this->getAnswers();
895  $result['correct_answers'] = $this->getCorrectAnswers();
896  $result['mobs'] = $mobs;
897  return json_encode($result);
898  }
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:

Field Documentation

◆ $answers

assLongMenu::$answers = []
private

◆ $answerType

array assLongMenu::$answerType = null
private

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

Referenced by getAnswerType(), and setAnswerType().

◆ $correct_answers

◆ $identical_scoring

assLongMenu::$identical_scoring
private

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

◆ $ilDB

assLongMenu::$ilDB
private

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

Referenced by lookupForExistingSolutions().

◆ $json_structure

assLongMenu::$json_structure
private

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

Referenced by getJsonStructure(), and setJsonStructure().

◆ $long_menu_text

assLongMenu::$long_menu_text
private

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

Referenced by getLongMenuTextValue(), and setLongMenuTextValue().

◆ $minAutoComplete

assLongMenu::$minAutoComplete
private

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

Referenced by setMinAutoComplete().

◆ $specificFeedbackSetting

assLongMenu::$specificFeedbackSetting
private

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