ILIAS  release_8 Revision v8.24
assOrderingQuestion Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for assOrderingQuestion:
+ Collaboration diagram for assOrderingQuestion:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="", $ordering_type=self::OQ_TERMS)
 assOrderingQuestion constructor More...
 
 isComplete ()
 Returns true, if a ordering question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a assOrderingQuestion object to a database. More...
 
 loadFromDb ($question_id)
 Loads a assOrderingQuestion object from a database. More...
 
 duplicate (bool $for_test=true, ?string $title="", ?string $author="", ?string $owner="", $testObjId=null)
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assOrderingQuestion object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 duplicateImages ($src_question_id, $src_object_id, $dest_question_id, $dest_object_id)
 
 copyImages ($question_id, $source_questionpool)
 
 setOrderingType ($ordering_type=self::OQ_TERMS)
 
 getOrderingType ()
 
 isOrderingTypeNested ()
 
 isImageOrderingType ()
 
 setContentType ($ct)
 
 setNestingType (bool $nesting)
 
 hasOrderingTypeUploadSupport ()
 
 getOrderingElementListForSolutionOutput ($forceCorrectSolution, $activeId, $passIndex)
 
 getSolutionOrderingElementListForTestOutput (ilAssNestedOrderingElementsInputGUI $inputGUI, $lastPost, $activeId, $pass)
 
 getSolutionOrderingElementList ($indexedSolutionValues)
 
 getShuffledOrderingElementList ()
 
 getOrderingElementList ()
 
 setOrderingElementList (ilAssOrderingElementList $list)
 
 getAnswer ($index=0)
 Returns the ordering element from the given position. More...
 
 deleteAnswer ($randomIdentifier)
 Deletes an answer with a given index. More...
 
 getAnswerCount ()
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getEncryptedFilename ($filename)
 
 dropImageFile ($imageFilename)
 
 isImageFileStored ($imageFilename)
 
 isImageReplaced (ilAssOrderingElement $newElement, ilAssOrderingElement $oldElement)
 
 storeImageFile (string $upload_file, string $upload_name)
 
 updateImageFile (string $existing_image_name)
 
 validateSolutionSubmit ()
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 
 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...
 
 getOrderElements ()
 Returns the answers array. More...
 
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output. More...
 
 supportsNonJsOutput ()
 
 setExportDetailsXLS (ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
 {} More...
 
 getElementHeight ()
 
 setElementHeight (?int $a_height)
 
 rebuildThumbnails ()
 
 getThumbPrefix ()
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 buildOrderingElementInputGui ()
 
 initOrderingElementAuthoringProperties (ilFormPropertyGUI $formField)
 
 initOrderingElementFormFieldLabels (ilFormPropertyGUI $formField)
 
 buildOrderingTextsInputGui ()
 
 buildOrderingImagesInputGui ()
 
 buildNestedOrderingElementInputGui ()
 
 fetchSolutionListFromFormSubmissionData ($userSolutionPost)
 
 getSolutionListFromPostSubmit ()
 
 getSolutionPostSubmit ()
 
 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...
 
 buildTestPresentationConfig ()
 build basic test question configuration instance More...
 
 fetchSolutionSubmit ($formSubmissionDataStructure)
 
- Public Member Functions inherited from assQuestion
 __construct (string $title="", string $comment="", string $author="", int $owner=-1, string $question="")
 assQuestion constructor More...
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML ($item, int $questionpool_id, ?int $tst_id, &$tst_object, int &$question_counter, array $import_mapping, array &$solutionhints=[])
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $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 (int $questionpool_id, string $title)
 Returns TRUE if the question title exists in a question pool in the database. More...
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 setOutputType (int $outputType=OUTPUT_HTML)
 
 setShuffle (?bool $shuffle=true)
 
 setAuthor (string $author="")
 
 setOwner (int $owner=-1)
 
 getTitle ()
 
 getTitleForHTMLOutput ()
 
 getTitleFilenameCompliant ()
 
 getId ()
 
 getShuffle ()
 
 getTestId ()
 
 getComment ()
 
 getDescriptionForHTMLOutput ()
 
 getThumbSize ()
 
 setThumbSize (int $a_size)
 
 getMinimumThumbSize ()
 
 getMaximumThumbSize ()
 
 getOutputType ()
 
 supportsJavascriptOutput ()
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 _getSuggestedSolution (int $question_id, int $subquestion_index=0)
 
 loadSuggestedSolution (int $question_id, int $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution (int $active_id, int $pass, bool $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $obligationsEnabled=false, bool $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 (int $active_id, int $pass, bool $authorized=true)
 Saves the learners input of the question to the database. More...
 
 moveUploadedMediaFile (string $file, string $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 
 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...
 
 getSuggestedSolutionPathWeb ()
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getTestOutputSolutions (int $activeId, int $pass)
 
 getUserSolutionPreferingIntermediate (int $active_id, $pass=null)
 
 getSolutionValues ($active_id, $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse (int $question_id=0)
 Checks whether the question is in use or not in pools or tests. More...
 
 usageNumber (int $question_id=0)
 Returns the number of place the question is in use in pools or tests. More...
 
 isClone (int $question_id=0)
 Checks whether the question is a clone of another question or not. More...
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 copyXHTMLMediaObjectsOfQuestion (int $a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 
 copyPageOfQuestion (int $a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
 fixSvgToPng (string $imageFilenameContainingString)
 
 fixUnavailableSkinImageSources (string $html)
 
 loadFromDb (int $question_id)
 
 createNewQuestion (bool $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 (int $original_id=-1)
 
 saveToDb ()
 
 setNewOriginalId (int $newId)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle (int $subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution (string $solution_id="", int $subquestion_index=0, bool $is_import=false)
 Sets a suggested solution for the question. More...
 
 updateSuggestedSolutions (int $original_id=-1, int $original_obj_id=-1)
 
 _resolveInternalLink (string $internal_link)
 
 _resolveIntLinks (int $question_id)
 
 syncWithOriginal ()
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool (int $question_id)
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 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 (string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
 
 QTIMaterialToString (ilQTIMaterial $a_material)
 Reads an QTI material tag and creates a text or XHTML string. More...
 
 addQTIMaterial (ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 
 syncHints ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 setExportDetailsXLS (ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 __isset ($key)
 Object issetter. More...
 
 getNrOfTries ()
 
 setNrOfTries (int $a_nr_of_tries)
 
 setExportImagePath (string $path)
 
 formatSAQuestion ($a_q)
 
 setPreventRteUsage (bool $prevent_rte_usage)
 
 getPreventRteUsage ()
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode (bool $selfassessmenteditingmode)
 
 getSelfAssessmentEditingMode ()
 
 setDefaultNrOfTries (int $defaultnroftries)
 
 getDefaultNrOfTries ()
 
 syncSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 ensureHintPageObjectExists ($pageObjectId)
 
 isAnswered (int $active_id, int $pass)
 
 isAutosaveable ()
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 removeCurrentSolution (int $active_id, int $pass, bool $authorized=true)
 
 saveCurrentSolution (int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
 updateCurrentSolution (int $solutionId, $value1, $value2, bool $authorized=true)
 
 updateCurrentSolutionsAuthorization (int $activeId, int $pass, bool $authorized, bool $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate (bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
 
 intermediateSolutionExists (int $active_id, int $pass)
 
 authorizedSolutionExists (int $active_id, ?int $pass)
 
 authorizedOrIntermediateSolutionExists (int $active_id, int $pass)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions (int $activeId, int $pass)
 
 resetUsersAnswer (int $activeId, int $pass)
 
 removeResultRecord (int $activeId, int $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered (bool $obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
 savePartial ()
 
 isInActiveTest ()
 
- Public Member Functions inherited from ilObjQuestionScoringAdjustable
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
- Public Member Functions inherited from iQuestionCondition
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. 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...
 

Data Fields

const ORDERING_ELEMENT_FORM_FIELD_POSTVAR = 'order_elems'
 
const ORDERING_ELEMENT_FORM_CMD_UPLOAD_IMG = 'uploadElementImage'
 
const ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG = 'removeElementImage'
 
const OQ_PICTURES = 0
 
const OQ_TERMS = 1
 
const OQ_NESTED_PICTURES = 2
 
const OQ_NESTED_TERMS = 3
 
const OQ_CT_PICTURES = 'pics'
 
const OQ_CT_TERMS = 'terms'
 
const VALID_UPLOAD_SUFFIXES = ["jpg", "jpeg", "png", "gif"]
 
int $element_height = null
 
 $old_ordering_depth = array()
 
 $leveled_ordering = array()
 
- 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 TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
ilAssQuestionFeedback $feedbackOBJ
 
bool $prevent_rte_usage = false
 
bool $selfassessmenteditingmode = false
 
int $defaultnroftries = 0
 
string $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 = "?"
 

Protected Member Functions

 getRepository ()
 
 getValidOrderingTypes ()
 
 getSolutionValuePairBrandedOrderingElementByRandomIdentifier ($value1, $value2)
 
 getSolutionValuePairBrandedOrderingElementBySolutionIdentifier ($value1, $value2)
 
 cleanImagefiles ()
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 getQuestionRepository ()
 
 generateThumbForFile ($path, $file)
 
 calculateReachedPointsForSolution (ilAssOrderingElementList $solutionOrderingElementList)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 {} More...
 
 ensureImagePathExists ()
 
 buildOrderingElementFormDataConverter ()
 
 buildOrderingImagesFormDataConverter ()
 
 buildOrderingTextsFormDataConverter ()
 
 buildNestedOrderingFormDataConverter ()
 
- Protected Member Functions inherited from assQuestion
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $postSubmissionFieldname)
 
 ensureCurrentTestPass (int $active_id, int $pass)
 
 lookupCurrentTestPass (int $active_id, int $pass)
 
 lookupTestId (int $active_id)
 @refactor Move to ilObjTest or similar More...
 
 log (int $active_id, string $langVar)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 deletePageOfQuestion (int $question_id)
 
 onDuplicate (int $originalParentId, int $originalQuestionId, int $duplicateParentId, int $duplicateQuestionId)
 
 beforeSyncWithOriginal (int $origQuestionId, int $dupQuestionId, int $origParentObjId, int $dupParentObjId)
 
 afterSyncWithOriginal (int $origQuestionId, int $dupQuestionId, int $origParentObjId, int $dupParentObjId)
 
 onCopy (int $sourceParentId, int $sourceQuestionId, int $targetParentId, int $targetQuestionId)
 
 duplicateSuggestedSolutionFiles (int $parent_id, int $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles (int $target_question_id, int $target_obj_id)
 
 copySuggestedSolutionFiles (int $source_questionpool_id, int $source_question_id)
 
 ensureNonNegativePoints ($points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints (int $originalQuestionId, int $duplicateQuestionId)
 
 duplicateSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet (int $active_id, int $pass, bool $authorized=true)
 
 removeSolutionRecordById (int $solutionId)
 
 getSolutionRecordById (int $solutionId)
 
 deleteDummySolutionRecord (int $activeId, int $passIndex)
 
 isDummySolutionRecord (array $solutionRecord)
 
 deleteSolutionRecordByValues (int $activeId, int $passIndex, bool $authorized, array $matchValues)
 
 duplicateIntermediateSolutionAuthorized (int $activeId, int $passIndex)
 
 forceExistingIntermediateSolution (int $activeId, int $passIndex, bool $considerDummyRecordCreation)
 
 lookupMaxStep (int $active_id, int $pass)
 
 buildTestPresentationConfig ()
 build basic test question configuration instance More...
 

Protected Attributes

const HAS_SPECIFIC_FEEDBACK = false
 
 $orderingElementList
 
 $ordering_type
 
 $oq_repository = null
 
- Protected Attributes inherited from assQuestion
const HAS_SPECIFIC_FEEDBACK = true
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
ILIAS DI LoggingServices $ilLog
 
int $id
 
string $title
 
string $comment
 
string $owner
 
string $author
 
int $thumb_size
 
string $question
 The question text. More...
 
float $points
 The maximum available points for the question. More...
 
bool $shuffle
 Indicates whether the answers will be shuffled or not. More...
 
int $test_id
 The database id of a test in which the question is contained. More...
 
int $obj_id = 0
 Object id of the container object. More...
 
 $ilias
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
ilDBInterface $db
 
Container $dic
 
int $outputType = OUTPUT_JAVASCRIPT
 Contains the output type of a question. More...
 
array $suggested_solutions
 
int $original_id = null
 
 $page
 
string $external_id = null
 
ilAssQuestionProcessLocker $processLocker
 
 $step
 
 $lastChange
 
Transformation $shuffler
 
ilTestQuestionConfig $testQuestionConfig
 
ilAssQuestionLifecycle $lifecycle
 
ilObjUser $current_user
 

Private Attributes

 $postSolutionOrderingElementList = null
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $forcePassResultsUpdateEnabled)
 
static isForcePassResultUpdateEnabled ()
 
static isAllowedImageMimeType ($mimeType)
 
static fetchMimeTypeIdentifier (string $contentType)
 
static getAllowedFileExtensionsForMimeType (string $mimeType)
 
static isAllowedImageFileExtension (string $mimeType, string $fileExtension)
 
static getAllowedImageMaterialFileExtensions ()
 
static _getMaximumPoints (int $question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
static _getQuestionInfo (int $question_id)
 
static _getSuggestedSolutionCount (int $question_id)
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static _updateTestResultCache (int $active_id, ilAssQuestionProcessLocker $processLocker=null)
 @TODO Move this to a proper place. More...
 
static logAction (string $logtext, int $active_id, int $question_id)
 
static getQuestionTypeFromDb (int $question_id)
 
static _getTotalRightAnswers (int $a_q_id)
 
static _getTitle (int $a_q_id)
 
static _getQuestionText (int $a_q_id)
 
static isFileAvailable (string $file)
 
static _getQuestionType (int $question_id)
 
static _getQuestionTitle (int $question_id)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static _getInternalLinkHref (string $target="")
 
static _getOriginalId (int $question_id)
 
static originalQuestionExists (int $questionId)
 
static _instanciateQuestion (int $question_id)
 
static _instantiateQuestion (int $question_id)
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static _isWriteable (int $question_id, int $user_id)
 
static _isUsedInRandomTest (int $question_id)
 
static _isWorkedThrough (int $active_id, int $question_id, int $pass)
 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 (int $a_user_id, array $a_question_ids)
 Checks if an array of question ids is answered by a user or not. More...
 
static _setReachedPoints (int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring, bool $obligationsEnabled)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static _needsManualScoring (int $question_id)
 
static _includeClass (string $question_type, int $gui=0)
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static isCoreQuestionType (string $questionType)
 
static includeCoreClass ($questionType, $withGuiClass)
 
static _getQuestionTypeName ($type_tag)
 
static _instanciateQuestionGUI (int $question_id)
 
static instantiateQuestionGUI (int $a_question_id)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $questionId)
 
static lookupOriginalParentObjId (int $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 (int $questionId)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
static missingResultRecordExists (int $activeId, int $pass, array $questionIds)
 
static getQuestionsMissingResultRecord (int $activeId, int $pass, array $questionIds)
 
static lookupResultRecordExist (int $activeId, int $questionId, int $pass)
 
static extendedTrim (string $value)
 Trim non-printable characters from the beginning and end of a string. More...
 
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $allowedImageMaterialFileExtensionsByMimeType
 
static $forcePassResultsUpdateEnabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class for ordering questions

assOrderingQuestion is a class for ordering 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
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Nils Haagen nils..nosp@m.haag.nosp@m.en@co.nosp@m.ncep.nosp@m.ts-an.nosp@m.d-tr.nosp@m.ainin.nosp@m.g.de
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

assOrderingQuestion::__construct (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $question = "",
  $ordering_type = self::OQ_TERMS 
)

assOrderingQuestion constructor

The constructor takes possible arguments an creates an instance of the assOrderingQuestion object.

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 ordering test
int$ordering_type

Definition at line 90 of file class.assOrderingQuestion.php.

97 {
99 $this->orderingElementList = new ilAssOrderingElementList();
100 $this->ordering_type = $ordering_type;
101 }
string $question
The question text.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References assQuestion\$author, assQuestion\$comment, $ordering_type, assQuestion\$owner, assQuestion\$question, assQuestion\$title, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ afterSyncWithOriginal()

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

{}

Definition at line 1406 of file class.assOrderingQuestion.php.

1406 : void
1407 {
1408 parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
1409 $this->duplicateImages($dupQuestionId, $dupParentObjId, $origQuestionId, $origParentObjId);
1410 }
duplicateImages($src_question_id, $src_object_id, $dest_question_id, $dest_object_id)

◆ buildNestedOrderingElementInputGui()

assOrderingQuestion::buildNestedOrderingElementInputGui ( )
Returns
ilAssNestedOrderingElementsInputGUI

Definition at line 1208 of file class.assOrderingQuestion.php.

1209 {
1210 $formDataConverter = $this->buildNestedOrderingFormDataConverter();
1211
1212 $orderingElementInput = new ilAssNestedOrderingElementsInputGUI(
1213 $formDataConverter,
1214 self::ORDERING_ELEMENT_FORM_FIELD_POSTVAR
1215 );
1216
1217 $orderingElementInput->setUniquePrefix($this->getId());
1218 $orderingElementInput->setOrderingType($this->getOrderingType());
1219 $orderingElementInput->setElementImagePath($this->getImagePathWeb());
1220 $orderingElementInput->setThumbPrefix($this->getThumbPrefix());
1221
1222 $this->initOrderingElementFormFieldLabels($orderingElementInput);
1223
1224 return $orderingElementInput;
1225 }
initOrderingElementFormFieldLabels(ilFormPropertyGUI $formField)
getImagePathWeb()
Returns the web image path for web accessable images of a question.

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ buildNestedOrderingFormDataConverter()

assOrderingQuestion::buildNestedOrderingFormDataConverter ( )
protected

Definition at line 1510 of file class.assOrderingQuestion.php.

1511 {
1512 $formDataConverter = $this->buildOrderingElementFormDataConverter();
1514
1515 if ($this->getOrderingType() == OQ_NESTED_PICTURES) {
1516 $formDataConverter->setImageRemovalCommand(self::ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG);
1517 $formDataConverter->setImageUrlPath($this->getImagePathWeb());
1518 $formDataConverter->setThumbnailPrefix($this->getThumbPrefix());
1519 }
1520
1521 return $formDataConverter;
1522 }

References ilAssOrderingFormValuesObjectsConverter\CONTEXT_MAINTAIN_HIERARCHY, and OQ_NESTED_PICTURES.

◆ buildOrderingElementFormDataConverter()

assOrderingQuestion::buildOrderingElementFormDataConverter ( )
protected

Definition at line 1479 of file class.assOrderingQuestion.php.

1480 {
1481 require_once 'Modules/TestQuestionPool/classes/forms/class.ilAssOrderingFormValuesObjectsConverter.php';
1482 $converter = new ilAssOrderingFormValuesObjectsConverter();
1483 $converter->setPostVar(self::ORDERING_ELEMENT_FORM_FIELD_POSTVAR);
1484
1485 return $converter;
1486 }

◆ buildOrderingElementInputGui()

assOrderingQuestion::buildOrderingElementInputGui ( )
Returns
ilAssNestedOrderingElementsInputGUI|ilAssOrderingImagesInputGUI|ilAssOrderingTextsInputGUI
Exceptions
ilTestQuestionPoolException

Definition at line 1143 of file class.assOrderingQuestion.php.

1144 {
1145 if ($this->isImageOrderingType()) {
1146 return $this->buildOrderingImagesInputGui();
1147 }
1148 return $this->buildOrderingTextsInputGui();
1149 }

Referenced by ilAssOrderingQuestionAuthoringFormGUI\renewOrderingElementInput().

+ Here is the caller graph for this function:

◆ buildOrderingImagesFormDataConverter()

assOrderingQuestion::buildOrderingImagesFormDataConverter ( )
protected

Definition at line 1488 of file class.assOrderingQuestion.php.

1489 {
1490 $formDataConverter = $this->buildOrderingElementFormDataConverter();
1492
1493 $formDataConverter->setImageRemovalCommand(self::ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG);
1494 $formDataConverter->setImageUrlPath($this->getImagePathWeb());
1495 $formDataConverter->setImageFsPath($this->getImagePath());
1496
1497 if ($this->getThumbPrefix()) {
1498 $formDataConverter->setThumbnailPrefix($this->getThumbPrefix());
1499 }
1500 return $formDataConverter;
1501 }
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.

References ilAssOrderingFormValuesObjectsConverter\CONTEXT_MAINTAIN_ELEMENT_IMAGE.

◆ buildOrderingImagesInputGui()

assOrderingQuestion::buildOrderingImagesInputGui ( )

Definition at line 1188 of file class.assOrderingQuestion.php.

1189 {
1190 $formDataConverter = $this->buildOrderingImagesFormDataConverter();
1191
1192 $orderingElementInput = new ilAssOrderingImagesInputGUI(
1193 $formDataConverter,
1194 self::ORDERING_ELEMENT_FORM_FIELD_POSTVAR
1195 );
1196
1197 $orderingElementInput->setImageUploadCommand(self::ORDERING_ELEMENT_FORM_CMD_UPLOAD_IMG);
1198 $orderingElementInput->setImageRemovalCommand(self::ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG);
1199
1200 $this->initOrderingElementFormFieldLabels($orderingElementInput);
1201
1202 return $orderingElementInput;
1203 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ buildOrderingTextsFormDataConverter()

assOrderingQuestion::buildOrderingTextsFormDataConverter ( )
protected

◆ buildOrderingTextsInputGui()

assOrderingQuestion::buildOrderingTextsInputGui ( )

Definition at line 1174 of file class.assOrderingQuestion.php.

1175 {
1176 $formDataConverter = $this->buildOrderingTextsFormDataConverter();
1177
1178 $orderingElementInput = new ilAssOrderingTextsInputGUI(
1179 $formDataConverter,
1180 self::ORDERING_ELEMENT_FORM_FIELD_POSTVAR
1181 );
1182
1183 $this->initOrderingElementFormFieldLabels($orderingElementInput);
1184
1185 return $orderingElementInput;
1186 }

◆ buildTestPresentationConfig()

assOrderingQuestion::buildTestPresentationConfig ( )

build basic test question configuration instance

method can be overwritten to configure an instance use parent call for building when possible

Reimplemented from assQuestion.

Definition at line 1412 of file class.assOrderingQuestion.php.

1413 {
1414 return parent::buildTestPresentationConfig()
1416 ->setUseUnchangedAnswerLabel($this->lng->txt('tst_unchanged_order_is_correct'));
1417 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setIsUnchangedAnswerPossible($isUnchangedAnswerPossible)
Set if the saving of an unchanged answer is supported with an additional checkbox.

References ILIAS\Repository\lng(), and ilTestQuestionConfig\setIsUnchangedAnswerPossible().

+ Here is the call graph for this function:

◆ calculateReachedPoints()

assOrderingQuestion::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.

@access public

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

Reimplemented from assQuestion.

Definition at line 677 of file class.assOrderingQuestion.php.

678 {
679 if ($returndetails) {
680 throw new ilTestException('return details not implemented for ' . __METHOD__);
681 }
682
683 if (is_null($pass)) {
684 $pass = $this->getSolutionMaxPass($active_id);
685 }
686
687 $solutionValuePairs = $this->getSolutionValues($active_id, $pass, $authorizedSolution);
688
689 if (!count($solutionValuePairs)) {
690 return 0;
691 }
692
693 $indexedSolutionValues = $this->fetchIndexedValuesFromValuePairs($solutionValuePairs);
694 $solutionOrderingElementList = $this->getSolutionOrderingElementList($indexedSolutionValues);
695
696 return $this->calculateReachedPointsForSolution($solutionOrderingElementList);
697 }
getSolutionOrderingElementList($indexedSolutionValues)
calculateReachedPointsForSolution(ilAssOrderingElementList $solutionOrderingElementList)
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
fetchIndexedValuesFromValuePairs(array $valuePairs)
getSolutionMaxPass(int $active_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ calculateReachedPointsForSolution()

assOrderingQuestion::calculateReachedPointsForSolution ( ilAssOrderingElementList  $solutionOrderingElementList)
protected

Definition at line 1288 of file class.assOrderingQuestion.php.

1288 : float
1289 {
1290 $reachedPoints = $this->getPoints();
1291
1292 foreach ($this->getOrderingElementList() as $correctElement) {
1293 $userElement = $solutionOrderingElementList->getElementByPosition($correctElement->getPosition());
1294
1295 if (!$correctElement->isSameElement($userElement)) {
1296 $reachedPoints = 0;
1297 break;
1298 }
1299 }
1300
1301 return $reachedPoints;
1302 }

References ilAssOrderingElementList\getElementByPosition().

+ Here is the call graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assOrderingQuestion::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

Reimplemented from assQuestion.

Definition at line 699 of file class.assOrderingQuestion.php.

700 {
701 if (!$previewSession->hasParticipantSolution()) {
702 return 0;
703 }
704
705 $solutionOrderingElementList = unserialize(
706 $previewSession->getParticipantsSolution(),
707 ["allowed_classes" => true]
708 );
709
710 $reachedPoints = $this->calculateReachedPointsForSolution($solutionOrderingElementList);
711 $reachedPoints = $this->deductHintPointsFromReachedPoints($previewSession, $reachedPoints);
712
713 return $this->ensureNonNegativePoints($reachedPoints);
714 }
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
ensureNonNegativePoints($points)

References ilAssQuestionPreviewSession\getParticipantsSolution(), and ilAssQuestionPreviewSession\hasParticipantSolution().

+ Here is the call graph for this function:

◆ cleanImagefiles()

assOrderingQuestion::cleanImagefiles ( )
protected

Definition at line 742 of file class.assOrderingQuestion.php.

742 : void
743 {
744 if ($this->getOrderingType() == self::OQ_PICTURES) {
745 if (@file_exists($this->getImagePath())) {
746 $contents = ilFileUtils::getDir($this->getImagePath());
747 foreach ($contents as $f) {
748 if (strcmp($f['type'], 'file') == 0) {
749 $found = false;
750 foreach ($this->getOrderingElementList() as $orderElement) {
751 if (strcmp($f['entry'], $orderElement->getContent()) == 0) {
752 $found = true;
753 }
754 if (strcmp($f['entry'], $this->getThumbPrefix() . $orderElement->getContent()) == 0) {
755 $found = true;
756 }
757 }
758 if (!$found) {
759 if (@file_exists($this->getImagePath() . $f['entry'])) {
760 @unlink($this->getImagePath() . $f['entry']);
761 }
762 }
763 }
764 }
765 }
766 } else {
767 if (@file_exists($this->getImagePath())) {
769 }
770 }
771 }
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
const OQ_PICTURES
Ordering question constants.

References Vendor\Package\$f, ilFileUtils\delDir(), ilFileUtils\getDir(), and OQ_PICTURES.

+ Here is the call graph for this function:

◆ copyImages()

assOrderingQuestion::copyImages (   $question_id,
  $source_questionpool 
)
Deprecated:
(!) simply use the working method duplicateImages(), we do not search the difference here and we will delete this soon (!) currently no usage found, remove for il5.3

Definition at line 375 of file class.assOrderingQuestion.php.

375 : void
376 {
377 global $DIC;
378 $ilLog = $DIC['ilLog'];
379 if ($this->getOrderingType() == OQ_PICTURES) {
380 $imagepath = $this->getImagePath();
381 $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
382 $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
383 if (!file_exists($imagepath)) {
384 ilFileUtils::makeDirParents($imagepath);
385 }
386 foreach ($this->getOrderingElementList() as $element) {
387 $filename = $element->getContent();
388 if (!@copy($imagepath_original . $filename, $imagepath . $filename)) {
389 $ilLog->write("Ordering Question image could not be copied: ${imagepath_original}${filename}");
390 }
391 if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename)) {
392 if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
393 $ilLog->write("Ordering Question image thumbnail could not be copied: $imagepath_original" . $this->getThumbPrefix() . $filename);
394 }
395 }
396 }
397 }
398 }
$filename
Definition: buildRTE.php:78
ILIAS DI LoggingServices $ilLog
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
global $DIC
Definition: feed.php:28

References $DIC, $filename, ilFileUtils\makeDirParents(), and OQ_PICTURES.

+ Here is the call graph for this function:

◆ copyObject()

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

Copies an assOrderingQuestion object.

@access public

Definition at line 265 of file class.assOrderingQuestion.php.

265 : int
266 {
267 if ($this->getId() <= 0) {
268 throw new RuntimeException('The question has not been saved. It cannot be duplicated');
269 }
270 // duplicate the question in database
271 $clone = clone $this;
272 $this_id = $this->getId();
274 $clone->id = -1;
275 $source_questionpool_id = $this->getObjId();
276 $clone->setObjId($target_questionpool_id);
277 if ($title) {
278 $clone->setTitle($title);
279 }
280 $clone->saveToDb();
281
282 $list = $this->getRepository()->getOrderingList($this_id)
283 ->withQuestionId($clone->getId());
284 $list->distributeNewRandomIdentifiers();
285 $clone->setOrderingElementList($list);
286 $clone->saveToDb();
287
288 $clone->copyPageOfQuestion($original_id);
289 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
290 $clone->duplicateImages($original_id, $source_questionpool_id, $clone->getId(), $target_questionpool_id);
291
292 $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
293
294 return $clone->getId();
295 }
static _getOriginalId(int $question_id)

References assQuestion\_getOriginalId(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

Definition at line 297 of file class.assOrderingQuestion.php.

297 : int
298 {
299 if ($this->getId() <= 0) {
300 throw new RuntimeException('The question has not been saved. It cannot be duplicated');
301 }
302
303 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
304
305 $sourceQuestionId = $this->id;
306 $sourceParentId = $this->getObjId();
307
308 // duplicate the question in database
309 $clone = clone $this;
310 $clone->id = -1;
311
312 $clone->setObjId($targetParentId);
313
314 if ($targetQuestionTitle) {
315 $clone->setTitle($targetQuestionTitle);
316 }
317
318 $clone->saveToDb();
319
320 $list = $this->getRepository()->getOrderingList($this->getId())
321 ->withQuestionId($clone->getId());
322 $list->distributeNewRandomIdentifiers();
323 $clone->setOrderingElementList($list);
324 $clone->saveToDb();
325
326 // copy question page content
327 $clone->copyPageOfQuestion($sourceQuestionId);
328 // copy XHTML media objects
329 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
330 // duplicate the image
331 $clone->duplicateImages($sourceQuestionId, $sourceParentId, $clone->getId(), $clone->getObjId());
332
333 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
334
335 return $clone->id;
336 }

References $id, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ deleteAnswer()

assOrderingQuestion::deleteAnswer (   $randomIdentifier)

Deletes an answer with a given index.

The index of the first answer is 0, the index of the second answer is 1 and so on.

Parameters
integer$indexA nonnegative index of the n-th answer @access public
See also
$answers

Definition at line 654 of file class.assOrderingQuestion.php.

654 : void
655 {
656 $this->getOrderingElementList()->removeElement(
657 $this->getOrderingElementList()->getElementByRandomIdentifier($randomIdentifier)
658 );
659 $this->getOrderingElementList()->saveToDb();
660 }

◆ dropImageFile()

assOrderingQuestion::dropImageFile (   $imageFilename)

Definition at line 777 of file class.assOrderingQuestion.php.

778 {
779 if (!strlen($imageFilename)) {
780 return false;
781 }
782
783 $result = @unlink($this->getImagePath() . $imageFilename);
784 $result = $result && @unlink($this->getImagePath() . $this->getThumbPrefix() . $imageFilename);
785
786 return $result;
787 }

◆ duplicate()

assOrderingQuestion::duplicate ( bool  $for_test = true,
?string  $title = "",
?string  $author = "",
?string  $owner = "",
  $testObjId = null 
)

Definition at line 207 of file class.assOrderingQuestion.php.

213 : int {
214 if ($this->id <= 0) {
215 // The question has not been saved. It cannot be duplicated
216 return -1;
217 }
218 // duplicate the question in database
219 $this_id = $this->getId();
220 $thisObjId = $this->getObjId();
221
222 $clone = clone $this;
224 $clone->id = -1;
225
226 if ((int) $testObjId > 0) {
227 $clone->setObjId($testObjId);
228 }
229
230 if ($title) {
231 $clone->setTitle($title);
232 }
233 if ($author) {
234 $clone->setAuthor($author);
235 }
236 if ($owner) {
237 $clone->setOwner($owner);
238 }
239 if ($for_test) {
240 $clone->saveToDb($original_id);
241 } else {
242 $clone->saveToDb();
243 }
244
245 //$list = $this->getRepository()->getOrderingList($original_id)
246 $list = $this->getRepository()->getOrderingList($this_id)
247 ->withQuestionId($clone->getId());
248 $list->distributeNewRandomIdentifiers();
249 $clone->setOrderingElementList($list);
250 $clone->saveToDb();
251
252 $clone->copyPageOfQuestion($this_id);
253 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
254 $clone->duplicateImages($this_id, $thisObjId, $clone->getId(), $testObjId);
255
256 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
257 return $clone->getId();
258 }

◆ duplicateImages()

assOrderingQuestion::duplicateImages (   $src_question_id,
  $src_object_id,
  $dest_question_id,
  $dest_object_id 
)

Definition at line 338 of file class.assOrderingQuestion.php.

338 : void
339 {
340 global $DIC;
341 $ilLog = $DIC['ilLog'];
342 if ($this->isImageOrderingType()) {
343 $imagepath_original = $this->getImagePath($src_question_id, $src_object_id);
344 $imagepath = $this->getImagePath($dest_question_id, $dest_object_id);
345
346 if (!file_exists($imagepath)) {
347 ilFileUtils::makeDirParents($imagepath);
348 }
349 foreach ($this->getOrderingElementList() as $element) {
350 $filename = $element->getContent();
351
352 if ($filename === '') {
353 continue;
354 }
355
356 if (!file_exists($imagepath_original . $filename)
357 || !copy($imagepath_original . $filename, $imagepath . $filename)) {
358 $ilLog->write("image could not be duplicated!!!!");
359 $ilLog->write($imagepath_original . $filename);
360 $ilLog->write($imagepath . $filename);
361 }
362 if (file_exists($imagepath_original . $this->getThumbPrefix() . $filename)
363 && !copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename)) {
364 $ilLog->write("image thumbnail could not be duplicated!!!!");
365 }
366 }
367 }
368 }

References $DIC, $filename, and ilFileUtils\makeDirParents().

+ Here is the call graph for this function:

◆ ensureImagePathExists()

assOrderingQuestion::ensureImagePathExists ( )
protected

Definition at line 1419 of file class.assOrderingQuestion.php.

1419 : void
1420 {
1421 if (!file_exists($this->getImagePath())) {
1423 }
1424 }

References ilFileUtils\makeDirParents().

+ Here is the call graph for this function:

◆ fetchSolutionListFromFormSubmissionData()

assOrderingQuestion::fetchSolutionListFromFormSubmissionData (   $userSolutionPost)
Parameters
array$userSolutionPost

Definition at line 1231 of file class.assOrderingQuestion.php.

1232 {
1233 $orderingGUI = $this->buildNestedOrderingElementInputGui();
1235 $orderingGUI->setValueByArray($userSolutionPost);
1236
1237 if (!$orderingGUI->checkInput()) {
1238 throw new ilTestException('error on validating user solution post');
1239 }
1240
1241 $solutionOrderingElementList = ilAssOrderingElementList::buildInstance($this->getId());
1242
1243 $storedElementList = $this->getOrderingElementList();
1244
1245 foreach ($orderingGUI->getElementList($this->getId()) as $submittedElement) {
1246 $solutionElement = $storedElementList->getElementByRandomIdentifier(
1247 $submittedElement->getRandomIdentifier()
1248 )->getClone();
1249
1250 $solutionElement->setPosition($submittedElement->getPosition());
1251
1252 if ($this->isOrderingTypeNested()) {
1253 $solutionElement->setIndentation($submittedElement->getIndentation());
1254 }
1255
1256 $solutionOrderingElementList->addElement($solutionElement);
1257 }
1258
1259 return $solutionOrderingElementList;
1260 }
static buildInstance(int $question_id, array $elements=[])

References ilAssOrderingElementList\buildInstance(), ilAssNestedOrderingElementsInputGUI\CONTEXT_USER_SOLUTION_SUBMISSION, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ fetchSolutionSubmit()

assOrderingQuestion::fetchSolutionSubmit (   $formSubmissionDataStructure)

Definition at line 1426 of file class.assOrderingQuestion.php.

1426 : array
1427 {
1428 $solutionSubmit = array();
1429
1430 if (isset($formSubmissionDataStructure['orderresult'])) {
1431 $orderresult = $formSubmissionDataStructure['orderresult'];
1432
1433 if (strlen($orderresult)) {
1434 $orderarray = explode(":", $orderresult);
1435 $ordervalue = 1;
1436 foreach ($orderarray as $index) {
1437 $idmatch = null;
1438 if (preg_match("/id_(\\d+)/", $index, $idmatch)) {
1439 $randomid = $idmatch[1];
1440 foreach ($this->getOrderingElementList() as $answeridx => $answer) {
1441 if ($answer->getRandomIdentifier() == $randomid) {
1442 $solutionSubmit[$answeridx] = $ordervalue;
1443 $ordervalue++;
1444 }
1445 }
1446 }
1447 }
1448 }
1449 } elseif ($this->getOrderingType() == OQ_NESTED_TERMS || $this->getOrderingType() == OQ_NESTED_PICTURES) {
1450 $index = 0;
1451 foreach ($formSubmissionDataStructure['content'] as $randomId => $content) {
1452 $indentation = $formSubmissionDataStructure['indentation'];
1453
1454 $value1 = $index++;
1455 $value2 = implode(':', array($randomId, $indentation));
1456
1457 $solutionSubmit[$value1] = $value2;
1458 }
1459 } else {
1460 foreach ($formSubmissionDataStructure as $key => $value) {
1461 $matches = null;
1462 if (preg_match("/^order_(\d+)/", $key, $matches)) {
1463 if (!(preg_match("/initial_value_\d+/", $value))) {
1464 if (strlen($value)) {
1465 foreach ($this->getOrderingElementList() as $answeridx => $answer) {
1466 if ($answer->getRandomIdentifier() == $matches[1]) {
1467 $solutionSubmit[$answeridx] = $value;
1468 }
1469 }
1470 }
1471 }
1472 }
1473 }
1474 }
1475
1476 return $solutionSubmit;
1477 }
$index
Definition: metadata.php:145
string $key
Consumer key/client ID value.
Definition: System.php:193

References $index, ILIAS\LTI\ToolProvider\$key, OQ_NESTED_PICTURES, and OQ_NESTED_TERMS.

◆ generateThumbForFile()

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

Definition at line 1073 of file class.assOrderingQuestion.php.

1073 : void
1074 {
1075 $filename = $path . $file;
1076 if (@file_exists($filename)) {
1077 $thumbpath = $path . $this->getThumbPrefix() . $file;
1078 $path_info = @pathinfo($filename);
1079 $ext = "";
1080 switch (strtoupper($path_info['extension'])) {
1081 case 'PNG':
1082 $ext = 'PNG';
1083 break;
1084 case 'GIF':
1085 $ext = 'GIF';
1086 break;
1087 default:
1088 $ext = 'JPEG';
1089 break;
1090 }
1091 ilShellUtil::convertImage($filename, $thumbpath, $ext, (string) $this->getThumbSize());
1092 }
1093 }
static convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")
convert image
$path
Definition: ltiservices.php:32

References $filename, $path, and ilShellUtil\convertImage().

+ Here is the call graph for this function:

◆ getAdditionalTableName()

assOrderingQuestion::getAdditionalTableName ( )
Returns
string|array Or Array?
See also
Deletion methods here

Reimplemented from assQuestion.

Definition at line 957 of file class.assOrderingQuestion.php.

957 : string
958 {
959 return "qpl_qst_ordering";
960 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ getAnswer()

assOrderingQuestion::getAnswer (   $index = 0)

Returns the ordering element from the given position.

Parameters
int$position
Returns
ilAssOrderingElement|null

Definition at line 637 of file class.assOrderingQuestion.php.

638 {
639 if (!$this->getOrderingElementList()->elementExistByPosition($index)) {
640 return null;
641 }
642
643 return $this->getOrderingElementList()->getElementByPosition($index);
644 }

References $index.

◆ getAnswerCount()

assOrderingQuestion::getAnswerCount ( )

Definition at line 662 of file class.assOrderingQuestion.php.

662 : int
663 {
664 return $this->getOrderingElementList()->countElements();
665 }

◆ getAnswerTableName()

assOrderingQuestion::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name @access public

Reimplemented from assQuestion.

Definition at line 968 of file class.assOrderingQuestion.php.

968 : string
969 {
970 return "qpl_a_ordering";
971 }

◆ getAvailableAnswerOptions()

assOrderingQuestion::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

Implements iQuestionCondition.

Definition at line 1394 of file class.assOrderingQuestion.php.

1395 {
1396 if ($index !== null) {
1397 return $this->getOrderingElementList()->getElementByPosition($index);
1398 }
1399
1400 return $this->getOrderingElementList()->getElements();
1401 }

References $index.

◆ getElementHeight()

assOrderingQuestion::getElementHeight ( )

Definition at line 1044 of file class.assOrderingQuestion.php.

1044 : ?int
1045 {
1046 return $this->element_height;
1047 }

◆ getEncryptedFilename()

assOrderingQuestion::getEncryptedFilename (   $filename)

Definition at line 733 of file class.assOrderingQuestion.php.

733 : string
734 {
735 $extension = "";
736 if (preg_match("/.*\\.(\\w+)$/", $filename, $matches)) {
737 $extension = $matches[1];
738 }
739 return md5($filename) . "." . $extension;
740 }

References $filename.

◆ getExpressionTypes()

◆ getMaximumPoints()

assOrderingQuestion::getMaximumPoints ( )

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

See also
$points

Reimplemented from assQuestion.

Definition at line 720 of file class.assOrderingQuestion.php.

720 : float
721 {
722 return $this->getPoints();
723 }

Referenced by isComplete().

+ Here is the caller graph for this function:

◆ getOperators()

assOrderingQuestion::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
string$expression

Implements iQuestionCondition.

Definition at line 1309 of file class.assOrderingQuestion.php.

1309 : array
1310 {
1312 }

References ilOperatorsExpressionMapping\getOperatorsByExpression().

+ Here is the call graph for this function:

◆ getOrderElements()

assOrderingQuestion::getOrderElements ( )

Returns the answers array.

Deprecated:
seriously, stop looking for this kind data at this point (!) look where it comes from and learn (!)

Definition at line 992 of file class.assOrderingQuestion.php.

992 : array
993 {
994 return $this->getOrderingElementList()->getRandomIdentifierIndexedElements();
995 }

◆ getOrderingElementList()

assOrderingQuestion::getOrderingElementList ( )

Definition at line 614 of file class.assOrderingQuestion.php.

615 {
616 return $this->getRepository()->getOrderingList($this->getId());
617 }

References ILIAS\Survey\Mode\getId().

Referenced by isComplete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOrderingElementListForSolutionOutput()

assOrderingQuestion::getOrderingElementListForSolutionOutput (   $forceCorrectSolution,
  $activeId,
  $passIndex 
)
Parameters
$forceCorrectSolution
$activeId
$passIndex
Returns
ilAssOrderingElementList

Definition at line 494 of file class.assOrderingQuestion.php.

495 {
496 if ($forceCorrectSolution || !$activeId || $passIndex === null) {
497 return $this->getOrderingElementList();
498 }
499
500 $solutionValues = $this->getSolutionValues($activeId, $passIndex);
501
502 if (!count($solutionValues)) {
503 return $this->getShuffledOrderingElementList();
504 }
505
506 return $this->getSolutionOrderingElementList($this->fetchIndexedValuesFromValuePairs($solutionValues));
507 }

◆ getOrderingType()

assOrderingQuestion::getOrderingType ( )

Definition at line 418 of file class.assOrderingQuestion.php.

418 : int
419 {
421 }

◆ getQuestionRepository()

assOrderingQuestion::getQuestionRepository ( )
protected

Definition at line 941 of file class.assOrderingQuestion.php.

942 {
943 global $DIC;
944 $ilDB = $DIC['ilDB'];
945 return new \ILIAS\TA\Questions\Ordering\assOrderingQuestionDatabaseRepository($ilDB);
946 }
repository for assOrderingQuestion (the answer elements within, at least...)

References $DIC, and $ilDB.

◆ getQuestionType()

assOrderingQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
string The question type of the question

Reimplemented from assQuestion.

Definition at line 952 of file class.assOrderingQuestion.php.

952 : string
953 {
954 return "assOrderingQuestion";
955 }

◆ getRepository()

assOrderingQuestion::getRepository ( )
protected

Definition at line 127 of file class.assOrderingQuestion.php.

128 {
129 if (is_null($this->oq_repository)) {
130 global $DIC;
131 $ilDB = $DIC['ilDB'];
132 $this->oq_repository = new OQRepository($ilDB);
133 }
135 }

References $DIC, $ilDB, and $oq_repository.

◆ getRTETextWithMediaObjects()

assOrderingQuestion::getRTETextWithMediaObjects ( )

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

Reimplemented from assQuestion.

Definition at line 977 of file class.assOrderingQuestion.php.

977 : string
978 {
979 $text = parent::getRTETextWithMediaObjects();
980
981 foreach ($this->getOrderingElementList() as $orderingElement) {
982 $text .= $orderingElement->getContent();
983 }
984
985 return $text;
986 }

◆ getShuffledOrderingElementList()

assOrderingQuestion::getShuffledOrderingElementList ( )

Definition at line 601 of file class.assOrderingQuestion.php.

602 {
603 $shuffledRandomIdentifierIndex = $this->getShuffler()->transform(
604 $this->getOrderingElementList()->getRandomIdentifierIndex()
605 );
606
607 $shuffledElementList = $this->getOrderingElementList()->getClone();
608 $shuffledElementList->reorderByRandomIdentifiers($shuffledRandomIdentifierIndex);
609 $shuffledElementList->resetElementsIndentations();
610
611 return $shuffledElementList;
612 }

References ilAssOrderingElementList\getClone().

+ Here is the call graph for this function:

◆ getSolutionListFromPostSubmit()

assOrderingQuestion::getSolutionListFromPostSubmit ( )

Definition at line 1267 of file class.assOrderingQuestion.php.

1268 {
1269 if ($this->postSolutionOrderingElementList === null) {
1270 $post_array = $_POST;
1271 if (!is_array($post_array)) {
1272 global $DIC;
1273 $request = $DIC->http()->request();
1274 $post_array = $request->getParsedBody();
1275 }
1277 $this->postSolutionOrderingElementList = $list;
1278 }
1279
1281 }
fetchSolutionListFromFormSubmissionData($userSolutionPost)
$post_array
Definition: webdav.php:31

References $DIC, and $post_array.

◆ getSolutionOrderingElementList()

assOrderingQuestion::getSolutionOrderingElementList (   $indexedSolutionValues)
Parameters
array$valuePairs
Returns
ilAssOrderingElementList
Exceptions
ilTestQuestionPoolException

Definition at line 579 of file class.assOrderingQuestion.php.

580 {
581 $solutionOrderingList = new ilAssOrderingElementList();
582 $solutionOrderingList->setQuestionId($this->getId());
583
584 foreach ($indexedSolutionValues as $value1 => $value2) {
585 if ($this->isOrderingTypeNested()) {
586 $element = $this->getSolutionValuePairBrandedOrderingElementByRandomIdentifier($value1, $value2);
587 } else {
588 $element = $this->getSolutionValuePairBrandedOrderingElementBySolutionIdentifier($value1, $value2);
589 }
590
591 $solutionOrderingList->addElement($element);
592 }
593
594 if (!$this->getOrderingElementList()->hasSameElementSetByRandomIdentifiers($solutionOrderingList)) {
595 throw new ilTestQuestionPoolException('inconsistent solution values given');
596 }
597
598 return $solutionOrderingList;
599 }
getSolutionValuePairBrandedOrderingElementBySolutionIdentifier($value1, $value2)
getSolutionValuePairBrandedOrderingElementByRandomIdentifier($value1, $value2)

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ getSolutionOrderingElementListForTestOutput()

assOrderingQuestion::getSolutionOrderingElementListForTestOutput ( ilAssNestedOrderingElementsInputGUI  $inputGUI,
  $lastPost,
  $activeId,
  $pass 
)
Parameters
ilAssNestedOrderingElementsInputGUI$inputGUI
array$lastPost
integer$activeId
integer$pass
Returns
ilAssOrderingElementList
Exceptions
ilTestException
ilTestQuestionPoolException

Definition at line 518 of file class.assOrderingQuestion.php.

519 {
520 if ($inputGUI->isPostSubmit($lastPost)) {
521 return $this->fetchSolutionListFromFormSubmissionData($lastPost);
522 }
523 $indexedSolutionValues = $this->fetchIndexedValuesFromValuePairs(
524 // hey: prevPassSolutions - obsolete due to central check
525 $this->getTestOutputSolutions($activeId, $pass)
526 // hey.
527 );
528
529 if (count($indexedSolutionValues)) {
530 return $this->getSolutionOrderingElementList($indexedSolutionValues);
531 }
532
533 return $this->getShuffledOrderingElementList();
534 }
getTestOutputSolutions(int $activeId, int $pass)

References ilAssNestedOrderingElementsInputGUI\isPostSubmit().

+ Here is the call graph for this function:

◆ getSolutionPostSubmit()

assOrderingQuestion::getSolutionPostSubmit ( )

Definition at line 1283 of file class.assOrderingQuestion.php.

1283 : array
1284 {
1285 return $this->fetchSolutionSubmit($_POST);
1286 }
fetchSolutionSubmit($formSubmissionDataStructure)

◆ getSolutionValuePairBrandedOrderingElementByRandomIdentifier()

assOrderingQuestion::getSolutionValuePairBrandedOrderingElementByRandomIdentifier (   $value1,
  $value2 
)
protected
Parameters
string$value1
string$value2

Definition at line 540 of file class.assOrderingQuestion.php.

541 {
542 $value2 = explode(':', $value2);
543
544 $randomIdentifier = $value2[0];
545 $selectedPosition = $value1;
546 $selectedIndentation = $value2[1];
547
548 $element = $this->getOrderingElementList()->getElementByRandomIdentifier($randomIdentifier)->getClone();
549
550 $element->setPosition($selectedPosition);
551 $element->setIndentation($selectedIndentation);
552
553 return $element;
554 }

◆ getSolutionValuePairBrandedOrderingElementBySolutionIdentifier()

assOrderingQuestion::getSolutionValuePairBrandedOrderingElementBySolutionIdentifier (   $value1,
  $value2 
)
protected
Parameters
string$value1
string$value2

Definition at line 560 of file class.assOrderingQuestion.php.

561 {
562 $solutionIdentifier = $value1;
563 $selectedPosition = ($value2 - 1);
564 $selectedIndentation = 0;
565
566 $element = $this->getOrderingElementList()->getElementBySolutionIdentifier($solutionIdentifier)->getClone();
567
568 $element->setPosition($selectedPosition);
569 $element->setIndentation($selectedIndentation);
570
571 return $element;
572 }

References ilAssOrderingElement\getClone().

+ Here is the call graph for this function:

◆ getThumbPrefix()

assOrderingQuestion::getThumbPrefix ( )

Definition at line 1068 of file class.assOrderingQuestion.php.

1068 : string
1069 {
1070 return "thumb.";
1071 }

◆ getValidOrderingTypes()

assOrderingQuestion::getValidOrderingTypes ( )
protected

Definition at line 400 of file class.assOrderingQuestion.php.

400 : array
401 {
402 return [
407 ];
408 }

References OQ_NESTED_PICTURES, OQ_NESTED_TERMS, OQ_PICTURES, and OQ_TERMS.

◆ hasOrderingTypeUploadSupport()

assOrderingQuestion::hasOrderingTypeUploadSupport ( )

Definition at line 483 of file class.assOrderingQuestion.php.

483 : bool
484 {
485 return $this->isImageOrderingType();
486 }

◆ initOrderingElementAuthoringProperties()

assOrderingQuestion::initOrderingElementAuthoringProperties ( ilFormPropertyGUI  $formField)

Definition at line 1151 of file class.assOrderingQuestion.php.

1151 : void
1152 {
1153 switch (true) {
1154 case $formField instanceof ilAssNestedOrderingElementsInputGUI:
1155 $formField->setInteractionEnabled(true);
1156 $formField->setNestingEnabled($this->isOrderingTypeNested());
1157 break;
1158
1159 case $formField instanceof ilAssOrderingTextsInputGUI:
1160 case $formField instanceof ilAssOrderingImagesInputGUI:
1161 default:
1162
1163 $formField->setEditElementOccuranceEnabled(true);
1164 $formField->setEditElementOrderEnabled(true);
1165 }
1166 }

Referenced by ilAssOrderingQuestionAuthoringFormGUI\renewOrderingElementInput().

+ Here is the caller graph for this function:

◆ initOrderingElementFormFieldLabels()

assOrderingQuestion::initOrderingElementFormFieldLabels ( ilFormPropertyGUI  $formField)

Definition at line 1168 of file class.assOrderingQuestion.php.

1168 : void
1169 {
1170 $formField->setInfo($this->lng->txt('ordering_answer_sequence_info'));
1171 $formField->setTitle($this->lng->txt('answers'));
1172 }

References ILIAS\Repository\lng(), ilFormPropertyGUI\setInfo(), and ilFormPropertyGUI\setTitle().

+ Here is the call graph for this function:

◆ isComplete()

assOrderingQuestion::isComplete ( )

Returns true, if a ordering question is complete for use.

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

Reimplemented from assQuestion.

Definition at line 108 of file class.assOrderingQuestion.php.

108 : bool
109 {
110 $elements = array_filter(
111 $this->getOrderingElementList()->getElements(),
112 fn ($element) => trim($element->getContent()) != ''
113 );
114 $has_at_least_two_elements = count($elements) > 1;
115
116 $complete = $this->getAuthor()
117 && $this->getTitle()
118 && $this->getQuestion()
119 && $this->getMaximumPoints()
120 && $has_at_least_two_elements;
121
122 return $complete;
123 }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.

References assQuestion\getAuthor(), getMaximumPoints(), getOrderingElementList(), assQuestion\getQuestion(), and assQuestion\getTitle().

+ Here is the call graph for this function:

◆ isImageFileStored()

assOrderingQuestion::isImageFileStored (   $imageFilename)

Definition at line 789 of file class.assOrderingQuestion.php.

789 : bool
790 {
791 if (!strlen($imageFilename)) {
792 return false;
793 }
794
795 if (!file_exists($this->getImagePath() . $imageFilename)) {
796 return false;
797 }
798
799 return is_file($this->getImagePath() . $imageFilename);
800 }

◆ isImageOrderingType()

assOrderingQuestion::isImageOrderingType ( )

Definition at line 432 of file class.assOrderingQuestion.php.

432 : bool
433 {
434 $with_images = [
437 ];
438 return in_array($this->getOrderingType(), $with_images);
439 }

References OQ_NESTED_PICTURES, and OQ_PICTURES.

Referenced by ilAssOrderingQuestionAuthoringFormGUI\addSpecificOrderingQuestionCommandButtons().

+ Here is the caller graph for this function:

◆ isImageReplaced()

assOrderingQuestion::isImageReplaced ( ilAssOrderingElement  $newElement,
ilAssOrderingElement  $oldElement 
)

Definition at line 802 of file class.assOrderingQuestion.php.

802 : bool
803 {
804 if (!$this->hasOrderingTypeUploadSupport()) {
805 return false;
806 }
807
808 if (!$newElement->getContent()) {
809 return false;
810 }
811
812 return $newElement->getContent() != $oldElement->getContent();
813 }

References ilAssOrderingElement\getContent().

+ Here is the call graph for this function:

◆ isOrderingTypeNested()

assOrderingQuestion::isOrderingTypeNested ( )

Definition at line 423 of file class.assOrderingQuestion.php.

423 : bool
424 {
425 $nested = [
428 ];
429 return in_array($this->getOrderingType(), $nested);
430 }

References OQ_NESTED_PICTURES, and OQ_NESTED_TERMS.

◆ loadFromDb()

assOrderingQuestion::loadFromDb (   $question_id)

Loads a assOrderingQuestion object from a database.

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

Definition at line 163 of file class.assOrderingQuestion.php.

163 : void
164 {
165 global $DIC;
166 $ilDB = $DIC['ilDB'];
167
168 $result = $ilDB->queryF(
169 "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",
170 array("integer"),
171 array($question_id)
172 );
173 if ($result->numRows() == 1) {
174 $data = $ilDB->fetchAssoc($result);
175 $this->setId($question_id);
176 $this->setObjId($data["obj_fi"]);
177 $this->setTitle((string) $data["title"]);
178 $this->setComment((string) $data["description"]);
179 $this->setOriginalId($data["original_id"]);
180 $this->setAuthor($data["author"]);
181 $this->setNrOfTries($data['nr_of_tries']);
182 $this->setPoints($data["points"]);
183 $this->setOwner($data["owner"]);
184 include_once("./Services/RTE/classes/class.ilRTE.php");
185 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
186 $this->ordering_type = $data["ordering_type"] !== null ? (int) $data["ordering_type"] : OQ_TERMS;
187 if ($data['thumb_geometry'] !== null && $data['thumb_geometry'] >= $this->getMinimumThumbSize()) {
188 $this->setThumbSize($data['thumb_geometry']);
189 }
190 $this->element_height = $data["element_height"] ? (int) $data['element_height'] : null;
191
192 try {
196 }
197
198 try {
199 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
201 }
202 }
203
204 parent::loadFromDb($question_id);
205 }
setOriginalId(?int $original_id)
setId(int $id=-1)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
setAuthor(string $author="")
setThumbSize(int $a_size)
setComment(string $comment="")
setObjId(int $obj_id=0)
setOwner(int $owner=-1)
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
setPoints(float $points)
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...

References $data, $DIC, Vendor\Package\$e, $ilDB, ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), assQuestion\getMinimumThumbSize(), ILIAS\Repository\int(), OQ_TERMS, assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setId(), assQuestion\setLifecycle(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), assQuestion\setThumbSize(), and assQuestion\setTitle().

+ Here is the call graph for this function:

◆ rebuildThumbnails()

assOrderingQuestion::rebuildThumbnails ( )

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

1057 : void
1058 {
1059 if ($this->isImageOrderingType()) {
1060 foreach ($this->getOrderElements() as $orderingElement) {
1061 if ($orderingElement->getContent() !== '') {
1062 $this->generateThumbForFile($this->getImagePath(), $orderingElement->getContent());
1063 }
1064 }
1065 }
1066 }
getOrderElements()
Returns the answers array.

◆ saveAnswerSpecificDataToDb()

assOrderingQuestion::saveAnswerSpecificDataToDb ( )

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

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

Definition at line 948 of file class.assOrderingQuestion.php.

949 {
950 }

◆ savePreviewData()

assOrderingQuestion::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

Reimplemented from assQuestion.

Definition at line 908 of file class.assOrderingQuestion.php.

908 : void
909 {
910 if ($this->validateSolutionSubmit()) {
911 $previewSession->setParticipantsSolution(serialize($this->getSolutionListFromPostSubmit()));
912 }
913 }

References ilAssQuestionPreviewSession\setParticipantsSolution().

+ Here is the call graph for this function:

◆ saveToDb()

assOrderingQuestion::saveToDb (   $original_id = "")

Saves a assOrderingQuestion object to a database.

Parameters
string$original_id

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

145 : void
146 {
147 if ($original_id == '') {
148 $this->saveQuestionDataToDb();
149 } else {
151 }
153 parent::saveToDb();
154 }
saveQuestionDataToDb(int $original_id=-1)
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.

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

+ Here is the call graph for this function:

◆ saveWorkingData()

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

Saves the learners input of the question to the database.

@access public

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

Definition at line 871 of file class.assOrderingQuestion.php.

871 : bool
872 {
873 global $DIC;
874 if ($DIC->testQuestionPool()->internal()->request()->raw('test_answer_changed') === null) {
875 return true;
876 }
877
878 $entered_values = 0;
879
880 if (is_null($pass)) {
881 $pass = ilObjTest::_getPass($active_id);
882 }
883
884 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
885 function () use (&$entered_values, $active_id, $pass, $authorized) {
886 $this->removeCurrentSolution($active_id, $pass, $authorized);
887
888 foreach ($this->getSolutionListFromPostSubmit() as $orderingElement) {
889 $value1 = $orderingElement->getStorageValue1($this->getOrderingType());
890 $value2 = $orderingElement->getStorageValue2($this->getOrderingType());
891
892 $this->saveCurrentSolution($active_id, $pass, $value1, trim($value2), $authorized);
893
894 $entered_values++;
895 }
896 }
897 );
898
899 if ($entered_values) {
900 $this->log($active_id, 'log_user_entered_values');
901 } else {
902 $this->log($active_id, 'log_user_not_entered_values');
903 }
904
905 return true;
906 }
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
log(int $active_id, string $langVar)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.

References $DIC, and ilObjTest\_getPass().

+ Here is the call graph for this function:

◆ setContentType()

assOrderingQuestion::setContentType (   $ct)

Definition at line 441 of file class.assOrderingQuestion.php.

442 {
443 if (!in_array($ct, [
444 self::OQ_CT_PICTURES,
445 self::OQ_CT_TERMS
446 ])) {
447 throw new \InvalidArgumentException("use OQ content-type", 1);
448 }
449 if ($ct == self::OQ_CT_PICTURES) {
450 if ($this->isOrderingTypeNested()) {
452 } else {
454 }
455 $this->setThumbSize($this->getThumbSize());
456 }
457 if ($ct == self::OQ_CT_TERMS) {
458 if ($this->isOrderingTypeNested()) {
460 } else {
462 }
463 }
464 }
setOrderingType($ordering_type=self::OQ_TERMS)
const OQ_NESTED_PICTURES
const OQ_TERMS
const OQ_NESTED_TERMS

References OQ_NESTED_PICTURES, OQ_NESTED_TERMS, OQ_PICTURES, and OQ_TERMS.

◆ setElementHeight()

assOrderingQuestion::setElementHeight ( ?int  $a_height)

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

1049 : void
1050 {
1051 $this->element_height = ($a_height < 20) ? null : $a_height;
1052 }

◆ setExportDetailsXLS()

assOrderingQuestion::setExportDetailsXLS ( ilAssExcelFormatHelper  $worksheet,
int  $startrow,
int  $active_id,
int  $pass 
)

{}

Reimplemented from assQuestion.

Definition at line 1016 of file class.assOrderingQuestion.php.

1016 : int
1017 {
1018 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
1019
1020 $solutions = $this->getSolutionValues($active_id, $pass);
1021 $sol = array();
1022 foreach ($solutions as $solution) {
1023 $sol[$solution["value1"]] = $solution["value2"];
1024 }
1025 asort($sol);
1026 $sol = array_keys($sol);
1027
1028 $i = 1;
1029 foreach ($sol as $idx) {
1030 foreach ($solutions as $solution) {
1031 if ($solution["value1"] == $idx) {
1032 $worksheet->setCell($startrow + $i, 0, $solution["value2"]);
1033 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
1034 }
1035 }
1036 $element = $this->getOrderingElementList()->getElementBySolutionIdentifier($idx);
1037 $worksheet->setCell($startrow + $i, 2, $element->getContent());
1038 $i++;
1039 }
1040
1041 return $startrow + $i + 1;
1042 }
setCell($a_row, $a_col, $a_value, $datatype=null)
setBold(string $a_coords)
Set cell(s) to bold.
getColumnCoord(int $a_col)
Get column "name" from number.
$i
Definition: metadata.php:41

References $i, ilExcel\getColumnCoord(), ilExcel\setBold(), and ilAssExcelFormatHelper\setCell().

+ Here is the call graph for this function:

◆ setNestingType()

assOrderingQuestion::setNestingType ( bool  $nesting)

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

467 {
468 if ($nesting) {
469 if ($this->isImageOrderingType()) {
471 } else {
473 }
474 } else {
475 if ($this->isImageOrderingType()) {
477 } else {
479 }
480 }
481 }

References OQ_NESTED_PICTURES, OQ_NESTED_TERMS, OQ_PICTURES, and OQ_TERMS.

◆ setOrderingElementList()

assOrderingQuestion::setOrderingElementList ( ilAssOrderingElementList  $list)

Definition at line 619 of file class.assOrderingQuestion.php.

619 : void
620 {
621 $list = $list->withQuestionId($this->getId());
622 $elements = $list->getElements();
623 $nu = [];
624 foreach ($elements as $e) {
625 $nu[] = $list->ensureValidIdentifiers($e);
626 }
627 $list = $list->withElements($nu);
628 $this->getRepository()->updateOrderingList($list);
629 }
ensureValidIdentifiers(ilAssOrderingElement $element)

References Vendor\Package\$e, ilAssOrderingElementList\ensureValidIdentifiers(), ilAssOrderingElementList\getElements(), ILIAS\Survey\Mode\getId(), ilAssOrderingElementList\withElements(), and ilAssOrderingElementList\withQuestionId().

+ Here is the call graph for this function:

◆ setOrderingType()

assOrderingQuestion::setOrderingType (   $ordering_type = self::OQ_TERMS)

Definition at line 410 of file class.assOrderingQuestion.php.

411 {
412 if (!in_array($ordering_type, $this->getValidOrderingTypes())) {
413 throw new \InvalidArgumentException('Must be valid ordering type.');
414 }
415 $this->ordering_type = $ordering_type;
416 }

◆ storeImageFile()

assOrderingQuestion::storeImageFile ( string  $upload_file,
string  $upload_name 
)

Definition at line 815 of file class.assOrderingQuestion.php.

815 : ?string
816 {
817 $name_parts = explode(".", $upload_name);
818 $suffix = strtolower(array_pop($name_parts));
819 if (!in_array($suffix, self::VALID_UPLOAD_SUFFIXES)) {
820 return null;
821 }
822
823 $this->ensureImagePathExists();
824 $target_filename = $this->buildHashedImageFilename($upload_name, true);
825 $target_filepath = $this->getImagePath() . $target_filename;
826 if (ilFileUtils::moveUploadedFile($upload_file, $target_filename, $target_filepath)) {
827 $thumb_path = $this->getImagePath() . $this->getThumbPrefix() . $target_filename;
828 ilShellUtil::convertImage($target_filepath, $thumb_path, "JPEG", (string) $this->getThumbSize());
829
830 return $target_filename;
831 }
832
833 return null;
834 }
buildHashedImageFilename(string $plain_image_filename, bool $unique=false)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file

References ilShellUtil\convertImage(), and ilFileUtils\moveUploadedFile().

+ Here is the call graph for this function:

◆ supportsJavascriptOutput()

assOrderingQuestion::supportsJavascriptOutput ( )

Returns true if the question type supports JavaScript output.

Returns
boolean TRUE if the question type supports JavaScript output, FALSE otherwise @access public

Reimplemented from assQuestion.

Definition at line 1003 of file class.assOrderingQuestion.php.

1003 : bool
1004 {
1005 return true;
1006 }

◆ supportsNonJsOutput()

assOrderingQuestion::supportsNonJsOutput ( )

Reimplemented from assQuestion.

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

1008 : bool
1009 {
1010 return false;
1011 }

◆ toJSON()

assOrderingQuestion::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

Definition at line 1098 of file class.assOrderingQuestion.php.

1098 : string
1099 {
1100 include_once("./Services/RTE/classes/class.ilRTE.php");
1101 $result = array();
1102 $result['id'] = $this->getId();
1103 $result['type'] = (string) $this->getQuestionType();
1104 $result['title'] = $this->getTitleForHTMLOutput();
1105 $result['question'] = $this->formatSAQuestion($this->getQuestion());
1106 $result['nr_of_tries'] = $this->getNrOfTries();
1107 $result['shuffle'] = true;
1108 $result['points'] = $this->getPoints();
1109 $result['feedback'] = array(
1110 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1111 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1112 );
1113 if ($this->getOrderingType() == self::OQ_PICTURES) {
1114 $result['path'] = $this->getImagePathWeb();
1115 }
1116
1117 $counter = 1;
1118 $answers = array();
1119 foreach ($this->getOrderingElementList() as $orderingElement) {
1120 $answers[$counter] = $orderingElement->getContent();
1121 $counter++;
1122 }
1123 $answers = $this->getShuffler()->transform($answers);
1124 $arr = array();
1125 foreach ($answers as $order => $answer) {
1126 array_push($arr, array(
1127 "answertext" => (string) $answer,
1128 "order" => (int) $order
1129 ));
1130 }
1131 $result['answers'] = $arr;
1132
1133 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1134 $result['mobs'] = $mobs;
1135
1136 return json_encode($result);
1137 }
getQuestionType()
Returns the question type of the question.
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
$mobs
Definition: imgupload.php:70

References $mobs, ilObjMediaObject\_getMobsOfObject(), ILIAS\Survey\Mode\getId(), and OQ_PICTURES.

+ Here is the call graph for this function:

◆ updateImageFile()

assOrderingQuestion::updateImageFile ( string  $existing_image_name)

Definition at line 836 of file class.assOrderingQuestion.php.

836 : ?string
837 {
838 $existing_image_path = $this->getImagePath() . $existing_image_name;
839 $target_filename = $this->buildHashedImageFilename($existing_image_name, true);
840 $target_filepath = $this->getImagePath() . $target_filename;
841 if (ilFileUtils::rename($existing_image_path, $target_filepath)) {
842 unlink($this->getImagePath() . $this->getThumbPrefix() . $existing_image_name);
843 $thumb_path = $this->getImagePath() . $this->getThumbPrefix() . $target_filename;
844 ilShellUtil::convertImage($target_filepath, $thumb_path, "JPEG", (string) $this->getThumbSize());
845
846 return $target_filename;
847 }
848
849 return $existing_image_name;
850 }
static rename(string $a_source, string $a_target)

References ilShellUtil\convertImage(), and ilFileUtils\rename().

+ Here is the call graph for this function:

◆ validateSolutionSubmit()

assOrderingQuestion::validateSolutionSubmit ( )

Reimplemented from assQuestion.

Definition at line 852 of file class.assOrderingQuestion.php.

852 : bool
853 {
854 $submittedSolutionList = $this->getSolutionListFromPostSubmit();
855
856 if (!$submittedSolutionList->hasElements()) {
857 return true;
858 }
859
860 return $this->getOrderingElementList()->hasSameElementSetByRandomIdentifiers($submittedSolutionList);
861 }

Field Documentation

◆ $element_height

int assOrderingQuestion::$element_height = null

Definition at line 68 of file class.assOrderingQuestion.php.

◆ $leveled_ordering

assOrderingQuestion::$leveled_ordering = array()

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

◆ $old_ordering_depth

assOrderingQuestion::$old_ordering_depth = array()

Definition at line 70 of file class.assOrderingQuestion.php.

◆ $oq_repository

assOrderingQuestion::$oq_repository = null
protected

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

Referenced by getRepository().

◆ $ordering_type

assOrderingQuestion::$ordering_type
protected

Definition at line 66 of file class.assOrderingQuestion.php.

Referenced by __construct().

◆ $orderingElementList

assOrderingQuestion::$orderingElementList
protected

Definition at line 60 of file class.assOrderingQuestion.php.

◆ $postSolutionOrderingElementList

assOrderingQuestion::$postSolutionOrderingElementList = null
private

Definition at line 1265 of file class.assOrderingQuestion.php.

◆ HAS_SPECIFIC_FEEDBACK

const assOrderingQuestion::HAS_SPECIFIC_FEEDBACK = false
protected

Definition at line 54 of file class.assOrderingQuestion.php.

◆ OQ_CT_PICTURES

const assOrderingQuestion::OQ_CT_PICTURES = 'pics'

Definition at line 49 of file class.assOrderingQuestion.php.

◆ OQ_CT_TERMS

const assOrderingQuestion::OQ_CT_TERMS = 'terms'

Definition at line 50 of file class.assOrderingQuestion.php.

◆ OQ_NESTED_PICTURES

◆ OQ_NESTED_TERMS

◆ OQ_PICTURES

◆ OQ_TERMS

◆ ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG

const assOrderingQuestion::ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG = 'removeElementImage'

Definition at line 42 of file class.assOrderingQuestion.php.

◆ ORDERING_ELEMENT_FORM_CMD_UPLOAD_IMG

const assOrderingQuestion::ORDERING_ELEMENT_FORM_CMD_UPLOAD_IMG = 'uploadElementImage'

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

◆ ORDERING_ELEMENT_FORM_FIELD_POSTVAR

◆ VALID_UPLOAD_SUFFIXES

const assOrderingQuestion::VALID_UPLOAD_SUFFIXES = ["jpg", "jpeg", "png", "gif"]

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