ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
assOrderingQuestion Class Reference

Class for ordering questions. More...

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

Public Member Functions

 __construct (string $title="", string $comment="", string $author="", int $owner=-1, string $question="", protected int $ordering_type=self::OQ_TERMS)
 
 isComplete ()
 
 saveToDb (?int $original_id=null)
 
 loadFromDb ($question_id)
 Loads a assOrderingQuestion object from a database. More...
 
 cloneImages (int $source_question_id, int $source_parent_id, int $target_question_id, int $target_parent_id)
 
 setOrderingType (int $ordering_type=self::OQ_TERMS)
 
 getOrderingType ()
 
 isOrderingTypeNested ()
 
 isImageOrderingType ()
 
 setContentType ($ct)
 
 setNestingType (bool $nesting)
 
 hasOrderingTypeUploadSupport ()
 
 getOrderingElementListForSolutionOutput (bool $force_correct_solution, int $active_id, ?int $pass_index)
 
 getSolutionOrderingElementListForTestOutput (ilAssNestedOrderingElementsInputGUI $input_gui, array $last_post, int $active_id, int $pass)
 
 getSolutionOrderingElementList (array $indexed_solution_values)
 
 getShuffledOrderingElementList ()
 
 getOrderingElementList ()
 
 setOrderingElementList (ilAssOrderingElementList $list)
 
 getAnswer (int $index=0)
 Returns the ordering element from the given position. More...
 
 deleteAnswer (int $random_identifier)
 
 getAnswerCount ()
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 getMaximumPoints ()
 
 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 (int $active_id, ?int $pass=null, bool $authorized=true)
 
 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...
 
 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...
 
 getOrderElements ()
 Returns the answers array. 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 (array $user_solution_post)
 
 getSolutionListFromPostSubmit ()
 
 getOperators (string $expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getUserQuestionResult (int $active_id, int $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...
 
 buildTestPresentationConfig ()
 Get the test question configuration. More...
 
 fetchSolutionSubmit (array $form_submission_data_structure)
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 solutionValuesToText (array $solution_values)
 MUST convert the given solution values into text. More...
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
 toNormalized (Transformations $transformations, array $context=[])
 
 fromNormalized (array $normalized, Transformations $transformations)
 
- Public Member Functions inherited from assQuestion
 getQuestionType ()
 
 isComplete ()
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 getCurrentUser ()
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML (string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping)
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $force_image_references=false)
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 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 ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorized_solution=true)
 
 calculateResultsFromSolution (int $active_id, int $pass)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $preview_session)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 getSuggestedSolutionPath ()
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images 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, ?int $pass=null)
 
 getSolutionValues (int $active_id, ?int $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 cloneXHTMLMediaObjectsOfQuestion (int $source_question_id)
 
 createPageObject ()
 
 clonePageOfQuestion (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=null)
 
 updateOriginalId (?int $original_id=null)
 
 duplicate (bool $set_original_id=true, string $title='', string $author='', int $owner=-1, $test_obj_id=null)
 
 copyObject (int $target_parent_id, string $title='')
 
 createNewOriginalFromThisDuplicate (int $target_parent_id, string $target_question_title='')
 
 saveToDb (?int $original_id=null)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 
 resolveInternalLink (string $internal_link)
 
 resolveSuggestedSolutionLinks ()
 
 getInternalLinkHref (string $target)
 
 syncWithOriginal ()
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 isWriteable ()
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $preview_session)
 
 adjustReachedPointsByScoringOptions (float $points, int $active_id)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionTypeID ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 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)
 
 isAnswered (int $active_id, int $pass)
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange (int $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 ()
 
 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 $value_pairs)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
 hasWritableOriginalInQuestionPool ()
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 getSolutionForTextOutput (int $active_id, int $pass)
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
 getVariablesAsTextArray (int $active_id, int $pass)
 
 toNormalized (Transformations $transformations, array $context=[])
 
 fromNormalized (array $normalized, Transformations $transformations)
 
 validateSolutionSubmit ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 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 (string $expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getUserQuestionResult (int $active_id, int $pass)
 Get the user solution for a question by active_id and the test pass. More...
 
 getAvailableAnswerOptions (?int $index=null)
 If index is null, the function returns an array with all anwser options else it returns the specific answer option. More...
 
 toJSON ()
 
 toNormalized (Transformations $transformations, array $context=[])
 Convert the internal state of the implementing object into a language-neutral array structure. More...
 
 fromNormalized (array $normalized, Transformations $transformations)
 Restore the object from its normalized representation. 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 = []
 
 $leveled_ordering = []
 
- Data Fields inherited from assQuestion
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
const TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
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 ()
 
 cloneQuestionTypeSpecificProperties (\assQuestion $target)
 
 getValidOrderingTypes ()
 
 getSolutionValuePairBrandedOrderingElementByRandomIdentifier (int $value1, string $value2)
 
 getSolutionValuePairBrandedOrderingElementBySolutionIdentifier (int $value1, string $value2)
 
 cleanImagefiles ()
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 getQuestionRepository ()
 
 generateThumbForFile ($path, $file)
 
 calculateReachedPointsForSolution (ilAssOrderingElementList $solution_ordering_element_list)
 
 ensureImagePathExists ()
 
 buildOrderingElementFormDataConverter ()
 
 buildOrderingImagesFormDataConverter ()
 
 buildOrderingTextsFormDataConverter ()
 
 buildNestedOrderingFormDataConverter ()
 
 solutionValuesToLog (AdditionalInformationGenerator $additional_info, array $solution_values)
 MUST convert the given solution values into an array or a string that can be stored in the log. More...
 
- Protected Member Functions inherited from assQuestion
 solutionValuesToLog (AdditionalInformationGenerator $additional_info, array $solution_values)
 MUST convert the given solution values into an array or a string that can be stored in the log. More...
 
 solutionValuesToText (array $solution_values)
 MUST convert the given solution values into text. More...
 
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $post_submission_field_name)
 
 savePreviewData (ilAssQuestionPreviewSession $preview_session)
 
 deletePageOfQuestion (int $question_id)
 
 cloneQuestionTypeSpecificProperties (self $target)
 
 removeAllImageFiles (string $image_target_path)
 
 onDuplicate (int $original_parent_id, int $original_question_id, int $duplicate_parent_id, int $duplicate_question_id)
 
 afterSyncWithOriginal (int $original_question_id, int $clone_question_id, int $original_parent_id, int $clone_parent_id)
 
 onCopy (int $sourceParentId, int $sourceQuestionId, int $targetParentId, int $targetQuestionId)
 
 duplicateComments (int $parent_source_id, int $source_id, int $parent_target_id, int $target_id)
 
 deleteComments ()
 
 getNotesManager ()
 
 getNotesDataService ()
 
 getNotesRepo ()
 
 cloneSuggestedSolutions (int $source_question_id, int $target_question_id)
 
 duplicateSuggestedSolutionFiles (int $parent_id, int $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 cloneSuggestedSolutionFiles (int $source_question_id, int $target_question_id)
 
 copySuggestedSolutions (int $target_question_id)
 
 ensureNonNegativePoints (float $points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 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 ()
 
 getSuggestedSolutionsRepo ()
 
 loadSuggestedSolutions ()
 
 answerToLog (AdditionalInformationGenerator $additional_info, int $active_id, int $pass)
 

Protected Attributes

const HAS_SPECIFIC_FEEDBACK = false
 
OQRepository $oq_repository = null
 
ilAssOrderingElementList $element_list_for_deferred_saving = null
 
- Protected Attributes inherited from assQuestion
const HAS_SPECIFIC_FEEDBACK = true
 
GeneralQuestionPropertiesRepository $questionrepository
 
RequestDataCollector $questionpool_request
 
QuestionFiles $question_files
 
ilAssQuestionProcessLocker $processLocker
 
ilTestQuestionConfig $testQuestionConfig
 
SuggestedSolutionsDatabaseRepository $suggestedsolution_repo
 
ILIAS $ilias
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
ilDBInterface $db
 
ilObjUser $current_user
 
SkillUsageService $skillUsageService
 
HTTPServices $http
 
Refinery $refinery
 
Transformation $shuffler
 
LoggingServices $log
 
Container $dic
 
ilAssQuestionLifecycle $lifecycle
 
ilAssQuestionPage $page
 
TestResultRepository $test_result_repository
 
int $id
 
string $title
 
string $comment
 
int $owner
 
string $author
 
int $thumb_size
 
string $question
 
float $points = 0.0
 
bool $shuffle = true
 
int $test_id
 
int $obj_id = 0
 
int $original_id = null
 
int $lastChange = null
 
string $external_id = null
 
int $step = null
 
array $suggested_solutions
 

Private Member Functions

 getOrderingTypeLangVars (int $ordering_type)
 
 getSolutionOutputForLog ()
 
 getElementArrayWithIdentationsForTextOutput (array $elements)
 

Private Attributes

ilAssOrderingElementList $postSolutionOrderingElementList = null
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $force_pass_results_update_enabled)
 
static isForcePassResultUpdateEnabled ()
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static isFileAvailable (string $file)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $question_id)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
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 $force_pass_results_update_enabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

