ILIAS  release_8 Revision v8.24
assKprimChoice Class Reference
+ Inheritance diagram for assKprimChoice:
+ Collaboration diagram for assKprimChoice:

Public Member Functions

 __construct ($title='', $comment='', $author='', $owner=-1, $question='')
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 setShuffleAnswersEnabled ($shuffleAnswersEnabled)
 
 isShuffleAnswersEnabled ()
 
 setAnswerType ($answerType)
 
 getAnswerType ()
 
 setThumbSize (int $thumbSize)
 
 getThumbSize ()
 
 setScorePartialSolutionEnabled ($scorePartialSolutionEnabled)
 
 isScorePartialSolutionEnabled ()
 
 setOptionLabel ($optionLabel)
 
 getOptionLabel ()
 
 setCustomTrueOptionLabel ($customTrueOptionLabel)
 
 getCustomTrueOptionLabel ()
 
 setCustomFalseOptionLabel ($customFalseOptionLabel)
 
 getCustomFalseOptionLabel ()
 
 setSpecificFeedbackSetting ($specificFeedbackSetting)
 
 getSpecificFeedbackSetting ()
 
 setAnswers ($answers)
 
 getAnswers ()
 
 getAnswer ($position)
 
 addAnswer (ilAssKprimChoiceAnswer $answer)
 
 loadFromDb ($questionId)
 
 saveToDb ($originalId='')
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 isComplete ()
 Returns true, if a question is complete for use. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 getValidAnswerTypes ()
 
 isValidAnswerType ($answerType)
 
 isSingleLineAnswerType ($answerType)
 
 getAnswerTypeSelectOptions (ilLanguage $lng)
 
 getValidOptionLabels ()
 
 getValidOptionLabelsTranslated (ilLanguage $lng)
 
 isValidOptionLabel ($optionLabel)
 
 getTrueOptionLabelTranslation (ilLanguage $lng, $optionLabel)
 
 getFalseOptionLabelTranslation (ilLanguage $lng, $optionLabel)
 
 getInstructionTextTranslation (ilLanguage $lng, $optionLabel)
 
 isCustomOptionLabel ($labelValue)
 
 getThumbPrefix ()
 
 rebuildThumbnails ()
 
 handleFileUploads ($answers, $files)
 
 removeAnswerImage ($position)
 
 duplicate (bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assMultipleChoice object. More...
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getSpecificFeedbackAllCorrectOptionLabel ()
 
 isAnswered (int $active_id, int $pass)
 
 setExportDetailsXLS (ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
 {} More...
 
 moveAnswerDown ($position)
 
 moveAnswerUp ($position)
 
- 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 ()
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 getSpecificFeedbackAllCorrectOptionLabel ()
 

Static Public Member Functions

static isObligationPossible (int $questionId)
 
- 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)
 @TODO 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...
 

Data Fields

const NUM_REQUIRED_ANSWERS = 4
 
const PARTIAL_SCORING_NUM_CORRECT_ANSWERS = 3
 
const ANSWER_TYPE_SINGLE_LINE = 'singleLine'
 
const ANSWER_TYPE_MULTI_LINE = 'multiLine'
 
const OPTION_LABEL_RIGHT_WRONG = 'right_wrong'
 
const OPTION_LABEL_PLUS_MINUS = 'plus_minus'
 
const OPTION_LABEL_APPLICABLE_OR_NOT = 'applicable_or_not'
 
const OPTION_LABEL_ADEQUATE_OR_NOT = 'adequate_or_not'
 
const OPTION_LABEL_CUSTOM = 'customlabel'
 
const DEFAULT_THUMB_SIZE = 150
 
const THUMB_PREFIX = 'thumb.'
 
- 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 = ':'
 

Protected Member Functions

 generateThumbForFile ($path, $file)
 
 getSolutionSubmit ()
 
 calculateReachedPointsForSolution ($found_values, $active_id=0)
 
 beforeSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 getRTETextWithMediaObjects ()
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
- 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)
 @refactor 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...
 

Private Member Functions

 loadAnswerData ($questionId)
 
 handleFileUpload (ilAssKprimChoiceAnswer $answer, $fileData)
 
 getNumAllowedFailures ()
 

Private Attributes

 $shuffleAnswersEnabled
 
 $answerType
 
 $thumbSize
 
 $scorePartialSolutionEnabled
 
 $optionLabel
 
 $customTrueOptionLabel
 
 $customFalseOptionLabel
 
 $specificFeedbackSetting
 
 $answers
 

Additional Inherited Members

- 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

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

Constructor & Destructor Documentation

◆ __construct()

assKprimChoice::__construct (   $title = '',
  $comment = '',
  $author = '',
  $owner = -1,
  $question = '' 
)

Definition at line 61 of file class.assKprimChoice.php.

62 {
64
65 $this->shuffleAnswersEnabled = true;
66 $this->answerType = self::ANSWER_TYPE_SINGLE_LINE;
67 $this->thumbSize = self::DEFAULT_THUMB_SIZE;
68 $this->scorePartialSolutionEnabled = true;
69 $this->optionLabel = self::OPTION_LABEL_RIGHT_WRONG;
70 $this->customTrueOptionLabel = '';
71 $this->customFalseOptionLabel = '';
72
74
75 $this->answers = array();
76 }
string $question
The question text.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References assQuestion\$author, assQuestion\$comment, assQuestion\$owner, assQuestion\$question, assQuestion\$title, ILIAS\GlobalScreen\Provider\__construct(), ANSWER_TYPE_SINGLE_LINE, DEFAULT_THUMB_SIZE, ilAssConfigurableMultiOptionQuestionFeedback\FEEDBACK_SETTING_ALL, and OPTION_LABEL_RIGHT_WRONG.

+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswer()

assKprimChoice::addAnswer ( ilAssKprimChoiceAnswer  $answer)

Definition at line 203 of file class.assKprimChoice.php.

203 : void
204 {
205 $answer->setAnswertext(
206 $this->getHtmlQuestionContentPurifier()->purify($answer->getAnswertext())
207 );
208 $this->answers[] = $answer;
209 }

References ilAssKprimChoiceAnswer\getAnswertext(), assQuestion\getHtmlQuestionContentPurifier(), and ilAssKprimChoiceAnswer\setAnswertext().

+ Here is the call graph for this function:

◆ afterSyncWithOriginal()

assKprimChoice::afterSyncWithOriginal (   $origQuestionId,
  $dupQuestionId,
  $origParentObjId,
  $dupParentObjId 
)
protected

Definition at line 865 of file class.assKprimChoice.php.

865 : void
866 {
867 parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
868
869 $this->cloneAnswerImages($dupQuestionId, $dupParentObjId, $origQuestionId, $origParentObjId);
870 }

◆ beforeSyncWithOriginal()

assKprimChoice::beforeSyncWithOriginal (   $origQuestionId,
  $dupQuestionId,
  $origParentObjId,
  $dupParentObjId 
)
protected

Definition at line 854 of file class.assKprimChoice.php.

854 : void
855 {
856 parent::beforeSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
857
858 $question = self::instantiateQuestion($origQuestionId);
859
860 foreach ($question->getAnswers() as $answer) {
861 $question->removeAnswerImage($answer->getPosition());
862 }
863 }
static instantiateQuestion(int $question_id)

References assQuestion\$question, and assQuestion\instantiateQuestion().

+ Here is the call graph for this function:

◆ calculateReachedPoints()

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

@access public

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

Reimplemented from assQuestion.

Definition at line 467 of file class.assKprimChoice.php.

468 {
469 if ($returndetails) {
470 throw new ilTestException('return details not implemented for ' . __METHOD__);
471 }
472
473 global $DIC;
474 $ilDB = $DIC['ilDB'];
475
476 $found_values = array();
477 if (is_null($pass)) {
478 $pass = $this->getSolutionMaxPass($active_id);
479 }
480
481 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
482
483 while ($data = $ilDB->fetchAssoc($result)) {
484 $found_values[(int) $data['value1']] = (int) $data['value2'];
485 }
486
487 $points = $this->calculateReachedPointsForSolution($found_values, $active_id);
488
489 return $points;
490 }
calculateReachedPointsForSolution($found_values, $active_id=0)
float $points
The maximum available points for the question.
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
getSolutionMaxPass(int $active_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28

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

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assKprimChoice::calculateReachedPointsForSolution (   $found_values,
  $active_id = 0 
)
protected

Definition at line 709 of file class.assKprimChoice.php.

710 {
711 $numCorrect = 0;
712 if ($found_values == null) {
713 $found_values = [];
714 }
715 foreach ($this->getAnswers() as $key => $answer) {
716 if (!isset($found_values[$answer->getPosition()])) {
717 continue;
718 }
719
720 if ($found_values[$answer->getPosition()] == $answer->getCorrectness()) {
721 $numCorrect++;
722 }
723 }
724
725 if ($numCorrect >= self::NUM_REQUIRED_ANSWERS) {
726 $points = $this->getPoints();
727 } elseif ($this->isScorePartialSolutionEnabled() && $numCorrect >= self::PARTIAL_SCORING_NUM_CORRECT_ANSWERS) {
728 $points = $this->getPoints() / 2;
729 } else {
730 $points = 0;
731 }
732
733 if ($active_id) {
734 if (count($found_values) == 0) {
735 $points = 0;
736 }
737 }
738 return $points;
739 }
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, assQuestion\$points, getAnswers(), assQuestion\getPoints(), and isScorePartialSolutionEnabled().

Referenced by calculateReachedPoints().

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

◆ copyObject()

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

Copies an assMultipleChoice object.

Definition at line 826 of file class.assKprimChoice.php.

826 : int
827 {
828 if ($this->getId() <= 0) {
829 throw new RuntimeException('The question has not been saved. It cannot be duplicated');
830 }
831 // duplicate the question in database
832 $clone = $this;
833 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
835 $clone->id = -1;
836 $source_questionpool_id = $this->getObjId();
837 $clone->setObjId($target_questionpool_id);
838 if ($title) {
839 $clone->setTitle($title);
840 }
841 $clone->saveToDb();
842 // copy question page content
843 $clone->copyPageOfQuestion($original_id);
844 // copy XHTML media objects
845 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
846 // duplicate the image
847 $clone->cloneAnswerImages($original_id, $source_questionpool_id, $clone->getId(), $clone->getObjId());
848
849 $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
850
851 return $clone->id;
852 }
static _getOriginalId(int $question_id)

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

+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

Definition at line 789 of file class.assKprimChoice.php.

789 : int
790 {
791 if ($this->getId() <= 0) {
792 throw new RuntimeException('The question has not been saved. It cannot be duplicated');
793 }
794
795 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
796
797 $sourceQuestionId = $this->id;
798 $sourceParentId = $this->getObjId();
799
800 // duplicate the question in database
801 $clone = $this;
802 $clone->id = -1;
803
804 $clone->setObjId($targetParentId);
805
806 if ($targetQuestionTitle) {
807 $clone->setTitle($targetQuestionTitle);
808 }
809
810 $clone->saveToDb();
811 // copy question page content
812 $clone->copyPageOfQuestion($sourceQuestionId);
813 // copy XHTML media objects
814 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
815 // duplicate the image
816 $clone->cloneAnswerImages($sourceQuestionId, $sourceParentId, $clone->getId(), $clone->getObjId());
817
818 $clone->onCopy($sourceParentId, $sourceQuestionId, $targetParentId, $clone->getId());
819
820 return $clone->id;
821 }

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

+ Here is the call graph for this function:

◆ duplicate()

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

Reimplemented from assQuestion.

Definition at line 741 of file class.assKprimChoice.php.

741 : int
742 {
743 if ($this->id <= 0) {
744 // The question has not been saved. It cannot be duplicated
745 return -1;
746 }
747 // duplicate the question in database
748 $this_id = $this->getId();
749 $thisObjId = $this->getObjId();
750
751 $clone = $this;
752 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
754 $clone->id = -1;
755
756 if ((int) $testObjId > 0) {
757 $clone->setObjId($testObjId);
758 }
759
760 if ($title) {
761 $clone->setTitle($title);
762 }
763
764 if ($author) {
765 $clone->setAuthor($author);
766 }
767 if ($owner) {
768 $clone->setOwner($owner);
769 }
770
771 if ($for_test) {
772 $clone->saveToDb($original_id);
773 } else {
774 $clone->saveToDb();
775 }
776
777 // copy question page content
778 $clone->copyPageOfQuestion($this_id);
779 // copy XHTML media objects
780 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
781 // duplicate the images
782 $clone->cloneAnswerImages($this_id, $thisObjId, $clone->getId(), $clone->getObjId());
783
784 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
785
786 return $clone->id;
787 }

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

+ Here is the call graph for this function:

◆ generateThumbForFile()

assKprimChoice::generateThumbForFile (   $path,
  $file 
)
protected

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

620 : void
621 {
622 $filename = $path . $file;
623 if (@file_exists($filename)) {
624 $thumbpath = $path . $this->getThumbPrefix() . $file;
625 $path_info = @pathinfo($filename);
626 $ext = "";
627 switch (strtoupper($path_info['extension'])) {
628 case 'PNG':
629 $ext = 'PNG';
630 break;
631 case 'GIF':
632 $ext = 'GIF';
633 break;
634 default:
635 $ext = 'JPEG';
636 break;
637 }
638 ilShellUtil::convertImage($filename, $thumbpath, $ext, (string) $this->getThumbSize());
639 }
640 }
$filename
Definition: buildRTE.php:78
static convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")
convert image
$path
Definition: ltiservices.php:32

References $filename, $path, ilShellUtil\convertImage(), getThumbPrefix(), and getThumbSize().

Referenced by rebuildThumbnails().

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

◆ getAdditionalTableName()

assKprimChoice::getAdditionalTableName ( )
Returns
string|array Or Array?
See also
Deletion methods here

Reimplemented from assQuestion.

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

83 : string
84 {
85 return "qpl_qst_kprim";
86 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAnswer()

assKprimChoice::getAnswer (   $position)

Definition at line 192 of file class.assKprimChoice.php.

193 {
194 foreach ($this->getAnswers() as $answer) {
195 if ($answer->getPosition() == $position) {
196 return $answer;
197 }
198 }
199
200 return null;
201 }

References getAnswers().

Referenced by removeAnswerImage().

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

◆ getAnswers()

assKprimChoice::getAnswers ( )

◆ getAnswerTableName()

assKprimChoice::getAnswerTableName ( )
Returns
string|array Or Array?
See also
Deletion methods here

Reimplemented from assQuestion.

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

88 : string
89 {
90 return "qpl_a_kprim";
91 }

Referenced by saveAnswerSpecificDataToDb().

+ Here is the caller graph for this function:

◆ getAnswerType()

assKprimChoice::getAnswerType ( )

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

108 : string
109 {
110 return $this->answerType;
111 }

References $answerType.

Referenced by rebuildThumbnails(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAnswerTypeSelectOptions()

assKprimChoice::getAnswerTypeSelectOptions ( ilLanguage  $lng)
Parameters
ilLanguage$lng
Returns
array

Definition at line 512 of file class.assKprimChoice.php.

512 : array
513 {
514 return array(
515 self::ANSWER_TYPE_SINGLE_LINE => $lng->txt('answers_singleline'),
516 self::ANSWER_TYPE_MULTI_LINE => $lng->txt('answers_multiline')
517 );
518 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...

References assQuestion\$lng, and ilLanguage\txt().

+ Here is the call graph for this function:

◆ getCustomFalseOptionLabel()

assKprimChoice::getCustomFalseOptionLabel ( )

Definition at line 158 of file class.assKprimChoice.php.

References $customFalseOptionLabel.

Referenced by getFalseOptionLabelTranslation(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getCustomTrueOptionLabel()

assKprimChoice::getCustomTrueOptionLabel ( )

Definition at line 148 of file class.assKprimChoice.php.

References $customTrueOptionLabel.

Referenced by getTrueOptionLabelTranslation(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getFalseOptionLabelTranslation()

assKprimChoice::getFalseOptionLabelTranslation ( ilLanguage  $lng,
  $optionLabel 
)

Definition at line 569 of file class.assKprimChoice.php.

570 {
571 switch ($optionLabel) {
573 return $lng->txt('option_label_wrong');
574
576 return $lng->txt('option_label_minus');
577
579 return $lng->txt('option_label_not_applicable');
580
582 return $lng->txt('option_label_not_adequate');
583
585 default:
586 return $this->getCustomFalseOptionLabel();
587 }
588 }
const OPTION_LABEL_APPLICABLE_OR_NOT

References assQuestion\$lng, $optionLabel, getCustomFalseOptionLabel(), OPTION_LABEL_ADEQUATE_OR_NOT, OPTION_LABEL_APPLICABLE_OR_NOT, OPTION_LABEL_CUSTOM, OPTION_LABEL_PLUS_MINUS, OPTION_LABEL_RIGHT_WRONG, and ilLanguage\txt().

Referenced by toJSON().

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

◆ getInstructionTextTranslation()

assKprimChoice::getInstructionTextTranslation ( ilLanguage  $lng,
  $optionLabel 
)

Definition at line 590 of file class.assKprimChoice.php.

590 : string
591 {
592 return sprintf(
593 $lng->txt('kprim_instruction_text'),
594 $this->getTrueOptionLabelTranslation($lng, $optionLabel),
595 $this->getFalseOptionLabelTranslation($lng, $optionLabel)
596 );
597 }

References assQuestion\$lng, $optionLabel, and ilLanguage\txt().

Referenced by toJSON().

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

◆ getNumAllowedFailures()

assKprimChoice::getNumAllowedFailures ( )
private

Definition at line 1003 of file class.assKprimChoice.php.

1003 : int
1004 {
1005 if ($this->isScorePartialSolutionEnabled()) {
1006 return self::NUM_REQUIRED_ANSWERS - self::PARTIAL_SCORING_NUM_CORRECT_ANSWERS;
1007 }
1008
1009 return 0;
1010 }
const PARTIAL_SCORING_NUM_CORRECT_ANSWERS

References isScorePartialSolutionEnabled(), and PARTIAL_SCORING_NUM_CORRECT_ANSWERS.

Referenced by toJSON().

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

◆ getOptionLabel()

assKprimChoice::getOptionLabel ( )

Definition at line 138 of file class.assKprimChoice.php.

138 : string
139 {
140 return $this->optionLabel;
141 }

References $optionLabel.

Referenced by saveAdditionalQuestionDataToDb(), and toJSON().

+ Here is the caller graph for this function:

◆ getQuestionType()

assKprimChoice::getQuestionType ( )

Returns the question type of the question.

Returns
string The question type of the question

Reimplemented from assQuestion.

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

78 : string
79 {
80 return 'assKprimChoice';
81 }

Referenced by toJSON().

+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assKprimChoice::getRTETextWithMediaObjects ( )
protected

Reimplemented from assQuestion.

Definition at line 920 of file class.assKprimChoice.php.

920 : string
921 {
922 $combinedText = parent::getRTETextWithMediaObjects();
923
924 foreach ($this->getAnswers() as $answer) {
925 $combinedText .= $answer->getAnswertext();
926 }
927
928 return $combinedText;
929 }

References getAnswers().

+ Here is the call graph for this function:

◆ getSolutionSubmit()

assKprimChoice::getSolutionSubmit ( )
protected

Definition at line 690 of file class.assKprimChoice.php.

690 : array
691 {
692 $solutionSubmit = [];
693 $post = $this->dic->http()->wrapper()->post();
694
695 foreach ($this->getAnswers() as $index => $a) {
696 if ($post->has("kprim_choice_result_$index")) {
697 $value = $post->retrieve(
698 "kprim_choice_result_$index",
699 $this->dic->refinery()->kindlyTo()->string()
700 );
701 if (is_numeric($value)) {
702 $solutionSubmit[] = $value;
703 }
704 }
705 }
706 return $solutionSubmit;
707 }
$post
Definition: ltitoken.php:49
$index
Definition: metadata.php:145
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

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

+ Here is the call graph for this function:

◆ getSpecificFeedbackAllCorrectOptionLabel()

assKprimChoice::getSpecificFeedbackAllCorrectOptionLabel ( )

Implements ilAssSpecificFeedbackOptionLabelProvider.

Definition at line 1012 of file class.assKprimChoice.php.

1012 : string
1013 {
1014 return 'feedback_correct_kprim';
1015 }

◆ getSpecificFeedbackSetting()

assKprimChoice::getSpecificFeedbackSetting ( )

Definition at line 168 of file class.assKprimChoice.php.

168 : int
169 {
171 }

References $specificFeedbackSetting.

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getThumbPrefix()

assKprimChoice::getThumbPrefix ( )

Definition at line 604 of file class.assKprimChoice.php.

604 : string
605 {
606 return self::THUMB_PREFIX;
607 }

References THUMB_PREFIX.

Referenced by generateThumbForFile(), and loadAnswerData().

+ Here is the caller graph for this function:

◆ getThumbSize()

assKprimChoice::getThumbSize ( )

Reimplemented from assQuestion.

Definition at line 118 of file class.assKprimChoice.php.

118 : int
119 {
120 return $this->thumbSize;
121 }

References $thumbSize.

Referenced by generateThumbForFile(), rebuildThumbnails(), saveAdditionalQuestionDataToDb(), and toJSON().

+ Here is the caller graph for this function:

◆ getTrueOptionLabelTranslation()

assKprimChoice::getTrueOptionLabelTranslation ( ilLanguage  $lng,
  $optionLabel 
)

Definition at line 548 of file class.assKprimChoice.php.

549 {
550 switch ($optionLabel) {
552 return $lng->txt('option_label_right');
553
555 return $lng->txt('option_label_plus');
556
558 return $lng->txt('option_label_applicable');
559
561 return $lng->txt('option_label_adequate');
562
564 default:
565 return $this->getCustomTrueOptionLabel();
566 }
567 }

References assQuestion\$lng, $optionLabel, getCustomTrueOptionLabel(), OPTION_LABEL_ADEQUATE_OR_NOT, OPTION_LABEL_APPLICABLE_OR_NOT, OPTION_LABEL_CUSTOM, OPTION_LABEL_PLUS_MINUS, OPTION_LABEL_RIGHT_WRONG, and ilLanguage\txt().

Referenced by toJSON().

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

◆ getValidAnswerTypes()

assKprimChoice::getValidAnswerTypes ( )

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

492 : array
493 {
494 return array(self::ANSWER_TYPE_SINGLE_LINE, self::ANSWER_TYPE_MULTI_LINE);
495 }

Referenced by isValidAnswerType().

+ Here is the caller graph for this function:

◆ getValidOptionLabels()

assKprimChoice::getValidOptionLabels ( )

Definition at line 520 of file class.assKprimChoice.php.

520 : array
521 {
522 return array(
523 self::OPTION_LABEL_RIGHT_WRONG,
524 self::OPTION_LABEL_PLUS_MINUS,
525 self::OPTION_LABEL_APPLICABLE_OR_NOT,
526 self::OPTION_LABEL_ADEQUATE_OR_NOT,
527 self::OPTION_LABEL_CUSTOM
528 );
529 }

Referenced by isValidOptionLabel().

+ Here is the caller graph for this function:

◆ getValidOptionLabelsTranslated()

assKprimChoice::getValidOptionLabelsTranslated ( ilLanguage  $lng)

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

531 : array
532 {
533 return array(
534 self::OPTION_LABEL_RIGHT_WRONG => $lng->txt('option_label_right_wrong'),
535 self::OPTION_LABEL_PLUS_MINUS => $lng->txt('option_label_plus_minus'),
536 self::OPTION_LABEL_APPLICABLE_OR_NOT => $lng->txt('option_label_applicable_or_not'),
537 self::OPTION_LABEL_ADEQUATE_OR_NOT => $lng->txt('option_label_adequate_or_not'),
538 self::OPTION_LABEL_CUSTOM => $lng->txt('option_label_custom')
539 );
540 }

References assQuestion\$lng, and ilLanguage\txt().

+ Here is the call graph for this function:

◆ handleFileUpload()

assKprimChoice::handleFileUpload ( ilAssKprimChoiceAnswer  $answer,
  $fileData 
)
private

Definition at line 655 of file class.assKprimChoice.php.

655 : int
656 {
657 $imagePath = $this->getImagePath();
658
659 if (!file_exists($imagePath)) {
660 ilFileUtils::makeDirParents($imagePath);
661 }
662
663 $filename = $this->buildHashedImageFilename($fileData['name'], true);
664
665 $answer->setImageFsDir($imagePath);
666 $answer->setImageFile($filename);
667
668 if (!ilFileUtils::moveUploadedFile($fileData['tmp_name'], $fileData['name'], $answer->getImageFsPath())) {
669 return 2;
670 }
671
672 return 0;
673 }
buildHashedImageFilename(string $plain_image_filename, bool $unique=false)
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file

References $filename, assQuestion\buildHashedImageFilename(), ilAssKprimChoiceAnswer\getImageFsPath(), assQuestion\getImagePath(), ilFileUtils\makeDirParents(), ilFileUtils\moveUploadedFile(), ilAssKprimChoiceAnswer\setImageFile(), and ilAssKprimChoiceAnswer\setImageFsDir().

Referenced by handleFileUploads().

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

◆ handleFileUploads()

assKprimChoice::handleFileUploads (   $answers,
  $files 
)

Definition at line 642 of file class.assKprimChoice.php.

642 : void
643 {
644 foreach ($answers as $answer) {
645 /* @var ilAssKprimChoiceAnswer $answer */
646
647 if (!isset($files[$answer->getPosition()])) {
648 continue;
649 }
650
651 $this->handleFileUpload($answer, $files[$answer->getPosition()]);
652 }
653 }
handleFileUpload(ilAssKprimChoiceAnswer $answer, $fileData)

References $answers, and handleFileUpload().

+ Here is the call graph for this function:

◆ isAnswered()

assKprimChoice::isAnswered ( int  $active_id,
int  $pass 
)

Reimplemented from assQuestion.

Definition at line 1022 of file class.assKprimChoice.php.

1022 : bool
1023 {
1024 $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1025
1026 return $numExistingSolutionRecords >= 4;
1027 }
static getNumExistingSolutionRecords(int $activeId, int $pass, int $questionId)

References assQuestion\getId(), and assQuestion\getNumExistingSolutionRecords().

+ Here is the call graph for this function:

◆ isComplete()

assKprimChoice::isComplete ( )

Returns true, if a question is complete for use.

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

Reimplemented from assQuestion.

Definition at line 373 of file class.assKprimChoice.php.

373 : bool
374 {
375 foreach (array($this->title, $this->author, $this->question) as $text) {
376 if (!strlen($text)) {
377 return false;
378 }
379 }
380
381 if (!isset($this->points)) {
382 return false;
383 }
384
385 foreach ($this->getAnswers() as $answer) {
386 /* @var ilAssKprimChoiceAnswer $answer */
387
388 if (is_null($answer->getCorrectness())) {
389 return false;
390 }
391
392 if (
393 (!is_string($answer->getAnswertext()) || $answer->getAnswertext() === '') &&
394 (!is_string($answer->getImageFile()) || $answer->getImageFile() === '')
395 ) {
396 return false;
397 }
398 }
399
400 return true;
401 }

References getAnswers().

+ Here is the call graph for this function:

◆ isCustomOptionLabel()

assKprimChoice::isCustomOptionLabel (   $labelValue)

Definition at line 599 of file class.assKprimChoice.php.

599 : bool
600 {
601 return $labelValue == self::OPTION_LABEL_CUSTOM;
602 }

References OPTION_LABEL_CUSTOM.

◆ isObligationPossible()

static assKprimChoice::isObligationPossible ( int  $questionId)
static

Reimplemented from assQuestion.

Definition at line 1017 of file class.assKprimChoice.php.

1017 : bool
1018 {
1019 return true;
1020 }

◆ isScorePartialSolutionEnabled()

assKprimChoice::isScorePartialSolutionEnabled ( )

Definition at line 128 of file class.assKprimChoice.php.

128 : bool
129 {
131 }

References $scorePartialSolutionEnabled.

Referenced by calculateReachedPointsForSolution(), getNumAllowedFailures(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ isShuffleAnswersEnabled()

assKprimChoice::isShuffleAnswersEnabled ( )

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

98 : bool
99 {
101 }

References $shuffleAnswersEnabled.

Referenced by saveAdditionalQuestionDataToDb(), and toJSON().

+ Here is the caller graph for this function:

◆ isSingleLineAnswerType()

assKprimChoice::isSingleLineAnswerType (   $answerType)

Definition at line 503 of file class.assKprimChoice.php.

503 : bool
504 {
506 }

References $answerType, and ANSWER_TYPE_SINGLE_LINE.

Referenced by rebuildThumbnails().

+ Here is the caller graph for this function:

◆ isValidAnswerType()

assKprimChoice::isValidAnswerType (   $answerType)

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

497 : bool
498 {
499 $validTypes = $this->getValidAnswerTypes();
500 return in_array($answerType, $validTypes);
501 }

References $answerType, and getValidAnswerTypes().

Referenced by loadFromDb().

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

◆ isValidOptionLabel()

assKprimChoice::isValidOptionLabel (   $optionLabel)

Definition at line 542 of file class.assKprimChoice.php.

542 : bool
543 {
544 $validLabels = $this->getValidOptionLabels();
545 return in_array($optionLabel, $validLabels);
546 }

References $optionLabel, and getValidOptionLabels().

Referenced by loadFromDb().

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

◆ lmMigrateQuestionTypeSpecificContent()

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

Reimplemented from assQuestion.

Definition at line 934 of file class.assKprimChoice.php.

934 : void
935 {
936 foreach ($this->getAnswers() as $answer) {
937 /* @var ilAssKprimChoiceAnswer $answer */
938 $answer->setAnswertext($migrator->migrateToLmContent($answer->getAnswertext()));
939 }
940 }

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

+ Here is the call graph for this function:

◆ loadAnswerData()

assKprimChoice::loadAnswerData (   $questionId)
private

Definition at line 279 of file class.assKprimChoice.php.

279 : void
280 {
281 global $DIC;
282 $ilDB = $DIC['ilDB'];
283
284 $res = $this->db->queryF(
285 "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY position ASC",
286 array('integer'),
287 array($questionId)
288 );
289
290 require_once 'Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
291 require_once 'Services/RTE/classes/class.ilRTE.php';
292
293 while ($data = $ilDB->fetchAssoc($res)) {
294 $answer = new ilAssKprimChoiceAnswer();
295
296 $answer->setPosition($data['position']);
297
298 $answer->setAnswertext(ilRTE::_replaceMediaObjectImageSrc($data['answertext'] ?? '', 1));
299
300 $answer->setImageFile($data['imagefile']);
301 $answer->setThumbPrefix($this->getThumbPrefix());
302 $answer->setImageFsDir($this->getImagePath());
303 $answer->setImageWebDir($this->getImagePathWeb());
304
305 $answer->setCorrectness($data['correctness']);
306
307 $this->answers[$answer->getPosition()] = $answer;
308 }
309
310 for ($i = count($this->answers); $i < self::NUM_REQUIRED_ANSWERS; $i++) {
311 $answer = new ilAssKprimChoiceAnswer();
312
313 $answer->setPosition($i);
314
315 $this->answers[$answer->getPosition()] = $answer;
316 }
317 }
getImagePathWeb()
Returns the web image path for web accessable images of a question.
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...
$res
Definition: ltiservices.php:69
$i
Definition: metadata.php:41

References $data, $DIC, $i, $ilDB, $res, ilRTE\_replaceMediaObjectImageSrc(), assQuestion\getImagePath(), assQuestion\getImagePathWeb(), getThumbPrefix(), and NUM_REQUIRED_ANSWERS.

Referenced by loadFromDb().

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

◆ loadFromDb()

assKprimChoice::loadFromDb (   $questionId)

Definition at line 211 of file class.assKprimChoice.php.

211 : void
212 {
213 $res = $this->db->queryF($this->buildQuestionDataQuery(), array('integer'), array($questionId));
214
215 while ($data = $this->db->fetchAssoc($res)) {
216 $this->setId($questionId);
217
218 $this->setOriginalId($data['original_id']);
219
220 $this->setObjId($data['obj_fi']);
221
222 $this->setTitle($data['title'] ?? '');
223 $this->setNrOfTries($data['nr_of_tries']);
224 $this->setComment($data['description'] ?? '');
225 $this->setAuthor($data['author']);
226 $this->setPoints($data['points']);
227 $this->setOwner($data['owner']);
228 $this->setLastChange($data['tstamp']);
229 require_once 'Services/RTE/classes/class.ilRTE.php';
230 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data['question_text'] ?? '', 1));
231
232 $this->setShuffleAnswersEnabled((bool) $data['shuffle_answers']);
233
234 if ($this->isValidAnswerType($data['answer_type'])) {
235 $this->setAnswerType($data['answer_type']);
236 }
237
238 if (is_numeric($data['thumb_size'])) {
239 $this->setThumbSize((int) $data['thumb_size']);
240 }
241
242 if ($this->isValidOptionLabel($data['opt_label'])) {
243 $this->setOptionLabel($data['opt_label']);
244 }
245
246 if ($data['custom_true'] !== null) {
247 $this->setCustomTrueOptionLabel($data['custom_true']);
248 }
249
250 if ($data['custom_false'] !== null) {
251 $this->setCustomFalseOptionLabel($data['custom_false']);
252 }
253
254 if ($data['score_partsol'] !== null) {
255 $this->setScorePartialSolutionEnabled((bool) $data['score_partsol']);
256 }
257
258 if (isset($data['feedback_setting'])) {
259 $this->setSpecificFeedbackSetting((int) $data['feedback_setting']);
260 }
261
262 try {
266 }
267
268 try {
269 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
271 }
272 }
273
274 $this->loadAnswerData($questionId);
275
276 parent::loadFromDb($questionId);
277 }
setCustomTrueOptionLabel($customTrueOptionLabel)
setCustomFalseOptionLabel($customFalseOptionLabel)
loadAnswerData($questionId)
setSpecificFeedbackSetting($specificFeedbackSetting)
setAnswerType($answerType)
isValidOptionLabel($optionLabel)
isValidAnswerType($answerType)
setOptionLabel($optionLabel)
setShuffleAnswersEnabled($shuffleAnswersEnabled)
setScorePartialSolutionEnabled($scorePartialSolutionEnabled)
setThumbSize(int $thumbSize)
setOriginalId(?int $original_id)
setId(int $id=-1)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
setAuthor(string $author="")
setComment(string $comment="")
setObjId(int $obj_id=0)
setOwner(int $owner=-1)
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
setLastChange($lastChange)
setPoints(float $points)

References $data, Vendor\Package\$e, $res, ilRTE\_replaceMediaObjectImageSrc(), assQuestion\buildQuestionDataQuery(), ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), isValidAnswerType(), isValidOptionLabel(), loadAnswerData(), assQuestion\setAdditionalContentEditingMode(), setAnswerType(), assQuestion\setAuthor(), assQuestion\setComment(), setCustomFalseOptionLabel(), setCustomTrueOptionLabel(), assQuestion\setId(), assQuestion\setLastChange(), assQuestion\setLifecycle(), assQuestion\setNrOfTries(), assQuestion\setObjId(), setOptionLabel(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setScorePartialSolutionEnabled(), setShuffleAnswersEnabled(), setSpecificFeedbackSetting(), setThumbSize(), and assQuestion\setTitle().

+ Here is the call graph for this function:

◆ moveAnswerDown()

assKprimChoice::moveAnswerDown (   $position)

Definition at line 1056 of file class.assKprimChoice.php.

1056 : bool
1057 {
1058 if ($position < 0 || $position >= (self::NUM_REQUIRED_ANSWERS - 1)) {
1059 return false;
1060 }
1061
1062 for ($i = 0, $max = count($this->answers); $i < $max; $i++) {
1063 if ($i == $position) {
1064 $movingAnswer = $this->answers[$i];
1065 $targetAnswer = $this->answers[ $i + 1 ];
1066
1067 $movingAnswer->setPosition($position + 1);
1068 $targetAnswer->setPosition($position);
1069
1070 $this->answers[ $i + 1 ] = $movingAnswer;
1071 $this->answers[$i] = $targetAnswer;
1072 }
1073 }
1074 return true;
1075 }

References $i.

◆ moveAnswerUp()

assKprimChoice::moveAnswerUp (   $position)

Definition at line 1077 of file class.assKprimChoice.php.

1077 : bool
1078 {
1079 if ($position <= 0 || $position > (self::NUM_REQUIRED_ANSWERS - 1)) {
1080 return false;
1081 }
1082
1083 for ($i = 0, $max = count($this->answers); $i < $max; $i++) {
1084 if ($i == $position) {
1085 $movingAnswer = $this->answers[$i];
1086 $targetAnswer = $this->answers[ $i - 1 ];
1087
1088 $movingAnswer->setPosition($position - 1);
1089 $targetAnswer->setPosition($position);
1090
1091 $this->answers[ $i - 1 ] = $movingAnswer;
1092 $this->answers[$i] = $targetAnswer;
1093 }
1094 }
1095
1096 return true;
1097 }

References $i.

◆ rebuildThumbnails()

assKprimChoice::rebuildThumbnails ( )

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

609 : void
610 {
611 if ($this->isSingleLineAnswerType($this->getAnswerType()) && $this->getThumbSize()) {
612 foreach ($this->getAnswers() as $answer) {
613 if (strlen($answer->getImageFile())) {
614 $this->generateThumbForFile($answer->getImageFsDir(), $answer->getImageFile());
615 }
616 }
617 }
618 }
isSingleLineAnswerType($answerType)
generateThumbForFile($path, $file)

References generateThumbForFile(), getAnswers(), getAnswerType(), getThumbSize(), and isSingleLineAnswerType().

Referenced by saveAnswerSpecificDataToDb().

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

◆ removeAnswerImage()

assKprimChoice::removeAnswerImage (   $position)

Definition at line 675 of file class.assKprimChoice.php.

675 : void
676 {
677 $answer = $this->getAnswer($position);
678
679 if (file_exists($answer->getImageFsPath())) {
680 ilFileUtils::delDir($answer->getImageFsPath());
681 }
682
683 if (file_exists($answer->getThumbFsPath())) {
684 ilFileUtils::delDir($answer->getThumbFsPath());
685 }
686
687 $answer->setImageFile(null);
688 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

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

+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assKprimChoice::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

Definition at line 333 of file class.assKprimChoice.php.

334 {
335 $this->db->replace(
336 $this->getAdditionalTableName(),
337 array(
338 'question_fi' => array('integer', $this->getId())
339 ),
340 array(
341 'shuffle_answers' => array('integer', (int) $this->isShuffleAnswersEnabled()),
342 'answer_type' => array('text', $this->getAnswerType()),
343 'thumb_size' => array('integer', $this->getThumbSize()),
344 'opt_label' => array('text', $this->getOptionLabel()),
345 'custom_true' => array('text', $this->getCustomTrueOptionLabel()),
346 'custom_false' => array('text', $this->getCustomFalseOptionLabel()),
347 'score_partsol' => array('integer', (int) $this->isScorePartialSolutionEnabled()),
348 'feedback_setting' => array('integer', $this->getSpecificFeedbackSetting())
349 )
350 );
351 }

References getAdditionalTableName(), getAnswerType(), getCustomFalseOptionLabel(), getCustomTrueOptionLabel(), assQuestion\getId(), getOptionLabel(), getSpecificFeedbackSetting(), getThumbSize(), isScorePartialSolutionEnabled(), and isShuffleAnswersEnabled().

Referenced by saveToDb().

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

◆ saveAnswerSpecificDataToDb()

assKprimChoice::saveAnswerSpecificDataToDb ( )

Saves the answer specific records into a question types answer table.

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

Definition at line 353 of file class.assKprimChoice.php.

354 {
355 foreach ($this->getAnswers() as $answer) {
356 $this->db->replace(
357 $this->getAnswerTableName(),
358 array(
359 'question_fi' => array('integer', $this->getId()),
360 'position' => array('integer', (int) $answer->getPosition())
361 ),
362 array(
363 'answertext' => array('text', $answer->getAnswertext()),
364 'imagefile' => array('text', $answer->getImageFile()),
365 'correctness' => array('integer', (int) $answer->getCorrectness())
366 )
367 );
368 }
369
370 $this->rebuildThumbnails();
371 }

References getAnswers(), getAnswerTableName(), assQuestion\getId(), and rebuildThumbnails().

Referenced by saveToDb().

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

◆ saveToDb()

assKprimChoice::saveToDb (   $originalId = '')

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

319 : void
320 {
321 if ($originalId == '') {
322 $this->saveQuestionDataToDb();
323 } else {
324 $this->saveQuestionDataToDb($originalId);
325 }
326
329
330 parent::saveToDb($originalId);
331 }
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb(int $original_id=-1)

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

+ Here is the call graph for this function:

◆ setAnswers()

assKprimChoice::setAnswers (   $answers)

Definition at line 173 of file class.assKprimChoice.php.

173 : void
174 {
175 if (is_null($answers)) {
176 return;
177 }
178 $clean_answer_text = function (ilAssKprimChoiceAnswer $answer) {
179 $answer->setAnswertext(
180 $this->getHtmlQuestionContentPurifier()->purify($answer->getAnswertext())
181 );
182 return $answer;
183 };
184 $this->answers = array_map($clean_answer_text, $answers);
185 }

References $answers, and assQuestion\getHtmlQuestionContentPurifier().

+ Here is the call graph for this function:

◆ setAnswerType()

assKprimChoice::setAnswerType (   $answerType)

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

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

References $answerType.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setCustomFalseOptionLabel()

assKprimChoice::setCustomFalseOptionLabel (   $customFalseOptionLabel)

Definition at line 153 of file class.assKprimChoice.php.

153 : void
154 {
155 $this->customFalseOptionLabel = $customFalseOptionLabel;
156 }

References $customFalseOptionLabel.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setCustomTrueOptionLabel()

assKprimChoice::setCustomTrueOptionLabel (   $customTrueOptionLabel)

Definition at line 143 of file class.assKprimChoice.php.

143 : void
144 {
145 $this->customTrueOptionLabel = $customTrueOptionLabel;
146 }

References $customTrueOptionLabel.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

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

{}

Reimplemented from assQuestion.

Definition at line 1032 of file class.assKprimChoice.php.

1032 : int
1033 {
1034 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
1035
1036 $solution = $this->getSolutionValues($active_id, $pass);
1037
1038 $i = 1;
1039 foreach ($this->getAnswers() as $id => $answer) {
1040 $worksheet->setCell($startrow + $i, 0, $answer->getAnswertext());
1041 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
1042 $correctness = false;
1043 foreach ($solution as $solutionvalue) {
1044 if ($id == $solutionvalue['value1']) {
1045 $correctness = $solutionvalue['value2'];
1046 break;
1047 }
1048 }
1049 $worksheet->setCell($startrow + $i, 2, $correctness);
1050 $i++;
1051 }
1052
1053 return $startrow + $i + 1;
1054 }
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)
setBold(string $a_coords)
Set cell(s) to bold.
getColumnCoord(int $a_col)
Get column "name" from number.

References $i, assQuestion\$id, getAnswers(), ilExcel\getColumnCoord(), assQuestion\getSolutionValues(), ilExcel\setBold(), and ilAssExcelFormatHelper\setCell().

+ Here is the call graph for this function:

◆ setOptionLabel()

assKprimChoice::setOptionLabel (   $optionLabel)

Definition at line 133 of file class.assKprimChoice.php.

133 : void
134 {
135 $this->optionLabel = $optionLabel;
136 }

References $optionLabel.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setScorePartialSolutionEnabled()

assKprimChoice::setScorePartialSolutionEnabled (   $scorePartialSolutionEnabled)

Definition at line 123 of file class.assKprimChoice.php.

123 : void
124 {
125 $this->scorePartialSolutionEnabled = $scorePartialSolutionEnabled;
126 }

References $scorePartialSolutionEnabled.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setShuffleAnswersEnabled()

assKprimChoice::setShuffleAnswersEnabled (   $shuffleAnswersEnabled)

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

93 : void
94 {
95 $this->shuffleAnswersEnabled = $shuffleAnswersEnabled;
96 }

References $shuffleAnswersEnabled.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setSpecificFeedbackSetting()

assKprimChoice::setSpecificFeedbackSetting (   $specificFeedbackSetting)

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

163 : void
164 {
165 $this->specificFeedbackSetting = $specificFeedbackSetting;
166 }

References $specificFeedbackSetting.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setThumbSize()

assKprimChoice::setThumbSize ( int  $thumbSize)

Reimplemented from assQuestion.

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

113 : void
114 {
115 $this->thumbSize = $thumbSize;
116 }

References $thumbSize.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ toJSON()

assKprimChoice::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

Definition at line 945 of file class.assKprimChoice.php.

945 : string
946 {
947 $this->lng->loadLanguageModule('assessment');
948
949 require_once './Services/RTE/classes/class.ilRTE.php';
950 $result = array();
951 $result['id'] = $this->getId();
952 $result['type'] = $this->getQuestionType();
953 $result['title'] = $this->getTitleForHTMLOutput();
954 $result['question'] = $this->formatSAQuestion($this->getQuestion());
955 $result['instruction'] = $this->getInstructionTextTranslation(
956 $this->lng,
957 $this->getOptionLabel()
958 );
959 $result['nr_of_tries'] = $this->getNrOfTries();
960 $result['shuffle'] = $this->isShuffleAnswersEnabled();
961 $result['feedback'] = array(
962 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
963 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
964 );
965
966 $result['trueOptionLabel'] = $this->getTrueOptionLabelTranslation($this->lng, $this->getOptionLabel());
967 $result['falseOptionLabel'] = $this->getFalseOptionLabelTranslation($this->lng, $this->getOptionLabel());
968
969 $result['num_allowed_failures'] = $this->getNumAllowedFailures();
970
971 $answers = array();
972 $has_image = false;
973
974 foreach ($this->getAnswers() as $key => $answer) {
975 if (strlen((string) $answer->getImageFile())) {
976 $has_image = true;
977 }
978
979 $answers[] = array(
980 'answertext' => $this->formatSAQuestion($answer->getAnswertext() ?? ''),
981 'correctness' => (bool) $answer->getCorrectness(),
982 'order' => (int) $answer->getPosition(),
983 'image' => (string) $answer->getImageFile(),
984 'feedback' => $this->formatSAQuestion(
985 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
986 )
987 );
988 }
989
990 $result['answers'] = $answers;
991
992 if ($has_image) {
993 $result['path'] = $this->getImagePathWeb();
994 $result['thumb'] = $this->getThumbSize();
995 }
996
997 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
998 $result['mobs'] = $mobs;
999
1000 return json_encode($result);
1001 }
getQuestionType()
Returns the question type of the question.
getTrueOptionLabelTranslation(ilLanguage $lng, $optionLabel)
getFalseOptionLabelTranslation(ilLanguage $lng, $optionLabel)
getInstructionTextTranslation(ilLanguage $lng, $optionLabel)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
$mobs
Definition: imgupload.php:70

References $answers, ILIAS\LTI\ToolProvider\$key, $mobs, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getAnswers(), getFalseOptionLabelTranslation(), assQuestion\getId(), assQuestion\getImagePathWeb(), getInstructionTextTranslation(), assQuestion\getNrOfTries(), getNumAllowedFailures(), getOptionLabel(), assQuestion\getQuestion(), getQuestionType(), getThumbSize(), assQuestion\getTitleForHTMLOutput(), getTrueOptionLabelTranslation(), isShuffleAnswersEnabled(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $answers

assKprimChoice::$answers
private

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

Referenced by getAnswers(), handleFileUploads(), setAnswers(), and toJSON().

◆ $answerType

assKprimChoice::$answerType
private

◆ $customFalseOptionLabel

assKprimChoice::$customFalseOptionLabel
private

◆ $customTrueOptionLabel

assKprimChoice::$customTrueOptionLabel
private

Definition at line 53 of file class.assKprimChoice.php.

Referenced by getCustomTrueOptionLabel(), and setCustomTrueOptionLabel().

◆ $optionLabel

◆ $scorePartialSolutionEnabled

assKprimChoice::$scorePartialSolutionEnabled
private

◆ $shuffleAnswersEnabled

assKprimChoice::$shuffleAnswersEnabled
private

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

Referenced by isShuffleAnswersEnabled(), and setShuffleAnswersEnabled().

◆ $specificFeedbackSetting

assKprimChoice::$specificFeedbackSetting
private

◆ $thumbSize

assKprimChoice::$thumbSize
private

Definition at line 47 of file class.assKprimChoice.php.

Referenced by getThumbSize(), and setThumbSize().

◆ ANSWER_TYPE_MULTI_LINE

const assKprimChoice::ANSWER_TYPE_MULTI_LINE = 'multiLine'

Definition at line 32 of file class.assKprimChoice.php.

Referenced by assKprimChoiceGUI\handleAnswerTextsSubmit().

◆ ANSWER_TYPE_SINGLE_LINE

const assKprimChoice::ANSWER_TYPE_SINGLE_LINE = 'singleLine'

Definition at line 31 of file class.assKprimChoice.php.

Referenced by __construct(), and isSingleLineAnswerType().

◆ DEFAULT_THUMB_SIZE

const assKprimChoice::DEFAULT_THUMB_SIZE = 150

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

Referenced by __construct().

◆ NUM_REQUIRED_ANSWERS

const assKprimChoice::NUM_REQUIRED_ANSWERS = 4

Definition at line 27 of file class.assKprimChoice.php.

Referenced by loadAnswerData().

◆ OPTION_LABEL_ADEQUATE_OR_NOT

const assKprimChoice::OPTION_LABEL_ADEQUATE_OR_NOT = 'adequate_or_not'

◆ OPTION_LABEL_APPLICABLE_OR_NOT

const assKprimChoice::OPTION_LABEL_APPLICABLE_OR_NOT = 'applicable_or_not'

◆ OPTION_LABEL_CUSTOM

const assKprimChoice::OPTION_LABEL_CUSTOM = 'customlabel'

◆ OPTION_LABEL_PLUS_MINUS

const assKprimChoice::OPTION_LABEL_PLUS_MINUS = 'plus_minus'

◆ OPTION_LABEL_RIGHT_WRONG

const assKprimChoice::OPTION_LABEL_RIGHT_WRONG = 'right_wrong'

◆ PARTIAL_SCORING_NUM_CORRECT_ANSWERS

const assKprimChoice::PARTIAL_SCORING_NUM_CORRECT_ANSWERS = 3

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

Referenced by getNumAllowedFailures().

◆ THUMB_PREFIX

const assKprimChoice::THUMB_PREFIX = 'thumb.'

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

Referenced by getThumbPrefix().


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