ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assErrorText Class Reference

Class for error text questions. More...

+ Inheritance diagram for assErrorText:
+ Collaboration diagram for assErrorText:

Public Member Functions

 __construct ( $title='', $comment='', $author='', $owner=-1, $question='')
 assErorText constructor More...
 
 isComplete ()
 Returns true, if a single choice question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a the object to the database. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 saveAdditionalQuestionDataToDb ()
 Saves the data for the additional data table. More...
 
 loadFromDb ($question_id)
 Loads the object from the database. More...
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates the object. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 {} More...
 
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Creates a question from a QTI file. 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 and sets the internal domxml variable with the DOM XML representation of the QTI xml representation. More...
 
 getBestSolution ($active_id, $pass)
 Returns the best solution for a given pass of a participant. More...
 
 getErrorsFromText ($a_text="")
 
 setErrorData ($a_data)
 
 createErrorTextOutput ($selections=null, $graphicalOutput=false, $correct_solution=false, $use_link_tags=true)
 
 createErrorTextExport ($selections=null)
 
 getBestSelection ($withPositivePointsOnly=true)
 
 flushErrorData ()
 Flush error data. More...
 
 addErrorData ($text_wrong, $text_correct, $points)
 
 getErrorData ()
 Get error data. More...
 
 getErrorText ()
 Get error text. More...
 
 setErrorText ($a_value)
 Set error text. More...
 
 getTextSize ()
 Set text size in percent. More...
 
 setTextSize ($a_value)
 Set text size in percent. More...
 
 getPointsWrong ()
 Get wrong points. More...
 
 setPointsWrong ($a_value)
 Set wrong points. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 
- 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)
 
 isAddableAnswerOptionValue ($qIndex, $answerOptionValue)
 
 addAnswerOptionValue ($qIndex, $answerOptionValue, $points)
 
 removeAllExistingSolutions ()
 
 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...
 
 savePartial ()
 
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 

Protected Member Functions

 isTokenSelected ($counter, array $selection)
 
 getPointsForSelectedPositions ($positions)
 
- Protected Member Functions inherited from assQuestion
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission ($postSubmissionFieldname)
 
 ensureCurrentTestPass ($active_id, $pass)
 
 lookupCurrentTestPass ($active_id, $pass)
 
 lookupTestId ($active_id)
 
 log ($active_id, $langVar)
 
 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)
 
 isDummySolutionRecord ($solutionRecord)
 
 deleteSolutionRecordByValues ($activeId, $passIndex, $authorized, $matchValues)
 
 duplicateIntermediateSolutionAuthorized ($activeId, $passIndex)
 
 forceExistingIntermediateSolution ($activeId, $passIndex, $considerDummyRecordCreation)
 
 buildTestPresentationConfig ()
 build basic test question configuration instance More...
 

Protected Attributes

 $errortext
 
 $textsize
 
 $errordata
 
 $points_wrong
 
- 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
 

Private Member Functions

 getErrorTokenHtml ($item, $class, $useLinkTags)
 

Additional Inherited Members

- 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 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 = ':'
 
- Data Fields inherited from iQuestionCondition
const StringResultExpression = '~TEXT~'
 
const PercentageResultExpression = '%n%'
 
const NumericResultExpression = '#n#'
 
const MatchingResultExpression = ';n:m;'
 
const OrderingResultExpression = '$n,m,o,p$'
 
const NumberOfResultExpression = '+n+'
 
const ExclusiveResultExpression = '*n,m,o,p*'
 
const EmptyAnswerExpression = "?"
 
- 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 ()
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $allowedImageMaterialFileExtensionsByMimeType
 
static $forcePassResultsUpdateEnabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

Class for error text questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Grégory Saive gsaiv.nosp@m.e@da.nosp@m.tabay.nosp@m..de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

assErorText constructor

Parameters
string$titleA title string to describe the question.
string$commentA comment string to describe the question.
string$authorA string containing the name of the questions author.
integer$ownerA numerical ID to identify the owner/creator.
string$questionThe question string of the single choice question.
Returns

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

References assQuestion\$author, assQuestion\$comment, assQuestion\$owner, assQuestion\$question, and assQuestion\$title.

47  {
48  parent::__construct($title, $comment, $author, $owner, $question);
49  $this->errortext = '';
50  $this->textsize = 100.0;
51  $this->errordata = array();
52  }

Member Function Documentation

◆ __get()

assErrorText::__get (   $value)

Object getter.

Definition at line 1057 of file class.assErrorText.php.

References getErrorText(), getPointsWrong(), and getTextSize().

1058  {
1059  switch ($value) {
1060  case "errortext":
1061  return $this->getErrorText();
1062  break;
1063  case "textsize":
1064  return $this->getTextSize();
1065  break;
1066  case "points_wrong":
1067  return $this->getPointsWrong();
1068  break;
1069  default:
1070  return parent::__get($value);
1071  break;
1072  }
1073  }
getErrorText()
Get error text.
getTextSize()
Set text size in percent.
getPointsWrong()
Get wrong points.
+ Here is the call graph for this function:

◆ __set()

assErrorText::__set (   $key,
  $value 
)

Object setter.

Definition at line 1078 of file class.assErrorText.php.

References $key, setErrorText(), setPointsWrong(), and setTextSize().

1079  {
1080  switch ($key) {
1081  case "errortext":
1082  $this->setErrorText($value);
1083  break;
1084  case "textsize":
1085  $this->setTextSize($value);
1086  break;
1087  case "points_wrong":
1088  $this->setPointsWrong($value);
1089  break;
1090  default:
1091  parent::__set($key, $value);
1092  break;
1093  }
1094  }
setTextSize($a_value)
Set text size in percent.
setErrorText($a_value)
Set error text.
setPointsWrong($a_value)
Set wrong points.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ addErrorData()

assErrorText::addErrorData (   $text_wrong,
  $text_correct,
  $points 
)

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

References assQuestion\$points.