Member Function Documentation

◆ buildNestedOrderingElementInputGui()

assOrderingQuestion::buildNestedOrderingElementInputGui ( )
Returns
ilAssNestedOrderingElementsInputGUI

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

963 {
964 $form_data_converter = $this->buildNestedOrderingFormDataConverter();
965
966 $ordering_element_input = new ilAssNestedOrderingElementsInputGUI(
967 $form_data_converter,
968 self::ORDERING_ELEMENT_FORM_FIELD_POSTVAR
969 );
970
971 $ordering_element_input->setUniquePrefix($this->getId());
972 $ordering_element_input->setOrderingType($this->getOrderingType());
973 $ordering_element_input->setElementImagePath($this->getImagePathWeb());
974 $ordering_element_input->setThumbPrefix($this->getThumbPrefix());
975
976 $this->initOrderingElementFormFieldLabels($ordering_element_input);
977
978 return $ordering_element_input;
979 }
initOrderingElementFormFieldLabels(ilFormPropertyGUI $formField)
getImagePathWeb()
Returns the web image path for web accessable images of a question.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ buildNestedOrderingFormDataConverter()

assOrderingQuestion::buildNestedOrderingFormDataConverter ( )
protected
Returns
ilAssOrderingFormValuesObjectsConverter

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

1254 {
1255 $form_data_converter = $this->buildOrderingElementFormDataConverter();
1257
1258 if ($this->getOrderingType() === self::OQ_NESTED_PICTURES) {
1259 $form_data_converter->setImageRemovalCommand(self::ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG);
1260 $form_data_converter->setImageUrlPath($this->getImagePathWeb());
1261 $form_data_converter->setThumbnailPrefix($this->getThumbPrefix());
1262 }
1263
1264 return $form_data_converter;
1265 }

References ilAssOrderingFormValuesObjectsConverter\CONTEXT_MAINTAIN_HIERARCHY.

◆ buildOrderingElementFormDataConverter()

assOrderingQuestion::buildOrderingElementFormDataConverter ( )
protected
Returns
ilAssOrderingFormValuesObjectsConverter

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

1215 {
1216 $converter = new ilAssOrderingFormValuesObjectsConverter();
1217 $converter->setPostVar(self::ORDERING_ELEMENT_FORM_FIELD_POSTVAR);
1218
1219 return $converter;
1220 }

◆ buildOrderingElementInputGui()

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

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

Referenced by ilAssOrderingQuestionAuthoringFormGUI\renewOrderingElementInput().

+ Here is the caller graph for this function:

◆ buildOrderingImagesFormDataConverter()

assOrderingQuestion::buildOrderingImagesFormDataConverter ( )
protected
Returns
ilAssOrderingFormValuesObjectsConverter

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

1226 {
1227 $formDataConverter = $this->buildOrderingElementFormDataConverter();
1229
1230 $formDataConverter->setImageRemovalCommand(self::ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG);
1231 $formDataConverter->setImageUrlPath($this->getImagePathWeb());
1232 $formDataConverter->setImageFsPath($this->getImagePath());
1233
1234 if ($this->getThumbPrefix()) {
1235 $formDataConverter->setThumbnailPrefix($this->getThumbPrefix());
1236 }
1237 return $formDataConverter;
1238 }
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 ( )
Returns
ilAssOrderingImagesInputGUI

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

943 {
944 $formDataConverter = $this->buildOrderingImagesFormDataConverter();
945
946 $orderingElementInput = new ilAssOrderingImagesInputGUI(
947 $formDataConverter,
948 self::ORDERING_ELEMENT_FORM_FIELD_POSTVAR
949 );
950
951 $orderingElementInput->setImageUploadCommand(self::ORDERING_ELEMENT_FORM_CMD_UPLOAD_IMG);
952 $orderingElementInput->setImageRemovalCommand(self::ORDERING_ELEMENT_FORM_CMD_REMOVE_IMG);
953
954 $this->initOrderingElementFormFieldLabels($orderingElementInput);
955
956 return $orderingElementInput;
957 }
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 ( )
Returns
ilAssOrderingTextsInputGUI

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

925 {
926 $formDataConverter = $this->buildOrderingTextsFormDataConverter();
927
928 $orderingElementInput = new ilAssOrderingTextsInputGUI(
929 $formDataConverter,
930 self::ORDERING_ELEMENT_FORM_FIELD_POSTVAR
931 );
932
933 $this->initOrderingElementFormFieldLabels($orderingElementInput);
934 $orderingElementInput->setInfo($orderingElementInput->getInfo() . ' ' . $this->lng->txt('latex_edit_info'));
935
936 return $orderingElementInput;
937 }

◆ buildTestPresentationConfig()

assOrderingQuestion::buildTestPresentationConfig ( )

Get the test question configuration.

Returns
ilTestQuestionConfig

Reimplemented from assQuestion.

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

1138 // hey.
1139 {
1140 // hey: refactored identifiers
1141 return parent::buildTestPresentationConfig()
1142 // hey.
1144 ->setUseUnchangedAnswerLabel($this->lng->txt('tst_unchanged_order_is_correct'));
1145 }
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 ( int  $active_id,
?int  $pass = null,
bool  $authorized_solution = true 
)

Reimplemented from assQuestion.

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

479 : float {
480 if ($pass === null) {
481 $pass = $this->getSolutionMaxPass($active_id);
482 }
483
484 $solution_value_pairs = $this->getSolutionValues($active_id, $pass, $authorized_solution);
485
486 if ($solution_value_pairs === []) {
487 return 0.0;
488 }
489
490 $solution_ordering_element_list = $this->getSolutionOrderingElementList(
491 $this->fetchIndexedValuesFromValuePairs($solution_value_pairs)
492 );
493
494 return $this->calculateReachedPointsForSolution($solution_ordering_element_list);
495 }
getSolutionOrderingElementList(array $indexed_solution_values)
calculateReachedPointsForSolution(ilAssOrderingElementList $solution_ordering_element_list)
getSolutionValues(int $active_id, ?int $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
getSolutionMaxPass(int $active_id)
fetchIndexedValuesFromValuePairs(array $value_pairs)

◆ calculateReachedPointsForSolution()

assOrderingQuestion::calculateReachedPointsForSolution ( ilAssOrderingElementList  $solution_ordering_element_list)
protected

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

1030 : float
1031 {
1032 $reached_points = $this->getPoints();
1033
1034 foreach ($this->getOrderingElementList() as $correct_element) {
1035 $user_element = $solution_ordering_element_list->getElementByPosition($correct_element->getPosition());
1036 if (!$correct_element->isSameElement($user_element)) {
1037 $reached_points = 0;
1038 break;
1039 }
1040 }
1041
1042 return $reached_points;
1043 }

References ilAssOrderingElementList\getElementByPosition().

+ Here is the call graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assOrderingQuestion::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $preview_session)

Reimplemented from assQuestion.

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

497 : float
498 {
499 if (!$preview_session->hasParticipantSolution()) {
500 return 0.0;
501 }
502
503 $solution_ordering_element_list = unserialize(
504 $preview_session->getParticipantsSolution(),
505 ['allowed_classes' => true]
506 );
507
508 $reached_points = $this->calculateReachedPointsForSolution($solution_ordering_element_list);
509
510 return $this->ensureNonNegativePoints($reached_points);
511 }
ensureNonNegativePoints(float $points)

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

+ Here is the call graph for this function:

◆ cleanImagefiles()

assOrderingQuestion::cleanImagefiles ( )
protected

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

535 : void
536 {
537 if ($this->getOrderingType() == self::OQ_PICTURES) {
538 if (@file_exists($this->getImagePath())) {
540 foreach ($contents as $f) {
541 if (strcmp($f['type'], 'file') == 0) {
542 $found = false;
543 foreach ($this->getOrderingElementList() as $orderElement) {
544 if (strcmp($f['entry'], $orderElement->getContent()) == 0) {
545 $found = true;
546 }
547 if (strcmp($f['entry'], $this->getThumbPrefix() . $orderElement->getContent()) == 0) {
548 $found = true;
549 }
550 }
551 if (!$found) {
552 if (@file_exists($this->getImagePath() . $f['entry'])) {
553 @unlink($this->getImagePath() . $f['entry']);
554 }
555 }
556 }
557 }
558 }
559 } else {
560 if (@file_exists($this->getImagePath())) {
562 }
563 }
564 }
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

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

+ Here is the call graph for this function:

◆ cloneImages()

assOrderingQuestion::cloneImages ( int  $source_question_id,
int  $source_parent_id,
int  $target_question_id,
int  $target_parent_id 
)

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

183 : void {
184 if (!$this->isImageOrderingType()) {
185 return;
186 }
187
188 $image_source_path = $this->getImagePath($source_question_id, $source_parent_id);
189 $image_target_path = $this->getImagePath($target_question_id, $target_parent_id);
190
191 if (!file_exists($image_target_path)) {
192 ilFileUtils::makeDirParents($image_target_path);
193 } else {
194 $this->removeAllImageFiles($image_target_path);
195 }
196 foreach ($this->getOrderingElementList() as $element) {
197 $filename = $element->getContent();
198
199 if ($filename === '') {
200 continue;
201 }
202
203 if (!file_exists($image_source_path . $filename)
204 || !copy($image_source_path . $filename, $image_target_path . $filename)) {
205 $this->log->forComponent('qpl')->warning('Image could not be cloned for object for question: ' . $target_question_id);
206 }
207 if (!file_exists($image_source_path . $this->getThumbPrefix() . $filename)
208 || !copy($image_source_path . $this->getThumbPrefix() . $filename, $image_target_path . $this->getThumbPrefix() . $filename)) {
209 $this->log->forComponent('qpl')->warning('Image thumbnails could not be cloned for object for question: ' . $target_question_id);
210 }
211 }
212 }
$filename
Definition: buildRTE.php:78
removeAllImageFiles(string $image_target_path)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.

◆ cloneQuestionTypeSpecificProperties()

assOrderingQuestion::cloneQuestionTypeSpecificProperties ( \assQuestion  $target)
protected

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

168 : \assQuestion {
169 $list = $this->getRepository()->getOrderingList($this->getId())
170 ->withQuestionId($target->getId());
171 $list->distributeNewRandomIdentifiers();
172 $target->setOrderingElementList($list);
173 $this->cloneImages($this->getId(), $this->getObjId(), $target->getId(), $target->getObjId());
174 $target->saveToDb();
175 return $target;
176 }
cloneImages(int $source_question_id, int $source_parent_id, int $target_question_id, int $target_parent_id)

◆ deleteAnswer()

assOrderingQuestion::deleteAnswer ( int  $random_identifier)

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

462 : void
463 {
464 $this->getOrderingElementList()->removeElement(
465 $this->getOrderingElementList()->getElementByRandomIdentifier($random_identifier)
466 );
467 $this->getOrderingElementList()->saveToDb();
468 }

◆ dropImageFile()

assOrderingQuestion::dropImageFile (   $imageFilename)

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

573 {
574 if (!strlen($imageFilename)) {
575 return false;
576 }
577
578 $cleaned_image_file_name = basename($imageFilename);
579 $result = @unlink($this->getImagePath() . $cleaned_image_file_name);
580 $result = $result && @unlink($this->getImagePath() . $this->getThumbPrefix() . $cleaned_image_file_name);
581
582 return $result;
583 }

◆ ensureImagePathExists()

assOrderingQuestion::ensureImagePathExists ( )
protected

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

1148 : void
1149 {
1150 if (!file_exists($this->getImagePath())) {
1152 }
1153 }

References ilFileUtils\makeDirParents().

+ Here is the call graph for this function:

◆ fetchSolutionListFromFormSubmissionData()

assOrderingQuestion::fetchSolutionListFromFormSubmissionData ( array  $user_solution_post)

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

982 {
983 $ordering_gui = $this->buildNestedOrderingElementInputGui();
985 $ordering_gui->setValueByArray($user_solution_post);
986
987 if (!$ordering_gui->checkInput()) {
988 throw new ilTestException('error on validating user solution post');
989 }
990
991 $solution_ordering_element_list = ilAssOrderingElementList::buildInstance($this->getId());
992
993 $stored_element_list = $this->getOrderingElementList();
994
995 foreach ($ordering_gui->getElementList($this->getId()) as $submitted_element) {
996 $solution_element = $stored_element_list->getElementByRandomIdentifier(
997 $submitted_element->getRandomIdentifier()
998 )?->getClone();
999
1000 if ($solution_element === null) {
1001 continue;
1002 }
1003
1004 $solution_element->setPosition($submitted_element->getPosition());
1005
1006 if ($this->isOrderingTypeNested()) {
1007 $solution_element->setIndentation($submitted_element->getIndentation());
1008 }
1009
1010 $solution_ordering_element_list->addElement($solution_element);
1011 }
1012
1013 return $solution_ordering_element_list;
1014 }
static buildInstance(int $question_id, array $elements=[])
Base Exception for all Exceptions relating to Modules/Test.

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

+ Here is the call graph for this function:

◆ fetchSolutionSubmit()

assOrderingQuestion::fetchSolutionSubmit ( array  $form_submission_data_structure)
Returns
array

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

1158 : array
1159 {
1160 $solution_submit = [];
1161
1162 if (isset($form_submission_data_structure['orderresult'])) {
1163 $orderresult = $form_submission_data_structure['orderresult'];
1164
1165 if (strlen($orderresult)) {
1166 $orderarray = explode(":", $orderresult);
1167 $ordervalue = 1;
1168 foreach ($orderarray as $index) {
1169 $idmatch = null;
1170 if (preg_match("/id_(\\d+)/", $index, $idmatch)) {
1171 $randomid = $idmatch[1];
1172 foreach ($this->getOrderingElementList() as $answeridx => $answer) {
1173 if ($answer->getRandomIdentifier() == $randomid) {
1174 $solution_submit[$answeridx] = $ordervalue;
1175 $ordervalue++;
1176 }
1177 }
1178 }
1179 }
1180 }
1181 } elseif ($this->getOrderingType() == self::OQ_NESTED_TERMS || $this->getOrderingType() == self::OQ_NESTED_PICTURES) {
1182 $index = 0;
1183 foreach ($form_submission_data_structure['content'] as $randomId => $content) {
1184 $indentation = $form_submission_data_structure['indentation'];
1185
1186 $value1 = $index++;
1187 $value2 = implode(':', [$randomId, $indentation]);
1188
1189 $solution_submit[$value1] = $value2;
1190 }
1191 } else {
1192 foreach ($form_submission_data_structure as $key => $value) {
1193 $matches = null;
1194 if (preg_match("/^order_(\d+)/", $key, $matches)) {
1195 if (!(preg_match("/initial_value_\d+/", $value))) {
1196 if (strlen($value)) {
1197 foreach ($this->getOrderingElementList() as $answeridx => $answer) {
1198 if ($answer->getRandomIdentifier() == $matches[1]) {
1199 $solution_submit[$answeridx] = $value;
1200 }
1201 }
1202 }
1203 }
1204 }
1205 }
1206 }
1207
1208 return $solution_submit;
1209 }

◆ fromNormalized()

assOrderingQuestion::fromNormalized ( array  $normalized,
Transformations  $transformations 
)
Parameters
array<array-key,mixed>$normalized

Reimplemented from assQuestion.

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

1393 : static
1394 {
1395 $clone = parent::fromNormalized($normalized, $transformations);
1396 $clone->ordering_type = $transformations->int($normalized['ordering_type']);
1397 $denormalized_elements = array_map(
1398 static fn(array $element): ilAssOrderingElement => $transformations->denormalize($element, new ilAssOrderingElement()),
1399 $normalized['ordering_elements']
1400 );
1401 $clone->element_list_for_deferred_saving = new ilAssOrderingElementList(null, $denormalized_elements);
1402
1403 return $clone;
1404 }
denormalize(array|float|bool|int|string|null $normalized, string|object $expected)

References ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\denormalize(), and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\int().

+ Here is the call graph for this function:

◆ generateThumbForFile()

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

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

814 : void
815 {
816 $filename = $path . $file;
817 if (@file_exists($filename)) {
818 $thumbpath = $path . $this->getThumbPrefix() . $file;
819 $path_info = @pathinfo($filename);
820 $ext = "";
821 switch (strtoupper($path_info['extension'])) {
822 case 'PNG':
823 $ext = 'PNG';
824 break;
825 case 'GIF':
826 $ext = 'GIF';
827 break;
828 default:
829 $ext = 'JPEG';
830 break;
831 }
832 ilShellUtil::convertImage($filename, $thumbpath, $ext, (string) $this->getThumbSize());
833 }
834 }
static convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")

References $filename, and ilShellUtil\convertImage().

+ Here is the call graph for this function:

◆ getAdditionalTableName()

assOrderingQuestion::getAdditionalTableName ( )

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

Returns
string The additional table name @access public

Reimplemented from assQuestion.

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

745 : string
746 {
747 return "qpl_qst_ordering";
748 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ getAnswer()

assOrderingQuestion::getAnswer ( int  $index = 0)

Returns the ordering element from the given position.

Parameters
int$position
Returns
ilAssOrderingElement|null

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

454 {
455 if (!$this->getOrderingElementList()->elementExistByPosition($index)) {
456 return null;
457 }
458
459 return $this->getOrderingElementList()->getElementByPosition($index);
460 }

◆ getAnswerCount()

assOrderingQuestion::getAnswerCount ( )

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

470 : int
471 {
472 return $this->getOrderingElementList()->countElements();
473 }

◆ 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 756 of file class.assOrderingQuestion.php.

756 : string
757 {
758 return "qpl_a_ordering";
759 }

◆ 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

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

1123 {
1124 if ($index !== null) {
1125 return $this->getOrderingElementList()->getElementByPosition($index);
1126 }
1127
1128 return $this->getOrderingElementList()->getElements();
1129 }

◆ getCorrectSolutionForTextOutput()

assOrderingQuestion::getCorrectSolutionForTextOutput ( int  $active_id,
int  $pass 
)

Reimplemented from assQuestion.

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

1341 : array
1342 {
1344 $this->getOrderingElementList()->getElements()
1345 );
1346 }
getElementArrayWithIdentationsForTextOutput(array $elements)

◆ getElementArrayWithIdentationsForTextOutput()

assOrderingQuestion::getElementArrayWithIdentationsForTextOutput ( array  $elements)
private
Parameters
array<ilAssOrderingElement>$elements
Returns
array

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

