ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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)
 
 solutionValuesToText (array $solution_values)
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
- 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)
 Returns a QTI xml representation of the question. More...
 
 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 ()
 
static 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)
 
 duplicate (bool $for_test=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)
 

Protected Member Functions

 getSolutionSubmit ()
 
 calculateReachedPointsForSolution (?string $value)
 
 solutionValuesToLog (AdditionalInformationGenerator $additional_info, array $solution_values)
 
- 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 36 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 58 of file class.assOrderingHorizontal.php.

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

64  {
66  $this->ordertext = "";
67  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ buildTestPresentationConfig()

assOrderingHorizontal::buildTestPresentationConfig ( )

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

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

524  // hey.
525  {
526  // hey: refactored identifiers
527  return parent::buildTestPresentationConfig()
528  // hey.
530  ->setUseUnchangedAnswerLabel($this->lng->txt('tst_unchanged_order_is_correct'));
531  }
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.
+ Here is the call graph for this function:

◆ calculateReachedPoints()

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

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

References $data, assQuestion\$points, calculateReachedPointsForSolution(), assQuestion\getCurrentSolutionResultSet(), assQuestion\getSolutionMaxPass(), and null.

Referenced by getUserQuestionResult().

155  : float {
156  if ($pass === null) {
157  $pass = $this->getSolutionMaxPass($active_id);
158  }
159 
160  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
161  $points = 0.0;
162  if ($this->db->numRows($result) > 0) {
163  $data = $this->db->fetchAssoc($result);
164  $points = $this->calculateReachedPointsForSolution($data['value1']);
165  }
166 
167  return $points;
168  }
calculateReachedPointsForSolution(?string $value)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getSolutionMaxPass(int $active_id)
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsForSolution()

assOrderingHorizontal::calculateReachedPointsForSolution ( ?string  $value)
protected
Parameters
$value
Returns
float

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

References assQuestion\$points, getOrderingElements(), assQuestion\getPoints(), and splitAndTrimOrderElementText().

Referenced by calculateReachedPoints().

512  : float
513  {
514  $value = $this->splitAndTrimOrderElementText($value ?? "", $this->answer_separator);
515  $value = join($this->answer_separator, $value);
516  if (strcmp($value, join($this->answer_separator, $this->getOrderingElements())) == 0) {
517  $points = $this->getPoints();
518  return $points;
519  }
520  return 0;
521  }
splitAndTrimOrderElementText(string $in_string, string $separator)
getOrderingElements()
Get ordering elements from order text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 284 of file class.assOrderingHorizontal.php.

284  : void
285  {
286  }

◆ getAdditionalTableName()

assOrderingHorizontal::getAdditionalTableName ( )

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

Returns
string The additional table name

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

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

264  : string
265  {
266  return "qpl_qst_horder";
267  }
+ Here is the caller graph for this function:

◆ getAnswerSeparator()

assOrderingHorizontal::getAnswerSeparator ( )
Returns
string

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

References $answer_separator.

97  : string
98  {
100  }

◆ getAnswerTableName()

assOrderingHorizontal::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name

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

274  : string
275  {
276  return "";
277  }

◆ getAvailableAnswerOptions()

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

Implements iQuestionCondition.

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

References getOrderingElements(), and null.

495  : array|ASS_AnswerSimple|null
496  {
497  $elements = $this->getOrderingElements();
498  if ($index !== null) {
499  if (array_key_exists($index, $elements)) {
500  return $elements[$index];
501  }
502  return null;
503  } else {
504  return $elements;
505  }
506  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getOrderingElements()
Get ordering elements from order text.
+ Here is the call graph for this function:

◆ 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 303 of file class.assOrderingHorizontal.php.

303  : array
304  {
305  $user_solution = [];
306  return $user_solution;
307  }

◆ getCorrectSolutionForTextOutput()

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

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

References getOrderText().

571  : string
572  {
573  return $this->getOrderText();
574  }
+ Here is the call graph for this function:

◆ getExpressionTypes()

◆ getMaximumPoints()

assOrderingHorizontal::getMaximumPoints ( )

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

References assQuestion\getPoints().

Referenced by getUserQuestionResult(), and isComplete().

146  : float
147  {
148  return $this->getPoints();
149  }
+ 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 430 of file class.assOrderingHorizontal.php.

430  : array
431  {
432  return ilOperatorsExpressionMapping::getOperatorsByExpression($expression);
433  }

◆ getOrderingElements()

assOrderingHorizontal::getOrderingElements ( )

Get ordering elements from order text.

Returns
array Ordering elements

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

References getOrderText(), and splitAndTrimOrderElementText().

Referenced by calculateReachedPointsForSolution(), getAvailableAnswerOptions(), getRandomOrderingElements(), getUserQuestionResult(), and toJSON().

314  : array
315  {
316  return $this->splitAndTrimOrderElementText($this->getOrderText() ?? "", $this->separator);
317  }
splitAndTrimOrderElementText(string $in_string, string $separator)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOrderText()

assOrderingHorizontal::getOrderText ( )

Get order text.

Returns
string Order text

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

References $ordertext.

Referenced by getCorrectSolutionForTextOutput(), getOrderingElements(), saveAdditionalQuestionDataToDb(), and toLog().

+ Here is the caller graph for this function:

◆ getQuestionType()

assOrderingHorizontal::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

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

Referenced by toJSON(), and toLog().

254  : string
255  {
256  return "assOrderingHorizontal";
257  }
+ Here is the caller graph for this function:

◆ getRandomOrderingElements()

assOrderingHorizontal::getRandomOrderingElements ( )

Get ordering elements from order text in random sequence.

Returns
array Ordering elements

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

References getOrderingElements(), and assQuestion\getShuffler().

324  : array
325  {
326  $elements = $this->getOrderingElements();
327  $elements = $this->getShuffler()->transform($elements);
328  return $elements;
329  }
getOrderingElements()
Get ordering elements from order text.
+ Here is the call graph for this function:

◆ getRTETextWithMediaObjects()

assOrderingHorizontal::getRTETextWithMediaObjects ( )

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

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

292  : string
293  {
294  $text = parent::getRTETextWithMediaObjects();
295  return $text;
296  }

◆ getSeparator()

assOrderingHorizontal::getSeparator ( )

Get order text separator.

Returns
string Separator

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

References $separator.

379  : string
380  {
381  return $this->separator;
382  }

◆ getSolutionSubmit()

assOrderingHorizontal::getSolutionSubmit ( )
protected

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

Referenced by saveWorkingData().

187  : string
188  {
189  return $this->questionpool_request->string('orderresult');
190  }
+ Here is the caller graph for this function:

◆ getTextSize()

assOrderingHorizontal::getTextSize ( )

Get text size.

Returns
double Text size in percent maybe

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

References $textsize.

Referenced by saveAdditionalQuestionDataToDb(), toJSON(), and toLog().

+ Here is the caller graph for this function:

◆ 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 445 of file class.assOrderingHorizontal.php.

References $data, assQuestion\$points, calculateReachedPoints(), assQuestion\getId(), getMaximumPoints(), getOrderingElements(), assQuestion\lookupMaxStep(), null, and splitAndTrimOrderElementText().

449  $result = new ilUserQuestionResult($this, $active_id, $pass);
450 
451  $maxStep = $this->lookupMaxStep($active_id, $pass);
452  if ($maxStep > 0) {
453  $data = $this->db->queryF(
454  "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
455  ["integer", "integer", "integer","integer"],
456  [$active_id, $pass, $this->getId(), $maxStep]
457  );
458  } else {
459  $data = $this->db->queryF(
460  "SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
461  ["integer", "integer", "integer"],
462  [$active_id, $pass, $this->getId()]
463  );
464  }
465  $row = $this->db->fetchAssoc($data);
466 
467  $answer_elements = $this->splitAndTrimOrderElementText($row["value1"] ?? "", $this->answer_separator);
468  $elements = $this->getOrderingElements();
469 
470  foreach ($answer_elements as $answer) {
471  foreach ($elements as $key => $element) {
472  if ($element == $answer) {
473  $result->addKeyValue($key + 1, $answer);
474  }
475  }
476  }
477 
478  $glue = " ";
479  if ($this->answer_separator = '{::}') {
480  $glue = "";
481  }
482  $result->addKeyValue(null, join($glue, $answer_elements));
483 
484  $points = $this->calculateReachedPoints($active_id, $pass);
485  $max_points = $this->getMaximumPoints();
486 
487  $result->setReachedPercentage(($points / $max_points) * 100);
488 
489  return $result;
490  }
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
splitAndTrimOrderElementText(string $in_string, string $separator)
lookupMaxStep(int $active_id, int $pass)
getOrderingElements()
Get ordering elements from order text.
+ Here is the call graph for this function:

◆ 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

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

References getMaximumPoints().

74  : bool
75  {
76  if (strlen($this->title) and ($this->author) and ($this->question) and ($this->getMaximumPoints() > 0)) {
77  return true;
78  } else {
79  return false;
80  }
81  }
+ 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 109 of file class.assOrderingHorizontal.php.

References $data, Vendor\Package\$e, ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), 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().

