ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. 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...
 
 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 ()
 
 _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
_getQuestionInfo ($question_id)
 Returns question information from the database. More...
 
 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, $question_id, $pass=NULL)
 Returns the points, a learner has reached answering the question. 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...
 
 saveWorkingData ($active_id, $pass=NULL, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place. More...
 
 logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
 _logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. 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...
 
 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...
 
 getQuestionTypeFromDb ($question_id)
 get question type for question id 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...
 
 _getTitle ($a_q_id)
 Returns the title of a question. More...
 
 _getQuestionText ($a_q_id)
 Returns question text. More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 create page object of question More...
 
 copyPageOfQuestion ($a_q_id)
 
 getPageOfQuestion ()
 
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
 _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
 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)
 
 _getInternalLinkHref ($target="")
 
 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...
 
 _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution. More...
 
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
 _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not. More...
 
 calculateReachedPoints ($active_id, $pass=NULL, $authorizedSolution=true, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question. More...
 
 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...
 
 createNewImageFileName ($image_filename, $unique=false)
 
 _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...
 
 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...
 
 _needsManualScoring ($question_id)
 
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id. More...
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 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)
 
 _questionExistsInTest ($question_id, $test_id)
 
 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, $ignoredSolutionIds=array())
 
 saveCurrentSolution ($active_id, $pass, $value1, $value2, $authorized=true)
 
 updateCurrentSolution ($solutionId, $value1, $value2, $authorized=true)
 
 updateCurrentSolutionsAuthorization ($activeId, $pass, $authorized)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
 authorizedSolutionExists ($active_id, $pass)
 
 authorizedOrIntermediateSolutionExists ($active_id, $pass)
 
 lookupForExistingSolutions ($activeId, $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 removeExistingSolutions ($activeId, $pass)
 
 resetUsersAnswer ($activeId, $pass)
 
 removeResultRecord ($activeId, $pass)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered ($obligationsToBeConsidered)
 
 validateSolutionSubmit ()
 
 updateTimestamp ()
 
- 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)
 Reworks the allready saved working data if neccessary. More...
 
 isTokenSelected ($counter, array $selection)
 
 getPointsForSelectedPositions ($positions)
 
- Protected Member Functions inherited from assQuestion
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 Reworks the allready saved working data if neccessary. More...
 
 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)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 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)
 
 getSelfAssessmentFormatter ()
 

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
 
 $suggested_solutions
 
 $original_id
 
 $page
 
 $external_id = ''
 
 $questionChangeListeners = array()
 
 $processLocker
 
 $step = null
 
 $lastChange
 
 $shuffler
 

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 getAllowedImageFileExtensions ()
 
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 _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
static isFileAvailable ($file)
 
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 _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 _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 lookupParentObjId ($questionId)
 ilDB $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 setResultGateway ($resultGateway)
 
static getResultGateway ()
 
static sumTimesInISO8601FormatH_i_s_Extended ($time1, $time2)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds ($time)
 
static missingResultRecordExists ($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'
 
- 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 Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $forcePassResultsUpdateEnabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

Class for error text questions.

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

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

Constructor & Destructor Documentation

◆ __construct()

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

assErorText constructor

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

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

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

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

Member Function Documentation

◆ __get()

assErrorText::__get (   $value)

Object getter.

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

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

1165  {
1166  switch ($value)
1167  {
1168  case "errortext":
1169  return $this->getErrorText();
1170  break;
1171  case "textsize":
1172  return $this->getTextSize();
1173  break;
1174  case "points_wrong":
1175  return $this->getPointsWrong();
1176  break;
1177  default:
1178  return parent::__get($value);
1179  break;
1180  }
1181  }
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 1186 of file class.assErrorText.php.

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

1187  {
1188  switch ($key)
1189  {
1190  case "errortext":
1191  $this->setErrorText($value);
1192  break;
1193  case "textsize":
1194  $this->setTextSize($value);
1195  break;
1196  case "points_wrong":
1197  $this->setPointsWrong($value);
1198  break;
1199  default:
1200  parent::__set($key, $value);
1201  break;
1202  }
1203  }
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 1080 of file class.assErrorText.php.

References assQuestion\$points.

1081  {
1082  include_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
1083  array_push($this->errordata, new assAnswerErrorText($text_wrong, $text_correct, $points));
1084  }
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, 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)
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 ilAssQuestionPreviewSession\getParticipantsSolution(), and getPointsForSelectedPositions().

371  {
372  return $this->getPointsForSelectedPositions($previewSession->getParticipantsSolution());
373  }
getPointsForSelectedPositions($positions)
+ 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 841 of file class.assErrorText.php.

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

Referenced by setExportDetailsXLS().

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

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

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

1076  {
1077  $this->errordata = array();
1078  }

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

546  {
547  include_once "./Modules/TestQuestionPool/classes/import/qti12/class.assErrorTextImport.php";
548  $import = new assErrorTextImport($this);
549  $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
550  }
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 473 of file class.assErrorText.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