1353 : array
1354 {
1355 usort(
1356 $elements,
1358 => $a->getPosition() - $b->getPosition()
1359 );
1360
1361 return array_map(
1362 function (ilAssOrderingElement $v): string {
1363 $indentation = '';
1364 for ($i = 0;$i < $v->getIndentation();$i++) {
1365 $indentation .= ' |';
1366 }
1367 return $indentation . $v->getContent();
1368 },
1369 $elements
1370 );
1371 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, Vendor\Package\$b, ilAssOrderingElement\getContent(), and ilAssOrderingElement\getIndentation().

+ Here is the call graph for this function:

◆ getElementHeight()

assOrderingQuestion::getElementHeight ( )

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

785 : ?int
786 {
788 }

◆ getEncryptedFilename()

assOrderingQuestion::getEncryptedFilename (   $filename)

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

526 : string
527 {
528 $extension = "";
529 if (preg_match("/.*\\.(\\w+)$/", $filename, $matches)) {
530 $extension = $matches[1];
531 }
532 return md5($filename) . "." . $extension;
533 }

References $filename.

◆ getExpressionTypes()

◆ getMaximumPoints()

assOrderingQuestion::getMaximumPoints ( )

Reimplemented from assQuestion.

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

513 : float
514 {
515 return $this->getPoints();
516 }

Referenced by isComplete().

+ Here is the caller graph for this function:

◆ getOperators()

assOrderingQuestion::getOperators ( string  $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

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

1045 : array
1046 {
1048 }
static getOperatorsByExpression(string $expression)

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 780 of file class.assOrderingQuestion.php.

780 : array
781 {
782 return $this->getOrderingElementList()->getRandomIdentifierIndexedElements();
783 }

◆ getOrderingElementList()

assOrderingQuestion::getOrderingElementList ( )
Returns
ilAssOrderingElementList

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

423 {
424 return $this->getRepository()->getOrderingList($this->getId());
425 }

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 ( bool  $force_correct_solution,
int  $active_id,
?int  $pass_index 
)

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

307 if ($force_correct_solution || !$active_id || $pass_index === null) {
308 return $this->getOrderingElementList();
309 }
310
311 $solution_values = $this->getSolutionValues($active_id, $pass_index);
312
313 if (!count($solution_values)) {
314 return $this->getShuffledOrderingElementList();
315 }
316
317 return $this->getSolutionOrderingElementList($this->fetchIndexedValuesFromValuePairs($solution_values));
318 }

◆ getOrderingType()

assOrderingQuestion::getOrderingType ( )

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

232 : int
233 {
234 return $this->ordering_type;
235 }

◆ getOrderingTypeLangVars()

assOrderingQuestion::getOrderingTypeLangVars ( int  $ordering_type)
private

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

1287 : array
1288 {
1289 switch ($ordering_type) {
1290 case self::OQ_PICTURES:
1291 return ['qst_nested_nested_answers_off', 'oq_btn_use_order_pictures'];
1292 case self::OQ_TERMS:
1293 return ['qst_nested_nested_answers_off', 'oq_btn_use_order_terms'];
1295 return ['qst_nested_nested_answers_on', 'oq_btn_use_order_pictures'];
1297 return ['qst_nested_nested_answers_on', 'oq_btn_use_order_terms'];
1298 default:
1299 return ['', ''];
1300 }
1301 }

◆ getQuestionRepository()

assOrderingQuestion::getQuestionRepository ( )
protected

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

719 : OQRepository
720 {
721 return new OQRepository($this->db);
722 }

◆ getQuestionType()

assOrderingQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question @access public

Reimplemented from assQuestion.

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

734 : string
735 {
736 return "assOrderingQuestion";
737 }

◆ getRepository()

assOrderingQuestion::getRepository ( )
protected

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

101 : OQRepository
102 {
103 if (is_null($this->oq_repository)) {
104 $this->oq_repository = new OQRepository($this->db);
105 }
107 }

References $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 765 of file class.assOrderingQuestion.php.

765 : string
766 {
767 $text = parent::getRTETextWithMediaObjects();
768
769 foreach ($this->getOrderingElementList() as $orderingElement) {
770 $text .= $orderingElement->getContent();
771 }
772
773 return $text;
774 }
$text
Definition: xapiexit.php:21

References $text.

◆ getShuffledOrderingElementList()

assOrderingQuestion::getShuffledOrderingElementList ( )
Parameters
$active_id
$pass
Returns
ilAssOrderingElementList

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

407 {
408 $shuffledRandomIdentifierIndex = $this->getShuffler()->transform(
409 $this->getOrderingElementList()->getRandomIdentifierIndex()
410 );
411
412 $shuffledElementList = $this->getOrderingElementList()->getClone();
413 $shuffledElementList->reorderByRandomIdentifiers($shuffledRandomIdentifierIndex);
414 $shuffledElementList->resetElementsIndentations();
415
416 return $shuffledElementList;
417 }

References ilAssOrderingElementList\getClone().

+ Here is the call graph for this function:

◆ getSolutionListFromPostSubmit()

assOrderingQuestion::getSolutionListFromPostSubmit ( )

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

1019 {
1020 if ($this->postSolutionOrderingElementList === null) {
1022 $this->http->request()->getParsedBody()
1023 );
1024 $this->postSolutionOrderingElementList = $list;
1025 }
1026
1028 }
fetchSolutionListFromFormSubmissionData(array $user_solution_post)
ilAssOrderingElementList $postSolutionOrderingElementList
static http()
Fetches the global http state from ILIAS.

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getSolutionOrderingElementList()

assOrderingQuestion::getSolutionOrderingElementList ( array  $indexed_solution_values)
Exceptions
ilTestQuestionPoolException

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

380 {
381 $solution_ordering_list = new ilAssOrderingElementList();
382 $solution_ordering_list->setQuestionId($this->getId());
383
384 foreach ($indexed_solution_values as $value1 => $value2) {
385 if ($this->isOrderingTypeNested()) {
386 $element = $this->getSolutionValuePairBrandedOrderingElementByRandomIdentifier($value1, $value2);
387 } else {
388 $element = $this->getSolutionValuePairBrandedOrderingElementBySolutionIdentifier($value1, $value2);
389 }
390
391 $solution_ordering_list->addElement($element);
392 }
393
394 if (!$this->getOrderingElementList()->hasSameElementSetByRandomIdentifiers($solution_ordering_list)) {
395 throw new ilTestQuestionPoolException('inconsistent solution values given');
396 }
397
398 return $solution_ordering_list;
399 }
getSolutionValuePairBrandedOrderingElementByRandomIdentifier(int $value1, string $value2)
getSolutionValuePairBrandedOrderingElementBySolutionIdentifier(int $value1, string $value2)

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ getSolutionOrderingElementListForTestOutput()

assOrderingQuestion::getSolutionOrderingElementListForTestOutput ( ilAssNestedOrderingElementsInputGUI  $input_gui,
array  $last_post,
int  $active_id,
int  $pass 
)

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

326 if ($input_gui->isPostSubmit($last_post)) {
327 return $this->fetchSolutionListFromFormSubmissionData($last_post);
328 }
329 $indexedSolutionValues = $this->fetchIndexedValuesFromValuePairs(
330 // hey: prevPassSolutions - obsolete due to central check
331 $this->getTestOutputSolutions($active_id, $pass)
332 // hey.
333 );
334
335 if (count($indexedSolutionValues)) {
336 return $this->getSolutionOrderingElementList($indexedSolutionValues);
337 }
338
339 return $this->getShuffledOrderingElementList();
340 }
getTestOutputSolutions(int $activeId, int $pass)

◆ getSolutionOutputForLog()

assOrderingQuestion::getSolutionOutputForLog ( )
private

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

1303 : string
1304 {
1305 $solution_ordering_list = $this->getOrderingElementList();
1306
1307 $answers_gui = $this->buildNestedOrderingElementInputGui();
1309 $answers_gui->setInteractionEnabled(false);
1310 $answers_gui->setElementList($solution_ordering_list);
1311
1312 return $answers_gui->getHTML();
1313 }

References ilAssNestedOrderingElementsInputGUI\CONTEXT_CORRECT_SOLUTION_PRESENTATION.

◆ getSolutionValuePairBrandedOrderingElementByRandomIdentifier()

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

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

346 $value = explode(':', $value2);
347
348 $random_identifier = (int) $value[0];
349 $selected_position = $value1;
350 $selected_indentation = (int) $value[1];
351
352 $element = $this->getOrderingElementList()->getElementByRandomIdentifier($random_identifier)->getClone();
353
354 $element->setPosition($selected_position);
355 $element->setIndentation($selected_indentation);
356
357 return $element;
358 }

◆ getSolutionValuePairBrandedOrderingElementBySolutionIdentifier()

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

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

364 $solution_identifier = $value1;
365 $selected_position = ($value2 - 1);
366 $selected_indentation = 0;
367
368 $element = $this->getOrderingElementList()->getElementBySolutionIdentifier($solution_identifier)->getClone();
369
370 $element->setPosition($selected_position);
371 $element->setIndentation($selected_indentation);
372
373 return $element;
374 }

◆ getThumbPrefix()

assOrderingQuestion::getThumbPrefix ( )

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

809 : string
810 {
811 return "thumb.";
812 }

◆ getUserQuestionResult()

assOrderingQuestion::getUserQuestionResult ( int  $active_id,
int  $pass 
)

Get the user solution for a question by active_id and the test pass.

Implements iQuestionCondition.

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

1064 $result = new ilUserQuestionResult($this, $active_id, $pass);
1065
1066 $maxStep = $this->lookupMaxStep($active_id, $pass);
1067 if ($maxStep > 0) {
1068 $data = $this->db->queryF(
1069 "SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s ORDER BY value1 ASC ",
1070 ["integer", "integer", "integer","integer"],
1071 [$active_id, $pass, $this->getId(), $maxStep]
1072 );
1073 } else {
1074 $data = $this->db->queryF(
1075 "SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s ORDER BY value1 ASC ",
1076 ["integer", "integer", "integer"],
1077 [$active_id, $pass, $this->getId()]
1078 );
1079 }
1080
1081 $elements = [];
1082 while ($row = $this->db->fetchAssoc($data)) {
1083 $newKey = explode(":", $row["value2"]);
1084
1085 foreach ($this->getOrderingElementList() as $answer) {
1086 // Images not supported
1087 if (!$this->isOrderingTypeNested()) {
1088 if ($answer->getSolutionIdentifier() == $row["value1"]) {
1089 $elements[$row["value2"]] = $answer->getSolutionIdentifier() + 1;
1090 break;
1091 }
1092 } else {
1093 if ($answer->getRandomIdentifier() == $newKey[0]) {
1094 $elements[$row["value1"]] = $answer->getSolutionIdentifier() + 1;
1095 break;
1096 }
1097 }
1098 }
1099 }
1100
1101 ksort($elements);
1102
1103 foreach (array_values($elements) as $element) {
1104 $result->addKeyValue($element, $element);
1105 }
1106
1107 $points = $this->calculateReachedPoints($active_id, $pass);
1108 $max_points = $this->getMaximumPoints();
1109
1110 $result->setReachedPercentage(($points / $max_points) * 100);
1111
1112 return $result;
1113 }
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
lookupMaxStep(int $active_id, int $pass)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$data
Definition: storeScorm.php:45

◆ getValidOrderingTypes()

assOrderingQuestion::getValidOrderingTypes ( )
protected

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

214 : array
215 {
216 return [
221 ];
222 }

◆ hasOrderingTypeUploadSupport()

assOrderingQuestion::hasOrderingTypeUploadSupport ( )

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

297 : bool
298 {
299 return $this->isImageOrderingType();
300 }

◆ initOrderingElementAuthoringProperties()

assOrderingQuestion::initOrderingElementAuthoringProperties ( ilFormPropertyGUI  $formField)
Parameters
ilAssOrderingTextsInputGUI | ilAssOrderingImagesInputGUI | ilAssNestedOrderingElementsInputGUI$formField

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

895 : void
896 {
897 switch (true) {
898 case $formField instanceof ilAssNestedOrderingElementsInputGUI:
899 $formField->setInteractionEnabled(true);
900 $formField->setNestingEnabled($this->isOrderingTypeNested());
901 break;
902
903 case $formField instanceof ilAssOrderingTextsInputGUI:
904 case $formField instanceof ilAssOrderingImagesInputGUI:
905 default:
906
907 $formField->setEditElementOccuranceEnabled(true);
908 $formField->setEditElementOrderEnabled(true);
909 }
910 }

Referenced by ilAssOrderingQuestionAuthoringFormGUI\renewOrderingElementInput().

+ Here is the caller graph for this function:

◆ initOrderingElementFormFieldLabels()

assOrderingQuestion::initOrderingElementFormFieldLabels ( ilFormPropertyGUI  $formField)
Parameters
ilFormPropertyGUI$formField

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

915 : void
916 {
917 $formField->setInfo($this->lng->txt('ordering_answer_sequence_info'));
918 $formField->setTitle($this->lng->txt('answers'));
919 }

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

+ Here is the call graph for this function:

◆ isComplete()

assOrderingQuestion::isComplete ( )

Reimplemented from assQuestion.

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

79 : bool
80 {
81 $elements_list = $this->getOrderingElementList()->getElements();
82 if ($elements_list === [] && $this->element_list_for_deferred_saving !== null) {
83 $elements_list = $this->element_list_for_deferred_saving->getElements();
84 }
85 $elements = array_filter(
86 $elements_list,
87 fn($element) => trim($element->getContent()) != ''
88 );
89
90 $has_at_least_two_elements = count($elements) > 1;
91
92 $complete = $this->getAuthor()
93 && $this->getTitle()
94 && $this->getQuestion()
95 && $this->getMaximumPoints()
96 && $has_at_least_two_elements;
97
98 return $complete;
99 }

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 585 of file class.assOrderingQuestion.php.

585 : bool
586 {
587 if (!strlen($imageFilename)) {
588 return false;
589 }
590
591 if (!file_exists($this->getImagePath() . $imageFilename)) {
592 return false;
593 }
594
595 return is_file($this->getImagePath() . $imageFilename);
596 }

◆ isImageOrderingType()

assOrderingQuestion::isImageOrderingType ( )

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

246 : bool
247 {
248 $with_images = [
251 ];
252 return in_array($this->getOrderingType(), $with_images);
253 }

Referenced by ilAssOrderingQuestionAuthoringFormGUI\addSpecificOrderingQuestionCommandButtons().

+ Here is the caller graph for this function:

◆ isImageReplaced()

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

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

598 : bool
599 {
600 if (!$this->hasOrderingTypeUploadSupport()) {
601 return false;
602 }
603
604 if (!$newElement->getContent()) {
605 return false;
606 }
607
608 return $newElement->getContent() != $oldElement->getContent();
609 }

References ilAssOrderingElement\getContent().

+ Here is the call graph for this function:

◆ isOrderingTypeNested()

assOrderingQuestion::isOrderingTypeNested ( )

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

237 : bool
238 {
239 $nested = [
242 ];
243 return in_array($this->getOrderingType(), $nested);
244 }

◆ 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 126 of file class.assOrderingQuestion.php.

126 : void
127 {
128 $result = $this->db->queryF(
129 "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",
130 ["integer"],
131 [$question_id]
132 );
133 if ($result->numRows() == 1) {
134 $data = $this->db->fetchAssoc($result);
135 $this->setId($question_id);
136 $this->setObjId($data["obj_fi"]);
137 $this->setTitle((string) $data["title"]);
138 $this->setComment((string) $data["description"]);
139 $this->setOriginalId($data["original_id"]);
140 $this->setAuthor($data["author"]);
141 $this->setNrOfTries($data['nr_of_tries']);
142 $this->setPoints($data["points"]);
143 $this->setOwner($data["owner"]);
144 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
145 $this->ordering_type = $data["ordering_type"] !== null ? (int) $data["ordering_type"] : self::OQ_TERMS;
146 if ($data['thumb_geometry'] !== null && $data['thumb_geometry'] >= $this->getMinimumThumbSize()) {
147 $this->setThumbSize($data['thumb_geometry']);
148 }
149 $this->element_height = $data["element_height"] ? (int) $data['element_height'] : null;
150
151 try {
152 $this->setLifecycle(new ilAssQuestionLifecycle($data['lifecycle']));
155 }
156
157 try {
158 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
160 }
161 }
162
163 parent::loadFromDb($question_id);
164 }
getAdditionalTableName()
Returns the name of the additional question data table in the database.
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, Vendor\Package\$e, ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), assQuestion\getMinimumThumbSize(), ILIAS\Repository\int(), 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 798 of file class.assOrderingQuestion.php.

798 : void
799 {
800 if ($this->isImageOrderingType()) {
801 foreach ($this->getOrderElements() as $orderingElement) {
802 if ($orderingElement->getContent() !== '') {
803 $this->generateThumbForFile($this->getImagePath(), $orderingElement->getContent());
804 }
805 }
806 }
807 }
getOrderElements()
Returns the answers array.

◆ saveAdditionalQuestionDataToDb()

assOrderingQuestion::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

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

697 {
698 // save additional data
699 $this->db->manipulateF(
700 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
701 ["integer"],
702 [$this->getId()]
703 );
704
705 $this->db->manipulateF(
706 "INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, ordering_type, thumb_geometry, element_height)
707 VALUES (%s, %s, %s, %s)",
708 ["integer", "text", "integer", "integer"],
709 [
710 $this->getId(),
711 $this->ordering_type,
712 $this->getThumbSize(),
713 ($this->getElementHeight() > 20) ? $this->getElementHeight() : null
714 ]
715 );
716 }

References ILIAS\Survey\Mode\getId().

Referenced by saveToDb().

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

◆ saveAnswerSpecificDataToDb()

assOrderingQuestion::saveAnswerSpecificDataToDb ( )

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

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

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

725 {
726 }

◆ savePreviewData()

assOrderingQuestion::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

Reimplemented from assQuestion.

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

689 : void
690 {
691 if ($this->validateSolutionSubmit()) {
692 $previewSession->setParticipantsSolution(serialize($this->getSolutionListFromPostSubmit()));
693 }
694 }

References ilAssQuestionPreviewSession\setParticipantsSolution().

+ Here is the call graph for this function:

◆ saveToDb()

assOrderingQuestion::saveToDb ( ?int  $original_id = null)

Reimplemented from assQuestion.

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

109 : void
110 {
113 parent::saveToDb();
114 if ($this->element_list_for_deferred_saving !== null) {
115 $this->setOrderingElementList($this->element_list_for_deferred_saving);
116 }
117 }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
setOrderingElementList(ilAssOrderingElementList $list)
saveQuestionDataToDb(?int $original_id=null)

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

+ Here is the call graph for this function:

◆ saveWorkingData()

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

Reimplemented from assQuestion.

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

664 : bool {
665 if ($this->questionpool_request->raw('test_answer_changed') === null) {
666 return true;
667 }
668
669 if (is_null($pass)) {
670 $pass = ilObjTest::_getPass($active_id);
671 }
672
673 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
674 function () use ($active_id, $pass, $authorized) {
675 $this->removeCurrentSolution($active_id, $pass, $authorized);
676
677 foreach ($this->getSolutionListFromPostSubmit() as $orderingElement) {
678 $value1 = $orderingElement->getStorageValue1($this->getOrderingType());
679 $value2 = $orderingElement->getStorageValue2($this->getOrderingType());
680
681 $this->saveCurrentSolution($active_id, $pass, $value1, trim((string) $value2), $authorized);
682 }
683 }
684 );
685
686 return true;
687 }
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
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.

◆ setContentType()

assOrderingQuestion::setContentType (   $ct)

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

256 {
257 if (!in_array($ct, [
258 self::OQ_CT_PICTURES,
259 self::OQ_CT_TERMS
260 ])) {
261 throw new \InvalidArgumentException("use OQ content-type", 1);
262 }
263 if ($ct == self::OQ_CT_PICTURES) {
264 if ($this->isOrderingTypeNested()) {
265 $this->setOrderingType(self::OQ_NESTED_PICTURES);
266 } else {
267 $this->setOrderingType(self::OQ_PICTURES);
268 }
269 $this->setThumbSize($this->getThumbSize());
270 }
271 if ($ct == self::OQ_CT_TERMS) {
272 if ($this->isOrderingTypeNested()) {
273 $this->setOrderingType(self::OQ_NESTED_TERMS);
274 } else {
275 $this->setOrderingType(self::OQ_TERMS);
276 }
277 }
278 }
setOrderingType(int $ordering_type=self::OQ_TERMS)

◆ setElementHeight()

assOrderingQuestion::setElementHeight ( ?int  $a_height)

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

790 : void
791 {
792 $this->element_height = ($a_height < 20) ? null : $a_height;
793 }

◆ setNestingType()

assOrderingQuestion::setNestingType ( bool  $nesting)

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

281 {
282 if ($nesting) {
283 if ($this->isImageOrderingType()) {
284 $this->setOrderingType(self::OQ_NESTED_PICTURES);
285 } else {
286 $this->setOrderingType(self::OQ_NESTED_TERMS);
287 }
288 } else {
289 if ($this->isImageOrderingType()) {
290 $this->setOrderingType(self::OQ_PICTURES);
291 } else {
292 $this->setOrderingType(self::OQ_TERMS);
293 }
294 }
295 }

◆ setOrderingElementList()

assOrderingQuestion::setOrderingElementList ( ilAssOrderingElementList  $list)
Parameters
ilAssOrderingElementList$orderingElementList

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

430 : void
431 {
432 if ($this->getId() <= 0) {
433 $this->element_list_for_deferred_saving = $list;
434 return;
435 }
436 $list = $list->withQuestionId($this->getId());
437 $elements = $list->getElements();
438 $nu = [];
439 foreach ($elements as $e) {
440 $nu[] = $list->ensureValidIdentifiers($e);
441 }
442 $this->getRepository()->updateOrderingList(
443 $list->withElements($nu)
444 );
445 }
ensureValidIdentifiers(ilAssOrderingElement $element)

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

Referenced by saveToDb().

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

◆ setOrderingType()

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

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

225 {
226 if (!in_array($ordering_type, $this->getValidOrderingTypes())) {
227 throw new \InvalidArgumentException('Must be valid ordering type.');
228 }
229 $this->ordering_type = $ordering_type;
230 }

◆ solutionValuesToLog()

assOrderingQuestion::solutionValuesToLog ( AdditionalInformationGenerator  $additional_info,
array  $solution_values 
)
protected

MUST convert the given solution values into an array or a string that can be stored in the log.

Language variables must be generated through the corresponding functions in the AdditionalInformationGenerator. If an array is returned it will be rendered into a line per array entry in the format "key: value". If the key exists as a language variable, it will be translated.

Reimplemented from assQuestion.

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

1318 : array {
1319 if ($solution_values === []) {
1320 return [];
1321 }
1324 $this->fetchIndexedValuesFromValuePairs($solution_values)
1325 )->getElements()
1326 );
1327 }

◆ solutionValuesToText()

assOrderingQuestion::solutionValuesToText ( array  $solution_values)

MUST convert the given solution values into text.

If the text has multiple lines each line MUST be placed as an entry in an array.

Reimplemented from assQuestion.

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

1329 : array
1330 {
1331 if ($solution_values === []) {
1332 return [];
1333 }
1336 $this->fetchIndexedValuesFromValuePairs($solution_values)
1337 )->getElements()
1338 );
1339 }

◆ storeImageFile()

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

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

612 : ?string
613 {
614 $name_parts = explode(".", $upload_name);
615 $suffix = strtolower(array_pop($name_parts));
616 if (!in_array($suffix, self::VALID_UPLOAD_SUFFIXES)) {
617 return null;
618 }
619
620 $this->ensureImagePathExists();
621 $target_filename = $this->buildHashedImageFilename($upload_name, true);
622 $target_filepath = $this->getImagePath() . $target_filename;
623 if (ilFileUtils::moveUploadedFile($upload_file, $target_filename, $target_filepath)) {
624 $thumb_path = $this->getImagePath() . $this->getThumbPrefix() . $target_filename;
625 ilShellUtil::convertImage($target_filepath, $thumb_path, "JPEG", (string) $this->getThumbSize());
626
627 return $target_filename;
628 }
629
630 return null;
631 }
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:

◆ toJSON()

assOrderingQuestion::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

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

839 : string
840 {
841 $result = [];
842 $result['id'] = $this->getId();
843 $result['type'] = (string) $this->getQuestionType();
844 $result['title'] = $this->getTitleForHTMLOutput();
845 $result['question'] = $this->formatSAQuestion($this->getQuestion());
846 $result['nr_of_tries'] = $this->getNrOfTries();
847 $result['shuffle'] = true;
848 $result['points'] = $this->getPoints();
849 $result['feedback'] = [
850 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
851 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
852 ];
853 if ($this->getOrderingType() == self::OQ_PICTURES) {
854 $result['path'] = $this->getImagePathWeb();
855 }
856
857 $counter = 1;
858 $answers = [];
859 foreach ($this->getOrderingElementList() as $orderingElement) {
860 $answers[$counter] = $orderingElement->getContent();
861 $counter++;
862 }
863 $answers = $this->getShuffler()->transform($answers);
864 $arr = [];
865 foreach ($answers as $order => $answer) {
866 array_push($arr, [
867 "answertext" => (string) $answer,
868 "order" => (int) $order
869 ]);
870 }
871 $result['answers'] = $arr;
872
873 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
874 $result['mobs'] = $mobs;
875
876 return json_encode($result);
877 }
getQuestionType()
Returns the question type of the question.
static _getMobsOfObject(string $a_type, int $a_id, int|false $a_usage_hist_nr=0, string $a_lang="-")

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

+ Here is the call graph for this function:

◆ toLog()

assOrderingQuestion::toLog ( AdditionalInformationGenerator  $additional_info)

MUST return an array of the question settings that can be stored in the log.

Language variables must be generated through the corresponding functions in the AdditionalInformationGenerator. If an array is returned it will be rendered into a line per array entry in the format "key: value". If the key exists as a language variable, it will be translated.

Reimplemented from assQuestion.

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

1267 : array
1268 {
1269 return [
1270 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
1271 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
1272 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
1273 AdditionalInformationGenerator::KEY_QUESTION_ORDERING_NESTING_TYPE => array_reduce(
1275 static fn(string $string, string $lang_var) => $string . $additional_info->getTagForLangVar($lang_var),
1276 ''
1277 ),
1278 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->getPoints(),
1279 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION => $this->getSolutionOutputForLog(),
1280 AdditionalInformationGenerator::KEY_FEEDBACK => [
1281 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1282 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1283 ]
1284 ];
1285 }
getOrderingTypeLangVars(int $ordering_type)

References ILIAS\Test\Logging\AdditionalInformationGenerator\getTagForLangVar().

+ Here is the call graph for this function:

◆ toNormalized()

assOrderingQuestion::toNormalized ( Transformations  $transformations,
array  $context = [] 
)
Parameters
array<string,mixed>$context
Returns
array<array-key, mixed>|float|bool|int|string|null

Reimplemented from assQuestion.

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

1377 : array|float|bool|int|string|null
1378 {
1379 return [
1380 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
1381 'ordering_type' => $this->ordering_type,
1382 'ordering_elements' => $transformations->normalize(
1383 $this->getOrderingElementList()->getElements(),
1384 ['question_id' => $this->getId()]
1385 ),
1386 ];
1387 }

References ILIAS\Survey\Mode\getId(), and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\normalize().

+ Here is the call graph for this function:

◆ updateImageFile()

assOrderingQuestion::updateImageFile ( string  $existing_image_name)

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

633 : ?string
634 {
635 $existing_image_path = $this->getImagePath() . $existing_image_name;
636 $target_filename = $this->buildHashedImageFilename($existing_image_name, true);
637 $target_filepath = $this->getImagePath() . $target_filename;
638 if (ilFileUtils::rename($existing_image_path, $target_filepath)) {
639 unlink($this->getImagePath() . $this->getThumbPrefix() . $existing_image_name);
640 $thumb_path = $this->getImagePath() . $this->getThumbPrefix() . $target_filename;
641 ilShellUtil::convertImage($target_filepath, $thumb_path, "JPEG", (string) $this->getThumbSize());
642
643 return $target_filename;
644 }
645
646 return $existing_image_name;
647 }
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 649 of file class.assOrderingQuestion.php.

649 : bool
650 {
651 $submittedSolutionList = $this->getSolutionListFromPostSubmit();
652
653 if (!$submittedSolutionList->hasElements()) {
654 return true;
655 }
656
657 return $this->getOrderingElementList()->hasSameElementSetByRandomIdentifiers($submittedSolutionList);
658 }

Field Documentation

◆ $element_height

int assOrderingQuestion::$element_height = null

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

◆ $element_list_for_deferred_saving

ilAssOrderingElementList assOrderingQuestion::$element_list_for_deferred_saving = null
protected

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

◆ $leveled_ordering

assOrderingQuestion::$leveled_ordering = []

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

◆ $old_ordering_depth

assOrderingQuestion::$old_ordering_depth = []

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

◆ $oq_repository

OQRepository assOrderingQuestion::$oq_repository = null
protected

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

Referenced by getRepository().

◆ $postSolutionOrderingElementList

ilAssOrderingElementList assOrderingQuestion::$postSolutionOrderingElementList = null
private

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

◆ HAS_SPECIFIC_FEEDBACK

const assOrderingQuestion::HAS_SPECIFIC_FEEDBACK = false
protected

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

◆ OQ_CT_PICTURES

const assOrderingQuestion::OQ_CT_PICTURES = 'pics'

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

◆ OQ_CT_TERMS

const assOrderingQuestion::OQ_CT_TERMS = 'terms'

Definition at line 56 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 48 of file class.assOrderingQuestion.php.

◆ ORDERING_ELEMENT_FORM_CMD_UPLOAD_IMG

const assOrderingQuestion::ORDERING_ELEMENT_FORM_CMD_UPLOAD_IMG = 'uploadElementImage'

Definition at line 47 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: