ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 
 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...
 
- 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

 reworkWorkingData ($active_id, $pass, $obligationsAnswered, $authorized)
 {} More...
 
 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)
 
 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...
 

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, assQuestion\$title, and array.

47  {
48  parent::__construct($title, $comment, $author, $owner, $question);
49  $this->errortext = '';
50  $this->textsize = 100.0;
51  $this->errordata = array();
52  }
Create styles array
The data for the language used.

Member Function Documentation

◆ __get()

assErrorText::__get (   $value)

Object getter.

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

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

1061  {
1062  switch ($value) {
1063  case "errortext":
1064  return $this->getErrorText();
1065  break;
1066  case "textsize":
1067  return $this->getTextSize();
1068  break;
1069  case "points_wrong":
1070  return $this->getPointsWrong();
1071  break;
1072  default:
1073  return parent::__get($value);
1074  break;
1075  }
1076  }
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 1081 of file class.assErrorText.php.

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

1082  {
1083  switch ($key) {
1084  case "errortext":
1085  $this->setErrorText($value);
1086  break;
1087  case "textsize":
1088  $this->setTextSize($value);
1089  break;
1090  case "points_wrong":
1091  $this->setPointsWrong($value);
1092  break;
1093  default:
1094  parent::__set($key, $value);
1095  break;
1096  }
1097  }
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 977 of file class.assErrorText.php.

References assQuestion\$points.

978  {
979  include_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
980  array_push($this->errordata, new assAnswerErrorText($text_wrong, $text_correct, $points));
981  }
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 331 of file class.assErrorText.php.

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

Referenced by getExpressionTypes().

332  {
333  if ($returndetails) {
334  throw new ilTestException('return details not implemented for ' . __METHOD__);
335  }
336 
337  global $ilDB;
338 
339  /* First get the positions which were selected by the user. */
340  $positions = array();
341  if (is_null($pass)) {
342  $pass = $this->getSolutionMaxPass($active_id);
343  }
344  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
345 
346  while ($row = $ilDB->fetchAssoc($result)) {
347  array_push($positions, $row['value1']);
348  }
349  $points = $this->getPointsForSelectedPositions($positions);
350  return $points;
351  }
$result
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
getPointsForSelectedPositions($positions)
Create styles array
The data for the language used.
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 353 of file class.assErrorText.php.

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

354  {
355  $reachedPoints = $this->getPointsForSelectedPositions($previewSession->getParticipantsSolution());
356  $reachedPoints = $this->deductHintPointsFromReachedPoints($previewSession, $reachedPoints);
357  return $this->ensureNonNegativePoints($reachedPoints);
358  }
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 241 of file class.assErrorText.php.

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

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

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

Referenced by setExportDetailsXLS().

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

◆ createErrorTextOutput()

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

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

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

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

◆ createNewOriginalFromThisDuplicate()

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

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

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

273  {
274  if ($this->id <= 0) {
275  // The question has not been saved. It cannot be duplicated
276  return;
277  }
278 
279  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
280 
281  $sourceQuestionId = $this->id;
282  $sourceParentId = $this->getObjId();
283 
284  // duplicate the question in database
285  $clone = $this;
286  $clone->id = -1;
287 
288  $clone->setObjId($targetParentId);
289 
290  if ($targetQuestionTitle) {
291  $clone->setTitle($targetQuestionTitle);
292  }
293 
294  $clone->saveToDb();
295  // copy question page content
296  $clone->copyPageOfQuestion($sourceQuestionId);
297  // copy XHTML media objects
298  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
299 
300  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
301 
302  return $clone->id;
303  }
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 194 of file class.assErrorText.php.

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

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

References array.

973  {
974  $this->errordata = array();
975  }
Create styles array
The data for the language used.

◆ 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 502 of file class.assErrorText.php.

503  {
504  include_once "./Modules/TestQuestionPool/classes/import/qti12/class.assErrorTextImport.php";
505  $import = new assErrorTextImport($this);
506  $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
507  }
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 441 of file class.assErrorText.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

442  {
443  return "qpl_qst_errortext";
444  }
+ 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 451 of file class.assErrorText.php.

452  {
453  return "qpl_a_errortext";
454  }

◆ 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 1236 of file class.assErrorText.php.

References $index.

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

◆ getBestSelection()

assErrorText::getBestSelection (   $withPositivePointsOnly = true)

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

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

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

References array.

528  {
529  $user_solution = array();
530  return $user_solution;
531  }
Create styles array
The data for the language used.

◆ getErrorData()

assErrorText::getErrorData ( )

Get error data.

Returns
array Error data

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

References $errordata.

Referenced by toJSON().

989  {
990  return $this->errordata;
991  }
+ Here is the caller graph for this function:

◆ getErrorsFromText()

assErrorText::getErrorsFromText (   $a_text = "")

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

References array, and getErrorText().

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

◆ getErrorText()

assErrorText::getErrorText ( )

Get error text.

Returns
string Error text

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

References $errortext.

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

999  {
1000  return $this->errortext;
1001  }
+ Here is the caller graph for this function:

◆ getErrorTokenHtml()

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

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

References ilUtil\prepareFormOutput().

Referenced by createErrorTextOutput().

1256  {
1257  if ($useLinkTags) {
1258  return '<a class="' . $class . '" href="#">' . ($item == '&nbsp;' ? $item : ilUtil::prepareFormOutput($item)) . '</a>';
1259  }
1260 
1261  return '<span class="' . $class . '">' . ($item == '&nbsp;' ? $item : ilUtil::prepareFormOutput($item)) . '</span>';
1262  }
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 310 of file class.assErrorText.php.

Referenced by getExpressionTypes(), and isComplete().

311  {
312  $maxpoints = 0.0;
313  foreach ($this->errordata as $object) {
314  if ($object->points > 0) {
315  $maxpoints += $object->points;
316  }
317  }
318  return $maxpoints;
319  }
+ 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 1174 of file class.assErrorText.php.

References ilOperatorsExpressionMapping\getOperatorsByExpression().

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

◆ getPointsForSelectedPositions()

assErrorText::getPointsForSelectedPositions (   $positions)
protected

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

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

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

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

References $points_wrong.

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

1043  {
1044  return $this->points_wrong;
1045  }
+ 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 431 of file class.assErrorText.php.

Referenced by toJSON().

432  {
433  return "assErrorText";
434  }
+ 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 460 of file class.assErrorText.php.

References $text.

461  {
462  $text = parent::getRTETextWithMediaObjects();
463  return $text;
464  }
$text
Definition: errorreport.php:18

◆ getTextSize()

assErrorText::getTextSize ( )

Set text size in percent.

Returns
double Text size in percent

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

References $textsize.

Referenced by __get(), and saveAdditionalQuestionDataToDb().

1019  {
1020  return $this->textsize;
1021  }
+ 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 751 of file class.assErrorText.php.

References $counter, and $data.

Referenced by createErrorTextOutput().

752  {
753  foreach ($selection as $data) {
754  if (!is_array($data)) {
755  if ($counter == $data) {
756  return true;
757  }
758  } elseif (in_array($counter, $data)) {
759  return true;
760  }
761  }
762 
763  return false;
764  }
$counter
+ 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 143 of file class.assErrorText.php.

References $data, $ilDB, $result, ilRTE\_replaceMediaObjectImageSrc(), array, 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().

144  {
145  global $ilDB;
146 
147  $result = $ilDB->queryF(
148  "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",
149  array("integer"),
150  array($question_id)
151  );
152  if ($result->numRows() == 1) {
153  $data = $ilDB->fetchAssoc($result);
154  $this->setId($question_id);
155  $this->setObjId($data["obj_fi"]);
156  $this->setTitle($data["title"]);
157  $this->setComment($data["description"]);
158  $this->setOriginalId($data["original_id"]);
159  $this->setNrOfTries($data['nr_of_tries']);
160  $this->setAuthor($data["author"]);
161  $this->setPoints($data["points"]);
162  $this->setOwner($data["owner"]);
163  include_once("./Services/RTE/classes/class.ilRTE.php");
164  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
165  $this->setErrorText($data["errortext"]);
166  $this->setTextSize($data["textsize"]);
167  $this->setPointsWrong($data["points_wrong"]);
168  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
169 
170  try {
171  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
172  } catch (ilTestQuestionPoolException $e) {
173  }
174  }
175 
176  $result = $ilDB->queryF(
177  "SELECT * FROM qpl_a_errortext WHERE question_fi = %s ORDER BY sequence ASC",
178  array('integer'),
179  array($question_id)
180  );
181  include_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
182  if ($result->numRows() > 0) {
183  while ($data = $ilDB->fetchAssoc($result)) {
184  array_push($this->errordata, new assAnswerErrorText($data["text_wrong"], $data["text_correct"], $data["points"]));
185  }
186  }
187 
188  parent::loadFromDb($question_id);
189  }
setTextSize($a_value)
Set text size in percent.
$result
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.
Create styles array
The data for the language used.
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.
+ Here is the call graph for this function:

◆ reworkWorkingData()

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

{}

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

422  {
423  // nothing to rework!
424  }

◆ 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 115 of file class.assErrorText.php.

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

Referenced by saveToDb().

116  {
117  global $ilDB;
118  // save additional data
119  $ilDB->manipulateF(
120  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
121  array( "integer" ),
122  array( $this->getId() )
123  );
124 
125  $ilDB->manipulateF(
126  "INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, errortext, textsize, points_wrong) VALUES (%s, %s, %s, %s)",
127  array("integer", "text", "float", "float"),
128  array(
129  $this->getId(),
130  $this->getErrorText(),
131  $this->getTextSize(),
132  $this->getPointsWrong()
133  )
134  );
135  }
getErrorText()
Get error text.
getId()
Gets the id of the assQuestion object.
getTextSize()
Set text size in percent.
getPointsWrong()
Get wrong points.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
Create styles array
The data for the language used.
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 $ilDB, array, and assQuestion\getId().

Referenced by saveToDb().

84  {
85  global $ilDB;
86  $ilDB->manipulateF(
87  "DELETE FROM qpl_a_errortext WHERE question_fi = %s",
88  array( 'integer' ),
89  array( $this->getId() )
90  );
91 
92  $sequence = 0;
93  foreach ($this->errordata as $object) {
94  $next_id = $ilDB->nextId('qpl_a_errortext');
95  $ilDB->manipulateF(
96  "INSERT INTO qpl_a_errortext (answer_id, question_fi, text_wrong, text_correct, points, sequence) VALUES (%s, %s, %s, %s, %s, %s)",
97  array( 'integer', 'integer', 'text', 'text', 'float', 'integer' ),
98  array(
99  $next_id,
100  $this->getId(),
101  $object->text_wrong,
102  $object->text_correct,
103  $object->points,
104  $sequence++
105  )
106  );
107  }
108  }
getId()
Gets the id of the assQuestion object.
Create styles array
The data for the language used.
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 407 of file class.assErrorText.php.

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

408  {
409  if (strlen($_POST["qst_" . $this->getId()])) {
410  $selection = explode(',', $_POST["qst_{$this->getId()}"]);
411  } else {
412  $selection = array();
413  }
414 
415  $previewSession->setParticipantsSolution($selection);
416  }
getId()
Gets the id of the assQuestion object.
Create styles array
The data for the language used.
$_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 368 of file class.assErrorText.php.

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

369  {
370  global $ilDB;
371  global $ilUser;
372 
373  if (is_null($pass)) {
374  include_once "./Modules/Test/classes/class.ilObjTest.php";
375  $pass = ilObjTest::_getPass($active_id);
376  }
377 
378  $entered_values = false;
379 
380  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $active_id, $pass, $authorized) {
381  $this->removeCurrentSolution($active_id, $pass, $authorized);
382 
383  if (strlen($_POST["qst_" . $this->getId()])) {
384  $selected = explode(",", $_POST["qst_" . $this->getId()]);
385  foreach ($selected as $position) {
386  $this->saveCurrentSolution($active_id, $pass, $position, null, $authorized);
387  }
388  $entered_values = true;
389  }
390  });
391 
392  if ($entered_values) {
393  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
395  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
396  }
397  } else {
398  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
400  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
401  }
402  }
403 
404  return true;
405  }
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.
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 569 of file class.assErrorText.php.

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

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

◆ setErrorText()

assErrorText::setErrorText (   $a_value)

Set error text.

Parameters
string$a_valueError text

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

Referenced by __set(), and loadFromDb().

1009  {
1010  $this->errortext = $a_value;
1011  }
+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

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

{}

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

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

470  {
471  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
472 
473  $i= 0;
474  $selections = array();
475  $solutions =&$this->getSolutionValues($active_id, $pass);
476  if (is_array($solutions)) {
477  foreach ($solutions as $solution) {
478  array_push($selections, $solution['value1']);
479  }
480  $errortext_value = join(",", $selections);
481  }
482  $errortext = $this->createErrorTextExport($selections);
483  $i++;
484  $worksheet->setCell($startrow+$i, 0, $errortext);
485  $i++;
486 
487  return $startrow + $i + 1;
488  }
$worksheet
createErrorTextExport($selections=null)
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
Create styles array
The data for the language used.
$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 1052 of file class.assErrorText.php.

Referenced by __set(), and loadFromDb().

1053  {
1054  $this->points_wrong = $a_value;
1055  }
+ 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 1028 of file class.assErrorText.php.

Referenced by __set(), and loadFromDb().

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

◆ toJSON()

assErrorText::toJSON ( )

Returns a JSON representation of the question.

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

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

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

516  {
517  include_once "./Modules/TestQuestionPool/classes/export/qti12/class.assErrorTextExport.php";
518  $export = new assErrorTextExport($this);
519  return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
520  }
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: