ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
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.

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

Member Function Documentation

◆ __get()

assErrorText::__get (   $value)

Object getter.

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

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

1154  {
1155  switch ($value)
1156  {
1157  case "errortext":
1158  return $this->getErrorText();
1159  break;
1160  case "textsize":
1161  return $this->getTextSize();
1162  break;
1163  case "points_wrong":
1164  return $this->getPointsWrong();
1165  break;
1166  default:
1167  return parent::__get($value);
1168  break;
1169  }
1170  }
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 1175 of file class.assErrorText.php.

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

1176  {
1177  switch ($key)
1178  {
1179  case "errortext":
1180  $this->setErrorText($value);
1181  break;
1182  case "textsize":
1183  $this->setTextSize($value);
1184  break;
1185  case "points_wrong":
1186  $this->setPointsWrong($value);
1187  break;
1188  default:
1189  parent::__set($key, $value);
1190  break;
1191  }
1192  }
setTextSize($a_value)
Set text size in percent.
setErrorText($a_value)
Set error text.
setPointsWrong($a_value)
Set wrong points.
+ Here is the call graph for this function:

◆ addErrorData()

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

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

References assQuestion\$points.

1070  {
1071  include_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
1072  array_push($this->errordata, new assAnswerErrorText($text_wrong, $text_correct, $points));
1073  }
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 347 of file class.assErrorText.php.

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

Referenced by getExpressionTypes().

348  {
349  if( $returndetails )
350  {
351  throw new ilTestException('return details not implemented for '.__METHOD__);
352  }
353 
354  global $ilDB;
355 
356  /* First get the positions which were selected by the user. */
357  $positions = array();
358  if (is_null($pass)) {
359  $pass = $this->getSolutionMaxPass($active_id);
360  }
361  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
362 
363  while ($row = $ilDB->fetchAssoc($result)) {
364  array_push($positions, $row['value1']);
365  }
366  $points = $this->getPointsForSelectedPositions($positions);
367  return $points;
368  }
$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 370 of file class.assErrorText.php.

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

371  {
372  $reachedPoints = $this->getPointsForSelectedPositions($previewSession->getParticipantsSolution());
373  $reachedPoints = $this->deductHintPointsFromReachedPoints($previewSession, $reachedPoints);
374  return $this->ensureNonNegativePoints($reachedPoints);
375  }
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 254 of file class.assErrorText.php.

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

255  {
256  if ($this->id <= 0)
257  {
258  // The question has not been saved. It cannot be duplicated
259  return;
260  }
261  // duplicate the question in database
262 
263  $thisId = $this->getId();
264  $thisObjId = $this->getObjId();
265 
266  $clone = $this;
267  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
269  $clone->id = -1;
270  $clone->setObjId($target_questionpool_id);
271  if ($title)
272  {
273  $clone->setTitle($title);
274  }
275  $clone->saveToDb();
276 
277  // copy question page content
278  $clone->copyPageOfQuestion($original_id);
279  // copy XHTML media objects
280  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
281 
282  $clone->onCopy($thisObjId, $thisId, $clone->getObjId(), $clone->getId());
283 
284  return $clone->id;
285  }
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 830 of file class.assErrorText.php.

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

Referenced by setExportDetailsXLS().