109  : void
110  {
111  $result = $this->db->queryF(
112  "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",
113  ["integer"],
114  [$question_id]
115  );
116  if ($result->numRows() == 1) {
117  $data = $this->db->fetchAssoc($result);
118  $this->setId($question_id);
119  $this->setObjId($data["obj_fi"]);
120  $this->setTitle((string) $data["title"]);
121  $this->setComment((string) $data["description"]);
122  $this->setOriginalId($data["original_id"]);
123  $this->setNrOfTries($data['nr_of_tries']);
124  $this->setAuthor($data["author"]);
125  $this->setPoints($data["points"]);
126  $this->setOwner($data["owner"]);
127  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
128  $this->setOrderText($data["ordertext"]);
129  $this->setTextSize($data["textsize"]);
130 
131  try {
135  }
136 
137  try {
138  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
139  } catch (ilTestQuestionPoolException $e) {
140  }
141  }
142 
143  parent::loadFromDb($question_id);
144  }
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...
setNrOfTries(int $a_nr_of_tries)
setOwner(int $owner=-1)
setOrderText($a_value)
Set order text.
setComment(string $comment="")
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setTextSize(?float $textsize)
Set text size.
setPoints(float $points)
setObjId(int $obj_id=0)
setId(int $id=-1)
setOriginalId(?int $original_id)
setTitle(string $title="")
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setAuthor(string $author="")
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
+ 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 227 of file class.assOrderingHorizontal.php.

References getAdditionalTableName(), assQuestion\getId(), getOrderText(), getTextSize(), and null.

Referenced by saveToDb().

228  {
229  // save additional data
230  $this->db->manipulateF(
231  "DELETE FROM " . $this->getAdditionalTableName()
232  . " WHERE question_fi = %s",
233  [ "integer" ],
234  [ $this->getId() ]
235  );
236 
237  $this->db->manipulateF(
238  "INSERT INTO " . $this->getAdditionalTableName()
239  . " (question_fi, ordertext, textsize) VALUES (%s, %s, %s)",
240  [ "integer", "text", "float" ],
241  [
242  $this->getId(),
243  $this->getOrderText(),
244  ($this->getTextSize() < 10) ? null : (float) $this->getTextSize()
245  ]
246  );
247  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getAdditionalTableName()
Returns the name of the additional question data table in the database.
+ 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.

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

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

87  : void
88  {
91  parent::saveToDb();
92  }
saveQuestionDataToDb(?int $original_id=null)
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
+ Here is the call graph for this function:

◆ saveWorkingData()

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

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

References ilObjTest\_getPass(), assQuestion\getProcessLocker(), getSolutionSubmit(), null, assQuestion\removeCurrentSolution(), and assQuestion\saveCurrentSolution().

196  : bool {
197  if ($this->questionpool_request->raw('test_answer_changed') === null) {
198  return true;
199  }
200 
201  if (is_null($pass)) {
202  $pass = ilObjTest::_getPass($active_id);
203  }
204 
205  $answer = $this->getSolutionSubmit();
206  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
207  function () use ($answer, $active_id, $pass, $authorized) {
208  $this->removeCurrentSolution($active_id, $pass, $authorized);
209 
210  if ($answer === '') {
211  return;
212  }
213 
214  $this->saveCurrentSolution(
215  $active_id,
216  $pass,
217  $answer,
218  null,
219  $authorized
220  );
221  }
222  );
223 
224  return true;
225  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
+ Here is the call graph for this function:

◆ setOrderText()

assOrderingHorizontal::setOrderText (   $a_value)

Set order text.

Parameters
string$a_valueOrder text

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

Referenced by loadFromDb().

346  : void
347  {
348  $this->ordertext = $a_value;
349  }
+ Here is the caller graph for this function:

◆ setSeparator()

assOrderingHorizontal::setSeparator (   $a_value)

Set order text separator.

Parameters
string$a_valueSeparator

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

389  : void
390  {
391  $this->separator = $a_value;
392  }

◆ setTextSize()

assOrderingHorizontal::setTextSize ( ?float  $textsize)

Set text size.

Parameters
double$a_valueText size in percent

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

References $textsize, and null.

Referenced by loadFromDb().

366  : void
367  {
368  if ($textsize === null || $textsize === 0.0) {
369  $textsize = self::DEFAULT_TEXT_SIZE;
370  }
371  $this->textsize = $textsize;
372  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ solutionValuesToLog()

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

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

552  : string {
553  if (!array_key_exists(0, $solution_values) ||
554  !array_key_exists('value1', $solution_values[0])) {
555  return '';
556  }
557 
558  return str_replace("{::}", " ", $solution_values[0]['value1']);
559  }

◆ solutionValuesToText()

assOrderingHorizontal::solutionValuesToText ( array  $solution_values)

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

561  : string
562  {
563  if (!array_key_exists(0, $solution_values) ||
564  !array_key_exists('value1', $solution_values[0])) {
565  return '';
566  }
567 
568  return str_replace("{::}", " ", $solution_values[0]['value1']);
569  }

◆ splitAndTrimOrderElementText()

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

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

References ilStr\strPos().

Referenced by calculateReachedPointsForSolution(), getOrderingElements(), and getUserQuestionResult().

170  : array
171  {
172  $result = [];
173 
174  if (ilStr::strPos($in_string, $separator, 0) === false) {
175  $result = preg_split("/\\s+/", $in_string);
176  } else {
177  $result = explode($separator, $in_string);
178  }
179 
180  foreach ($result as $key => $value) {
181  $result[$key] = trim($value);
182  }
183 
184  return $result;
185  }
static strPos(string $a_haystack, string $a_needle, int $a_offset=0)
Definition: class.ilStr.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toJSON()

assOrderingHorizontal::toJSON ( )

Returns a JSON representation of the question.

Implements ILIAS\TestQuestionPool\Questions\QuestionLMExportable.

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

References ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), assQuestion\getId(), assQuestion\getNrOfTries(), getOrderingElements(), assQuestion\getPoints(), assQuestion\getQuestion(), getQuestionType(), getTextSize(), assQuestion\getTitleForHTMLOutput(), and ILIAS\Repository\int().

397  : string
398  {
399  $result = [];
400  $result['id'] = $this->getId();
401  $result['type'] = (string) $this->getQuestionType();
402  $result['title'] = $this->getTitleForHTMLOutput();
403  $result['question'] = $this->formatSAQuestion($this->getQuestion());
404  $result['nr_of_tries'] = $this->getNrOfTries();
405  $result['shuffle'] = true;
406  $result['points'] = (bool) $this->getPoints();
407  $result['textsize'] = ((int) $this->getTextSize()) // #10923
408  ? (int) $this->getTextSize()
409  : self::DEFAULT_TEXT_SIZE;
410  $result['feedback'] = [
411  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
412  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
413  ];
414 
415  $arr = [];
416  foreach ($this->getOrderingElements() as $order => $answer) {
417  array_push($arr, [
418  "answertext" => (string) $answer,
419  "order" => (int) $order + 1
420  ]);
421  }
422  $result['answers'] = $arr;
423 
424  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
425  $result['mobs'] = $mobs;
426 
427  return json_encode($result);
428  }
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
getQuestionType()
Returns the question type of the question.
getOrderingElements()
Get ordering elements from order text.
+ Here is the call graph for this function:

◆ toLog()

assOrderingHorizontal::toLog ( AdditionalInformationGenerator  $additional_info)

Implements ILIAS\TestQuestionPool\Questions\Question.

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

References assQuestion\formatSAQuestion(), getOrderText(), assQuestion\getPoints(), assQuestion\getQuestion(), getQuestionType(), getTextSize(), assQuestion\getTitleForHTMLOutput(), and ILIAS\Repository\int().

533  : array
534  {
535  return [
536  AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
537  AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
538  AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
539  AdditionalInformationGenerator::KEY_QUESTION_TEXTSIZE => ((int) $this->getTextSize()) ? (int) $this->getTextSize() : 100,
540  AdditionalInformationGenerator::KEY_QUESTION_CORRECT_ANSWER_OPTIONS => $this->getOrderText(),
541  AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->getPoints(),
542  AdditionalInformationGenerator::KEY_FEEDBACK => [
543  AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
544  AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
545  ]
546  ];
547  }
getQuestionType()
Returns the question type of the question.
+ Here is the call graph for this function:

Field Documentation

◆ $answer_separator

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

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

Referenced by getAnswerSeparator().

◆ $ordertext

assOrderingHorizontal::$ordertext
protected

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

Referenced by getOrderText().

◆ $separator

assOrderingHorizontal::$separator = "::"
protected

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

Referenced by getSeparator().

◆ $textsize

assOrderingHorizontal::$textsize
protected

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

Referenced by getTextSize(), and setTextSize().

◆ DEFAULT_TEXT_SIZE

const assOrderingHorizontal::DEFAULT_TEXT_SIZE = 100
protected

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

◆ HAS_SPECIFIC_FEEDBACK

const assOrderingHorizontal::HAS_SPECIFIC_FEEDBACK = false
protected

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


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