975  {
976  include_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
977  array_push($this->errordata, new assAnswerErrorText($text_wrong, $text_correct, $points));
978  }
Class for error text answers.

◆ calculateReachedPoints()

assErrorText::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 334 of file class.assErrorText.php.

References $DIC, $ilDB, $pass, assQuestion\$points, $result, $row, assQuestion\getCurrentSolutionResultSet(), getPointsForSelectedPositions(), and assQuestion\getSolutionMaxPass().

Referenced by getExpressionTypes().

335  {
336  if ($returndetails) {
337  throw new ilTestException('return details not implemented for ' . __METHOD__);
338  }
339 
340  global $DIC;
341  $ilDB = $DIC['ilDB'];
342 
343  /* First get the positions which were selected by the user. */
344  $positions = array();
345  if (is_null($pass)) {
346  $pass = $this->getSolutionMaxPass($active_id);
347  }
348  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
349 
350  while ($row = $ilDB->fetchAssoc($result)) {
351  array_push($positions, $row['value1']);
352  }
353  $points = $this->getPointsForSelectedPositions($positions);
354  return $points;
355  }
$result
global $DIC
Definition: saml.php:7
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
getPointsForSelectedPositions($positions)
$row
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:
+ Here is the caller graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assErrorText::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

Definition at line 357 of file class.assErrorText.php.

References assQuestion\deductHintPointsFromReachedPoints(), assQuestion\ensureNonNegativePoints(), ilAssQuestionPreviewSession\getParticipantsSolution(), and getPointsForSelectedPositions().

358  {
359  $reachedPoints = $this->getPointsForSelectedPositions($previewSession->getParticipantsSolution());
360  $reachedPoints = $this->deductHintPointsFromReachedPoints($previewSession, $reachedPoints);
361  return $this->ensureNonNegativePoints($reachedPoints);
362  }
ensureNonNegativePoints($points)
getPointsForSelectedPositions($positions)
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
+ Here is the call graph for this function:

◆ copyObject()

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

Copies an object.

Definition at line 244 of file class.assErrorText.php.

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

245  {
246  if ($this->id <= 0) {
247  // The question has not been saved. It cannot be duplicated
248  return;
249  }
250  // duplicate the question in database
251 
252  $thisId = $this->getId();
253  $thisObjId = $this->getObjId();
254 
255  $clone = $this;
256  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
258  $clone->id = -1;
259  $clone->setObjId($target_questionpool_id);
260  if ($title) {
261  $clone->setTitle($title);
262  }
263  $clone->saveToDb();
264 
265  // copy question page content
266  $clone->copyPageOfQuestion($original_id);
267  // copy XHTML media objects
268  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
269 
270  $clone->onCopy($thisObjId, $thisId, $clone->getObjId(), $clone->getId());
271 
272  return $clone->id;
273  }
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:

◆ createErrorTextExport()

assErrorText::createErrorTextExport (   $selections = null)

Definition at line 763 of file class.assErrorText.php.

References $text, getErrorText(), and ilUtil\prepareFormOutput().

Referenced by setExportDetailsXLS().

764  {
765  $counter = 0;
766  $errorcounter = 0;
767  include_once "./Services/Utilities/classes/class.ilStr.php";
768  if (!is_array($selections)) {
769  $selections = array();
770  }
771  $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
772  foreach ($textarray as $textidx => $text) {
773  $items = preg_split("/\s+/", $text);
774  foreach ($items as $idx => $item) {
775  if (($posHash = strpos($item, '#')) === 0
776  || ($posOpeningBrackets = strpos($item, '((')) === 0
777  || ($posClosingBrackets = strpos($item, '))')) !== false) {
778  /* (Word|Passage)-Marking delimiter found. */
779 
780  if ($posHash !== false) {
781  $item = ilStr::substr($item, 1, ilStr::strlen($item) - 1);
782  } elseif ($posOpeningBrackets !== false) {
783  $item = ilStr::substr($item, 2, ilStr::strlen($item) - 2);
784 
785  /* Sometimes a closing bracket group needs
786  to be removed as well. */
787  if (strpos($item, '))') !== false) {
788  $item = ilStr::substr($item, 0, ilStr::strlen($item) - 2);
789  }
790  } else {
791  $appendComma = "";
792  if ($item[$posClosingBrackets + 2] == ',') {
793  $appendComma = ",";
794  }
795 
796  $item = ilStr::substr($item, 0, $posClosingBrackets) . $appendComma;
797  }
798  }
799 
800  $word = "";
801  if (in_array($counter, $selections)) {
802  $word .= '#';
803  }
804  $word .= ilUtil::prepareFormOutput($item);
805  if (in_array($counter, $selections)) {
806  $word .= '#';
807  }
808  $items[$idx] = $word;
809  $counter++;
810  }
811  $textarray[$textidx] = join(" ", $items);
812  }
813  return join("\n", $textarray);
814  }
getErrorText()
Get error text.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$text
Definition: errorreport.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createErrorTextOutput()

assErrorText::createErrorTextOutput (   $selections = null,
  $graphicalOutput = false,
  $correct_solution = false,
  $use_link_tags = true 
)

Definition at line 591 of file class.assErrorText.php.

References $img, $text, getErrorText(), getErrorTokenHtml(), ilUtil\getImagePath(), getPointsForSelectedPositions(), and isTokenSelected().

592  {
593  $counter = 0;
594  $errorcounter = 0;
595  include_once "./Services/Utilities/classes/class.ilStr.php";
596  if (!is_array($selections)) {
597  $selections = array();
598  }
599  $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
600 
601  foreach ($textarray as $textidx => $text) {
602  $in_passage = false;
603  $passage_end = false;
604  $items = preg_split("/\s+/", $text);
605  foreach ($items as $idx => $item) {
606  $img = '';
607 
608  if (
609  ($posHash = strpos($item, '#')) === 0 ||
610  ($posOpeningBrackets = strpos($item, '((')) === 0 ||
611  ($posClosingBrackets = strpos($item, '))')) !== false
612  ) {
613  /* (Word|Passage)-Marking delimiter found. */
614 
615  if ($posHash !== false) {
616  $item = ilStr::substr($item, 1, ilStr::strlen($item) - 1);
617  $passage_end = false;
618  } elseif ($posOpeningBrackets !== false) {
619  $in_passage = true;
620  $passage_start_idx = $counter;
621  $items_in_passage = array();
622  $passage_end = false;
623  $item = ilStr::substr($item, 2, ilStr::strlen($item) - 2);
624 
625  /* Sometimes a closing bracket group needs
626  to be removed as well. */
627  if (strpos($item, '))') !== false) {
628  $item = str_replace("))", "", $item);
629  $passage_end = true;
630  }
631  } else {
632  $passage_end = true;
633  $item = str_replace("))", "", $item);
634  }
635 
636  if ($correct_solution && !$in_passage) {
637  $errorobject = $this->errordata[$errorcounter];
638  if (is_object($errorobject)) {
639  $item = strlen($errorobject->text_correct) ? $errorobject->text_correct : '&nbsp;';
640  }
641  $errorcounter++;
642  }
643  }
644 
645  if ($in_passage && !$passage_end) {
646  $items_in_passage[$idx] = $item;
647  $items[$idx] = '';
648  $counter++;
649  continue;
650  }
651 
652  if ($in_passage && $passage_end) {
653  $in_passage = false;
654  $passage_end = false;
655  if ($correct_solution) {
656  $class = (
657  $this->isTokenSelected($counter, $selections) ?
658  "ilc_qetitem_ErrorTextSelected" : "ilc_qetitem_ErrorTextItem"
659  );
660 
661  $errorobject = $this->errordata[$errorcounter];
662  if (is_object($errorobject)) {
663  $item = strlen($errorobject->text_correct) ? $errorobject->text_correct : '&nbsp;';
664  }
665  $errorcounter++;
666  $items[$idx] = $this->getErrorTokenHtml($item, $class, $use_link_tags) . $img;
667  $counter++;
668  continue;
669  }
670 
671  $group_selected = true;
672  if ($graphicalOutput) {
673  $start_idx = $passage_start_idx;
674  foreach ($items_in_passage as $tmp_idx => $tmp_item) {
675  if (!$this->isTokenSelected($start_idx, $selections)) {
676  $group_selected = false;
677  break;
678  }
679 
680  ++$start_idx;
681  }
682  if ($group_selected) {
683  if (!$this->isTokenSelected($counter, $selections)) {
684  $group_selected = false;
685  }
686  }
687  }
688 
689  $item_stack = array();
690  $start_idx = $passage_start_idx;
691  foreach ($items_in_passage as $tmp_idx => $tmp_item) {
692  $class = (
693  $this->isTokenSelected($counter, $selections) ?
694  "ilc_qetitem_ErrorTextSelected" : "ilc_qetitem_ErrorTextItem"
695  );
696  $item_stack[] = $this->getErrorTokenHtml($tmp_item, $class, $use_link_tags) . $img;
697  $start_idx++;
698  }
699  $class = (
700  $this->isTokenSelected($counter, $selections) ?
701  "ilc_qetitem_ErrorTextSelected" : "ilc_qetitem_ErrorTextItem"
702  );
703  if ($graphicalOutput) {
704  if ($group_selected) {
705  $img = ' <img src="' . ilUtil::getImagePath("icon_ok.svg") . '" alt="' . $this->lng->txt("answer_is_right") . '" title="' . $this->lng->txt("answer_is_right") . '" /> ';
706  } else {
707  $img = ' <img src="' . ilUtil::getImagePath("icon_not_ok.svg") . '" alt="' . $this->lng->txt("answer_is_wrong") . '" title="' . $this->lng->txt("answer_is_wrong") . '" /> ';
708  }
709  }
710 
711  $item_stack[] = $this->getErrorTokenHtml($item, $class, $use_link_tags) . $img;
712  $item_stack = trim(implode(" ", $item_stack));
713  $item_stack = strlen($item_stack) ? $item_stack : '&nbsp;';
714 
715  if ($graphicalOutput) {
716  $items[$idx] = '<span class="selGroup">' . $item_stack . '</span>';
717  } else {
718  $items[$idx] = $item_stack;
719  }
720 
721  $counter++;
722  continue;
723  }
724 
725  // Errors markes with #, group errors (()) are handled above
726  $class = 'ilc_qetitem_ErrorTextItem';
727  $img = '';
728  if ($this->isTokenSelected($counter, $selections)) {
729  $class = "ilc_qetitem_ErrorTextSelected";
730  if ($graphicalOutput) {
731  if ($this->getPointsForSelectedPositions(array($counter)) > 0) {
732  $img = ' <img src="' . ilUtil::getImagePath("icon_ok.svg") . '" alt="' . $this->lng->txt("answer_is_right") . '" title="' . $this->lng->txt("answer_is_right") . '" /> ';
733  } else {
734  $img = ' <img src="' . ilUtil::getImagePath("icon_not_ok.svg") . '" alt="' . $this->lng->txt("answer_is_wrong") . '" title="' . $this->lng->txt("answer_is_wrong") . '" /> ';
735  }
736  }
737  }
738 
739  $items[$idx] = $this->getErrorTokenHtml($item, $class, $use_link_tags) . $img;
740  $counter++;
741  }
742  $textarray[$textidx] = '<p>' . implode(" ", $items) . '</p>';
743  }
744 
745  return implode("\n", $textarray);
746  }
getErrorText()
Get error text.
isTokenSelected($counter, array $selection)
getPointsForSelectedPositions($positions)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$text
Definition: errorreport.php:18
getErrorTokenHtml($item, $class, $useLinkTags)
+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

Definition at line 275 of file class.assErrorText.php.

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

