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

Class for horizontal ordering questions. More...

+ Inheritance diagram for assOrderingHorizontal:
+ Collaboration diagram for assOrderingHorizontal:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assOrderingHorizontal constructor More...
 
 isComplete ()
 Returns true, if a single choice question is complete for use. More...
 
 saveToDb (?int $original_id=null)
 Saves a assOrderingHorizontal object to a database. More...
 
 getAnswerSeparator ()
 
 loadFromDb ($question_id)
 Loads a assOrderingHorizontal object from a database. More...
 
 getMaximumPoints ()
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 splitAndTrimOrderElementText (string $in_string, string $separator)
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data 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...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 getBestSolution ($active_id, $pass)
 Returns the best solution for a given pass of a participant. More...
 
 getOrderingElements ()
 Get ordering elements from order text. More...
 
 getRandomOrderingElements ()
 Get ordering elements from order text in random sequence. More...
 
 getOrderText ()
 Get order text. More...
 
 setOrderText ($a_value)
 Set order text. More...
 
 getTextSize ()
 Get text size. More...
 
 setTextSize (?float $textsize)
 Set text size. More...
 
 getSeparator ()
 Get order text separator. More...
 
 setSeparator ($a_value)
 Set order text separator. More...
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 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)
 
 buildTestPresentationConfig ()
 
 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...
 
 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...
 

Protected Member Functions

 getSolutionSubmit ()
 
 calculateReachedPointsForSolution (?string $user_response)
 
 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
 
const DEFAULT_TEXT_SIZE = 100
 
 $ordertext
 
 $textsize
 
 $separator = "::"
 
 $answer_separator = '{::}'
 
- 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
 

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...
 
- 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 = "?"
 
- 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

Class for horizontal 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
Version
$Id$

Definition at line 39 of file class.assOrderingHorizontal.php.

Constructor & Destructor Documentation

◆ __construct()

assOrderingHorizontal::__construct (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $question = "" 
)

assOrderingHorizontal constructor

The constructor takes possible arguments an creates an instance of the assOrderingHorizontal 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 single choice question
See also
assQuestion:__construct()

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

67 {
69 $this->ordertext = "";
70 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ buildTestPresentationConfig()

assOrderingHorizontal::buildTestPresentationConfig ( )

Reimplemented from assQuestion.

Definition at line 536 of file class.assOrderingHorizontal.php.

537 // hey.
538 {
539 // hey: refactored identifiers
540 return parent::buildTestPresentationConfig()
541 // hey.
543 ->setUseUnchangedAnswerLabel($this->lng->txt('tst_unchanged_order_is_correct'));
544 }
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()

assOrderingHorizontal::calculateReachedPoints ( int  $active_id,
?int  $pass = null,
bool  $authorized_solution = true 
)

Reimplemented from assQuestion.

Definition at line 154 of file class.assOrderingHorizontal.php.

158 : float {
159 if ($pass === null) {
160 $pass = $this->getSolutionMaxPass($active_id);
161 }
162
163 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
164 $points = 0.0;
165 if ($this->db->numRows($result) > 0) {
166 $data = $this->db->fetchAssoc($result);
168 }
169
170 return $points;
171 }
calculateReachedPointsForSolution(?string $user_response)
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
getSolutionMaxPass(int $active_id)
$data
Definition: storeScorm.php:45

References assQuestion\getSolutionMaxPass().

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assOrderingHorizontal::calculateReachedPointsForSolution ( ?string  $user_response)
protected

Definition at line 511 of file class.assOrderingHorizontal.php.

511 : float
512 {
513 if ($user_response === null) {
514 return 0.0;
515 }
516
517 $cleaned_user_response = implode(
518 $this->answer_separator,
520 $user_response,
521 $this->answer_separator
522 )
523 );
524
525 $correct_solution = implode(
526 $this->answer_separator,
527 $this->getOrderingElements()
528 );
529
530 if ($cleaned_user_response === $correct_solution) {
531 return $this->getPoints();
532 }
533 return 0.0;
534 }
splitAndTrimOrderElementText(string $in_string, string $separator)
getOrderingElements()
Get ordering elements from order text.

◆ deleteAnswers()

assOrderingHorizontal::deleteAnswers (   $question_id)

Deletes datasets from answers tables.

Parameters
integer$question_idThe question id which should be deleted in the answers table

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

287 : void
288 {
289 }

◆ fromNormalized()

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

Reimplemented from assQuestion.

Definition at line 605 of file class.assOrderingHorizontal.php.

608 : static
609 {
610 $clone = parent::fromNormalized($normalized, $transformations);
611 $clone->ordertext = $transformations->string($normalized['ordertext']);
612 $clone->textsize = $transformations->float($normalized['textsize']);
613 $clone->separator = $transformations->string($normalized['separator']);
614 $clone->answer_separator = $transformations->string($normalized['answer_separator']);
615
616 return $clone;
617 }

References ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\float(), and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\string().

+ Here is the call graph for this function:

◆ getAdditionalTableName()

assOrderingHorizontal::getAdditionalTableName ( )

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

Returns
string The additional table name

Reimplemented from assQuestion.

Definition at line 267 of file class.assOrderingHorizontal.php.

267 : string
268 {
269 return "qpl_qst_horder";
270 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ getAnswerSeparator()

assOrderingHorizontal::getAnswerSeparator ( )
Returns
string

Definition at line 100 of file class.assOrderingHorizontal.php.

100 : string
101 {
103 }

References $answer_separator.

◆ getAnswerTableName()

assOrderingHorizontal::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name

Reimplemented from assQuestion.

Definition at line 277 of file class.assOrderingHorizontal.php.

277 : string
278 {
279 return "";
280 }

◆ getAvailableAnswerOptions()

assOrderingHorizontal::getAvailableAnswerOptions ( ?int  $index = null)
Returns
array<ASS_AnswerSimple>|ASS_AnswerSimple|null

Implements iQuestionCondition.

Definition at line 498 of file class.assOrderingHorizontal.php.

498 : array|ASS_AnswerSimple|null
499 {
500 $elements = $this->getOrderingElements();
501 if ($index !== null) {
502 if (array_key_exists($index, $elements)) {
503 return $elements[$index];
504 }
505 return null;
506 } else {
507 return $elements;
508 }
509 }
Class for simple answers.

◆ getBestSolution()

assOrderingHorizontal::getBestSolution (   $active_id,
  $pass 
)

Returns the best solution for a given pass of a participant.

Returns
array An associated array containing the best solution

Definition at line 306 of file class.assOrderingHorizontal.php.

306 : array
307 {
308 $user_solution = [];
309 return $user_solution;
310 }

◆ getCorrectSolutionForTextOutput()

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

Reimplemented from assQuestion.

Definition at line 584 of file class.assOrderingHorizontal.php.

584 : string
585 {
586 return $this->getOrderText();
587 }

◆ getExpressionTypes()

◆ getMaximumPoints()

assOrderingHorizontal::getMaximumPoints ( )

Reimplemented from assQuestion.

Definition at line 149 of file class.assOrderingHorizontal.php.

149 : float
150 {
151 return $this->getPoints();
152 }

References assQuestion\getPoints().

Referenced by isComplete().

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

◆ getOperators()

assOrderingHorizontal::getOperators ( string  $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

Definition at line 433 of file class.assOrderingHorizontal.php.

433 : array
434 {
436 }
static getOperatorsByExpression(string $expression)

References ilOperatorsExpressionMapping\getOperatorsByExpression().

+ Here is the call graph for this function:

◆ getOrderingElements()

assOrderingHorizontal::getOrderingElements ( )

Get ordering elements from order text.

Returns
array Ordering elements

Definition at line 317 of file class.assOrderingHorizontal.php.

317 : array
318 {
319 return $this->splitAndTrimOrderElementText($this->getOrderText() ?? "", $this->separator);
320 }

◆ getOrderText()

assOrderingHorizontal::getOrderText ( )

Get order text.

Returns
string Order text

Definition at line 339 of file class.assOrderingHorizontal.php.

◆ getQuestionType()

assOrderingHorizontal::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

Reimplemented from assQuestion.

Definition at line 257 of file class.assOrderingHorizontal.php.

257 : string
258 {
259 return "assOrderingHorizontal";
260 }

◆ getRandomOrderingElements()

assOrderingHorizontal::getRandomOrderingElements ( )

Get ordering elements from order text in random sequence.

Returns
array Ordering elements

Definition at line 327 of file class.assOrderingHorizontal.php.

327 : array
328 {
329 $elements = $this->getOrderingElements();
330 $elements = $this->getShuffler()->transform($elements);
331 return $elements;
332 }

◆ getRTETextWithMediaObjects()

assOrderingHorizontal::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 295 of file class.assOrderingHorizontal.php.

295 : string
296 {
297 $text = parent::getRTETextWithMediaObjects();
298 return $text;
299 }
$text
Definition: xapiexit.php:21

References $text.

◆ getSeparator()

assOrderingHorizontal::getSeparator ( )

Get order text separator.

Returns
string Separator

Definition at line 382 of file class.assOrderingHorizontal.php.

382 : string
383 {
384 return $this->separator;
385 }

◆ getSolutionSubmit()

assOrderingHorizontal::getSolutionSubmit ( )
protected

Definition at line 190 of file class.assOrderingHorizontal.php.

190 : string
191 {
192 return $this->questionpool_request->string('orderresult');
193 }

◆ getTextSize()

assOrderingHorizontal::getTextSize ( )

Get text size.

Returns
double Text size in percent maybe

Definition at line 359 of file class.assOrderingHorizontal.php.

◆ getUserQuestionResult()

assOrderingHorizontal::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 448 of file class.assOrderingHorizontal.php.

452 $result = new ilUserQuestionResult($this, $active_id, $pass);
453
454 $maxStep = $this->lookupMaxStep($active_id, $pass);
455 if ($maxStep > 0) {
456 $data = $this->db->queryF(
457 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
458 ["integer", "integer", "integer","integer"],
459 [$active_id, $pass, $this->getId(), $maxStep]
460 );
461 } else {
462 $data = $this->db->queryF(
463 "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
464 ["integer", "integer", "integer"],
465 [$active_id, $pass, $this->getId()]
466 );
467 }
468 $row = $this->db->fetchAssoc($data);
469
470 $answer_elements = $this->splitAndTrimOrderElementText($row["value1"] ?? "", $this->answer_separator);
471 $elements = $this->getOrderingElements();
472
473 foreach ($answer_elements as $answer) {
474 foreach ($elements as $key => $element) {
475 if ($element == $answer) {
476 $result->addKeyValue($key + 1, $answer);
477 }
478 }
479 }
480
481 $glue = " ";
482 if ($this->answer_separator = '{::}') {
483 $glue = "";
484 }
485 $result->addKeyValue(null, join($glue, $answer_elements));
486
487 $points = $this->calculateReachedPoints($active_id, $pass);
488 $max_points = $this->getMaximumPoints();
489
490 $result->setReachedPercentage(($points / $max_points) * 100);
491
492 return $result;
493 }
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...

◆ isComplete()

assOrderingHorizontal::isComplete ( )

Returns true, if a single choice question is complete for use.

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

Reimplemented from assQuestion.

Definition at line 77 of file class.assOrderingHorizontal.php.

77 : bool
78 {
79 if (strlen($this->title) and ($this->author) and ($this->question) and ($this->getMaximumPoints() > 0)) {
80 return true;
81 } else {
82 return false;
83 }
84 }

References getMaximumPoints().

+ Here is the call graph for this function:

◆ loadFromDb()

assOrderingHorizontal::loadFromDb (   $question_id)

Loads a assOrderingHorizontal object from a database.

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

Definition at line 112 of file class.assOrderingHorizontal.php.

112 : void
113 {
114 $result = $this->db->queryF(
115 "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",
116 ["integer"],
117 [$question_id]
118 );
119 if ($result->numRows() == 1) {
120 $data = $this->db->fetchAssoc($result);
121 $this->setId($question_id);
122 $this->setObjId($data["obj_fi"]);
123 $this->setTitle((string) $data["title"]);
124 $this->setComment((string) $data["description"]);
125 $this->setOriginalId($data["original_id"]);
126 $this->setNrOfTries($data['nr_of_tries']);
127 $this->setAuthor($data["author"]);
128 $this->setPoints($data["points"]);
129 $this->setOwner($data["owner"]);
130 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
131 $this->setOrderText($data["ordertext"]);
132 $this->setTextSize($data["textsize"]);
133
134 try {
135 $this->setLifecycle(new ilAssQuestionLifecycle($data['lifecycle']));
138 }
139
140 try {
141 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
143 }
144 }
145
146 parent::loadFromDb($question_id);
147 }
setOrderText($a_value)
Set order text.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setTextSize(?float $textsize)
Set text size.
setOriginalId(?int $original_id)
setId(int $id=-1)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
setAuthor(string $author="")
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\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setId(), assQuestion\setLifecycle(), assQuestion\setNrOfTries(), assQuestion\setObjId(), setOrderText(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setTextSize(), and assQuestion\setTitle().

+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assOrderingHorizontal::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

Definition at line 230 of file class.assOrderingHorizontal.php.

231 {
232 // save additional data
233 $this->db->manipulateF(
234 "DELETE FROM " . $this->getAdditionalTableName()
235 . " WHERE question_fi = %s",
236 [ "integer" ],
237 [ $this->getId() ]
238 );
239
240 $this->db->manipulateF(
241 "INSERT INTO " . $this->getAdditionalTableName()
242 . " (question_fi, ordertext, textsize) VALUES (%s, %s, %s)",
243 [ "integer", "text", "float" ],
244 [
245 $this->getId(),
246 $this->getOrderText(),
247 ($this->getTextSize() < 10) ? null : (float) $this->getTextSize()
248 ]
249 );
250 }

References ILIAS\Survey\Mode\getId().

Referenced by saveToDb().

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

◆ saveToDb()

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

Saves a assOrderingHorizontal object to a database.

Reimplemented from assQuestion.

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

90 : void
91 {
94 parent::saveToDb();
95 }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb(?int $original_id=null)

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

+ Here is the call graph for this function:

◆ saveWorkingData()

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

Reimplemented from assQuestion.

Definition at line 195 of file class.assOrderingHorizontal.php.

199 : bool {
200 if ($this->questionpool_request->raw('test_answer_changed') === null) {
201 return true;
202 }
203
204 if (is_null($pass)) {
205 $pass = ilObjTest::_getPass($active_id);
206 }
207
208 $answer = $this->getSolutionSubmit();
209 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
210 function () use ($answer, $active_id, $pass, $authorized) {
211 $this->removeCurrentSolution($active_id, $pass, $authorized);
212
213 if ($answer === '') {
214 return;
215 }
216
217 $this->saveCurrentSolution(
218 $active_id,
219 $pass,
220 $answer,
221 null,
222 $authorized
223 );
224 }
225 );
226
227 return true;
228 }
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.

◆ setOrderText()

assOrderingHorizontal::setOrderText (   $a_value)

Set order text.

Parameters
string$a_valueOrder text

Definition at line 349 of file class.assOrderingHorizontal.php.

349 : void
350 {
351 $this->ordertext = $a_value;
352 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setSeparator()

assOrderingHorizontal::setSeparator (   $a_value)

Set order text separator.

Parameters
string$a_valueSeparator

Definition at line 392 of file class.assOrderingHorizontal.php.

392 : void
393 {
394 $this->separator = $a_value;
395 }

◆ setTextSize()

assOrderingHorizontal::setTextSize ( ?float  $textsize)

Set text size.

Parameters
double$a_valueText size in percent

Definition at line 369 of file class.assOrderingHorizontal.php.

369 : void
370 {
371 if ($textsize === null || $textsize === 0.0) {
373 }
374 $this->textsize = $textsize;
375 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ solutionValuesToLog()

assOrderingHorizontal::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 562 of file class.assOrderingHorizontal.php.

565 : string {
566 if (!array_key_exists(0, $solution_values) ||
567 !array_key_exists('value1', $solution_values[0])) {
568 return '';
569 }
570
571 return str_replace("{::}", " ", $solution_values[0]['value1']);
572 }

◆ solutionValuesToText()

assOrderingHorizontal::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 574 of file class.assOrderingHorizontal.php.

574 : string
575 {
576 if (!array_key_exists(0, $solution_values) ||
577 !array_key_exists('value1', $solution_values[0])) {
578 return '';
579 }
580
581 return str_replace("{::}", " ", $solution_values[0]['value1']);
582 }

◆ splitAndTrimOrderElementText()

assOrderingHorizontal::splitAndTrimOrderElementText ( string  $in_string,
string  $separator 
)

Definition at line 173 of file class.assOrderingHorizontal.php.

173 : array
174 {
175 $result = [];
176
177 if (ilStr::strPos($in_string, $separator, 0) === false) {
178 $result = preg_split("/\\s+/", $in_string);
179 } else {
180 $result = explode($separator, $in_string);
181 }
182
183 foreach ($result as $key => $value) {
184 $result[$key] = trim($value);
185 }
186
187 return $result;
188 }
static strPos(string $a_haystack, string $a_needle, int $a_offset=0)
Definition: class.ilStr.php:39

References ilStr\strPos().

+ Here is the call graph for this function:

◆ toJSON()

assOrderingHorizontal::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

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

400 : string
401 {
402 $result = [];
403 $result['id'] = $this->getId();
404 $result['type'] = (string) $this->getQuestionType();
405 $result['title'] = $this->getTitleForHTMLOutput();
406 $result['question'] = $this->formatSAQuestion($this->getQuestion());
407 $result['nr_of_tries'] = $this->getNrOfTries();
408 $result['shuffle'] = true;
409 $result['points'] = (bool) $this->getPoints();
410 $result['textsize'] = ((int) $this->getTextSize()) // #10923
411 ? (int) $this->getTextSize()
412 : self::DEFAULT_TEXT_SIZE;
413 $result['feedback'] = [
414 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
415 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
416 ];
417
418 $arr = [];
419 foreach ($this->getOrderingElements() as $order => $answer) {
420 array_push($arr, [
421 "answertext" => (string) $answer,
422 "order" => (int) $order + 1
423 ]);
424 }
425 $result['answers'] = $arr;
426
427 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
428 $result['mobs'] = $mobs;
429
430 return json_encode($result);
431 }
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(), ILIAS\Survey\Mode\getId(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ toLog()

assOrderingHorizontal::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 546 of file class.assOrderingHorizontal.php.

546 : array
547 {
548 return [
549 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
550 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
551 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
552 AdditionalInformationGenerator::KEY_QUESTION_TEXTSIZE => ((int) $this->getTextSize()) ? (int) $this->getTextSize() : 100,
553 AdditionalInformationGenerator::KEY_QUESTION_CORRECT_ANSWER_OPTIONS => $this->getOrderText(),
554 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->getPoints(),
555 AdditionalInformationGenerator::KEY_FEEDBACK => [
556 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
557 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
558 ]
559 ];
560 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ toNormalized()

assOrderingHorizontal::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 590 of file class.assOrderingHorizontal.php.

593 : array|float|bool|int|string|null
594 {
595 return [
596 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
597 'ordertext' => $this->ordertext,
598 'textsize' => $this->textsize,
599 'separator' => $this->separator,
600 'answer_separator' => $this->answer_separator,
601 ];
602 }

Field Documentation

◆ $answer_separator

assOrderingHorizontal::$answer_separator = '{::}'
protected

Definition at line 47 of file class.assOrderingHorizontal.php.

Referenced by getAnswerSeparator().

◆ $ordertext

assOrderingHorizontal::$ordertext
protected

Definition at line 44 of file class.assOrderingHorizontal.php.

◆ $separator

assOrderingHorizontal::$separator = "::"
protected

Definition at line 46 of file class.assOrderingHorizontal.php.

◆ $textsize

assOrderingHorizontal::$textsize
protected

Definition at line 45 of file class.assOrderingHorizontal.php.

◆ DEFAULT_TEXT_SIZE

const assOrderingHorizontal::DEFAULT_TEXT_SIZE = 100
protected

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

◆ HAS_SPECIFIC_FEEDBACK

const assOrderingHorizontal::HAS_SPECIFIC_FEEDBACK = false
protected

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


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