831  {
832  $counter = 0;
833  $errorcounter = 0;
834  include_once "./Services/Utilities/classes/class.ilStr.php";
835  if (!is_array($selections)) $selections = array();
836  $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
837  foreach ($textarray as $textidx => $text)
838  {
839  $items = preg_split("/\s+/", $text);
840  foreach ($items as $idx => $item)
841  {
842  if (($posHash = strpos($item, '#')) === 0
843  || ($posOpeningBrackets = strpos($item, '((')) === 0
844  || ($posClosingBrackets = strpos($item, '))')) !== false) {
845  /* (Word|Passage)-Marking delimiter found. */
846 
847  if ($posHash !== false)
848  $item = ilStr::substr($item, 1, ilStr::strlen($item) - 1);
849  elseif ($posOpeningBrackets !== false) {
850  $item = ilStr::substr($item, 2, ilStr::strlen($item) - 2);
851 
852  /* Sometimes a closing bracket group needs
853  to be removed as well. */
854  if (strpos($item, '))') !== false)
855  $item = ilStr::substr($item, 0, ilStr::strlen($item) - 2);
856  }
857  else{
858  $appendComma = "";
859  if ($item{$posClosingBrackets+2} == ',')
860  $appendComma = ",";
861 
862  $item = ilStr::substr($item, 0, $posClosingBrackets) . $appendComma;
863  }
864  }
865 
866  $word = "";
867  if (in_array($counter, $selections))
868  {
869  $word .= '#';
870  }
871  $word .= ilUtil::prepareFormOutput($item);
872  if (in_array($counter, $selections))
873  {
874  $word .= '#';
875  }
876  $items[$idx] = $word;
877  $counter++;
878  }
879  $textarray[$textidx] = join($items, " ");
880  }
881  return join($textarray, "\n");
882  }
getErrorText()
Get error text.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$counter
Create styles array
The data for the language used.
$text
+ 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 625 of file class.assErrorText.php.

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

626  {
627  $counter = 0;
628  $errorcounter = 0;
629  include_once "./Services/Utilities/classes/class.ilStr.php";
630  if (!is_array($selections)) $selections = array();
631  $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
632 
633  foreach ($textarray as $textidx => $text)
634  {
635  $in_passage = false;
636  $passage_end = false;
637  $items = preg_split("/\s+/", $text);
638  foreach ($items as $idx => $item)
639  {
640  $img = '';
641 
642  if(
643  ($posHash = strpos($item, '#')) === 0 ||
644  ($posOpeningBrackets = strpos($item, '((')) === 0 ||
645  ($posClosingBrackets = strpos($item, '))')) !== false
646  )
647  {
648  /* (Word|Passage)-Marking delimiter found. */
649 
650  if($posHash !== false)
651  {
652  $item = ilStr::substr($item, 1, ilStr::strlen($item) - 1);
653  $passage_end = false;
654  }
655  else if($posOpeningBrackets !== false)
656  {
657  $in_passage = true;
658  $passage_start_idx = $counter;
659  $items_in_passage = array();
660  $passage_end = false;
661  $item = ilStr::substr($item, 2, ilStr::strlen($item) - 2);
662 
663  /* Sometimes a closing bracket group needs
664  to be removed as well. */
665  if(strpos($item, '))') !== false)
666  {
667  $item = str_replace("))", "", $item);
668  $passage_end = true;
669  }
670  }
671  else
672  {
673  $passage_end = true;
674  $item = str_replace("))", "", $item);
675  }
676 
677  if($correct_solution && !$in_passage)
678  {
679  $errorobject = $this->errordata[$errorcounter];
680  if (is_object($errorobject) )
681  {
682  $item = strlen($errorobject->text_correct) ? $errorobject->text_correct : '&nbsp;';
683  }
684  $errorcounter++;
685  }
686  }
687 
688  if($in_passage && !$passage_end)
689  {
690  $items_in_passage[$idx] = $item;
691  $items[$idx] = '';
692  $counter++;
693  continue;
694  }
695 
696  if($in_passage && $passage_end)
697  {
698  $in_passage = false;
699  $passage_end = false;
700  if($correct_solution)
701  {
702  $class = ( $this->isTokenSelected($counter, $selections) ?
703  "ilc_qetitem_ErrorTextSelected" : "ilc_qetitem_ErrorTextItem"
704  );
705 
706  $errorobject = $this->errordata[$errorcounter];
707  if (is_object($errorobject) )
708  {
709  $item = strlen($errorobject->text_correct) ? $errorobject->text_correct : '&nbsp;';
710  }
711  $errorcounter++;
712  $items[$idx] = $this->getErrorTokenHtml($item, $class, $use_link_tags) . $img;
713  $counter++;
714  continue;
715  }
716 
717  $group_selected = true;
718  if($graphicalOutput)
719  {
720  $start_idx = $passage_start_idx;
721  foreach($items_in_passage as $tmp_idx => $tmp_item)
722  {
723  if(!$this->isTokenSelected($start_idx, $selections))
724  {
725  $group_selected = false;
726  break;
727  }
728 
729  ++$start_idx;
730  }
731  if($group_selected)
732  {
733  if(!$this->isTokenSelected($counter, $selections))
734  {
735  $group_selected = false;
736  }
737  }
738  }
739 
740  $item_stack = array();
741  $start_idx = $passage_start_idx;
742  foreach($items_in_passage as $tmp_idx => $tmp_item)
743  {
744  $class = ( $this->isTokenSelected($counter, $selections) ?
745  "ilc_qetitem_ErrorTextSelected" : "ilc_qetitem_ErrorTextItem"
746  );
747  $item_stack[] = $this->getErrorTokenHtml($tmp_item, $class, $use_link_tags) . $img;
748  $start_idx++;
749  }
750  $class = ( $this->isTokenSelected($counter, $selections) ?
751  "ilc_qetitem_ErrorTextSelected" : "ilc_qetitem_ErrorTextItem"
752  );
753  if($graphicalOutput)
754  {
755  if ($group_selected)
756  {
757  $img = ' <img src="' . ilUtil::getImagePath("icon_ok.svg") . '" alt="' . $this->lng->txt("answer_is_right") . '" title="' . $this->lng->txt("answer_is_right") . '" /> ';
758  }
759  else
760  {
761  $img = ' <img src="' . ilUtil::getImagePath("icon_not_ok.svg") . '" alt="' . $this->lng->txt("answer_is_wrong") . '" title="' . $this->lng->txt("answer_is_wrong") . '" /> ';
762  }
763  }
764 
765  $item_stack[] = $this->getErrorTokenHtml($item, $class, $use_link_tags) . $img;
766  $item_stack = trim(implode(" ", $item_stack));
767  $item_stack = strlen($item_stack) ? $item_stack : '&nbsp;';
768 
769  if($graphicalOutput)
770  {
771  $items[$idx] = '<span class="selGroup">'.$item_stack.'</span>';
772  }
773  else
774  {
775  $items[$idx] = $item_stack;
776  }
777 
778  $counter++;
779  continue;
780  }
781 
782  // Errors markes with #, group errors (()) are handled above
783  $class = 'ilc_qetitem_ErrorTextItem';
784  $img = '';
785  if($this->isTokenSelected($counter, $selections))
786  {
787  $class = "ilc_qetitem_ErrorTextSelected";
788  if($graphicalOutput)
789  {
791  {
792  $img = ' <img src="' . ilUtil::getImagePath("icon_ok.svg") . '" alt="' . $this->lng->txt("answer_is_right") . '" title="' . $this->lng->txt("answer_is_right") . '" /> ';
793  }
794  else
795  {
796  $img = ' <img src="' . ilUtil::getImagePath("icon_not_ok.svg") . '" alt="' . $this->lng->txt("answer_is_wrong") . '" title="' . $this->lng->txt("answer_is_wrong") . '" /> ';
797  }
798  }
799  }
800 
801  $items[$idx] = $this->getErrorTokenHtml($item, $class, $use_link_tags) . $img;
802  $counter++;
803  }
804  $textarray[$textidx] = '<p>' . implode(" ", $items) . '</p>';
805  }
806 
807  return implode("\n", $textarray);
808  }
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)
Create styles array
The data for the language used.
$text
getErrorTokenHtml($item, $class, $useLinkTags)
+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

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

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

288  {
289  if ($this->id <= 0)
290  {
291  // The question has not been saved. It cannot be duplicated
292  return;
293  }
294 
295  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
296 
297  $sourceQuestionId = $this->id;
298  $sourceParentId = $this->getObjId();
299 
300  // duplicate the question in database
301  $clone = $this;
302  $clone->id = -1;
303 
304  $clone->setObjId($targetParentId);
305 
306  if ($targetQuestionTitle)
307  {
308  $clone->setTitle($targetQuestionTitle);
309  }
310 
311  $clone->saveToDb();
312  // copy question page content
313  $clone->copyPageOfQuestion($sourceQuestionId);
314  // copy XHTML media objects
315  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
316 
317  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
318 
319  return $clone->id;
320  }
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 199 of file class.assErrorText.php.

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

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

References array.

1065  {
1066  $this->errordata = array();
1067  }
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 534 of file class.assErrorText.php.

535  {
536  include_once "./Modules/TestQuestionPool/classes/import/qti12/class.assErrorTextImport.php";
537  $import = new assErrorTextImport($this);
538  $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
539  }
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 471 of file class.assErrorText.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

472  {
473  return "qpl_qst_errortext";
474  }
+ 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 481 of file class.assErrorText.php.

482  {
483  return "qpl_a_errortext";
484  }

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

1340  {
1341  $error_text_array = explode(' ', $this->errortext);
1342 
1343  if($index !== null)
1344  {
1345  if(array_key_exists($index, $error_text_array))
1346  {
1347  return $error_text_array[$index];
1348  }
1349  return null;
1350  }
1351  else
1352  {
1353  return $error_text_array;
1354  }
1355  }

◆ getBestSelection()

assErrorText::getBestSelection (   $withPositivePointsOnly = true)

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

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

885  {
886  $passages = array();
887  $words = array();
888  $counter = 0;
889  $errorcounter = 0;
890  $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
891  foreach ($textarray as $textidx => $text)
892  {
893  $items = preg_split("/\s+/", $text);
894  $inPassage = false;
895  foreach ($items as $word)
896  {
897  $points = $this->getPointsWrong();
898  $isErrorItem = false;
899  if (strpos($word, '#') === 0)
900  {
901  /* Word selection detected */
902  $errorobject = $this->errordata[$errorcounter];
903  if (is_object($errorobject))
904  {
905  $points = $errorobject->points;
906  $isErrorItem = true;
907  }
908  $errorcounter++;
909  }
910  elseif (($posOpeningBracket = strpos($word, '((')) === 0
911  || ($posClosingBracket = strpos($word, '))')) !== false
912  || $inPassage)
913  {
914  /* Passage selection detected */
915 
916  if ($posOpeningBracket !== false)
917  {
918  $passages[] = array('begin_pos' => $counter, 'cnt_words' => 0);
919  $inPassage = true;
920  }
921  elseif ($posClosingBracket !== false)
922  {
923  $inPassage = false;
924  $cur_pidx = count($passages) - 1;
925  $passages[$cur_pidx]['end_pos'] = $counter;
926 
927  $errorobject = $this->errordata[$errorcounter];
928  if (is_object($errorobject))
929  {
930  $passages[$cur_pidx]['score'] = $errorobject->points;
931  $passages[$cur_pidx]['isError'] = true;
932  }
933 
934  $errorcounter++;
935  }
936 
937  $cur_pidx = count($passages) - 1;
938  $passages[$cur_pidx]['cnt_words']++;
939  $points = 0;
940  }
941 
942  $words[$counter] = array("word" => $word, "points" => $points, "isError" => $isErrorItem);
943  $counter++;
944  }
945  }
946 
947  $selections = array();
948  foreach ($passages as $cnt => $pdata)
949  {
950  if (!$withPositivePointsOnly && $pdata['isError'] || $withPositivePointsOnly && $pdata['score'] > 0)
951  {
952  $indexes = range($pdata['begin_pos'], $pdata['end_pos']);
953  $selections[$pdata['begin_pos']] = $indexes;
954  }
955  }
956 
957  foreach ($words as $idx => $word)
958  {
959  if (!$withPositivePointsOnly && $word['isError'] || $withPositivePointsOnly && $word['points'] > 0)
960  {
961  $selections[$idx] = array($idx);
962  }
963  }
964 
965  ksort($selections);
966 
967  $selections = array_values($selections);
968 
969  return $selections;
970  }
getErrorText()
Get error text.
Resolve range
getPointsWrong()
Get wrong points.
$counter
Create styles array
The data for the language used.
$text
+ 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 559 of file class.assErrorText.php.

References array.

560  {
561  $user_solution = array();
562  return $user_solution;
563  }
Create styles array
The data for the language used.

◆ getErrorData()

assErrorText::getErrorData ( )

Get error data.

Returns
array Error data

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

References $errordata.

Referenced by toJSON().

1081  {
1082  return $this->errordata;
1083  }
+ Here is the caller graph for this function:

◆ getErrorsFromText()

assErrorText::getErrorsFromText (   $a_text = "")

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

References array, and getErrorText().

566  {
567  if (strlen($a_text) == 0)
568  $a_text = $this->getErrorText();
569 
570  /* Workaround to allow '(' and ')' in passages.
571  The beginning- and ending- Passage delimiters are
572  replaced by a ~ (Tilde) symbol. */
573  $a_text = str_replace(array("((", "))"), array("~", "~"), $a_text);
574 
575  /* Match either Passage delimited by double brackets
576  or single words marked with a hash (#). */
577  $r_passage = "/(~([^~]+)~|#([^\s]+))/";
578 
579  preg_match_all($r_passage, $a_text, $matches);
580 
581  if (is_array($matches[0]) && !empty($matches[0])) {
582  /* At least one match. */
583 
584  /* We need only groups 2 and 3, respectively representing
585  passage matches and single word matches. */
586  $matches = array_intersect_key($matches, array(2 => '', 3 => ''));
587 
588  /* Remove empty values. */
589  $matches[2] = array_diff($matches[2], array(''));
590  $matches[3] = array_diff($matches[3], array(''));
591 
592  return array(
593  "passages" => $matches[2],
594  "words" => $matches[3],);
595  }
596 
597  return array();
598  }
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 1090 of file class.assErrorText.php.

References $errortext.

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

1091  {
1092  return $this->errortext;
1093  }
+ Here is the caller graph for this function:

◆ getErrorTokenHtml()

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

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

References ilUtil\prepareFormOutput().

Referenced by createErrorTextOutput().

1363  {
1364  if($useLinkTags)
1365  {
1366  return '<a class="' . $class . '" href="#">' . ($item == '&nbsp;' ? $item : ilUtil::prepareFormOutput($item)) . '</a>';
1367  }
1368 
1369  return '<span class="' . $class . '">' . ($item == '&nbsp;' ? $item : ilUtil::prepareFormOutput($item)) . '</span>';
1370  }
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 327 of file class.assErrorText.php.

Referenced by getExpressionTypes(), and isComplete().

328  {
329  $maxpoints = 0.0;
330  foreach ($this->errordata as $object)
331  {
332  if ($object->points > 0) $maxpoints += $object->points;
333  }
334  return $maxpoints;
335  }
+ 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 1276 of file class.assErrorText.php.

References ilOperatorsExpressionMapping\getOperatorsByExpression().

1277  {
1278  require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1280  }
+ Here is the call graph for this function:

◆ getPointsForSelectedPositions()

assErrorText::getPointsForSelectedPositions (   $positions)
protected

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

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

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

973  {
974  $passages = array();
975  $words = array();
976  $counter = 0;
977  $errorcounter = 0;
978  $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
979  foreach ($textarray as $textidx => $text)
980  {
981  $items = preg_split("/\s+/", $text);
982  $inPassage = false;
983  foreach ($items as $word)
984  {
985  $points = $this->getPointsWrong();
986  if (strpos($word, '#') === 0)
987  {
988  /* Word selection detected */
989  $errorobject = $this->errordata[$errorcounter];
990  if (is_object($errorobject))
991  {
992  $points = $errorobject->points;
993  }
994  $errorcounter++;
995  }
996  elseif (($posOpeningBracket = strpos($word, '((')) === 0
997  || ($posClosingBracket = strpos($word, '))')) !== false
998  || $inPassage)
999  {
1000  /* Passage selection detected */
1001 
1002  if ($posOpeningBracket !== false)
1003  {
1004  $passages[] = array('begin_pos' => $counter, 'cnt_words' => 0);
1005  $inPassage = true;
1006  }
1007  elseif ($posClosingBracket !== false)
1008  {
1009  $inPassage = false;
1010  $cur_pidx = count($passages) - 1;
1011  $passages[$cur_pidx]['end_pos'] = $counter;
1012 
1013  $errorobject = $this->errordata[$errorcounter];
1014  if (is_object($errorobject))
1015  {
1016  $passages[$cur_pidx]['score'] = $errorobject->points;
1017  }
1018  $errorcounter++;
1019  }
1020 
1021  $cur_pidx = count($passages) - 1;
1022  $passages[$cur_pidx]['cnt_words']++;
1023  $points = 0;
1024  }
1025 
1026  $words[$counter] = array("word" => $word, "points" => $points);
1027  $counter++;
1028  }
1029  }
1030 
1031  /* Calculate reached points */
1032  $total = 0;
1033  foreach ($positions as $position)
1034  {
1035  /* First iterate through positions
1036  to identify single-word-selections. */
1037 
1038  $total += $words[$position]['points'];
1039  }
1040 
1041  foreach ($passages as $cnt => $p_data)
1042  {
1043  /* Iterate through configured passages to check
1044  wether the entire passage is selected or not.
1045  The total points is incremented by the passage's
1046  score only if the entire passage is selected. */
1047  $isSelected = in_array($p_data['begin_pos'], $positions);
1048 
1049  for ($i = 0; $i < $p_data['cnt_words']; $i++)
1050  {
1051  $current_pos = $p_data['begin_pos'] + $i;
1052  $isSelected = $isSelected && in_array($current_pos, $positions);
1053  }
1054 
1055  $total += $isSelected ? $p_data['score'] : 0;
1056  }
1057 
1058  return $total;
1059  }
getErrorText()
Get error text.
$total
Definition: Utf8Test.php:87
getPointsWrong()
Get wrong points.
$counter
Create styles array
The data for the language used.
$text
+ 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 1135 of file class.assErrorText.php.

References $points_wrong.

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

1136  {
1137  return $this->points_wrong;
1138  }
+ 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 461 of file class.assErrorText.php.

Referenced by toJSON().

462  {
463  return "assErrorText";
464  }
+ 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 490 of file class.assErrorText.php.

References $text.

491  {
492  $text = parent::getRTETextWithMediaObjects();
493  return $text;
494  }
$text

◆ getTextSize()

assErrorText::getTextSize ( )

Set text size in percent.

Returns
double Text size in percent

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

References $textsize.

Referenced by __get(), and saveAdditionalQuestionDataToDb().

1111  {
1112  return $this->textsize;
1113  }
+ 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 60 of file class.assErrorText.php.

References getMaximumPoints().

61  {
62  if (strlen($this->title)
63  && ($this->author)
64  && ($this->question)
65  && ($this->getMaximumPoints() > 0))
66  {
67  return true;
68  }
69  else
70  {
71  return false;
72  }
73  }
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 810 of file class.assErrorText.php.

References $counter, and $data.

Referenced by createErrorTextOutput().

811  {
812  foreach($selection as $data)
813  {
814  if( !is_array($data) )
815  {
816  if($counter == $data)
817  {
818  return true;
819  }
820  }
821  elseif( in_array($counter, $data) )
822  {
823  return true;
824  }
825  }
826 
827  return false;
828  }
$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 144 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().

145  {
146  global $ilDB;
147 
148  $result = $ilDB->queryF("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  {
154  $data = $ilDB->fetchAssoc($result);
155  $this->setId($question_id);
156  $this->setObjId($data["obj_fi"]);
157  $this->setTitle($data["title"]);
158  $this->setComment($data["description"]);
159  $this->setOriginalId($data["original_id"]);
160  $this->setNrOfTries($data['nr_of_tries']);
161  $this->setAuthor($data["author"]);
162  $this->setPoints($data["points"]);
163  $this->setOwner($data["owner"]);
164  include_once("./Services/RTE/classes/class.ilRTE.php");
165  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
166  $this->setErrorText($data["errortext"]);
167  $this->setTextSize($data["textsize"]);
168  $this->setPointsWrong($data["points_wrong"]);
169  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
170 
171  try
172  {
173  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
174  }
176  {
177  }
178  }
179 
180  $result = $ilDB->queryF("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  {
187  while ($data = $ilDB->fetchAssoc($result))
188  {
189  array_push($this->errordata, new assAnswerErrorText($data["text_wrong"], $data["text_correct"], $data["points"]));
190  }
191  }
192 
193  parent::loadFromDb($question_id);
194  }
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 451 of file class.assErrorText.php.

452  {
453  // nothing to rework!
454  }

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

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

Referenced by saveToDb().

119  {
120  global $ilDB;
121  // save additional data
122  $ilDB->manipulateF( "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
123  array( "integer" ),
124  array( $this->getId() )
125  );
126 
127  $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, errortext, textsize, points_wrong) VALUES (%s, %s, %s, %s)",
128  array("integer", "text", "float", "float"),
129  array(
130  $this->getId(),
131  $this->getErrorText(),
132  $this->getTextSize(),
133  $this->getPointsWrong()
134  )
135  );
136  }
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 87 of file class.assErrorText.php.

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

Referenced by saveToDb().

88  {
89  global $ilDB;
90  $ilDB->manipulateF( "DELETE FROM qpl_a_errortext WHERE question_fi = %s",
91  array( 'integer' ),
92  array( $this->getId() )
93  );
94 
95  $sequence = 0;
96  foreach ($this->errordata as $object)
97  {
98  $next_id = $ilDB->nextId( 'qpl_a_errortext' );
99  $ilDB->manipulateF( "INSERT INTO qpl_a_errortext (answer_id, question_fi, text_wrong, text_correct, points, sequence) VALUES (%s, %s, %s, %s, %s, %s)",
100  array( 'integer', 'integer', 'text', 'text', 'float', 'integer' ),
101  array(
102  $next_id,
103  $this->getId(),
104  $object->text_wrong,
105  $object->text_correct,
106  $object->points,
107  $sequence++
108  )
109  );
110  }
111  }
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 434 of file class.assErrorText.php.

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

435  {
436  if( strlen($_POST["qst_" . $this->getId()]) )
437  {
438  $selection = explode(',', $_POST["qst_{$this->getId()}"]);
439  }
440  else
441  {
442  $selection = array();
443  }
444 
445  $previewSession->setParticipantsSolution($selection);
446  }
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 79 of file class.assErrorText.php.

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

80  {
84  parent::saveToDb();
85  }
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 385 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().

386  {
387  global $ilDB;
388  global $ilUser;
389 
390  if (is_null($pass))
391  {
392  include_once "./Modules/Test/classes/class.ilObjTest.php";
393  $pass = ilObjTest::_getPass($active_id);
394  }
395 
396  $entered_values = false;
397 
398  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function() use (&$entered_values, $active_id, $pass, $authorized) {
399 
400  $this->removeCurrentSolution($active_id, $pass, $authorized);
401 
402  if(strlen($_POST["qst_" . $this->getId()]))
403  {
404  $selected = explode(",", $_POST["qst_" . $this->getId()]);
405  foreach ($selected as $position)
406  {
407  $this->saveCurrentSolution($active_id, $pass, $position, null, $authorized);
408  }
409  $entered_values = true;
410  }
411 
412  });
413 
414  if ($entered_values)
415  {
416  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
418  {
419  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
420  }
421  }
422  else
423  {
424  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
426  {
427  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
428  }
429  }
430 
431  return true;
432  }
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 600 of file class.assErrorText.php.

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

601  {
602  include_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
603  $temp = $this->errordata;
604  $this->errordata = array();
605  foreach ($a_data as $err_type => $errors) {
606  /* Iterate through error types (Passages|single words) */
607 
608  foreach ($errors as $idx => $error) {
609  /* Iterate through errors of this type. */
610  $text_correct = "";
611  $points = 0.0;
612  foreach ($temp as $object) {
613  if (strcmp($object->text_wrong, $error) == 0) {
614  $text_correct = $object->text_correct;
615  $points = $object->points;
616  continue;
617  }
618  }
619  $this->errordata[$idx] = new assAnswerErrorText($error, $text_correct, $points);
620  }
621  }
622  ksort($this->errordata);
623  }
$error
Definition: Error.php:17
Class for error text answers.
Create styles array
The data for the language used.
$errors

◆ setErrorText()

assErrorText::setErrorText (   $a_value)

Set error text.

Parameters
string$a_valueError text

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

Referenced by __set(), and loadFromDb().

1101  {
1102  $this->errortext = $a_value;
1103  }
+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

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

{}

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

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

500  {
501  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
502 
503  $i= 0;
504  $selections = array();
505  $solutions =& $this->getSolutionValues($active_id, $pass);
506  if (is_array($solutions))
507  {
508  foreach ($solutions as $solution)
509  {
510  array_push($selections, $solution['value1']);
511  }
512  $errortext_value = join(",", $selections);
513  }
514  $errortext = $this->createErrorTextExport($selections);
515  $i++;
516  $worksheet->setCell($startrow+$i, 0, $errortext);
517  $i++;
518 
519  return $startrow + $i + 1;
520  }
$worksheet
createErrorTextExport($selections=null)
Create styles array
The data for the language used.
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
+ 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 1145 of file class.assErrorText.php.

Referenced by __set(), and loadFromDb().

1146  {
1147  $this->points_wrong = $a_value;
1148  }
+ 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 1120 of file class.assErrorText.php.

Referenced by __set(), and loadFromDb().

1121  {
1122  // in self-assesment-mode value should always be set (and must not be null)
1123  if($a_value === null)
1124  {
1125  $a_value = 100;
1126  }
1127  $this->textsize = $a_value;
1128  }
+ Here is the caller graph for this function:

◆ toJSON()

assErrorText::toJSON ( )

Returns a JSON representation of the question.

Definition at line 1198 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.

1199  {
1200  include_once("./Services/RTE/classes/class.ilRTE.php");
1201  $result = array();
1202  $result['id'] = (int) $this->getId();
1203  $result['type'] = (string) $this->getQuestionType();
1204  $result['title'] = (string) $this->getTitle();
1205  $result['question'] = $this->formatSAQuestion($this->getQuestion());
1207  $result['nr_of_tries'] = (int) $this->getNrOfTries();
1208  $result['shuffle'] = (bool) $this->getShuffle();
1209  $result['feedback'] = array(
1210  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1211  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1212  );
1213 
1214  $answers = array();
1215  foreach ($this->getErrorData() as $idx => $answer_obj)
1216  {
1217  array_push($answers, array(
1218  "answertext_wrong" => (string) $answer_obj->text_wrong,
1219  "answertext_correct" => (string) $answer_obj->text_correct,
1220  "points" => (float)$answer_obj->points,
1221  "order" => (int)$idx+1
1222  ));
1223  }
1224  $result['correct_answers'] = $answers;
1225 
1226  $answers = array();
1227  $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
1228  foreach ($textarray as $textidx => $text)
1229  {
1230  $items = preg_split("/\s+/", trim($text));
1231  foreach ($items as $idx => $item)
1232  {
1233  if(substr($item, 0, 1) == "#")
1234  {
1235  $item = substr($item, 1);
1236 
1237  // #14115 - add position to correct answer
1238  foreach($result["correct_answers"] as $aidx => $answer)
1239  {
1240  if($answer["answertext_wrong"] == $item && !$answer["pos"])
1241  {
1242  $result["correct_answers"][$aidx]["pos"] = $this->getId()."_".$textidx."_".($idx+1);
1243  break;
1244  }
1245  }
1246  }
1247  array_push($answers, array(
1248  "answertext" => (string) ilUtil::prepareFormOutput($item),
1249  "order" => $this->getId()."_".$textidx."_".($idx+1)
1250  ));
1251  }
1252  if($textidx != sizeof($textarray)-1)
1253  {
1254  array_push($answers, array(
1255  "answertext" => "###",
1256  "order" => $this->getId()."_".$textidx."_".($idx+2)
1257  ));
1258  }
1259  }
1260  $result['answers'] = $answers;
1261 
1262  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1263  $result['mobs'] = $mobs;
1264 
1265  return json_encode($result);
1266  }
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
Add rich text string
The name of the decorator.
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
getQuestion()
Gets the question string of the question object.
Create styles array
The data for the language used.
$text
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 547 of file class.assErrorText.php.

548  {
549  include_once "./Modules/TestQuestionPool/classes/export/qti12/class.assErrorTextExport.php";
550  $export = new assErrorTextExport($this);
551  return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
552  }
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: