ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
assTextSubset 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 assTextSubset:
+ Collaboration diagram for assTextSubset:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assTextSubset constructor More...
 
 isComplete ()
 Returns true, if a TextSubset question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a assTextSubset object to a database. More...
 
 loadFromDb ($question_id)
 Loads a assTextSubset object from a database. More...
 
 addAnswer ($answertext, $points, $order)
 Adds an answer to the question. More...
 
 duplicate (bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
 Duplicates an assTextSubsetQuestion. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assTextSubset object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 getAnswerCount ()
 Returns the number of answers. More...
 
 getAnswer ($index=0)
 Returns an answer with a given index. More...
 
 deleteAnswer ($index=0)
 Deletes an answer with a given index. More...
 
 flushAnswers ()
 Deletes all answers. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
getAvailableAnswers ()
 Returns the available answers for the question. More...
 
 isAnswerCorrect ($answers, $answer)
 Returns the index of the found answer, if the given answer is in the set of correct answers and matchess the matching options, otherwise FALSE is returned. More...
 
 getTextRating ()
 Returns the rating option for text comparisons. More...
 
 setTextRating ($a_text_rating)
 Sets the rating option for text comparisons. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 setCorrectAnswers (int $a_correct_answers)
 Sets the number of correct answers needed to solve the question. More...
 
 getCorrectAnswers ()
 Returns the number of correct answers needed to solve the question. More...
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
joinAnswers ()
 Returns the answers of the question as a comma separated string. More...
 
 getMaxTextboxWidth ()
 Returns the maximum width needed for the answer textboxes. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 setExportDetailsXLS (ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
 {} More...
 
 getAnswers ()
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. 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...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
- 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...
 
 questionTitleExists (int $questionpool_id, string $title)
 Returns TRUE if the question title exists in a question pool in the database. More...
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 setOutputType (int $outputType=OUTPUT_HTML)
 
 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 ()
 
 getOutputType ()
 
 supportsJavascriptOutput ()
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 _getSuggestedSolution (int $question_id, int $subquestion_index=0)
 
 loadSuggestedSolution (int $question_id, int $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 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...
 
 moveUploadedMediaFile (string $file, string $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 buildImagePath ($questionId, $parentObjectId)
 
 getFlashPath ()
 Returns the image path for web accessable flash files 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...
 
 isInUse (int $question_id=0)
 Checks whether the question is in use or not in pools or tests. More...
 
 usageNumber (int $question_id=0)
 Returns the number of place the question is in use in pools or tests. More...
 
 isClone (int $question_id=0)
 Checks whether the question is a clone of another question or not. 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 ()
 
 setNewOriginalId (int $newId)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle (int $subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution (string $solution_id="", int $subquestion_index=0, bool $is_import=false)
 Sets a suggested solution for the question. More...
 
 updateSuggestedSolutions (int $original_id=-1, int $original_obj_id=-1)
 
 _resolveInternalLink (string $internal_link)
 
 _resolveIntLinks (int $question_id)
 
 syncWithOriginal ()
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool (int $question_id)
 
 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...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 prepareTextareaOutput (string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
 
 QTIMaterialToString (ilQTIMaterial $a_material)
 Reads an QTI material tag and creates a text or XHTML string. More...
 
 addQTIMaterial (ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
 
 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 ()
 
 setExportDetailsXLS (ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 __isset ($key)
 Object issetter. More...
 
 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)
 
 isAutosaveable ()
 
 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="", string $owner="", $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 ()
 
 savePartial ()
 
 isInActiveTest ()
 
- Public Member Functions inherited from ilObjQuestionScoringAdjustable
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
- Public Member Functions inherited from ilObjAnswerScoringAdjustable
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 

Data Fields

 $answers
 
 $correctanswers
 
 $text_rating
 
- Data Fields inherited from assQuestion
const IMG_MIME_TYPE_JPG = 'image/jpeg'
 
const IMG_MIME_TYPE_PNG = 'image/png'
 
const IMG_MIME_TYPE_GIF = 'image/gif'
 
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 = ':'
 
- Data Fields inherited from iQuestionCondition
const StringResultExpression = '~TEXT~'
 
const PercentageResultExpression = '%n%'
 
const NumericResultExpression = '#n#'
 
const MatchingResultExpression = ';n:m;'
 
const OrderingResultExpression = '$n,m,o,p$'
 
const NumberOfResultExpression = '+n+'
 
const ExclusiveResultExpression = '*n,m,o,p*'
 
const EmptyAnswerExpression = "?"
 

Protected Member Functions

 getSolutionSubmit ()
 
 calculateReachedPointsForSolution ($enteredTexts)
 
- Protected Member Functions inherited from assQuestion
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $postSubmissionFieldname)
 
 ensureCurrentTestPass (int $active_id, int $pass)
 
 lookupCurrentTestPass (int $active_id, int $pass)
 
 lookupTestId (int $active_id)
 Move to ilObjTest or similar More...
 
 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)
 
 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)
 
 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...
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $forcePassResultsUpdateEnabled)
 
static isForcePassResultUpdateEnabled ()
 
static isAllowedImageMimeType ($mimeType)
 
static fetchMimeTypeIdentifier (string $contentType)
 
static getAllowedFileExtensionsForMimeType (string $mimeType)
 
static isAllowedImageFileExtension (string $mimeType, string $fileExtension)
 
static getAllowedImageMaterialFileExtensions ()
 
static _getMaximumPoints (int $question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
static _getQuestionInfo (int $question_id)
 
static _getSuggestedSolutionCount (int $question_id)
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static _updateTestResultCache (int $active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place. More...
 
static logAction (string $logtext, int $active_id, int $question_id)
 
static getQuestionTypeFromDb (int $question_id)
 
static _getTotalRightAnswers (int $a_q_id)
 
static _getTitle (int $a_q_id)
 
static _getQuestionText (int $a_q_id)
 
static isFileAvailable (string $file)
 
static _getQuestionType (int $question_id)
 
static _getQuestionTitle (int $question_id)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static _getInternalLinkHref (string $target="")
 
static _getOriginalId (int $question_id)
 
static originalQuestionExists (int $questionId)
 
static _instanciateQuestion (int $question_id)
 
static _instantiateQuestion (int $question_id)
 
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 _isUsedInRandomTest (int $question_id)
 
static _isWorkedThrough (int $active_id, int $question_id, int $pass)
 Returns true if the question was worked through in the given pass Worked through means that the user entered at least one value. More...
 
static _areAnswered (int $a_user_id, array $a_question_ids)
 Checks if an array of question ids is answered by a user or not. More...
 
static _setReachedPoints (int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring, bool $obligationsEnabled)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static _needsManualScoring (int $question_id)
 
static _includeClass (string $question_type, int $gui=0)
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static isCoreQuestionType (string $questionType)
 
static includeCoreClass ($questionType, $withGuiClass)
 
static _getQuestionTypeName ($type_tag)
 
static _instanciateQuestionGUI (int $question_id)
 
static instantiateQuestionGUI (int $a_question_id)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $questionId)
 
static lookupOriginalParentObjId (int $originalQuestionId)
 returns the parent object id for given original question id (should be a qpl id, but theoretically it can be a tst id, too) More...
 
static isObligationPossible (int $questionId)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
static missingResultRecordExists (int $activeId, int $pass, array $questionIds)
 
static getQuestionsMissingResultRecord (int $activeId, int $pass, array $questionIds)
 
static lookupResultRecordExist (int $activeId, int $questionId, int $pass)
 
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)
 
- Protected Attributes inherited from assQuestion
const HAS_SPECIFIC_FEEDBACK = true
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
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
 
int $outputType = OUTPUT_JAVASCRIPT
 Contains the output type of a question. More...
 
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
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $allowedImageMaterialFileExtensionsByMimeType
 
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 Class for TextSubset questions

assTextSubset is a class for TextSubset questions. To solve a TextSubset question, a learner has to enter a TextSubsetal value in a defined range

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Nina Gharib nina@.nosp@m.wgse.nosp@m.rve.d.nosp@m.e
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

assTextSubset constructor

The constructor takes possible arguments an creates an instance of the assTextSubset object.

Parameters
string$titleA title string to describe the question
string$commentA comment string to describe the question
string$authorA string containing the name of the questions author
integer$ownerA TextSubsetal ID to identify the owner/creator
string$questionThe question string of the TextSubset question

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

References assQuestion\$author, assQuestion\$comment, assQuestion\$owner, assQuestion\$question, assQuestion\$title, and ILIAS\GlobalScreen\Provider\__construct().

76  {
78  $this->answers = array();
79  $this->correctanswers = 0;
80  }
string $question
The question text.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswer()

assTextSubset::addAnswer (   $answertext,
  $points,
  $order 
)

Adds an answer to the question.

public

Definition at line 188 of file class.assTextSubset.php.

References $i, and assQuestion\$points.

Referenced by addAnswerOptionValue().

188  : void
189  {
190  include_once "./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
191  if (array_key_exists($order, $this->answers)) {
192  // insert answer
193  $answer = new ASS_AnswerBinaryStateImage($answertext, $points, $order);
194  $newchoices = array();
195  for ($i = 0; $i < $order; $i++) {
196  $newchoices[] = $this->answers[$i];
197  }
198  $newchoices[] = $answer;
199  for ($i = $order, $iMax = count($this->answers); $i < $iMax; $i++) {
200  $changed = $this->answers[$i];
201  $changed->setOrder($i + 1);
202  $newchoices[] = $changed;
203  }
204  $this->answers = $newchoices;
205  } else {
206  // add answer
207  $this->answers[] = new ASS_AnswerBinaryStateImage($answertext, $points, count($this->answers));
208  }
209  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
float $points
The maximum available points for the question.
$i
Definition: metadata.php:41
+ Here is the caller graph for this function:

◆ addAnswerOptionValue()

assTextSubset::addAnswerOptionValue ( int  $qIndex,
string  $answerOptionValue,
float  $points 
)

Definition at line 986 of file class.assTextSubset.php.

References addAnswer().

986  : void
987  {
988  $this->addAnswer($answerOptionValue, $points, $qIndex);
989  }
addAnswer($answertext, $points, $order)
Adds an answer to the question.
float $points
The maximum available points for the question.
+ Here is the call graph for this function:

◆ calculateReachedPoints()

assTextSubset::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.

public

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

Definition at line 544 of file class.assTextSubset.php.

References $data, $DIC, $ilDB, calculateReachedPointsForSolution(), assQuestion\getCurrentSolutionResultSet(), and assQuestion\getSolutionMaxPass().

Referenced by getExpressionTypes().

545  {
546  if ($returndetails) {
547  throw new ilTestException('return details not implemented for ' . __METHOD__);
548  }
549 
550  global $DIC;
551  $ilDB = $DIC['ilDB'];
552 
553 
554  if (is_null($pass)) {
555  $pass = $this->getSolutionMaxPass($active_id);
556  }
557  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
558 
559  $enteredTexts = array();
560  while ($data = $ilDB->fetchAssoc($result)) {
561  $enteredTexts[] = $data["value1"];
562  }
563 
564  return $this->calculateReachedPointsForSolution($enteredTexts);
565  }
calculateReachedPointsForSolution($enteredTexts)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
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()

assTextSubset::calculateReachedPointsForSolution (   $enteredTexts)
protected
Parameters
$enteredTexts

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

References $index, assQuestion\$points, getAvailableAnswers(), and isAnswerCorrect().

Referenced by calculateReachedPoints().

869  : float
870  {
871  $enteredTexts ??= [];
872  $available_answers = $this->getAvailableAnswers();
873  $points = 0;
874  foreach ($enteredTexts as $enteredtext) {
875  $index = $this->isAnswerCorrect($available_answers, html_entity_decode($enteredtext));
876  if ($index !== false) {
877  unset($available_answers[$index]);
878  $points += $this->answers[$index]->getPoints();
879  }
880  }
881  return $points;
882  }
float $points
The maximum available points for the question.
$index
Definition: metadata.php:145
& getAvailableAnswers()
Returns the available answers for the question.
isAnswerCorrect($answers, $answer)
Returns the index of the found answer, if the given answer is in the set of correct answers and match...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyObject()

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

Copies an assTextSubset object.

public

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

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

267  : int
268  {
269  if ($this->getId() <= 0) {
270  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
271  }
272  // duplicate the question in database
273  $clone = $this;
274  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
276  $clone->id = -1;
277  $source_questionpool_id = $this->getObjId();
278  $clone->setObjId($target_questionpool_id);
279  if ($title) {
280  $clone->setTitle($title);
281  }
282  $clone->saveToDb();
283  // copy question page content
284  $clone->copyPageOfQuestion($original_id);
285  // copy XHTML media objects
286  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
287 
288  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
289 
290  return $clone->id;
291  }
static _getOriginalId(int $question_id)
+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

Definition at line 293 of file class.assTextSubset.php.

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

293  : int
294  {
295  if ($this->getId() <= 0) {
296  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
297  }
298 
299  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
300 
301  $sourceQuestionId = $this->id;
302  $sourceParentId = $this->getObjId();
303 
304  // duplicate the question in database
305  $clone = $this;
306  $clone->id = -1;
307 
308  $clone->setObjId($targetParentId);
309 
310  if ($targetQuestionTitle) {
311  $clone->setTitle($targetQuestionTitle);
312  }
313 
314  $clone->saveToDb();
315  // copy question page content
316  $clone->copyPageOfQuestion($sourceQuestionId);
317  // copy XHTML media objects
318  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
319 
320  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
321 
322  return $clone->id;
323  }
+ Here is the call graph for this function:

◆ deleteAnswer()

assTextSubset::deleteAnswer (   $index = 0)

Deletes an answer with a given index.

The index of the first answer is 0, the index of the second answer is 1 and so on.

Parameters
integer$indexA nonnegative index of the n-th answer public
See also
$answers

Definition at line 369 of file class.assTextSubset.php.

References $i, and $index.

369  : void
370  {
371  if ($index < 0) {
372  return;
373  }
374  if (count($this->answers) < 1) {
375  return;
376  }
377  if ($index >= count($this->answers)) {
378  return;
379  }
380  unset($this->answers[$index]);
381  $this->answers = array_values($this->answers);
382  for ($i = 0, $iMax = count($this->answers); $i < $iMax; $i++) {
383  if ($this->answers[$i]->getOrder() > $index) {
384  $this->answers[$i]->setOrder($i);
385  }
386  }
387  }
$index
Definition: metadata.php:145
$i
Definition: metadata.php:41

◆ duplicate()

assTextSubset::duplicate ( bool  $for_test = true,
string  $title = "",
string  $author = "",
string  $owner = "",
  $testObjId = null 
)

Duplicates an assTextSubsetQuestion.

public

Definition at line 216 of file class.assTextSubset.php.

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

216  : int
217  {
218  if ($this->id <= 0) {
219  // The question has not been saved. It cannot be duplicated
220  return -1;
221  }
222  // duplicate the question in database
223  $this_id = $this->getId();
224  $thisObjId = $this->getObjId();
225 
226  $clone = $this;
227  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
229  $clone->id = -1;
230 
231  if ((int) $testObjId > 0) {
232  $clone->setObjId($testObjId);
233  }
234 
235  if ($title) {
236  $clone->setTitle($title);
237  }
238 
239  if ($author) {
240  $clone->setAuthor($author);
241  }
242  if ($owner) {
243  $clone->setOwner($owner);
244  }
245 
246  if ($for_test) {
247  $clone->saveToDb($original_id);
248  } else {
249  $clone->saveToDb();
250  }
251 
252  // copy question page content
253  $clone->copyPageOfQuestion($this_id);
254  // copy XHTML media objects
255  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
256 
257  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
258 
259  return $clone->id;
260  }
static _getOriginalId(int $question_id)
+ Here is the call graph for this function:

◆ flushAnswers()

assTextSubset::flushAnswers ( )

Deletes all answers.

public

See also
$answers

Definition at line 395 of file class.assTextSubset.php.

395  : void
396  {
397  $this->answers = array();
398  }

◆ getAdditionalTableName()

assTextSubset::getAdditionalTableName ( )

Returns the name of the additional question data table in the database.

Returns
string The additional table name public

Definition at line 750 of file class.assTextSubset.php.

Referenced by loadFromDb(), and saveWorkingData().

750  : string
751  {
752  return "qpl_qst_textsubset";
753  }
+ Here is the caller graph for this function:

◆ getAnswer()

assTextSubset::getAnswer (   $index = 0)

Returns an answer with a given index.

The index of the first answer is 0, the index of the second answer is 1 and so on.

Parameters
integer$indexA nonnegative index of the n-th answer
Returns
object ASS_assAnswerBinaryStateImage-Object containing the answer public
See also
$answers

Definition at line 346 of file class.assTextSubset.php.

References $index.

Referenced by getAvailableAnswerOptions().

346  : ?object
347  {
348  if ($index < 0) {
349  return null;
350  }
351  if (count($this->answers) < 1) {
352  return null;
353  }
354  if ($index >= count($this->answers)) {
355  return null;
356  }
357 
358  return $this->answers[$index];
359  }
$index
Definition: metadata.php:145
+ Here is the caller graph for this function:

◆ getAnswerCount()

assTextSubset::getAnswerCount ( )

Returns the number of answers.

Returns
integer The number of answers of the TextSubset question public
See also
$ranges

Definition at line 332 of file class.assTextSubset.php.

332  : int
333  {
334  return count($this->answers);
335  }

◆ getAnswers()

assTextSubset::getAnswers ( )

Definition at line 793 of file class.assTextSubset.php.

References $answers.

Referenced by getAvailableAnswerOptions(), getSolutionSubmit(), isAddableAnswerOptionValue(), and toJSON().

793  : array
794  {
795  return $this->answers;
796  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assTextSubset::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name public

Definition at line 761 of file class.assTextSubset.php.

761  : string
762  {
763  return "qpl_a_textsubset";
764  }

◆ getAvailableAnswerOptions()

assTextSubset::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

Implements iQuestionCondition.

Definition at line 961 of file class.assTextSubset.php.

References $index, getAnswer(), and getAnswers().

962  {
963  if ($index !== null) {
964  return $this->getAnswer($index);
965  } else {
966  return $this->getAnswers();
967  }
968  }
$index
Definition: metadata.php:145
getAnswer($index=0)
Returns an answer with a given index.
+ Here is the call graph for this function:

◆ getAvailableAnswers()

& assTextSubset::getAvailableAnswers ( )

Returns the available answers for the question.

private

See also
$answers

Definition at line 430 of file class.assTextSubset.php.

Referenced by calculateReachedPointsForSolution().

430  : array
431  {
432  $available_answers = array();
433  foreach ($this->answers as $answer) {
434  $available_answers[] = $answer->getAnswertext();
435  }
436  return $available_answers;
437  }
+ Here is the caller graph for this function:

◆ getCorrectAnswers()

assTextSubset::getCorrectAnswers ( )

Returns the number of correct answers needed to solve the question.

Returns
integer The number of correct answers public

Definition at line 584 of file class.assTextSubset.php.

References $correctanswers.

Referenced by getMaximumPoints(), saveWorkingData(), and toJSON().

584  : int
585  {
586  return $this->correctanswers;
587  }
+ Here is the caller graph for this function:

◆ getExpressionTypes()

◆ getMaximumPoints()

assTextSubset::getMaximumPoints ( )

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

public

See also
$points

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

References assQuestion\$points, and getCorrectAnswers().

Referenced by getExpressionTypes(), and isComplete().

406  : float
407  {
408  $points = array();
409  foreach ($this->answers as $answer) {
410  if ($answer->getPoints() > 0) {
411  $points[] = $answer->getPoints();
412  }
413  }
414  rsort($points, SORT_NUMERIC);
415  $maxpoints = 0;
416  for ($counter = 0; $counter < $this->getCorrectAnswers(); $counter++) {
417  if (isset($points[$counter])) {
418  $maxpoints += $points[$counter];
419  }
420  }
421  return $maxpoints;
422  }
getCorrectAnswers()
Returns the number of correct answers needed to solve the question.
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:

◆ getMaxTextboxWidth()

assTextSubset::getMaxTextboxWidth ( )

Returns the maximum width needed for the answer textboxes.

Returns
integer Maximum textbox width public

Definition at line 732 of file class.assTextSubset.php.

732  : int
733  {
734  $maxwidth = 0;
735  foreach ($this->answers as $answer) {
736  $len = strlen($answer->getAnswertext());
737  if ($len > $maxwidth) {
738  $maxwidth = $len;
739  }
740  }
741  return $maxwidth + 3;
742  }

◆ getOperators()

assTextSubset::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

Definition at line 892 of file class.assTextSubset.php.

References ilOperatorsExpressionMapping\getOperatorsByExpression().

892  : array
893  {
895  }
+ Here is the call graph for this function:

◆ getQuestionType()

assTextSubset::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

Definition at line 701 of file class.assTextSubset.php.

Referenced by toJSON().

701  : string
702  {
703  return "assTextSubset";
704  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assTextSubset::getRTETextWithMediaObjects ( )

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

Definition at line 770 of file class.assTextSubset.php.

770  : string
771  {
772  return parent::getRTETextWithMediaObjects();
773  }

◆ getSolutionSubmit()

assTextSubset::getSolutionSubmit ( )
protected
Returns
array

Definition at line 843 of file class.assTextSubset.php.

References Vendor\Package\$a, $index, $post, assQuestion\extendedTrim(), getAnswers(), and assQuestion\getHtmlUserSolutionPurifier().

Referenced by saveWorkingData().

843  : array
844  {
845  $purifier = $this->getHtmlUserSolutionPurifier();
846  $post = $this->dic->http()->wrapper()->post();
847 
848  $solutionSubmit = [];
849  foreach ($this->getAnswers() as $index => $a) {
850  if ($post->has("TEXTSUBSET_$index")) {
851  $value = $post->retrieve(
852  "TEXTSUBSET_$index",
853  $this->dic->refinery()->kindlyTo()->string()
854  );
855  if ($value) {
856  $value = $this->extendedTrim($value);
857  $value = $purifier->purify($value);
858  $solutionSubmit[] = $value;
859  }
860  }
861  }
862 
863  return $solutionSubmit;
864  }
$index
Definition: metadata.php:145
static extendedTrim(string $value)
Trim non-printable characters from the beginning and end of a string.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$post
Definition: ltitoken.php:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextRating()

assTextSubset::getTextRating ( )

Returns the rating option for text comparisons.

Returns
string The rating option for text comparisons
See also
$text_rating public

Definition at line 504 of file class.assTextSubset.php.

References $text_rating.

Referenced by isAnswerCorrect(), saveWorkingData(), and toJSON().

504  : string
505  {
506  return $this->text_rating;
507  }
+ Here is the caller graph for this function:

◆ isAddableAnswerOptionValue()

assTextSubset::isAddableAnswerOptionValue ( int  $qIndex,
string  $answerOptionValue 
)

Definition at line 970 of file class.assTextSubset.php.

References getAnswers().

970  : bool
971  {
972  $found = false;
973 
974  foreach ($this->getAnswers() as $item) {
975  if ($answerOptionValue !== $item->getAnswerText()) {
976  continue;
977  }
978 
979  $found = true;
980  break;
981  }
982 
983  return !$found;
984  }
+ Here is the call graph for this function:

◆ isAnswerCorrect()

assTextSubset::isAnswerCorrect (   $answers,
  $answer 
)

Returns the index of the found answer, if the given answer is in the set of correct answers and matchess the matching options, otherwise FALSE is returned.

Parameters
array$answersAn array containing the correct answers
string$answerThe text of the given answer
Returns
mixed The index of the correct answer, FALSE otherwise public

Definition at line 449 of file class.assTextSubset.php.

References $answers, $DIC, ILIAS\LTI\ToolProvider\$key, assQuestion\$refinery, assQuestion\getPoints(), getTextRating(), ilStr\strToLower(), TEXTGAP_RATING_CASEINSENSITIVE, TEXTGAP_RATING_CASESENSITIVE, TEXTGAP_RATING_LEVENSHTEIN1, TEXTGAP_RATING_LEVENSHTEIN2, TEXTGAP_RATING_LEVENSHTEIN3, TEXTGAP_RATING_LEVENSHTEIN4, and TEXTGAP_RATING_LEVENSHTEIN5.

Referenced by calculateReachedPointsForSolution().

450  {
451  include_once "./Services/Utilities/classes/class.ilStr.php";
452  global $DIC;
453  $refinery = $DIC->refinery();
454  $textrating = $this->getTextRating();
455 
456  foreach ($answers as $key => $value) {
457  if ($this->answers[$key]->getPoints() <= 0) {
458  continue;
459  }
460  $value = html_entity_decode($value); #SB
461  switch ($textrating) {
463  if (strcmp(ilStr::strToLower($value), ilStr::strToLower($answer)) == 0) { #SB
464  return $key;
465  }
466  break;
468  if (strcmp($value, $answer) == 0) {
469  return $key;
470  }
471  break;
473  $transformation = $refinery->string()->levenshtein()->standard($answer, 1);
474  break;
476  $transformation = $refinery->string()->levenshtein()->standard($answer, 2);
477  break;
479  $transformation = $refinery->string()->levenshtein()->standard($answer, 3);
480  break;
482  $transformation = $refinery->string()->levenshtein()->standard($answer, 4);
483  break;
485  $transformation = $refinery->string()->levenshtein()->standard($answer, 5);
486  break;
487  }
488 
489  // run answers against Levenshtein2 methods
490  if (isset($transformation) && $transformation->transform($value) >= 0) {
491  return $key;
492  }
493  }
494  return false;
495  }
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
getTextRating()
Returns the rating option for text comparisons.
global $DIC
Definition: feed.php:28
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
string $key
Consumer key/client ID value.
Definition: System.php:193
const TEXTGAP_RATING_LEVENSHTEIN4
static strToLower(string $a_string)
Definition: class.ilStr.php:72
ILIAS Refinery Factory $refinery
const TEXTGAP_RATING_CASEINSENSITIVE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isComplete()

assTextSubset::isComplete ( )

Returns true, if a TextSubset question is complete for use.

Returns
boolean True, if the TextSubset question is complete for use, otherwise false public

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

References getMaximumPoints().

88  : bool
89  {
90  if (
91  strlen($this->title)
92  && $this->author
93  && $this->question &&
94  count($this->answers) >= $this->correctanswers
95  && $this->getMaximumPoints() > 0
96  ) {
97  return true;
98  }
99  return false;
100  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ joinAnswers()

& assTextSubset::joinAnswers ( )

Returns the answers of the question as a comma separated string.

Definition at line 710 of file class.assTextSubset.php.

References ILIAS\LTI\ToolProvider\$key.

710  : array
711  {
712  $join = [];
713  foreach ($this->answers as $answer) {
714  $key = $answer->getPoints() . '';
715 
716  if (!isset($join[$key]) || !is_array($join[$key])) {
717  $join[$key] = [];
718  }
719 
720  $join[$key][] = $answer->getAnswertext();
721  }
722 
723  return $join;
724  }
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ loadFromDb()

assTextSubset::loadFromDb (   $question_id)

Loads a assTextSubset object from a database.

Parameters
object$dbA pear DB object
integer$question_idA unique key which defines the multiple choice test in the database public

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

References $data, $DIC, Vendor\Package\$e, $ilDB, ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), setCorrectAnswers(), assQuestion\setId(), assQuestion\setLifecycle(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setTextRating(), and assQuestion\setTitle().

129  : void
130  {
131  global $DIC;
132  $ilDB = $DIC['ilDB'];
133 
134  $result = $ilDB->queryF(
135  "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",
136  array("integer"),
137  array($question_id)
138  );
139  if ($result->numRows() == 1) {
140  $data = $ilDB->fetchAssoc($result);
141  $this->setId($question_id);
142  $this->setObjId($data["obj_fi"]);
143  $this->setNrOfTries($data['nr_of_tries']);
144  $this->setTitle((string) $data["title"]);
145  $this->setComment((string) $data["description"]);
146  $this->setOriginalId($data["original_id"]);
147  $this->setAuthor($data["author"]);
148  $this->setPoints($data["points"]);
149  $this->setOwner($data["owner"]);
150  include_once("./Services/RTE/classes/class.ilRTE.php");
151  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
152  $this->setCorrectAnswers((int) $data["correctanswers"]);
153  $this->setTextRating($data["textgap_rating"]);
154 
155  try {
159  }
160 
161  try {
162  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
163  } catch (ilTestQuestionPoolException $e) {
164  }
165  }
166 
167 
168  $result = $ilDB->queryF(
169  "SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
170  array('integer'),
171  array($question_id)
172  );
173  include_once "./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
174  if ($result->numRows() > 0) {
175  while ($data = $ilDB->fetchAssoc($result)) {
176  $this->answers[] = new ASS_AnswerBinaryStateImage($data["answertext"], $data["points"], $data["aorder"]);
177  }
178  }
179 
180  parent::loadFromDb($question_id);
181  }
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)
setCorrectAnswers(int $a_correct_answers)
Sets the number of correct answers needed to solve the question.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setOwner(int $owner=-1)
setTextRating($a_text_rating)
Sets the rating option for text comparisons.
setComment(string $comment="")
global $DIC
Definition: feed.php:28
getAdditionalTableName()
Returns the name of the additional question data table in the database.
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:

◆ saveToDb()

assTextSubset::saveToDb (   $original_id = "")

Saves a assTextSubset object to a database.

Parameters
string$original_id

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

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

108  : void
109  {
110  if ($original_id == "") {
111  $this->saveQuestionDataToDb();
112  } else {
114  }
115 
118 
119  parent::saveToDb();
120  }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb(int $original_id=-1)
+ Here is the call graph for this function:

◆ saveWorkingData()

assTextSubset::saveWorkingData (   $active_id,
  $pass = null,
  $authorized = true 
)

Saves the learners input of the question to the database.

public

Parameters
integer$active_idActive id of the user
integer$passTest pass
Returns
boolean $status

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

References $DIC, $ilDB, $ilUser, ILIAS\LTI\ToolProvider\$key, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), getAdditionalTableName(), getCorrectAnswers(), assQuestion\getId(), assQuestion\getProcessLocker(), getSolutionSubmit(), getTextRating(), ILIAS\Repository\lng(), assQuestion\logAction(), assQuestion\removeCurrentSolution(), ilObjQuestionScoringAdjustable\saveAdditionalQuestionDataToDb(), ilObjAnswerScoringAdjustable\saveAnswerSpecificDataToDb(), and assQuestion\saveCurrentSolution().

597  : bool
598  {
599  global $DIC;
600  $ilDB = $DIC['ilDB'];
601  $ilUser = $DIC['ilUser'];
602 
603  if (is_null($pass)) {
604  include_once "./Modules/Test/classes/class.ilObjTest.php";
605  $pass = ilObjTest::_getPass($active_id);
606  }
607 
608  $entered_values = 0;
609  $solutionSubmit = $this->getSolutionSubmit();
610 
611  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $solutionSubmit, $active_id, $pass, $authorized) {
612  $this->removeCurrentSolution($active_id, $pass, $authorized);
613 
614  foreach ($solutionSubmit as $value) {
615  if (strlen($value)) {
616  $this->saveCurrentSolution($active_id, $pass, $value, null, $authorized);
617  $entered_values++;
618  }
619  }
620  });
621 
622  if ($entered_values) {
624  assQuestion::logAction($this->lng->txtlng(
625  "assessment",
626  "log_user_entered_values",
628  ), $active_id, $this->getId());
629  }
631  assQuestion::logAction($this->lng->txtlng(
632  "assessment",
633  "log_user_not_entered_values",
635  ), $active_id, $this->getId());
636  }
637 
638  return true;
639  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
global $DIC
Definition: feed.php:28
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)
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

◆ setCorrectAnswers()

assTextSubset::setCorrectAnswers ( int  $a_correct_answers)

Sets the number of correct answers needed to solve the question.

Parameters
integer$a_correct_anwersThe number of correct answers public

Definition at line 573 of file class.assTextSubset.php.

Referenced by loadFromDb().

573  : void
574  {
575  $this->correctanswers = $a_correct_answers;
576  }
+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

assTextSubset::setExportDetailsXLS ( ilAssExcelFormatHelper  $worksheet,
int  $startrow,
int  $active_id,
int  $pass 
)

{}

Definition at line 778 of file class.assTextSubset.php.

References $i, assQuestion\getSolutionValues(), and ilAssExcelFormatHelper\setCell().

778  : int
779  {
780  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
781 
782  $solutions = $this->getSolutionValues($active_id, $pass);
783 
784  $i = 1;
785  foreach ($solutions as $solution) {
786  $worksheet->setCell($startrow + $i, 2, $solution["value1"]);
787  $i++;
788  }
789 
790  return $startrow + $i + 1;
791  }
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
setCell($a_row, $a_col, $a_value, $datatype=null)
$i
Definition: metadata.php:41
+ Here is the call graph for this function:

◆ setTextRating()

assTextSubset::setTextRating (   $a_text_rating)

Sets the rating option for text comparisons.

Parameters
string$a_textgap_ratingThe rating option for text comparisons
See also
$textgap_rating public

Definition at line 516 of file class.assTextSubset.php.

References TEXTGAP_RATING_CASEINSENSITIVE, TEXTGAP_RATING_CASESENSITIVE, TEXTGAP_RATING_LEVENSHTEIN1, TEXTGAP_RATING_LEVENSHTEIN2, TEXTGAP_RATING_LEVENSHTEIN3, TEXTGAP_RATING_LEVENSHTEIN4, and TEXTGAP_RATING_LEVENSHTEIN5.

Referenced by loadFromDb().

516  : void
517  {
518  switch ($a_text_rating) {
526  $this->text_rating = $a_text_rating;
527  break;
528  default:
529  $this->text_rating = TEXTGAP_RATING_CASEINSENSITIVE;
530  break;
531  }
532  }
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_CASEINSENSITIVE
+ Here is the caller graph for this function:

◆ toJSON()

assTextSubset::toJSON ( )

Returns a JSON representation of the question.

Definition at line 801 of file class.assTextSubset.php.

References $answers, ILIAS\LTI\ToolProvider\$key, $mobs, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getAnswers(), getCorrectAnswers(), assQuestion\getId(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), getTextRating(), assQuestion\getTitleForHTMLOutput(), and ILIAS\Repository\int().

801  : string
802  {
803  include_once("./Services/RTE/classes/class.ilRTE.php");
804  $result = array();
805  $result['id'] = $this->getId();
806  $result['type'] = (string) $this->getQuestionType();
807  $result['title'] = $this->getTitleForHTMLOutput();
808  $result['question'] = $this->formatSAQuestion($this->getQuestion());
809  $result['nr_of_tries'] = $this->getNrOfTries();
810  $result['matching_method'] = $this->getTextRating();
811  $result['feedback'] = array(
812  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
813  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
814  );
815 
816  $answers = array();
817  foreach ($this->getAnswers() as $key => $answer_obj) {
818  $answers[] = array(
819  "answertext" => (string) $answer_obj->getAnswertext(),
820  "points" => (float) $answer_obj->getPoints(),
821  "order" => (int) $answer_obj->getOrder()
822  );
823  }
824  $result['correct_answers'] = $answers;
825 
826  $answers = array();
827  for ($loop = 1; $loop <= $this->getCorrectAnswers(); $loop++) {
828  $answers[] = array(
829  "answernr" => $loop
830  );
831  }
832  $result['answers'] = $answers;
833 
834  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
835  $result['mobs'] = $mobs;
836 
837  return json_encode($result);
838  }
getCorrectAnswers()
Returns the number of correct answers needed to solve the question.
$mobs
Definition: imgupload.php:70
getTextRating()
Returns the rating option for text comparisons.
getQuestionType()
Returns the question type of the question.
string $key
Consumer key/client ID value.
Definition: System.php:193
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
+ Here is the call graph for this function:

Field Documentation

◆ $answers

assTextSubset::$answers

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

Referenced by getAnswers(), isAnswerCorrect(), and toJSON().

◆ $correctanswers

assTextSubset::$correctanswers

Definition at line 50 of file class.assTextSubset.php.

Referenced by getCorrectAnswers().

◆ $text_rating

assTextSubset::$text_rating

Definition at line 57 of file class.assTextSubset.php.

Referenced by getTextRating().


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