276  {
277  if ($this->id <= 0) {
278  // The question has not been saved. It cannot be duplicated
279  return;
280  }
281 
282  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
283 
284  $sourceQuestionId = $this->id;
285  $sourceParentId = $this->getObjId();
286 
287  // duplicate the question in database
288  $clone = $this;
289  $clone->id = -1;
290 
291  $clone->setObjId($targetParentId);
292 
293  if ($targetQuestionTitle) {
294  $clone->setTitle($targetQuestionTitle);
295  }
296 
297  $clone->saveToDb();
298  // copy question page content
299  $clone->copyPageOfQuestion($sourceQuestionId);
300  // copy XHTML media objects
301  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
302 
303  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
304 
305  return $clone->id;
306  }
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ duplicate()

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

Duplicates the object.

Definition at line 197 of file class.assErrorText.php.

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

198  {
199  if ($this->id <= 0) {
200  // The question has not been saved. It cannot be duplicated
201  return;
202  }
203  // duplicate the question in database
204  $this_id = $this->getId();
205  $thisObjId = $this->getObjId();
206 
207  $clone = $this;
208  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
210  $clone->id = -1;
211 
212  if ((int) $testObjId > 0) {
213  $clone->setObjId($testObjId);
214  }
215 
216  if ($title) {
217  $clone->setTitle($title);
218  }
219 
220  if ($author) {
221  $clone->setAuthor($author);
222  }
223  if ($owner) {
224  $clone->setOwner($owner);
225  }
226 
227  if ($for_test) {
228  $clone->saveToDb($original_id);
229  } else {
230  $clone->saveToDb();
231  }
232  // copy question page content
233  $clone->copyPageOfQuestion($this_id);
234  // copy XHTML media objects
235  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
236 
237  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
238  return $clone->id;
239  }
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:

◆ flushErrorData()

assErrorText::flushErrorData ( )

Flush error data.

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

970  {
971  $this->errordata = array();
972  }

◆ fromXML()

assErrorText::fromXML ( $item,
$questionpool_id,
$tst_id,
$tst_object,
$question_counter,
$import_mapping 
)

Creates a question from a QTI file.

Receives parameters from a QTI parser and creates a valid ILIAS question object

Parameters
object$itemThe QTI item object
integer$questionpool_idThe id of the parent questionpool
integer$tst_idThe id of the parent test if the question is part of a test
object$tst_objectA reference to the parent test object
integer$question_counterA reference to a question counter to count the questions of an imported question pool
array$import_mappingAn array containing references to included ILIAS objects

Definition at line 499 of file class.assErrorText.php.

500  {
501  include_once "./Modules/TestQuestionPool/classes/import/qti12/class.assErrorTextImport.php";
502  $import = new assErrorTextImport($this);
503  $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
504  }
Class for error text question imports.

◆ getAdditionalTableName()

assErrorText::getAdditionalTableName ( )

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

Returns
string The additional table name

Definition at line 438 of file class.assErrorText.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

439  {
440  return "qpl_qst_errortext";
441  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assErrorText::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name

Definition at line 448 of file class.assErrorText.php.

449  {
450  return "qpl_a_errortext";
451  }

◆ getAvailableAnswerOptions()

assErrorText::getAvailableAnswerOptions (   $index = null)

If index is null, the function returns an array with all anwser options Else it returns the specific answer option.

Parameters
null | int$index
Returns
array|ASS_AnswerSimple

Implements iQuestionCondition.

Definition at line 1234 of file class.assErrorText.php.

References $index.

1235  {
1236  $error_text_array = explode(' ', $this->errortext);
1237 
1238  if ($index !== null) {
1239  if (array_key_exists($index, $error_text_array)) {
1240  return $error_text_array[$index];
1241  }
1242  return null;
1243  } else {
1244  return $error_text_array;
1245  }
1246  }
$index
Definition: metadata.php:60

◆ getBestSelection()

assErrorText::getBestSelection (   $withPositivePointsOnly = true)

Definition at line 816 of file class.assErrorText.php.

References assQuestion\$points, $text, getErrorText(), and getPointsWrong().

817  {
818  $passages = array();
819  $words = array();
820  $counter = 0;
821  $errorcounter = 0;
822  $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
823  foreach ($textarray as $textidx => $text) {
824  $items = preg_split("/\s+/", $text);
825  $inPassage = false;
826  foreach ($items as $word) {
827  $points = $this->getPointsWrong();
828  $isErrorItem = false;
829  if (strpos($word, '#') === 0) {
830  /* Word selection detected */
831  $errorobject = $this->errordata[$errorcounter];
832  if (is_object($errorobject)) {
833  $points = $errorobject->points;
834  $isErrorItem = true;
835  }
836  $errorcounter++;
837  } elseif (($posOpeningBracket = strpos($word, '((')) === 0
838  || ($posClosingBracket = strpos($word, '))')) !== false
839  || $inPassage) {
840  /* Passage selection detected */
841 
842  if ($posOpeningBracket !== false) {
843  $passages[] = array('begin_pos' => $counter, 'cnt_words' => 0);
844  $inPassage = true;
845  } elseif ($posClosingBracket !== false) {
846  $inPassage = false;
847  $cur_pidx = count($passages) - 1;
848  $passages[$cur_pidx]['end_pos'] = $counter;
849 
850  $errorobject = $this->errordata[$errorcounter];
851  if (is_object($errorobject)) {
852  $passages[$cur_pidx]['score'] = $errorobject->points;
853  $passages[$cur_pidx]['isError'] = true;
854  }
855 
856  $errorcounter++;
857  }
858 
859  $cur_pidx = count($passages) - 1;
860  $passages[$cur_pidx]['cnt_words']++;
861  $points = 0;
862  }
863 
864  $words[$counter] = array("word" => $word, "points" => $points, "isError" => $isErrorItem);
865  $counter++;
866  }
867  }
868 
869  $selections = array();
870  foreach ($passages as $cnt => $pdata) {
871  if (!$withPositivePointsOnly && $pdata['isError'] || $withPositivePointsOnly && $pdata['score'] > 0) {
872  $indexes = range($pdata['begin_pos'], $pdata['end_pos']);
873  $selections[$pdata['begin_pos']] = $indexes;
874  }
875  }
876 
877  foreach ($words as $idx => $word) {
878  if (!$withPositivePointsOnly && $word['isError'] || $withPositivePointsOnly && $word['points'] > 0) {
879  $selections[$idx] = array($idx);
880  }
881  }
882 
883  ksort($selections);
884 
885  $selections = array_values($selections);
886 
887  return $selections;
888  }
getErrorText()
Get error text.
getPointsWrong()
Get wrong points.
$text
Definition: errorreport.php:18
+ Here is the call graph for this function:

◆ getBestSolution()

assErrorText::getBestSolution (   $active_id,
  $pass 
)

Returns the best solution for a given pass of a participant.

Returns
array An associated array containing the best solution

Definition at line 524 of file class.assErrorText.php.

525  {
526  $user_solution = array();
527  return $user_solution;
528  }

◆ getErrorData()

assErrorText::getErrorData ( )

Get error data.

Returns
array Error data

Definition at line 985 of file class.assErrorText.php.

References $errordata.

Referenced by toJSON().

986  {
987  return $this->errordata;
988  }
+ Here is the caller graph for this function:

◆ getErrorsFromText()

assErrorText::getErrorsFromText (   $a_text = "")

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

References getErrorText().

531  {
532  if (strlen($a_text) == 0) {
533  $a_text = $this->getErrorText();
534  }
535 
536  /* Workaround to allow '(' and ')' in passages.
537  The beginning- and ending- Passage delimiters are
538  replaced by a ~ (Tilde) symbol. */
539  $a_text = str_replace(array("((", "))"), array("~", "~"), $a_text);
540 
541  /* Match either Passage delimited by double brackets
542  or single words marked with a hash (#). */
543  $r_passage = "/(~([^~]+)~|#([^\s]+))/";
544 
545  preg_match_all($r_passage, $a_text, $matches);
546 
547  if (is_array($matches[0]) && !empty($matches[0])) {
548  /* At least one match. */
549 
550  /* We need only groups 2 and 3, respectively representing
551  passage matches and single word matches. */
552  $matches = array_intersect_key($matches, array(2 => '', 3 => ''));
553 
554  /* Remove empty values. */
555  $matches[2] = array_diff($matches[2], array(''));
556  $matches[3] = array_diff($matches[3], array(''));
557 
558  return array(
559  "passages" => $matches[2],
560  "words" => $matches[3],);
561  }
562 
563  return array();
564  }
getErrorText()
Get error text.
+ Here is the call graph for this function:

◆ getErrorText()

assErrorText::getErrorText ( )

Get error text.

Returns
string Error text

Definition at line 995 of file class.assErrorText.php.

References $errortext.

Referenced by __get(), createErrorTextExport(), createErrorTextOutput(), getBestSelection(), getErrorsFromText(), getPointsForSelectedPositions(), saveAdditionalQuestionDataToDb(), and toJSON().

996  {
997  return $this->errortext;
998  }
+ Here is the caller graph for this function:

◆ getErrorTokenHtml()

assErrorText::getErrorTokenHtml (   $item,
  $class,
  $useLinkTags 
)
private
Parameters
$item
$class
Returns
string

Definition at line 1253 of file class.assErrorText.php.

References ilUtil\prepareFormOutput().

Referenced by createErrorTextOutput().

1254  {
1255  if ($useLinkTags) {
1256  return '<a class="' . $class . '" href="#">' . ($item == '&nbsp;' ? $item : ilUtil::prepareFormOutput($item)) . '</a>';
1257  }
1258 
1259  return '<span class="' . $class . '">' . ($item == '&nbsp;' ? $item : ilUtil::prepareFormOutput($item)) . '</span>';
1260  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExpressionTypes()

◆ getMaximumPoints()

assErrorText::getMaximumPoints ( )

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

See also
$points

Definition at line 313 of file class.assErrorText.php.

Referenced by getExpressionTypes(), and isComplete().

314  {
315  $maxpoints = 0.0;
316  foreach ($this->errordata as $object) {
317  if ($object->points > 0) {
318  $maxpoints += $object->points;
319  }
320  }
321  return $maxpoints;
322  }
+ Here is the caller graph for this function:

◆ getOperators()

assErrorText::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
string$expression

Implements iQuestionCondition.

Definition at line 1171 of file class.assErrorText.php.

References ilOperatorsExpressionMapping\getOperatorsByExpression().

1172  {
1173  require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1175  }
+ Here is the call graph for this function:

◆ getPointsForSelectedPositions()

assErrorText::getPointsForSelectedPositions (   $positions)
protected

Definition at line 890 of file class.assErrorText.php.

References $i, assQuestion\$points, $text, $total, getErrorText(), and getPointsWrong().

Referenced by calculateReachedPoints(), calculateReachedPointsFromPreviewSession(), and createErrorTextOutput().

891  {
892  $passages = array();
893  $words = array();
894  $counter = 0;
895  $errorcounter = 0;
896  $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
897  foreach ($textarray as $textidx => $text) {
898  $items = preg_split("/\s+/", $text);
899  $inPassage = false;
900  foreach ($items as $word) {
901  $points = $this->getPointsWrong();
902  if (strpos($word, '#') === 0) {
903  /* Word selection detected */
904  $errorobject = $this->errordata[$errorcounter];
905  if (is_object($errorobject)) {
906  $points = $errorobject->points;
907  }
908  $errorcounter++;
909  } elseif (($posOpeningBracket = strpos($word, '((')) === 0
910  || ($posClosingBracket = strpos($word, '))')) !== false
911  || $inPassage) {
912  /* Passage selection detected */
913 
914  if ($posOpeningBracket !== false) {
915  $passages[] = array('begin_pos' => $counter, 'cnt_words' => 0);
916  $inPassage = true;
917  } elseif ($posClosingBracket !== false) {
918  $inPassage = false;
919  $cur_pidx = count($passages) - 1;
920  $passages[$cur_pidx]['end_pos'] = $counter;
921 
922  $errorobject = $this->errordata[$errorcounter];
923  if (is_object($errorobject)) {
924  $passages[$cur_pidx]['score'] = $errorobject->points;
925  }
926  $errorcounter++;
927  }
928 
929  $cur_pidx = count($passages) - 1;
930  $passages[$cur_pidx]['cnt_words']++;
931  $points = 0;
932  }
933 
934  $words[$counter] = array("word" => $word, "points" => $points);
935  $counter++;
936  }
937  }
938 
939  /* Calculate reached points */
940  $total = 0;
941  foreach ($positions as $position) {
942  /* First iterate through positions
943  to identify single-word-selections. */
944 
945  $total += $words[$position]['points'];
946  }
947 
948  foreach ($passages as $cnt => $p_data) {
949  /* Iterate through configured passages to check
950  wether the entire passage is selected or not.
951  The total points is incremented by the passage's
952  score only if the entire passage is selected. */
953  $isSelected = in_array($p_data['begin_pos'], $positions);
954 
955  for ($i = 0; $i < $p_data['cnt_words']; $i++) {
956  $current_pos = $p_data['begin_pos'] + $i;
957  $isSelected = $isSelected && in_array($current_pos, $positions);
958  }
959 
960  $total += $isSelected ? $p_data['score'] : 0;
961  }
962 
963  return $total;
964  }
getErrorText()
Get error text.
$total
Definition: Utf8Test.php:87
getPointsWrong()
Get wrong points.
$text
Definition: errorreport.php:18
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPointsWrong()

assErrorText::getPointsWrong ( )

Get wrong points.

Returns
double Points for wrong selection

Definition at line 1039 of file class.assErrorText.php.

References $points_wrong.

Referenced by __get(), getBestSelection(), getPointsForSelectedPositions(), and saveAdditionalQuestionDataToDb().

1040  {
1041  return $this->points_wrong;
1042  }
+ Here is the caller graph for this function:

◆ getQuestionType()

assErrorText::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

Definition at line 428 of file class.assErrorText.php.

Referenced by toJSON().

429  {
430  return "assErrorText";
431  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assErrorText::getRTETextWithMediaObjects ( )

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

Definition at line 457 of file class.assErrorText.php.

References $text.

458  {
459  $text = parent::getRTETextWithMediaObjects();
460  return $text;
461  }
$text
Definition: errorreport.php:18

◆ getTextSize()

assErrorText::getTextSize ( )

Set text size in percent.

Returns
double Text size in percent

Definition at line 1015 of file class.assErrorText.php.

References $textsize.

Referenced by __get(), and saveAdditionalQuestionDataToDb().

1016  {
1017  return $this->textsize;
1018  }
+ Here is the caller graph for this function:

◆ isComplete()

assErrorText::isComplete ( )

Returns true, if a single choice question is complete for use.

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

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

References getMaximumPoints().

60  {
61  if (strlen($this->title)
62  && ($this->author)
63  && ($this->question)
64  && ($this->getMaximumPoints() > 0)) {
65  return true;
66  } else {
67  return false;
68  }
69  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ isTokenSelected()

assErrorText::isTokenSelected (   $counter,
array  $selection 
)
protected

Definition at line 748 of file class.assErrorText.php.

References $data.

Referenced by createErrorTextOutput().

749  {
750  foreach ($selection as $data) {
751  if (!is_array($data)) {
752  if ($counter == $data) {
753  return true;
754  }
755  } elseif (in_array($counter, $data)) {
756  return true;
757  }
758  }
759 
760  return false;
761  }
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

◆ loadFromDb()

assErrorText::loadFromDb (   $question_id)

Loads the object from the database.

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

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

References $data, $DIC, $ilDB, $result, ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), setErrorText(), assQuestion\setEstimatedWorkingTime(), assQuestion\setId(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), setPointsWrong(), assQuestion\setQuestion(), setTextSize(), and assQuestion\setTitle().

146  {
147  global $DIC;
148  $ilDB = $DIC['ilDB'];
149 
150  $result = $ilDB->queryF(
151  "SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s",
152  array("integer"),
153  array($question_id)
154  );
155  if ($result->numRows() == 1) {
156  $data = $ilDB->fetchAssoc($result);
157  $this->setId($question_id);
158  $this->setObjId($data["obj_fi"]);
159  $this->setTitle($data["title"]);
160  $this->setComment($data["description"]);
161  $this->setOriginalId($data["original_id"]);
162  $this->setNrOfTries($data['nr_of_tries']);
163  $this->setAuthor($data["author"]);
164  $this->setPoints($data["points"]);
165  $this->setOwner($data["owner"]);
166  include_once("./Services/RTE/classes/class.ilRTE.php");
167  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
168  $this->setErrorText($data["errortext"]);
169  $this->setTextSize($data["textsize"]);
170  $this->setPointsWrong($data["points_wrong"]);
171  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
172 
173  try {
174  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
175  } catch (ilTestQuestionPoolException $e) {
176  }
177  }
178 
179  $result = $ilDB->queryF(
180  "SELECT * FROM qpl_a_errortext WHERE question_fi = %s ORDER BY sequence ASC",
181  array('integer'),
182  array($question_id)
183  );
184  include_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
185  if ($result->numRows() > 0) {
186  while ($data = $ilDB->fetchAssoc($result)) {
187  array_push($this->errordata, new assAnswerErrorText($data["text_wrong"], $data["text_correct"], $data["points"]));
188  }
189  }
190 
191  parent::loadFromDb($question_id);
192  }
setTextSize($a_value)
Set text size in percent.
$result
global $DIC
Definition: saml.php:7
setId($id=-1)
Sets the id of the assQuestion object.
setErrorText($a_value)
Set error text.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second. ...
Class for error text answers.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this 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...
setAuthor($author="")
Sets the authors name of the assQuestion object.
setPointsWrong($a_value)
Set wrong points.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setPoints($a_points)
Sets the maximum available points for the question.
setQuestion($question="")
Sets the question string of the question object.
global $ilDB
setOriginalId($original_id)
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.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assErrorText::saveAdditionalQuestionDataToDb ( )

Saves the data for the additional data table.

This method uses the ugly DELETE-INSERT. Here, this does no harm.

Implements ilObjQuestionScoringAdjustable.

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

References $DIC, $ilDB, getAdditionalTableName(), getErrorText(), assQuestion\getId(), getPointsWrong(), and getTextSize().

Referenced by saveToDb().

117  {
118  global $DIC;
119  $ilDB = $DIC['ilDB'];
120  // save additional data
121  $ilDB->manipulateF(
122  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
123  array( "integer" ),
124  array( $this->getId() )
125  );
126 
127  $ilDB->manipulateF(
128  "INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, errortext, textsize, points_wrong) VALUES (%s, %s, %s, %s)",
129  array("integer", "text", "float", "float"),
130  array(
131  $this->getId(),
132  $this->getErrorText(),
133  $this->getTextSize(),
134  $this->getPointsWrong()
135  )
136  );
137  }
getErrorText()
Get error text.
getId()
Gets the id of the assQuestion object.
global $DIC
Definition: saml.php:7
getTextSize()
Set text size in percent.
getPointsWrong()
Get wrong points.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAnswerSpecificDataToDb()

assErrorText::saveAnswerSpecificDataToDb ( )

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

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

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

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

Referenced by saveToDb().

84  {
85  global $DIC;
86  $ilDB = $DIC['ilDB'];
87  $ilDB->manipulateF(
88  "DELETE FROM qpl_a_errortext WHERE question_fi = %s",
89  array( 'integer' ),
90  array( $this->getId() )
91  );
92 
93  $sequence = 0;
94  foreach ($this->errordata as $object) {
95  $next_id = $ilDB->nextId('qpl_a_errortext');
96  $ilDB->manipulateF(
97  "INSERT INTO qpl_a_errortext (answer_id, question_fi, text_wrong, text_correct, points, sequence) VALUES (%s, %s, %s, %s, %s, %s)",
98  array( 'integer', 'integer', 'text', 'text', 'float', 'integer' ),
99  array(
100  $next_id,
101  $this->getId(),
102  $object->text_wrong,
103  $object->text_correct,
104  $object->points,
105  $sequence++
106  )
107  );
108  }
109  }
getId()
Gets the id of the assQuestion object.
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePreviewData()

assErrorText::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)

Definition at line 412 of file class.assErrorText.php.

References $_POST, assQuestion\getId(), and ilAssQuestionPreviewSession\setParticipantsSolution().

413  {
414  if (strlen($_POST["qst_" . $this->getId()])) {
415  $selection = explode(',', $_POST["qst_{$this->getId()}"]);
416  } else {
417  $selection = array();
418  }
419 
420  $previewSession->setParticipantsSolution($selection);
421  }
getId()
Gets the id of the assQuestion object.
$_POST["username"]
+ Here is the call graph for this function:

◆ saveToDb()

assErrorText::saveToDb (   $original_id = "")

Saves a the object to the database.

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

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

76  {
80  parent::saveToDb();
81  }
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb($original_id="")
saveAdditionalQuestionDataToDb()
Saves the data for the additional data table.
+ Here is the call graph for this function:

◆ saveWorkingData()

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

Saves the learners input of the question to the database.

public

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

Definition at line 372 of file class.assErrorText.php.

References $_POST, $DIC, $ilDB, $ilUser, $pass, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), assQuestion\getId(), assQuestion\getProcessLocker(), assQuestion\logAction(), assQuestion\removeCurrentSolution(), and assQuestion\saveCurrentSolution().

373  {
374  global $DIC;
375  $ilDB = $DIC['ilDB'];
376  $ilUser = $DIC['ilUser'];
377 
378  if (is_null($pass)) {
379  include_once "./Modules/Test/classes/class.ilObjTest.php";
380  $pass = ilObjTest::_getPass($active_id);
381  }
382 
383  $entered_values = false;
384 
385  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $active_id, $pass, $authorized) {
386  $this->removeCurrentSolution($active_id, $pass, $authorized);
387 
388  if (strlen($_POST["qst_" . $this->getId()])) {
389  $selected = explode(",", $_POST["qst_" . $this->getId()]);
390  foreach ($selected as $position) {
391  $this->saveCurrentSolution($active_id, $pass, $position, null, $authorized);
392  }
393  $entered_values = true;
394  }
395  });
396 
397  if ($entered_values) {
398  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
400  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
401  }
402  } else {
403  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
405  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
406  }
407  }
408 
409  return true;
410  }
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getId()
Gets the id of the assQuestion object.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
global $DIC
Definition: saml.php:7
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
$ilUser
Definition: imgupload.php:18
removeCurrentSolution($active_id, $pass, $authorized=true)
global $ilDB
$_POST["username"]
+ Here is the call graph for this function:

◆ setErrorData()

assErrorText::setErrorData (   $a_data)

Definition at line 566 of file class.assErrorText.php.

References $errordata, $errors, and assQuestion\$points.

567  {
568  include_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
569  $temp = $this->errordata;
570  $this->errordata = array();
571  foreach ($a_data as $err_type => $errors) {
572  /* Iterate through error types (Passages|single words) */
573 
574  foreach ($errors as $idx => $error) {
575  /* Iterate through errors of this type. */
576  $text_correct = "";
577  $points = 0.0;
578  foreach ($temp as $object) {
579  if (strcmp($object->text_wrong, $error) == 0) {
580  $text_correct = $object->text_correct;
581  $points = $object->points;
582  continue;
583  }
584  }
585  $this->errordata[$idx] = new assAnswerErrorText($error, $text_correct, $points);
586  }
587  }
588  ksort($this->errordata);
589  }
Class for error text answers.
$errors
Definition: index.php:6

◆ setErrorText()

assErrorText::setErrorText (   $a_value)

Set error text.

Parameters
string$a_valueError text

Definition at line 1005 of file class.assErrorText.php.

Referenced by __set(), and loadFromDb().

1006  {
1007  $this->errortext = $a_value;
1008  }
+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

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

{}

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

References $errortext, $i, $pass, createErrorTextExport(), and assQuestion\getSolutionValues().

467  {
468  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
469 
470  $i = 0;
471  $selections = array();
472  $solutions = &$this->getSolutionValues($active_id, $pass);
473  if (is_array($solutions)) {
474  foreach ($solutions as $solution) {
475  array_push($selections, $solution['value1']);
476  }
477  $errortext_value = join(",", $selections);
478  }
479  $errortext = $this->createErrorTextExport($selections);
480  $i++;
481  $worksheet->setCell($startrow + $i, 0, $errortext);
482  $i++;
483 
484  return $startrow + $i + 1;
485  }
createErrorTextExport($selections=null)
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:

◆ setPointsWrong()

assErrorText::setPointsWrong (   $a_value)

Set wrong points.

Parameters
double$a_valuePoints for wrong selection

Definition at line 1049 of file class.assErrorText.php.

Referenced by __set(), and loadFromDb().

1050  {
1051  $this->points_wrong = $a_value;
1052  }
+ Here is the caller graph for this function:

◆ setTextSize()

assErrorText::setTextSize (   $a_value)

Set text size in percent.

Parameters
double$a_valuetext size in percent

Definition at line 1025 of file class.assErrorText.php.

Referenced by __set(), and loadFromDb().

1026  {
1027  // in self-assesment-mode value should always be set (and must not be null)
1028  if ($a_value === null) {
1029  $a_value = 100;
1030  }
1031  $this->textsize = $a_value;
1032  }
+ Here is the caller graph for this function:

◆ toJSON()

assErrorText::toJSON ( )

Returns a JSON representation of the question.

Definition at line 1100 of file class.assErrorText.php.

References $mobs, $result, $text, ilObjMediaObject\_getMobsOfObject(), ilRTE\_replaceMediaObjectImageSrc(), assQuestion\formatSAQuestion(), getErrorData(), getErrorText(), assQuestion\getId(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), assQuestion\getTitle(), and ilUtil\prepareFormOutput().

1101  {
1102  include_once("./Services/RTE/classes/class.ilRTE.php");
1103  $result = array();
1104  $result['id'] = (int) $this->getId();
1105  $result['type'] = (string) $this->getQuestionType();
1106  $result['title'] = (string) $this->getTitle();
1107  $result['question'] = $this->formatSAQuestion($this->getQuestion());
1108  $result['text'] = (string) ilRTE::_replaceMediaObjectImageSrc($this->getErrorText(), 0);
1109  $result['nr_of_tries'] = (int) $this->getNrOfTries();
1110  $result['shuffle'] = (bool) $this->getShuffle();
1111  $result['feedback'] = array(
1112  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1113  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1114  );
1115 
1116  $answers = array();
1117  foreach ($this->getErrorData() as $idx => $answer_obj) {
1118  array_push($answers, array(
1119  "answertext_wrong" => (string) $answer_obj->text_wrong,
1120  "answertext_correct" => (string) $answer_obj->text_correct,
1121  "points" => (float) $answer_obj->points,
1122  "order" => (int) $idx + 1
1123  ));
1124  }
1125  $result['correct_answers'] = $answers;
1126 
1127  $answers = array();
1128  $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
1129  foreach ($textarray as $textidx => $text) {
1130  $items = preg_split("/\s+/", trim($text));
1131  foreach ($items as $idx => $item) {
1132  if (substr($item, 0, 1) == "#") {
1133  $item = substr($item, 1);
1134 
1135  // #14115 - add position to correct answer
1136  foreach ($result["correct_answers"] as $aidx => $answer) {
1137  if ($answer["answertext_wrong"] == $item && !$answer["pos"]) {
1138  $result["correct_answers"][$aidx]["pos"] = $this->getId() . "_" . $textidx . "_" . ($idx + 1);
1139  break;
1140  }
1141  }
1142  }
1143  array_push($answers, array(
1144  "answertext" => (string) ilUtil::prepareFormOutput($item),
1145  "order" => $this->getId() . "_" . $textidx . "_" . ($idx + 1)
1146  ));
1147  }
1148  if ($textidx != sizeof($textarray) - 1) {
1149  array_push($answers, array(
1150  "answertext" => "###",
1151  "order" => $this->getId() . "_" . $textidx . "_" . ($idx + 2)
1152  ));
1153  }
1154  }
1155  $result['answers'] = $answers;
1156 
1157  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1158  $result['mobs'] = $mobs;
1159 
1160  return json_encode($result);
1161  }
getErrorText()
Get error text.
getId()
Gets the id of the assQuestion object.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getErrorData()
Get error data.
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
getQuestionType()
Returns the question type of the 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...
getShuffle()
Gets the shuffle flag.
$mobs
$text
Definition: errorreport.php:18
getQuestion()
Gets the question string of the question object.
getTitle()
Gets the title string of the assQuestion object.
+ Here is the call graph for this function:

◆ toXML()

assErrorText::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 and sets the internal domxml variable with the DOM XML representation of the QTI xml representation.

Returns
string The QTI xml representation of the question

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

513  {
514  include_once "./Modules/TestQuestionPool/classes/export/qti12/class.assErrorTextExport.php";
515  $export = new assErrorTextExport($this);
516  return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
517  }
Class for error text question exports.

Field Documentation

◆ $errordata

assErrorText::$errordata
protected

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

Referenced by getErrorData(), and setErrorData().

◆ $errortext

assErrorText::$errortext
protected

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

Referenced by getErrorText(), and setExportDetailsXLS().

◆ $points_wrong

assErrorText::$points_wrong
protected

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

Referenced by getPointsWrong().

◆ $textsize

assErrorText::$textsize
protected

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

Referenced by getTextSize().


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