474  {
475  return "qpl_qst_errortext";
476  }
+ 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 483 of file class.assErrorText.php.

484  {
485  return "qpl_a_errortext";
486  }

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

1351  {
1352  $error_text_array = explode(' ', $this->errortext);
1353 
1354  if($index !== null)
1355  {
1356  if(array_key_exists($index, $error_text_array))
1357  {
1358  return $error_text_array[$index];
1359  }
1360  return null;
1361  }
1362  else
1363  {
1364  return $error_text_array;
1365  }
1366  }

◆ getBestSelection()

assErrorText::getBestSelection (   $withPositivePointsOnly = true)

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

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

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

571  {
572  $user_solution = array();
573  return $user_solution;
574  }

◆ getErrorData()

assErrorText::getErrorData ( )

Get error data.

Returns
array Error data

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

References $errordata.

Referenced by toJSON().

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

◆ getErrorsFromText()

assErrorText::getErrorsFromText (   $a_text = "")

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

References getErrorText().

577  {
578  if (strlen($a_text) == 0)
579  $a_text = $this->getErrorText();
580 
581  /* Workaround to allow '(' and ')' in passages.
582  The beginning- and ending- Passage delimiters are
583  replaced by a ~ (Tilde) symbol. */
584  $a_text = str_replace(array("((", "))"), array("~", "~"), $a_text);
585 
586  /* Match either Passage delimited by double brackets
587  or single words marked with a hash (#). */
588  $r_passage = "/(~([^~]+)~|#([^\s]+))/";
589 
590  preg_match_all($r_passage, $a_text, $matches);
591 
592  if (is_array($matches[0]) && !empty($matches[0])) {
593  /* At least one match. */
594 
595  /* We need only groups 2 and 3, respectively representing
596  passage matches and single word matches. */
597  $matches = array_intersect_key($matches, array(2 => '', 3 => ''));
598 
599  /* Remove empty values. */
600  $matches[2] = array_diff($matches[2], array(''));
601  $matches[3] = array_diff($matches[3], array(''));
602 
603  return array(
604  "passages" => $matches[2],
605  "words" => $matches[3],);
606  }
607 
608  return array();
609  }
getErrorText()
Get error text.
+ Here is the call graph for this function:

◆ getErrorText()

assErrorText::getErrorText ( )

Get error text.

Returns
string Error text

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

References $errortext.

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

1102  {
1103  return $this->errortext;
1104  }
+ Here is the caller graph for this function:

◆ getErrorTokenHtml()

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

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

References ilUtil\prepareFormOutput().

Referenced by createErrorTextOutput().

1374  {
1375  if($useLinkTags)
1376  {
1377  return '<a class="' . $class . '" href="#">' . ($item == '&nbsp;' ? $item : ilUtil::prepareFormOutput($item)) . '</a>';
1378  }
1379 
1380  return '<span class="' . $class . '">' . ($item == '&nbsp;' ? $item : ilUtil::prepareFormOutput($item)) . '</span>';
1381  }
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 1287 of file class.assErrorText.php.

References ilOperatorsExpressionMapping\getOperatorsByExpression().

1288  {
1289  require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1291  }
+ Here is the call graph for this function:

◆ getPointsForSelectedPositions()

assErrorText::getPointsForSelectedPositions (   $positions)
protected

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

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

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

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

References $points_wrong.

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

1147  {
1148  return $this->points_wrong;
1149  }
+ 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 463 of file class.assErrorText.php.

Referenced by toJSON().

464  {
465  return "assErrorText";
466  }
+ 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 492 of file class.assErrorText.php.

References $text.

493  {
494  $text = parent::getRTETextWithMediaObjects();
495  return $text;
496  }
$text

◆ getTextSize()

assErrorText::getTextSize ( )

Set text size in percent.

Returns
double Text size in percent

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

References $textsize.

Referenced by __get(), and saveAdditionalQuestionDataToDb().

1122  {
1123  return $this->textsize;
1124  }
+ 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 821 of file class.assErrorText.php.

References $data.

Referenced by createErrorTextOutput().

822  {
823  foreach($selection as $data)
824  {
825  if( !is_array($data) )
826  {
827  if($counter == $data)
828  {
829  return true;
830  }
831  }
832  elseif( in_array($counter, $data) )
833  {
834  return true;
835  }
836  }
837 
838  return false;
839  }
$data
+ 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(), 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.
$data
setPointsWrong($a_value)
Set wrong points.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setPoints($a_points)
Sets the maximum available points for the question.
setQuestion($question="")
Sets the question string of the question object.
global $ilDB
setOriginalId($original_id)
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setComment($comment="")
Sets the comment string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
+ Here is the call graph for this function:

◆ reworkWorkingData()

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

Reworks the allready saved working data if neccessary.

protected

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered

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

454  {
455  // nothing to rework!
456  }

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

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

432  {
433  if( strlen($_POST["qst_" . $this->getId()]) )
434  {
435  $selection = explode(',', $_POST["qst_{$this->getId()}"]);
436  }
437  else
438  {
439  $selection = array();
440  }
441 
442  $previewSession->setParticipantsSolution($selection);
443  }
getId()
Gets the id of the assQuestion object.
$_POST['username']
Definition: cron.php:12
+ 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 383 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().

384  {
385  global $ilDB;
386  global $ilUser;
387 
388  if (is_null($pass))
389  {
390  include_once "./Modules/Test/classes/class.ilObjTest.php";
391  $pass = ilObjTest::_getPass($active_id);
392  }
393 
394  $this->getProcessLocker()->requestUserSolutionUpdateLock();
395 
396  $affectedRows = $this->removeCurrentSolution($active_id, $pass, $authorized);
397 
398  $entered_values = false;
399  if (strlen($_POST["qst_" . $this->getId()]))
400  {
401  $selected = split(",", $_POST["qst_" . $this->getId()]);
402  foreach ($selected as $position)
403  {
404  $affectedRows = $this->saveCurrentSolution($active_id, $pass, $position, null, $authorized);
405  }
406  $entered_values = true;
407  }
408 
409  $this->getProcessLocker()->releaseUserSolutionUpdateLock();
410 
411  if ($entered_values)
412  {
413  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
415  {
416  $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
417  }
418  }
419  else
420  {
421  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
423  {
424  $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
425  }
426  }
427 
428  return true;
429  }
getId()
Gets the id of the assQuestion object.
$_POST['username']
Definition: cron.php:12
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true)
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
removeCurrentSolution($active_id, $pass, $authorized=true, $ignoredSolutionIds=array())
_getLogLanguage()
retrieve the log language for assessment logging
global $ilUser
Definition: imgupload.php:15
global $ilDB
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
+ Here is the call graph for this function:

◆ setErrorData()

assErrorText::setErrorData (   $a_data)

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

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

612  {
613  include_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
614  $temp = $this->errordata;
615  $this->errordata = array();
616  foreach ($a_data as $err_type => $errors) {
617  /* Iterate through error types (Passages|single words) */
618 
619  foreach ($errors as $idx => $error) {
620  /* Iterate through errors of this type. */
621  $text_correct = "";
622  $points = 0.0;
623  foreach ($temp as $object) {
624  if (strcmp($object->text_wrong, $error) == 0) {
625  $text_correct = $object->text_correct;
626  $points = $object->points;
627  continue;
628  }
629  }
630  $this->errordata[$idx] = new assAnswerErrorText($error, $text_correct, $points);
631  }
632  }
633  ksort($this->errordata);
634  }
Class for error text answers.
$errors

◆ setErrorText()

assErrorText::setErrorText (   $a_value)

Set error text.

Parameters
string$a_valueError text

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

Referenced by __set(), and loadFromDb().

1112  {
1113  $this->errortext = $a_value;
1114  }
+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

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

Creates an Excel worksheet for the detailed cumulated results of this question.

Parameters
object$worksheetReference to the parent excel worksheet
object$startrowStartrow of the output in the excel worksheet
object$active_idActive id of the participant
object$passTest pass
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data

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

References $errortext, $pass, ilExcelUtils\_convert_text(), createErrorTextExport(), assQuestion\getSolutionValues(), and assQuestion\getTitle().

510  {
511  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
512  $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
513  $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
514 
515  $i= 0;
516  $selections = array();
517  $solutions =& $this->getSolutionValues($active_id, $pass);
518  if (is_array($solutions))
519  {
520  foreach ($solutions as $solution)
521  {
522  array_push($selections, $solution['value1']);
523  }
524  $errortext_value = join(",", $selections);
525  }
526  $errortext = $this->createErrorTextExport($selections);
527  $i++;
528  $worksheet->writeString($startrow+$i, 0, ilExcelUtils::_convert_text($errortext));
529  $i++;
530  return $startrow + $i + 1;
531  }
createErrorTextExport($selections=null)
_convert_text($a_text, $a_target="has been removed")
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
getTitle()
Gets the title string of the assQuestion object.
+ 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 1156 of file class.assErrorText.php.

Referenced by __set(), and loadFromDb().

1157  {
1158  $this->points_wrong = $a_value;
1159  }
+ 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 1131 of file class.assErrorText.php.

Referenced by __set(), and loadFromDb().

1132  {
1133  // in self-assesment-mode value should always be set (and must not be null)
1134  if($a_value === null)
1135  {
1136  $a_value = 100;
1137  }
1138  $this->textsize = $a_value;
1139  }
+ Here is the caller graph for this function:

◆ toJSON()

assErrorText::toJSON ( )

Returns a JSON representation of the question.

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

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

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

559  {
560  include_once "./Modules/TestQuestionPool/classes/export/qti12/class.assErrorTextExport.php";
561  $export = new assErrorTextExport($this);
562  return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
563  }
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: