ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assKprimChoice Class Reference
+ Inheritance diagram for assKprimChoice:
+ Collaboration diagram for assKprimChoice:

Public Member Functions

 __construct ($title='', $comment='', $author='', $owner=-1, $question='')
 
 getQuestionType ()
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 setShuffleAnswersEnabled ($shuffleAnswersEnabled)
 
 isShuffleAnswersEnabled ()
 
 setAnswerType ($answerType)
 
 getAnswerType ()
 
 setThumbSize ($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 ()
 
 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 ($for_test=true, $title="", $author="", $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 ($active_id, $pass=null)
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 {} More...
 
 moveAnswerDown ($position)
 
 moveAnswerUp ($position)
 
- Public Member Functions inherited from assQuestion
 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assQuestion constructor More...
 
 getShuffler ()
 
 setShuffler (ilArrayElementShuffler $shuffler)
 
 setProcessLocker ($processLocker)
 
 getProcessLocker ()
 
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $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 ($questionpool_id, $title)
 Returns TRUE if the question title exists in the database. More...
 
 setTitle ($title="")
 Sets the title string of the assQuestion object. More...
 
 setId ($id=-1)
 Sets the id of the assQuestion object. More...
 
 setTestId ($id=-1)
 Sets the test id of the assQuestion object. More...
 
 setComment ($comment="")
 Sets the comment string of the assQuestion object. More...
 
 setOutputType ($outputType=OUTPUT_HTML)
 Sets the output type. More...
 
 setShuffle ($shuffle=true)
 Sets the shuffle flag. More...
 
 setEstimatedWorkingTime ($hour=0, $min=0, $sec=0)
 Sets the estimated working time of a question from given hour, minute and second. More...
 
 setEstimatedWorkingTimeFromDurationString ($durationString)
 Sets the estimated working time of a question from a given datetime string. More...
 
 keyInArray ($searchkey, $array)
 returns TRUE if the key occurs in an array More...
 
 setAuthor ($author="")
 Sets the authors name of the assQuestion object. More...
 
 setOwner ($owner="")
 Sets the creator/owner ID of the assQuestion object. More...
 
 getTitle ()
 Gets the title string of the assQuestion object. More...
 
 getTitleFilenameCompliant ()
 returns the object title prepared to be used as a filename More...
 
 getId ()
 Gets the id of the assQuestion object. More...
 
 getShuffle ()
 Gets the shuffle flag. More...
 
 getTestId ()
 Gets the test id of the assQuestion object. More...
 
 getComment ()
 Gets the comment string of the assQuestion object. More...
 
 getOutputType ()
 Gets the output type. More...
 
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output. More...
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getEstimatedWorkingTime ()
 Gets the estimated working time of a question. More...
 
 getAuthor ()
 Gets the authors name of the assQuestion object. More...
 
 getOwner ()
 Gets the creator/owner ID of the assQuestion object. More...
 
 getObjId ()
 Get the object id of the container object. More...
 
 setObjId ($obj_id=0)
 Set the object id of the container object. More...
 
 setExternalId ($external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 Return the suggested solutions. More...
 
 getReachedPoints ($active_id, $pass=null)
 Returns the points, a learner has reached answering the question This is the fast way to get the points directly from the database. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getAdjustedReachedPoints ($active_id, $pass=null, $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution ($active_id, $pass=null, $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState ($active_id, $pass=null, $obligationsEnabled=false, $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 ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution. More...
 
 getJavaPath ()
 Returns the image path for web accessable images of a question. More...
 
 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...
 
 getJavaPathWeb ()
 Returns the web image path for web accessable java applets of a question. More...
 
 getSuggestedSolutionPathWeb ()
 Returns the web path for a suggested solution. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getFlashPathWeb ()
 Returns the web image path for web accessable flash applications of a question. More...
 
 getTestOutputSolutions ($activeId, $pass)
 
 getUserSolutionPreferingIntermediate ($active_id, $pass=null)
 
 getSolutionValues ($active_id, $pass=null, $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse ($question_id="")
 Checks whether the question is in use or not. More...
 
 isClone ($question_id="")
 Checks whether the question is a clone of another question or not. More...
 
 pcArrayShuffle ($array)
 Shuffles the values of a given array. 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...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 getTotalAnswers ()
 get total number of answers More...
 
 _getTotalAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 create page object of question More...
 
 copyPageOfQuestion ($a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 fixSvgToPng ($imageFilenameContainingString)
 
 fixUnavailableSkinImageSources ($html)
 
 loadFromDb ($question_id)
 Loads the question from the database. More...
 
 createNewQuestion ($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 ($original_id="")
 
 saveToDb ($original_id="")
 Saves the question to the database. More...
 
 setNewOriginalId ($newId)
 
 deleteSuggestedSolutions ()
 Deletes all suggestes solutions in the database. More...
 
 getSuggestedSolution ($subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle ($subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution ($solution_id="", $subquestion_index=0, $is_import=false)
 Sets a suggested solution for the question. More...
 
 _resolveInternalLink ($internal_link)
 
 _resolveIntLinks ($question_id)
 
 syncWithOriginal ()
 
 createRandomSolution ($test_id, $user_id)
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool ($question_id)
 Returns true if the question already exists in the database and is assigned to a question pool. More...
 
 getPoints ()
 Returns the maximum available points for the question. More...
 
 setPoints ($a_points)
 Sets the maximum available points for the question. More...
 
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution. More...
 
 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 ($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output in tests. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addQTIMaterial (&$a_xml_writer, $a_material, $close_material_tag=true, $add_mobs=true)
 Creates a QTI material tag from a plain text or xhtml text. More...
 
 buildHashedImageFilename ($plain_image_filename, $unique=false)
 
 getQuestion ()
 Gets the question string of the question object. More...
 
 setQuestion ($question="")
 Sets the question string of the question object. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 Returns the question type of the question. More...
 
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table More...
 
getInstances ()
 Gets all instances of the question. More...
 
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id. More...
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getNrOfTries ()
 
 setNrOfTries ($a_nr_of_tries)
 
 setExportImagePath ($a_path)
 
 formatSAQuestion ($a_q)
 Format self assessment question. More...
 
 setPreventRteUsage ($a_val)
 Set prevent rte usage. More...
 
 getPreventRteUsage ()
 Get prevent rte usage. More...
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode ($a_selfassessmenteditingmode)
 Set Self-Assessment Editing Mode. More...
 
 getSelfAssessmentEditingMode ()
 Get Self-Assessment Editing Mode. More...
 
 setDefaultNrOfTries ($a_defaultnroftries)
 Set Default Nr of Tries. More...
 
 getDefaultNrOfTries ()
 Get Default Nr of Tries. More...
 
 syncSkillAssignments ($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId)
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not More...
 
 isAutosaveable ()
 
 getAdditionalContentEditingMode ()
 getter for additional content editing mode for this question More...
 
 setAdditionalContentEditingMode ($additinalContentEditingMode)
 setter for additional content editing mode for this question More...
 
 isAdditionalContentEditingModePageObject ()
 isser for additional "pageobject" content editing mode More...
 
 isValidAdditionalContentEditingMode ($additionalContentEditingMode)
 returns the fact wether the passed additional content mode is valid or not More...
 
 getValidAdditionalContentEditingModes ()
 getter for valid additional content editing modes More...
 
 addQuestionChangeListener (ilQuestionChangeListener $listener)
 
 getQuestionChangeListeners ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution ($active_id, $pass)
 
 removeCurrentSolution ($active_id, $pass, $authorized=true)
 
 saveCurrentSolution ($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
 
 updateCurrentSolution ($solutionId, $value1, $value2, $authorized=true)
 
 updateCurrentSolutionsAuthorization ($activeId, $pass, $authorized, $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
 intermediateSolutionExists ($active_id, $pass)
 
 authorizedSolutionExists ($active_id, $pass)
 
 authorizedOrIntermediateSolutionExists ($active_id, $pass)
 
 removeExistingSolutions ($activeId, $pass)
 
 resetUsersAnswer ($activeId, $pass)
 
 removeResultRecord ($activeId, $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered ($obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 Get the test question configuration (initialised once) More...
 

Static Public Member Functions

static isObligationPossible ($questionId)
 
- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled ($forcePassResultsUpdateEnabled)
 
static isForcePassResultUpdateEnabled ()
 
static isAllowedImageMimeType ($mimeType)
 
static fetchMimeTypeIdentifier ($contentTypeString)
 
static getAllowedFileExtensionsForMimeType ($mimeType)
 
static isAllowedImageFileExtension ($mimeType, $fileExtension)
 
static getAllowedImageMaterialFileExtensions ()
 
static _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
static _getQuestionInfo ($question_id)
 Returns question information from the database. More...
 
static _getSuggestedSolutionCount ($question_id)
 Returns the number of suggested solutions associated with a question. More...
 
static _getSuggestedSolutionOutput ($question_id)
 Returns the output of the suggested solution. More...
 
static _getReachedPoints ($active_id, $question_id, $pass=null)
 Returns the points, a learner has reached answering the question. More...
 
static _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place. More...
 
static logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
static getQuestionTypeFromDb ($question_id)
 get question type for question id More...
 
static _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
static _getTitle ($a_q_id)
 Returns the title of a question. More...
 
static _getQuestionText ($a_q_id)
 Returns question text. More...
 
static isFileAvailable ($file)
 
static _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
static _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
static saveOriginalId ($questionId, $originalId)
 
static resetOriginalId ($questionId)
 
static _getInternalLinkHref ($target="")
 
static _getOriginalId ($question_id)
 Returns the original id of a question. More...
 
static originalQuestionExists ($questionId)
 
static _instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id. More...
 
static _instantiateQuestion ($question_id)
 
static _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution. More...
 
static _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
static _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not. More...
 
static _isWorkedThrough ($active_id, $question_id, $pass=null)
 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 ($a_user_id, $a_question_ids)
 Checks if an array of question ids is answered by an user or not. More...
 
static _setReachedPoints ($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static _needsManualScoring ($question_id)
 
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type. More...
 
static getGuiClassNameByQuestionType ($questionType)
 
static getObjectClassNameByQuestionType ($questionType)
 
static getFeedbackClassNameByQuestionType ($questionType)
 
static isCoreQuestionType ($questionType)
 
static includeCoreClass ($questionType, $withGuiClass)
 
static includePluginClass ($questionType, $withGuiClass)
 
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag. More...
 
static & _instanciateQuestionGUI ($question_id)
 Creates an instance of a question gui with a given question id. More...
 
static instantiateQuestionGUI ($a_question_id)
 Creates an instance of a question gui with a given question id. More...
 
static _questionExistsInTest ($question_id, $test_id)
 
static lookupParentObjId ($questionId)
 ilDBInterface $ilDB More...
 
static lookupOriginalParentObjId ($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 ($questionId)
 returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration More...
 
static implodeKeyValues ($keyValues)
 
static explodeKeyValues ($keyValues)
 
static setResultGateway ($resultGateway)
 
static getResultGateway ()
 
static sumTimesInISO8601FormatH_i_s_Extended ($time1, $time2)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds ($time)
 
static missingResultRecordExists ($activeId, $pass, $questionIds)
 
static getQuestionsMissingResultRecord ($activeId, $pass, $questionIds)
 
static lookupResultRecordExist ($activeId, $questionId, $pass)
 

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 ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT = 'default'
 constant for additional content editing mode "default" More...
 
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT = 'pageobject'
 constant for additional content editing mode "pageobject" More...
 
 $feedbackOBJ = null
 
 $prevent_rte_usage = false
 
 $selfassessmenteditingmode = false
 
 $defaultnroftries = 0
 
 $questionActionCmd = 'handleQuestionAction'
 
const KEY_VALUES_IMPLOSION_SEPARATOR = ':'
 

Protected Member Functions

 reworkWorkingData ($active_id, $pass, $obligationsAnswered, $authorized)
 {} More...
 
 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 ($postSubmissionFieldname)
 
 ensureCurrentTestPass ($active_id, $pass)
 
 lookupCurrentTestPass ($active_id, $pass)
 
 lookupTestId ($active_id)
 
 log ($active_id, $langVar)
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered, $authorized)
 Reworks the allready saved working data if neccessary. More...
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID. More...
 
 onDuplicate ($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test) More...
 
 beforeSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 onCopy ($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId)
 Will be called when a question is copied (into another question pool) More...
 
 duplicateSuggestedSolutionFiles ($parent_id, $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles ($original_id)
 Syncs the files of a suggested solution if the question is synced. More...
 
 copySuggestedSolutionFiles ($source_questionpool_id, $source_question_id)
 
 ensureNonNegativePoints ($points)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 
 duplicateSkillAssignments ($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet ($active_id, $pass, $authorized=true)
 Get a restulset for the current user solution for a this question by active_id and pass. More...
 
 removeSolutionRecordById ($solutionId)
 
 getSolutionRecordById ($solutionId)
 
 deleteDummySolutionRecord ($activeId, $passIndex)
 
 deleteSolutionRecordByValues ($activeId, $passIndex, $authorized, $matchValues)
 
 duplicateIntermediateSolutionAuthorized ($activeId, $passIndex)
 
 forceExistingIntermediateSolution ($activeId, $passIndex, $considerDummyRecordCreation)
 
 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 ($activeId, $pass, $questionId)
 returns the number of existing solution records for the given test active / pass and given question id More...
 
static getKeyValuesImplosionSeparator ()
 
- Protected Attributes inherited from assQuestion
 $id
 
 $title
 
 $comment
 
 $owner
 
 $author
 
 $question
 
 $points
 
 $est_working_time
 
 $shuffle
 
 $test_id
 
 $obj_id
 
 $ilias
 
 $tpl
 
 $lng
 
 $db
 
 $outputType = OUTPUT_JAVASCRIPT
 
 $suggested_solutions
 
 $original_id
 
 $page
 
 $external_id = ''
 
 $questionChangeListeners = array()
 
 $processLocker
 
 $step = null
 
 $lastChange
 
 $shuffler
 
 $testQuestionConfig
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $allowedImageMaterialFileExtensionsByMimeType
 
static $forcePassResultsUpdateEnabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References assQuestion\$author, assQuestion\$comment, assQuestion\$owner, assQuestion\$question, assQuestion\$title, array, ilAssConfigurableMultiOptionQuestionFeedback\FEEDBACK_SETTING_ALL, and assQuestion\setPoints().

52  {
53  parent::__construct($title, $comment, $author, $owner, $question);
54 
55  $this->shuffleAnswersEnabled = true;
56  $this->answerType = self::ANSWER_TYPE_SINGLE_LINE;
57  $this->thumbSize = self::DEFAULT_THUMB_SIZE;
58  $this->scorePartialSolutionEnabled = true;
59  $this->optionLabel = self::OPTION_LABEL_RIGHT_WRONG;
60  $this->customTrueOptionLabel = '';
61  $this->customFalseOptionLabel = '';
62 
63  require_once 'Modules/TestQuestionPool/classes/feedback/class.ilAssConfigurableMultiOptionQuestionFeedback.php';
65 
66  $this->answers = array();
67 
68  $this->setPoints('');
69  }
Create styles array
The data for the language used.
setPoints($a_points)
Sets the maximum available points for the question.
+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswer()

assKprimChoice::addAnswer ( ilAssKprimChoiceAnswer  $answer)

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

188  {
189  $this->answers[] = $answer;
190  }

◆ afterSyncWithOriginal()

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

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

References $filename, $ilLog, assQuestion\buildImagePath(), getAnswers(), getThumbPrefix(), and ilUtil\makeDirParents().

824  {
825  parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
826 
827  $this->cloneAnswerImages($dupQuestionId, $dupParentObjId, $origQuestionId, $origParentObjId);
828  }
+ Here is the call graph for this function:

◆ beforeSyncWithOriginal()

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

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

References assQuestion\$question.

813  {
814  parent::beforeSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
815 
816  $question = self::_instanciateQuestion($origQuestionId);
817 
818  foreach ($question->getAnswers() as $answer) {
819  $question->removeAnswerImage($answer->getPosition());
820  }
821  }

◆ 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.

public

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

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

References $data, $ilDB, $pass, assQuestion\$points, $result, array, calculateReachedPointsForSolution(), assQuestion\getCurrentSolutionResultSet(), and assQuestion\getSolutionMaxPass().

431  {
432  if ($returndetails) {
433  throw new ilTestException('return details not implemented for ' . __METHOD__);
434  }
435 
436  global $ilDB;
437 
438  $found_values = array();
439  if (is_null($pass)) {
440  $pass = $this->getSolutionMaxPass($active_id);
441  }
442 
443  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
444 
445  while ($data = $ilDB->fetchAssoc($result)) {
446  $found_values[(int) $data['value1']] = (int) $data['value2'];
447  }
448 
449  $points = $this->calculateReachedPointsForSolution($found_values, $active_id);
450 
451  return $points;
452  }
$result
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
Create styles array
The data for the language used.
calculateReachedPointsForSolution($found_values, $active_id=0)
global $ilDB
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

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

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

References $key, assQuestion\$points, ilObjTest\_getMCScoring(), getAnswers(), assQuestion\getPoints(), and isScorePartialSolutionEnabled().

Referenced by calculateReachedPoints().

666  {
667  $numCorrect = 0;
668 
669  foreach ($this->getAnswers() as $key => $answer) {
670  if (!isset($found_values[$answer->getPosition()])) {
671  continue;
672  }
673 
674  if ($found_values[$answer->getPosition()] == $answer->getCorrectness()) {
675  $numCorrect++;
676  }
677  }
678 
679  if ($numCorrect >= self::NUM_REQUIRED_ANSWERS) {
680  $points = $this->getPoints();
681  } elseif ($this->isScorePartialSolutionEnabled() && $numCorrect >= self::PARTIAL_SCORING_NUM_CORRECT_ANSWERS) {
682  $points = $this->getPoints() / 2;
683  } else {
684  $points = 0;
685  }
686 
687  if ($active_id) {
688  include_once "./Modules/Test/classes/class.ilObjTest.php";
689  $mc_scoring = ilObjTest::_getMCScoring($active_id);
690  if (($mc_scoring == 0) && (count($found_values) == 0)) {
691  $points = 0;
692  }
693  }
694  return $points;
695  }
getPoints()
Returns the maximum available points for the question.
static _getMCScoring($active_id)
Gets the scoring type for multiple choice questions.
$key
Definition: croninfo.php:18
+ 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 783 of file class.assKprimChoice.php.

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

784  {
785  if ($this->id <= 0) {
786  // The question has not been saved. It cannot be duplicated
787  return;
788  }
789  // duplicate the question in database
790  $clone = $this;
791  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
793  $clone->id = -1;
794  $source_questionpool_id = $this->getObjId();
795  $clone->setObjId($target_questionpool_id);
796  if ($title) {
797  $clone->setTitle($title);
798  }
799  $clone->saveToDb();
800  // copy question page content
801  $clone->copyPageOfQuestion($original_id);
802  // copy XHTML media objects
803  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
804  // duplicate the image
805  $clone->cloneAnswerImages($original_id, $source_questionpool_id, $clone->getId(), $clone->getObjId());
806 
807  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
808 
809  return $clone->id;
810  }
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

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

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

746  {
747  if ($this->id <= 0) {
748  // The question has not been saved. It cannot be duplicated
749  return;
750  }
751 
752  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
753 
754  $sourceQuestionId = $this->id;
755  $sourceParentId = $this->getObjId();
756 
757  // duplicate the question in database
758  $clone = $this;
759  $clone->id = -1;
760 
761  $clone->setObjId($targetParentId);
762 
763  if ($targetQuestionTitle) {
764  $clone->setTitle($targetQuestionTitle);
765  }
766 
767  $clone->saveToDb();
768  // copy question page content
769  $clone->copyPageOfQuestion($sourceQuestionId);
770  // copy XHTML media objects
771  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
772  // duplicate the image
773  $clone->cloneAnswerImages($sourceQuestionId, $sourceParentId, $clone->getId(), $clone->getObjId());
774 
775  $clone->onCopy($sourceParentId, $sourceQuestionId, $targetParentId, $clone->getId());
776 
777  return $clone->id;
778  }
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ duplicate()

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

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

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

698  {
699  if ($this->id <= 0) {
700  // The question has not been saved. It cannot be duplicated
701  return;
702  }
703  // duplicate the question in database
704  $this_id = $this->getId();
705  $thisObjId = $this->getObjId();
706 
707  $clone = $this;
708  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
710  $clone->id = -1;
711 
712  if ((int) $testObjId > 0) {
713  $clone->setObjId($testObjId);
714  }
715 
716  if ($title) {
717  $clone->setTitle($title);
718  }
719 
720  if ($author) {
721  $clone->setAuthor($author);
722  }
723  if ($owner) {
724  $clone->setOwner($owner);
725  }
726 
727  if ($for_test) {
728  $clone->saveToDb($original_id);
729  } else {
730  $clone->saveToDb();
731  }
732 
733  // copy question page content
734  $clone->copyPageOfQuestion($this_id);
735  // copy XHTML media objects
736  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
737  // duplicate the images
738  $clone->cloneAnswerImages($this_id, $thisObjId, $clone->getId(), $clone->getObjId());
739 
740  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
741 
742  return $clone->id;
743  }
getId()
Gets the id of the assQuestion object.
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ generateThumbForFile()

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

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

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

Referenced by rebuildThumbnails().

581  {
582  $filename = $path . $file;
583  if (@file_exists($filename)) {
584  $thumbpath = $path . $this->getThumbPrefix() . $file;
585  $path_info = @pathinfo($filename);
586  $ext = "";
587  switch (strtoupper($path_info['extension'])) {
588  case 'PNG':
589  $ext = 'PNG';
590  break;
591  case 'GIF':
592  $ext = 'GIF';
593  break;
594  default:
595  $ext = 'JPEG';
596  break;
597  }
598  ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbSize());
599  }
600  }
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdditionalTableName()

assKprimChoice::getAdditionalTableName ( )

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

Referenced by saveAdditionalQuestionDataToDb().

77  {
78  return "qpl_qst_kprim";
79  }
+ Here is the caller graph for this function:

◆ getAnswer()

assKprimChoice::getAnswer (   $position)

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

References getAnswers().

Referenced by removeAnswerImage().

177  {
178  foreach ($this->getAnswers() as $answer) {
179  if ($answer->getPosition() == $position) {
180  return $answer;
181  }
182  }
183 
184  return null;
185  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAnswers()

◆ getAnswerTableName()

assKprimChoice::getAnswerTableName ( )

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

Referenced by saveAnswerSpecificDataToDb().

82  {
83  return "qpl_a_kprim";
84  }
+ Here is the caller graph for this function:

◆ getAnswerType()

assKprimChoice::getAnswerType ( )

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

References $answerType.

Referenced by rebuildThumbnails(), and saveAdditionalQuestionDataToDb().

102  {
103  return $this->answerType;
104  }
+ Here is the caller graph for this function:

◆ getAnswerTypeSelectOptions()

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

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

References array, and ilLanguage\txt().

475  {
476  return array(
477  self::ANSWER_TYPE_SINGLE_LINE => $lng->txt('answers_singleline'),
478  self::ANSWER_TYPE_MULTI_LINE => $lng->txt('answers_multiline')
479  );
480  }
Create styles array
The data for the language used.
txt($a_topic, $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...
+ Here is the call graph for this function:

◆ getCustomFalseOptionLabel()

assKprimChoice::getCustomFalseOptionLabel ( )

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

References $customFalseOptionLabel.

Referenced by getFalseOptionLabelTranslation(), and saveAdditionalQuestionDataToDb().

152  {
154  }
+ Here is the caller graph for this function:

◆ getCustomTrueOptionLabel()

assKprimChoice::getCustomTrueOptionLabel ( )

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

References $customTrueOptionLabel.

Referenced by getTrueOptionLabelTranslation(), and saveAdditionalQuestionDataToDb().

142  {
144  }
+ Here is the caller graph for this function:

◆ getFalseOptionLabelTranslation()

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

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

References $optionLabel, getCustomFalseOptionLabel(), and ilLanguage\txt().

Referenced by getInstructionTextTranslation(), and toJSON().

531  {
532  switch ($optionLabel) {
533  case self::OPTION_LABEL_RIGHT_WRONG:
534  return $lng->txt('option_label_wrong');
535 
536  case self::OPTION_LABEL_PLUS_MINUS:
537  return $lng->txt('option_label_minus');
538 
539  case self::OPTION_LABEL_APPLICABLE_OR_NOT:
540  return $lng->txt('option_label_not_applicable');
541 
542  case self::OPTION_LABEL_ADEQUATE_OR_NOT:
543  return $lng->txt('option_label_not_adequate');
544 
545  case self::OPTION_LABEL_CUSTOM:
546  return $this->getCustomFalseOptionLabel();
547  }
548  }
txt($a_topic, $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...
+ 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 550 of file class.assKprimChoice.php.

References $optionLabel, getFalseOptionLabelTranslation(), getTrueOptionLabelTranslation(), and ilLanguage\txt().

Referenced by toJSON().

551  {
552  return sprintf(
553  $lng->txt('kprim_instruction_text'),
556  );
557  }
getTrueOptionLabelTranslation(ilLanguage $lng, $optionLabel)
getFalseOptionLabelTranslation(ilLanguage $lng, $optionLabel)
txt($a_topic, $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...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumAllowedFailures()

assKprimChoice::getNumAllowedFailures ( )
private

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

References isScorePartialSolutionEnabled().

Referenced by toJSON().

961  {
962  if ($this->isScorePartialSolutionEnabled()) {
963  return self::NUM_REQUIRED_ANSWERS - self::PARTIAL_SCORING_NUM_CORRECT_ANSWERS;
964  }
965 
966  return 0;
967  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOptionLabel()

assKprimChoice::getOptionLabel ( )

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

References $optionLabel.

Referenced by saveAdditionalQuestionDataToDb(), and toJSON().

132  {
133  return $this->optionLabel;
134  }
+ Here is the caller graph for this function:

◆ getQuestionType()

assKprimChoice::getQuestionType ( )

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

Referenced by toJSON().

72  {
73  return 'assKprimChoice';
74  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assKprimChoice::getRTETextWithMediaObjects ( )
protected

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

References getAnswers().

878  {
879  $combinedText = parent::getRTETextWithMediaObjects();
880 
881  foreach ($this->getAnswers() as $answer) {
882  $combinedText .= $answer->getAnswertext();
883  }
884 
885  return $combinedText;
886  }
+ Here is the call graph for this function:

◆ getSolutionSubmit()

assKprimChoice::getSolutionSubmit ( )
protected

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

References $_POST, $key, and array.

Referenced by isComplete().

651  {
652  $solutionSubmit = array();
653  foreach ($_POST as $key => $value) {
654  $matches = null;
655 
656  if (preg_match("/^kprim_choice_result_(\d+)/", $key, $matches)) {
657  if (strlen($value)) {
658  $solutionSubmit[$matches[1]] = $value;
659  }
660  }
661  }
662  return $solutionSubmit;
663  }
Create styles array
The data for the language used.
$key
Definition: croninfo.php:18
$_POST["username"]
+ Here is the caller graph for this function:

◆ getSpecificFeedbackAllCorrectOptionLabel()

assKprimChoice::getSpecificFeedbackAllCorrectOptionLabel ( )

Implements ilAssSpecificFeedbackOptionLabelProvider.

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

970  {
971  return 'feedback_correct_kprim';
972  }

◆ getSpecificFeedbackSetting()

assKprimChoice::getSpecificFeedbackSetting ( )

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

References $specificFeedbackSetting.

Referenced by saveAdditionalQuestionDataToDb().

162  {
164  }
+ Here is the caller graph for this function:

◆ getThumbPrefix()

assKprimChoice::getThumbPrefix ( )

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

Referenced by afterSyncWithOriginal(), generateThumbForFile(), and loadAnswerData().

565  {
566  return self::THUMB_PREFIX;
567  }
+ Here is the caller graph for this function:

◆ getThumbSize()

assKprimChoice::getThumbSize ( )

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

References $thumbSize.

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

112  {
113  return $this->thumbSize;
114  }
+ Here is the caller graph for this function:

◆ getTrueOptionLabelTranslation()

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

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

References $optionLabel, getCustomTrueOptionLabel(), and ilLanguage\txt().

Referenced by getInstructionTextTranslation(), and toJSON().

511  {
512  switch ($optionLabel) {
513  case self::OPTION_LABEL_RIGHT_WRONG:
514  return $lng->txt('option_label_right');
515 
516  case self::OPTION_LABEL_PLUS_MINUS:
517  return $lng->txt('option_label_plus');
518 
519  case self::OPTION_LABEL_APPLICABLE_OR_NOT:
520  return $lng->txt('option_label_applicable');
521 
522  case self::OPTION_LABEL_ADEQUATE_OR_NOT:
523  return $lng->txt('option_label_adequate');
524 
525  case self::OPTION_LABEL_CUSTOM:
526  return $this->getCustomTrueOptionLabel();
527  }
528  }
txt($a_topic, $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...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidAnswerTypes()

assKprimChoice::getValidAnswerTypes ( )

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

References array.

Referenced by isValidAnswerType().

455  {
456  return array(self::ANSWER_TYPE_SINGLE_LINE, self::ANSWER_TYPE_MULTI_LINE);
457  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getValidOptionLabels()

assKprimChoice::getValidOptionLabels ( )

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

References array.

Referenced by isValidOptionLabel().

483  {
484  return array(
485  self::OPTION_LABEL_RIGHT_WRONG,
486  self::OPTION_LABEL_PLUS_MINUS,
487  self::OPTION_LABEL_APPLICABLE_OR_NOT,
488  self::OPTION_LABEL_ADEQUATE_OR_NOT,
489  self::OPTION_LABEL_CUSTOM
490  );
491  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getValidOptionLabelsTranslated()

assKprimChoice::getValidOptionLabelsTranslated ( ilLanguage  $lng)

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

References array, and ilLanguage\txt().

494  {
495  return array(
496  self::OPTION_LABEL_RIGHT_WRONG => $lng->txt('option_label_right_wrong'),
497  self::OPTION_LABEL_PLUS_MINUS => $lng->txt('option_label_plus_minus'),
498  self::OPTION_LABEL_APPLICABLE_OR_NOT => $lng->txt('option_label_applicable_or_not'),
499  self::OPTION_LABEL_ADEQUATE_OR_NOT => $lng->txt('option_label_adequate_or_not'),
500  self::OPTION_LABEL_CUSTOM => $lng->txt('option_label_custom')
501  );
502  }
Create styles array
The data for the language used.
txt($a_topic, $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...
+ Here is the call graph for this function:

◆ handleFileUpload()

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

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

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

Referenced by handleFileUploads().

616  {
617  $imagePath = $this->getImagePath();
618 
619  if (!file_exists($imagePath)) {
620  ilUtil::makeDirParents($imagePath);
621  }
622 
623  $filename = $this->buildHashedImageFilename($fileData['name'], true);
624 
625  $answer->setImageFsDir($imagePath);
626  $answer->setImageFile($filename);
627 
628  if (!ilUtil::moveUploadedFile($fileData['tmp_name'], $fileData['name'], $answer->getImageFsPath())) {
629  return 2;
630  }
631 
632  return 0;
633  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
buildHashedImageFilename($plain_image_filename, $unique=false)
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleFileUploads()

assKprimChoice::handleFileUploads (   $answers,
  $files 
)

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

References $answers, $files, and handleFileUpload().

603  {
604  foreach ($answers as $answer) {
605  /* @var ilAssKprimChoiceAnswer $answer */
606 
607  if (!isset($files[$answer->getPosition()])) {
608  continue;
609  }
610 
611  $this->handleFileUpload($answer, $files[$answer->getPosition()]);
612  }
613  }
$files
Definition: add-vimline.php:18
handleFileUpload(ilAssKprimChoiceAnswer $answer, $fileData)
+ Here is the call graph for this function:

◆ isAnswered()

assKprimChoice::isAnswered (   $active_id,
  $pass = null 
)

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

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

980  {
981  $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
982 
983  return $numExistingSolutionRecords >= 4;
984  }
getId()
Gets the id of the assQuestion object.
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
+ Here is the call graph for this function:

◆ isComplete()

assKprimChoice::isComplete ( )

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

References $GLOBALS, $ilDB, $pass, $text, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), array, getAnswers(), assQuestion\getId(), assQuestion\getMaximumPoints(), assQuestion\getProcessLocker(), getSolutionSubmit(), assQuestion\logAction(), assQuestion\removeCurrentSolution(), assQuestion\saveCurrentSolution(), and assQuestion\saveWorkingData().

340  {
341  foreach (array($this->title, $this->author, $this->question) as $text) {
342  if (!strlen($text)) {
343  return false;
344  }
345  }
346 
347  if ($this->getMaximumPoints() <= 0) {
348  return false;
349  }
350 
351  foreach ($this->getAnswers() as $answer) {
352  /* @var ilAssKprimChoiceAnswer $answer */
353 
354  if (is_null($answer->getCorrectness())) {
355  return false;
356  }
357 
358  if (!strlen($answer->getAnswertext()) && !strlen($answer->getImageFile())) {
359  return false;
360  }
361  }
362 
363  return true;
364  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
$text
Definition: errorreport.php:18
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ isCustomOptionLabel()

assKprimChoice::isCustomOptionLabel (   $labelValue)

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

560  {
561  return $labelValue == self::OPTION_LABEL_CUSTOM;
562  }

◆ isObligationPossible()

static assKprimChoice::isObligationPossible (   $questionId)
static

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

975  {
976  return true;
977  }

◆ isScorePartialSolutionEnabled()

assKprimChoice::isScorePartialSolutionEnabled ( )

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

References $scorePartialSolutionEnabled.

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

122  {
124  }
+ Here is the caller graph for this function:

◆ isShuffleAnswersEnabled()

assKprimChoice::isShuffleAnswersEnabled ( )

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

References $shuffleAnswersEnabled.

Referenced by saveAdditionalQuestionDataToDb(), and toJSON().

92  {
94  }
+ Here is the caller graph for this function:

◆ isSingleLineAnswerType()

assKprimChoice::isSingleLineAnswerType (   $answerType)

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

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 459 of file class.assKprimChoice.php.

References $answerType, and getValidAnswerTypes().

Referenced by loadFromDb().

460  {
461  $validTypes = $this->getValidAnswerTypes();
462  return in_array($answerType, $validTypes);
463  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValidOptionLabel()

assKprimChoice::isValidOptionLabel (   $optionLabel)

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

References $optionLabel, and getValidOptionLabels().

Referenced by loadFromDb().

505  {
506  $validLabels = $this->getValidOptionLabels();
507  return in_array($optionLabel, $validLabels);
508  }
+ 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

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

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

892  {
893  foreach ($this->getAnswers() as $answer) {
894  /* @var ilAssKprimChoiceAnswer $answer */
895  $answer->setAnswertext($migrator->migrateToLmContent($answer->getAnswertext()));
896  }
897  }
+ Here is the call graph for this function:

◆ loadAnswerData()

assKprimChoice::loadAnswerData (   $questionId)
private

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

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

Referenced by loadFromDb().

251  {
252  global $ilDB;
253 
254  $res = $this->db->queryF(
255  "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY position ASC",
256  array('integer'),
257  array($questionId)
258  );
259 
260  require_once 'Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
261  require_once 'Services/RTE/classes/class.ilRTE.php';
262 
263  while ($data = $ilDB->fetchAssoc($res)) {
264  $answer = new ilAssKprimChoiceAnswer();
265 
266  $answer->setPosition($data['position']);
267 
268  $answer->setAnswertext(ilRTE::_replaceMediaObjectImageSrc($data['answertext'], 1));
269 
270  $answer->setImageFile($data['imagefile']);
271  $answer->setThumbPrefix($this->getThumbPrefix());
272  $answer->setImageFsDir($this->getImagePath());
273  $answer->setImageWebDir($this->getImagePathWeb());
274 
275  $answer->setCorrectness($data['correctness']);
276 
277  $this->answers[$answer->getPosition()] = $answer;
278  }
279 
280  for ($i = count($this->answers); $i < self::NUM_REQUIRED_ANSWERS; $i++) {
281  $answer = new ilAssKprimChoiceAnswer();
282 
283  $answer->setPosition($i);
284 
285  $this->answers[$answer->getPosition()] = $answer;
286  }
287  }
getImagePathWeb()
Returns the web image path for web accessable images of a question.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
global $ilDB
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadFromDb()

assKprimChoice::loadFromDb (   $questionId)

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

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

193  {
194  $res = $this->db->queryF($this->buildQuestionDataQuery(), array('integer'), array($questionId));
195 
196  while ($data = $this->db->fetchAssoc($res)) {
197  $this->setId($questionId);
198 
199  $this->setOriginalId($data['original_id']);
200 
201  $this->setObjId($data['obj_fi']);
202 
203  $this->setTitle($data['title']);
204  $this->setNrOfTries($data['nr_of_tries']);
205  $this->setComment($data['description']);
206  $this->setAuthor($data['author']);
207  $this->setPoints($data['points']);
208  $this->setOwner($data['owner']);
209  $this->setEstimatedWorkingTimeFromDurationString($data['working_time']);
210  $this->setLastChange($data['tstamp']);
211  require_once 'Services/RTE/classes/class.ilRTE.php';
212  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data['question_text'], 1));
213 
214  $this->setShuffleAnswersEnabled((bool) $data['shuffle_answers']);
215 
216  if ($this->isValidAnswerType($data['answer_type'])) {
217  $this->setAnswerType($data['answer_type']);
218  }
219 
220  if (is_numeric($data['thumb_size'])) {
221  $this->setThumbSize((int) $data['thumb_size']);
222  }
223 
224  if ($this->isValidOptionLabel($data['opt_label'])) {
225  $this->setOptionLabel($data['opt_label']);
226  }
227 
228  $this->setCustomTrueOptionLabel($data['custom_true']);
229  $this->setCustomFalseOptionLabel($data['custom_false']);
230 
231  if ($data['score_partsol'] !== null) {
232  $this->setScorePartialSolutionEnabled((bool) $data['score_partsol']);
233  }
234 
235  if (isset($data['feedback_setting'])) {
236  $this->setSpecificFeedbackSetting((int) $data['feedback_setting']);
237  }
238 
239  try {
240  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
241  } catch (ilTestQuestionPoolException $e) {
242  }
243  }
244 
245  $this->loadAnswerData($questionId);
246 
247  parent::loadFromDb($questionId);
248  }
isValidAnswerType($answerType)
setScorePartialSolutionEnabled($scorePartialSolutionEnabled)
setId($id=-1)
Sets the id of the assQuestion object.
setEstimatedWorkingTimeFromDurationString($durationString)
Sets the estimated working time of a question from a given datetime string.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setCustomTrueOptionLabel($customTrueOptionLabel)
isValidOptionLabel($optionLabel)
loadAnswerData($questionId)
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setOptionLabel($optionLabel)
setAuthor($author="")
Sets the authors name of the assQuestion object.
foreach($_POST as $key=> $value) $res
setShuffleAnswersEnabled($shuffleAnswersEnabled)
Create styles array
The data for the language used.
setPoints($a_points)
Sets the maximum available points for the question.
setCustomFalseOptionLabel($customFalseOptionLabel)
setQuestion($question="")
Sets the question string of the question object.
setSpecificFeedbackSetting($specificFeedbackSetting)
setOriginalId($original_id)
setLastChange($lastChange)
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setComment($comment="")
Sets the comment string of the assQuestion object.
setAnswerType($answerType)
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
+ Here is the call graph for this function:

◆ moveAnswerDown()

assKprimChoice::moveAnswerDown (   $position)

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

References $i.

1014  {
1015  if ($position < 0 || $position >= (self::NUM_REQUIRED_ANSWERS - 1)) {
1016  return false;
1017  }
1018 
1019  for ($i = 0, $max = count($this->answers); $i < $max; $i++) {
1020  if ($i == $position) {
1021  $movingAnswer = $this->answers[$i];
1022  $targetAnswer = $this->answers[ $i + 1 ];
1023 
1024  $movingAnswer->setPosition($position + 1);
1025  $targetAnswer->setPosition($position);
1026 
1027  $this->answers[ $i + 1 ] = $movingAnswer;
1028  $this->answers[$i] = $targetAnswer;
1029  }
1030  }
1031  }
$i
Definition: disco.tpl.php:19

◆ moveAnswerUp()

assKprimChoice::moveAnswerUp (   $position)

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

References $i.

1034  {
1035  if ($position <= 0 || $position > (self::NUM_REQUIRED_ANSWERS - 1)) {
1036  return false;
1037  }
1038 
1039  for ($i = 0, $max = count($this->answers); $i < $max; $i++) {
1040  if ($i == $position) {
1041  $movingAnswer = $this->answers[$i];
1042  $targetAnswer = $this->answers[ $i - 1 ];
1043 
1044  $movingAnswer->setPosition($position - 1);
1045  $targetAnswer->setPosition($position);
1046 
1047  $this->answers[ $i - 1 ] = $movingAnswer;
1048  $this->answers[$i] = $targetAnswer;
1049  }
1050  }
1051 
1052  return true;
1053  }
$i
Definition: disco.tpl.php:19

◆ rebuildThumbnails()

assKprimChoice::rebuildThumbnails ( )

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

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

Referenced by saveAnswerSpecificDataToDb().

570  {
571  if ($this->isSingleLineAnswerType($this->getAnswerType()) && $this->getThumbSize()) {
572  foreach ($this->getAnswers() as $answer) {
573  if (strlen($answer->getImageFile())) {
574  $this->generateThumbForFile($answer->getImageFsDir(), $answer->getImageFile());
575  }
576  }
577  }
578  }
isSingleLineAnswerType($answerType)
generateThumbForFile($path, $file)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAnswerImage()

assKprimChoice::removeAnswerImage (   $position)

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

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

636  {
637  $answer = $this->getAnswer($position);
638 
639  if (file_exists($answer->getImageFsPath())) {
640  ilUtil::delDir($answer->getImageFsPath());
641  }
642 
643  if (file_exists($answer->getThumbFsPath())) {
644  ilUtil::delDir($answer->getThumbFsPath());
645  }
646 
647  $answer->setImageFile(null);
648  }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ reworkWorkingData()

assKprimChoice::reworkWorkingData (   $active_id,
  $pass,
  $obligationsAnswered,
  $authorized 
)
protected

{}

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

416  {
417  // nothing to rework!
418  }

◆ saveAdditionalQuestionDataToDb()

assKprimChoice::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

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

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

Referenced by saveToDb().

300  {
301  $this->db->replace(
302  $this->getAdditionalTableName(),
303  array(
304  'question_fi' => array('integer', $this->getId())
305  ),
306  array(
307  'shuffle_answers' => array('integer', (int) $this->isShuffleAnswersEnabled()),
308  'answer_type' => array('text', $this->getAnswerType()),
309  'thumb_size' => array('integer', (int) $this->getThumbSize()),
310  'opt_label' => array('text', $this->getOptionLabel()),
311  'custom_true' => array('text', $this->getCustomTrueOptionLabel()),
312  'custom_false' => array('text', $this->getCustomFalseOptionLabel()),
313  'score_partsol' => array('integer', (int) $this->isScorePartialSolutionEnabled()),
314  'feedback_setting' => array('integer', (int) $this->getSpecificFeedbackSetting())
315  )
316  );
317  }
getId()
Gets the id of the assQuestion object.
Create styles array
The data for the language used.
+ 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 319 of file class.assKprimChoice.php.

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

Referenced by saveToDb().

320  {
321  foreach ($this->getAnswers() as $answer) {
322  $this->db->replace(
323  $this->getAnswerTableName(),
324  array(
325  'question_fi' => array('integer', (int) $this->getId()),
326  'position' => array('integer', (int) $answer->getPosition())
327  ),
328  array(
329  'answertext' => array('text', $answer->getAnswertext()),
330  'imagefile' => array('text', $answer->getImageFile()),
331  'correctness' => array('integer', (int) $answer->getCorrectness())
332  )
333  );
334  }
335 
336  $this->rebuildThumbnails();
337  }
getId()
Gets the id of the assQuestion object.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

assKprimChoice::saveToDb (   $originalId = '')

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

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

290  {
291  $this->saveQuestionDataToDb($originalId);
292 
295 
296  parent::saveToDb($originalId);
297  }
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb($original_id="")
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
+ Here is the call graph for this function:

◆ setAnswers()

assKprimChoice::setAnswers (   $answers)

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

References $answers.

167  {
168  $this->answers = $answers;
169  }

◆ setAnswerType()

assKprimChoice::setAnswerType (   $answerType)

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

References $answerType.

Referenced by loadFromDb().

97  {
98  $this->answerType = $answerType;
99  }
+ Here is the caller graph for this function:

◆ setCustomFalseOptionLabel()

assKprimChoice::setCustomFalseOptionLabel (   $customFalseOptionLabel)

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

References $customFalseOptionLabel.

Referenced by loadFromDb().

147  {
148  $this->customFalseOptionLabel = $customFalseOptionLabel;
149  }
+ Here is the caller graph for this function:

◆ setCustomTrueOptionLabel()

assKprimChoice::setCustomTrueOptionLabel (   $customTrueOptionLabel)

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

References $customTrueOptionLabel.

Referenced by loadFromDb().

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

◆ setExportDetailsXLS()

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

{}

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

References $i, assQuestion\$id, $pass, $worksheet, getAnswers(), and assQuestion\getSolutionValues().

990  {
991  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
992 
993  $solution = $this->getSolutionValues($active_id, $pass);
994 
995  $i = 1;
996  foreach ($this->getAnswers() as $id => $answer) {
997  $worksheet->setCell($startrow + $i, 0, $answer->getAnswertext());
998  $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
999  $correctness = false;
1000  foreach ($solution as $solutionvalue) {
1001  if ($id == $solutionvalue['value1']) {
1002  $correctness = $solutionvalue['value2'];
1003  break;
1004  }
1005  }
1006  $worksheet->setCell($startrow + $i, 1, $correctness);
1007  $i++;
1008  }
1009 
1010  return $startrow + $i + 1;
1011  }
$worksheet
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:

◆ setOptionLabel()

assKprimChoice::setOptionLabel (   $optionLabel)

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

References $optionLabel.

Referenced by loadFromDb().

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

◆ setScorePartialSolutionEnabled()

assKprimChoice::setScorePartialSolutionEnabled (   $scorePartialSolutionEnabled)

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

References $scorePartialSolutionEnabled.

Referenced by loadFromDb().

117  {
118  $this->scorePartialSolutionEnabled = $scorePartialSolutionEnabled;
119  }
+ Here is the caller graph for this function:

◆ setShuffleAnswersEnabled()

assKprimChoice::setShuffleAnswersEnabled (   $shuffleAnswersEnabled)

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

References $shuffleAnswersEnabled.

Referenced by loadFromDb().

87  {
88  $this->shuffleAnswersEnabled = $shuffleAnswersEnabled;
89  }
+ Here is the caller graph for this function:

◆ setSpecificFeedbackSetting()

assKprimChoice::setSpecificFeedbackSetting (   $specificFeedbackSetting)

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

References $specificFeedbackSetting.

Referenced by loadFromDb().

157  {
158  $this->specificFeedbackSetting = $specificFeedbackSetting;
159  }
+ Here is the caller graph for this function:

◆ setThumbSize()

assKprimChoice::setThumbSize (   $thumbSize)

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

References $thumbSize.

Referenced by loadFromDb().

107  {
108  $this->thumbSize = $thumbSize;
109  }
+ Here is the caller graph for this function:

◆ toJSON()

assKprimChoice::toJSON ( )

Returns a JSON representation of the question.

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

References $answers, $key, $mobs, $result, ilObjMediaObject\_getMobsOfObject(), array, assQuestion\formatSAQuestion(), getAnswers(), getFalseOptionLabelTranslation(), assQuestion\getId(), assQuestion\getImagePathWeb(), getInstructionTextTranslation(), assQuestion\getNrOfTries(), getNumAllowedFailures(), getOptionLabel(), assQuestion\getQuestion(), getQuestionType(), getThumbSize(), assQuestion\getTitle(), getTrueOptionLabelTranslation(), isShuffleAnswersEnabled(), and string.

903  {
904  $this->lng->loadLanguageModule('assessment');
905 
906  require_once './Services/RTE/classes/class.ilRTE.php';
907  $result = array();
908  $result['id'] = (int) $this->getId();
909  $result['type'] = (string) $this->getQuestionType();
910  $result['title'] = (string) $this->getTitle();
911  $result['question'] = $this->formatSAQuestion($this->getQuestion());
912  $result['instruction'] = $this->getInstructionTextTranslation(
913  $this->lng,
914  $this->getOptionLabel()
915  );
916  $result['nr_of_tries'] = (int) $this->getNrOfTries();
917  $result['shuffle'] = (bool) $this->isShuffleAnswersEnabled();
918  $result['feedback'] = array(
919  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
920  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
921  );
922 
923  $result['trueOptionLabel'] = $this->getTrueOptionLabelTranslation($this->lng, $this->getOptionLabel());
924  $result['falseOptionLabel'] = $this->getFalseOptionLabelTranslation($this->lng, $this->getOptionLabel());
925 
926  $result['num_allowed_failures'] = $this->getNumAllowedFailures();
927 
928  $answers = array();
929  $has_image = false;
930 
931  foreach ($this->getAnswers() as $key => $answer) {
932  if (strlen((string) $answer->getImageFile())) {
933  $has_image = true;
934  }
935 
936  $answers[] = array(
937  'answertext' => (string) $this->formatSAQuestion($answer->getAnswertext()),
938  'correctness' => (bool) $answer->getCorrectness(),
939  'order' => (int) $answer->getPosition(),
940  'image' => (string) $answer->getImageFile(),
941  'feedback' => $this->formatSAQuestion(
942  $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key)
943  )
944  );
945  }
946 
947  $result['answers'] = $answers;
948 
949  if ($has_image) {
950  $result['path'] = $this->getImagePathWeb();
951  $result['thumb'] = $this->getThumbSize();
952  }
953 
954  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
955  $result['mobs'] = $mobs;
956 
957  return json_encode($result);
958  }
getId()
Gets the id of the assQuestion object.
Add rich text string
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
formatSAQuestion($a_q)
Format self assessment question.
$result
getImagePathWeb()
Returns the web image path for web accessable images of a question.
getTrueOptionLabelTranslation(ilLanguage $lng, $optionLabel)
$mobs
getQuestion()
Gets the question string of the question object.
Create styles array
The data for the language used.
getFalseOptionLabelTranslation(ilLanguage $lng, $optionLabel)
getTitle()
Gets the title string of the assQuestion object.
$key
Definition: croninfo.php:18
getInstructionTextTranslation(ilLanguage $lng, $optionLabel)
+ Here is the call graph for this function:

Field Documentation

◆ $answers

assKprimChoice::$answers
private

Definition at line 49 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 43 of file class.assKprimChoice.php.

Referenced by getCustomTrueOptionLabel(), and setCustomTrueOptionLabel().

◆ $optionLabel

◆ $scorePartialSolutionEnabled

assKprimChoice::$scorePartialSolutionEnabled
private

◆ $shuffleAnswersEnabled

assKprimChoice::$shuffleAnswersEnabled
private

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

Referenced by isShuffleAnswersEnabled(), and setShuffleAnswersEnabled().

◆ $specificFeedbackSetting

assKprimChoice::$specificFeedbackSetting
private

◆ $thumbSize

assKprimChoice::$thumbSize
private

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

Referenced by getThumbSize(), and setThumbSize().

◆ ANSWER_TYPE_MULTI_LINE

const assKprimChoice::ANSWER_TYPE_MULTI_LINE = 'multiLine'

◆ ANSWER_TYPE_SINGLE_LINE

const assKprimChoice::ANSWER_TYPE_SINGLE_LINE = 'singleLine'

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

Referenced by isSingleLineAnswerType().

◆ DEFAULT_THUMB_SIZE

const assKprimChoice::DEFAULT_THUMB_SIZE = 150

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

◆ NUM_REQUIRED_ANSWERS

const assKprimChoice::NUM_REQUIRED_ANSWERS = 4

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

◆ OPTION_LABEL_ADEQUATE_OR_NOT

const assKprimChoice::OPTION_LABEL_ADEQUATE_OR_NOT = 'adequate_or_not'

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

◆ OPTION_LABEL_APPLICABLE_OR_NOT

const assKprimChoice::OPTION_LABEL_APPLICABLE_OR_NOT = 'applicable_or_not'

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

◆ OPTION_LABEL_CUSTOM

const assKprimChoice::OPTION_LABEL_CUSTOM = 'customlabel'

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

◆ OPTION_LABEL_PLUS_MINUS

const assKprimChoice::OPTION_LABEL_PLUS_MINUS = 'plus_minus'

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

◆ OPTION_LABEL_RIGHT_WRONG

const assKprimChoice::OPTION_LABEL_RIGHT_WRONG = 'right_wrong'

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

◆ PARTIAL_SCORING_NUM_CORRECT_ANSWERS

const assKprimChoice::PARTIAL_SCORING_NUM_CORRECT_ANSWERS = 3

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

◆ THUMB_PREFIX

const assKprimChoice::THUMB_PREFIX = 'thumb.'

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


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