ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
assTextQuestion Class Reference

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

+ Inheritance diagram for assTextQuestion:
+ Collaboration diagram for assTextQuestion:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assTextQuestion constructor More...
 
 getMatchcondition ()
 
 setMatchcondition (int $matchcondition)
 
 isComplete ()
 Returns true, if a multiple choice question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a assTextQuestion object to a database. More...
 
 loadFromDb ($question_id)
 Loads a assTextQuestion object from a database. More...
 
 duplicate (bool $for_test=true, string $title="", string $author="", int $owner=-1, $testObjId=null)
 Duplicates an assTextQuestion. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assTextQuestion object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 getMaxNumOfChars ()
 Gets the maximum number of characters for the text solution. More...
 
 setMaxNumOfChars (int $maxchars=0)
 Sets the maximum number of characters for the text solution. More...
 
 isWordCounterEnabled ()
 
 setWordCounterEnabled ($wordCounterEnabled)
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getMinimumPoints ()
 
 isKeywordMatching ($answertext, $a_keyword)
 Checks if one of the keywords matches the answertext. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 getSolutionSubmit ()
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getTextRating ()
 Returns the rating option for text comparisons. More...
 
 setTextRating ($a_text_rating)
 Sets the rating option for text comparisons. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data 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...
 
 setExportDetailsXLSX (ilAssExcelFormatHelper $worksheet, int $startrow, int $col, int $active_id, int $pass)
 {} More...
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getAnswerCount ()
 
 addAnswer ( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="")
 Adds a possible answer for a multiple choice question. More...
 
 getAnswers ()
 
 getAnswer ($index=0)
 Returns an answer with a given index. More...
 
 deleteAnswer ($index=0)
 Deletes an answer with a given index. More...
 
 getAnswerTableName ()
 
 flushAnswers ()
 Deletes all answers. More...
 
 setAnswers ($answers)
 
 duplicateAnswers ($original_id)
 
 getKeywordRelation ()
 
 setKeywordRelation (?string $relation)
 This method implements a default behaviour. More...
 
 countLetters ($text)
 
 countWords ($text)
 
 getLatestAutosaveContent (int $active_id, int $pass)
 
- Public Member Functions inherited from assQuestion
 __construct (string $title="", string $comment="", string $author="", int $owner=-1, string $question="")
 assQuestion constructor More...
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML ($item, int $questionpool_id, ?int $tst_id, &$tst_object, int &$question_counter, array $import_mapping, array &$solutionhints=[])
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 isComplete ()
 Returns true, if a question is complete for use. More...
 
 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 $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution (int $active_id, int $pass, bool $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $obligationsEnabled=false, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 saveWorkingData (int $active_id, int $pass, bool $authorized=true)
 Saves the learners input of the question to the database. More...
 
 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, $pass=null)
 
 getSolutionValues ($active_id, $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 copyXHTMLMediaObjectsOfQuestion (int $a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 
 copyPageOfQuestion (int $a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
 fixSvgToPng (string $imageFilenameContainingString)
 
 fixUnavailableSkinImageSources (string $html)
 
 loadFromDb (int $question_id)
 
 createNewQuestion (bool $a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb (int $original_id=-1)
 
 saveToDb ()
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 
 resolveInternalLink (string $internal_link)
 
 resolveSuggestedSolutionLinks ()
 
 syncWithOriginal ()
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 deductHintPointsFromReachedPoints (ilAssQuestionPreviewSession $previewSession, $reachedPoints)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=null)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 
 syncHints ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 setExportDetailsXLSX (ilAssExcelFormatHelper $worksheet, int $startrow, int $col, int $active_id, int $pass)
 
 getNrOfTries ()
 
 setNrOfTries (int $a_nr_of_tries)
 
 setExportImagePath (string $path)
 
 formatSAQuestion ($a_q)
 
 setPreventRteUsage (bool $prevent_rte_usage)
 
 getPreventRteUsage ()
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode (bool $selfassessmenteditingmode)
 
 getSelfAssessmentEditingMode ()
 
 setDefaultNrOfTries (int $defaultnroftries)
 
 getDefaultNrOfTries ()
 
 syncSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 ensureHintPageObjectExists ($pageObjectId)
 
 isAnswered (int $active_id, int $pass)
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 removeCurrentSolution (int $active_id, int $pass, bool $authorized=true)
 
 saveCurrentSolution (int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
 updateCurrentSolution (int $solutionId, $value1, $value2, bool $authorized=true)
 
 updateCurrentSolutionsAuthorization (int $activeId, int $pass, bool $authorized, bool $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate (bool $for_test=true, string $title="", string $author="", int $owner=-1, $testObjId=null)
 
 intermediateSolutionExists (int $active_id, int $pass)
 
 authorizedSolutionExists (int $active_id, ?int $pass)
 
 authorizedOrIntermediateSolutionExists (int $active_id, int $pass)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions (int $activeId, int $pass)
 
 resetUsersAnswer (int $activeId, int $pass)
 
 removeResultRecord (int $activeId, int $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered (bool $obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
- Public Member Functions inherited from ilObjQuestionScoringAdjustable
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
- Public Member Functions inherited from ilObjAnswerScoringAdjustable
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
- Public Member Functions inherited from assQuestionInterface
 validateSolutionSubmit ()
 

Static Public Member Functions

static getValidScoringModes ()
 
static getScoringModesWithPointsByQuestion ()
 
static getScoringModesWithPointsByKeyword ()
 
static isObligationPossible (int $questionId)
 returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration More...
 
- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $forcePassResultsUpdateEnabled)
 
static isForcePassResultUpdateEnabled ()
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static logAction (string $logtext, int $active_id, int $question_id)
 
static isFileAvailable (string $file)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static _getInternalLinkHref (string $target="")
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static _isWriteable (int $question_id, int $user_id)
 
static _setReachedPoints (int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring, bool $obligationsEnabled, ?int $test_id=null)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static _needsManualScoring (int $question_id)
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static instantiateQuestionGUI (int $a_question_id)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $questionId)
 
static isObligationPossible (int $questionId)
 
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

 $maxNumOfChars
 
 $keywords
 
 $answers
 
 $text_rating
 
 $keyword_relation = 'non'
 
- Data Fields inherited from assQuestion
const TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
ilAssQuestionFeedback $feedbackOBJ
 
bool $prevent_rte_usage = false
 
bool $selfassessmenteditingmode = false
 
int $defaultnroftries = 0
 
string $questionActionCmd = 'handleQuestionAction'
 
const KEY_VALUES_IMPLOSION_SEPARATOR = ':'
 

Protected Member Functions

 calculateReachedPointsForSolution ($solution)
 
- Protected Member Functions inherited from assQuestion
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $postSubmissionFieldname)
 
 log (int $active_id, string $langVar)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 deletePageOfQuestion (int $question_id)
 
 onDuplicate (int $originalParentId, int $originalQuestionId, int $duplicateParentId, int $duplicateQuestionId)
 
 beforeSyncWithOriginal (int $origQuestionId, int $dupQuestionId, int $origParentObjId, int $dupParentObjId)
 
 afterSyncWithOriginal (int $origQuestionId, int $dupQuestionId, int $origParentObjId, int $dupParentObjId)
 
 onCopy (int $sourceParentId, int $sourceQuestionId, int $targetParentId, int $targetQuestionId)
 
 duplicateComments (int $parent_source_id, int $source_id, int $parent_target_id, int $target_id)
 
 deleteComments ()
 
 getNotesManager ()
 
 getNotesDataService ()
 
 getNotesRepo ()
 
 syncSuggestedSolutions (int $target_question_id, int $target_obj_id)
 
 duplicateSuggestedSolutionFiles (int $parent_id, int $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles (int $target_question_id, int $target_obj_id)
 
 copySuggestedSolutionFiles (int $source_questionpool_id, int $source_question_id)
 
 copySuggestedSolutions (int $target_question_id)
 
 ensureNonNegativePoints ($points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints (int $originalQuestionId, int $duplicateQuestionId)
 
 duplicateSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet (int $active_id, int $pass, bool $authorized=true)
 
 removeSolutionRecordById (int $solutionId)
 
 getSolutionRecordById (int $solutionId)
 
 deleteDummySolutionRecord (int $activeId, int $passIndex)
 
 isDummySolutionRecord (array $solutionRecord)
 
 deleteSolutionRecordByValues (int $activeId, int $passIndex, bool $authorized, array $matchValues)
 
 duplicateIntermediateSolutionAuthorized (int $activeId, int $passIndex)
 
 forceExistingIntermediateSolution (int $activeId, int $passIndex, bool $considerDummyRecordCreation)
 
 lookupMaxStep (int $active_id, int $pass)
 
 buildTestPresentationConfig ()
 build basic test question configuration instance More...
 
 getSuggestedSolutionsRepo ()
 
 loadSuggestedSolutions ()
 

Protected Attributes

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

Private Member Functions

 isValidTextRating ($textRating)
 

Private Attributes

 $matchcondition
 

Additional Inherited Members

- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 
- Static Protected Attributes inherited from assQuestion
static $forcePassResultsUpdateEnabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

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

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

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

assTextQuestion is a class for text questions

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

Definition at line 34 of file class.assTextQuestion.php.

Constructor & Destructor Documentation

◆ __construct()

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

assTextQuestion constructor

The constructor takes possible arguments an creates an instance of the assTextQuestion 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 text question

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

References assQuestion\$author, assQuestion\$comment, assQuestion\$owner, assQuestion\$question, assQuestion\$title, and ILIAS\MetaData\Repository\Validation\Data\__construct().

93  {
95  $this->wordCounterEnabled = false;
96  $this->maxNumOfChars = 0;
97  $this->points = 1;
98  $this->answers = [];
99  $this->matchcondition = 0;
100  }
__construct(VocabulariesInterface $vocabularies)
string $question
The question text.
+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswer()

assTextQuestion::addAnswer (   $answertext = "",
  $points = 0.0,
  $points_unchecked = 0.0,
  $order = 0,
  $answerimage = "" 
)

Adds a possible answer for a multiple choice question.

A ASS_AnswerBinaryStateImage object will be created and assigned to the array $this->answers.

Parameters
string$answertextThe answer text
double$pointsThe points for selecting the answer (even negative points can be used)
boolean$stateDefines the answer as correct (TRUE) or incorrect (FALSE)
integer$orderA possible display order of the answer
double$pointsThe points for not selecting the answer (even negative points can be used) public
See also
$answers
ASS_AnswerBinaryStateImage

Definition at line 833 of file class.assTextQuestion.php.

References assQuestion\$points.

Referenced by loadFromDb(), and setAnswers().

839  : void {
840  $answer = new ASS_AnswerMultipleResponseImage($answertext, $points);
841  $this->answers[] = $answer;
842  }
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file.
float $points
The maximum available points for the question.
+ Here is the caller graph for this function:

◆ calculateReachedPoints()

assTextQuestion::calculateReachedPoints (   $active_id,
  $pass = null,
  $authorizedSolution = true,
  $returndetails = false 
)

Returns the points, a learner has reached answering the question.

The points are calculated from the given answers.

public

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

Definition at line 552 of file class.assTextQuestion.php.

References $DIC, $ilDB, calculateReachedPointsForSolution(), assQuestion\getCurrentSolutionResultSet(), getMinimumPoints(), and assQuestion\getSolutionMaxPass().

552  : float
553  {
554  if ($returndetails) {
555  throw new ilTestException('return details not implemented for ' . __METHOD__);
556  }
557 
558  global $DIC;
559  $ilDB = $DIC['ilDB'];
560 
561  if (is_null($pass)) {
562  $pass = $this->getSolutionMaxPass($active_id);
563  }
564 
565  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
566 
567  // Return min points when no answer was given.
568  if ($ilDB->numRows($result) == 0) {
569  return $this->getMinimumPoints();
570  }
571 
572  // Return points of points are already on the row.
573  $row = $ilDB->fetchAssoc($result);
574  if ($row["points"] != null) {
575  return (float) $row["points"];
576  }
577 
578  return $this->calculateReachedPointsForSolution($row['value1']);
579  }
Base Exception for all Exceptions relating to Modules/Test.
global $DIC
Definition: feed.php:28
calculateReachedPointsForSolution($solution)
getSolutionMaxPass(int $active_id)
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assTextQuestion::calculateReachedPointsForSolution (   $solution)
protected

Definition at line 487 of file class.assTextQuestion.php.

References $answers, assQuestion\$points, getAnswers(), getKeywordRelation(), getMaximumPoints(), getMinimumPoints(), and isKeywordMatching().

Referenced by calculateReachedPoints().

487  : float
488  {
489  $solution = html_entity_decode($solution);
490  // Return min points when keyword relation is NON KEYWORDS
491  if ($this->getKeywordRelation() == 'non') {
492  return $this->getMinimumPoints();
493  }
494 
495  // Return min points if there are no answers present.
496  $answers = $this->getAnswers();
497 
498  if (count($answers) == 0) {
499  return $this->getMinimumPoints();
500  }
501 
502  switch ($this->getKeywordRelation()) {
503  case 'any':
504  $points = 0;
505  foreach ($answers as $answer) {
506  $qst_answer = $answer->getAnswertext();
507  $user_answer = ' ' . $solution;
508  if ($this->isKeywordMatching($user_answer, $qst_answer)) {
509  $points += $answer->getPoints();
510  }
511  }
512  break;
513 
514  case 'all':
515  $points = $this->getMaximumPoints();
516  foreach ($answers as $answer) {
517  $qst_answer = $answer->getAnswertext();
518  $user_answer = ' ' . $solution;
519  if (!$this->isKeywordMatching($user_answer, $qst_answer)) {
520  $points = 0;
521  break;
522  }
523  }
524  break;
525 
526  case 'one':
527  $points = 0;
528  foreach ($answers as $answer) {
529  $qst_answer = $answer->getAnswertext();
530  $user_answer = ' ' . $solution;
531  if ($this->isKeywordMatching($user_answer, $qst_answer)) {
532  $points = $this->getMaximumPoints();
533  break;
534  }
535  }
536  break;
537  }
538 
539  return (float) $points;
540  }
float $points
The maximum available points for the question.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
isKeywordMatching($answertext, $a_keyword)
Checks if one of the keywords matches the answertext.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyObject()

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

Copies an assTextQuestion object.

public

Definition at line 266 of file class.assTextQuestion.php.

References assQuestion\$original_id, assQuestion\$title, assQuestion\getId(), and assQuestion\getObjId().

266  : int
267  {
268  if ($this->getId() <= 0) {
269  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
270  }
271  // duplicate the question in database
272  $clone = $this;
273 
274  $original_id = $this->questioninfo->getOriginalId($this->id);
275  $clone->id = -1;
276  $source_questionpool_id = $this->getObjId();
277  $clone->setObjId($target_questionpool_id);
278  if ($title) {
279  $clone->setTitle($title);
280  }
281  $clone->saveToDb();
282  // copy question page content
283  $clone->copyPageOfQuestion($original_id);
284  // copy XHTML media objects
285  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
286  // duplicate answers
287  #$clone->duplicateAnswers($original_id);
288 
289  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
290 
291  return $clone->id;
292  }
+ Here is the call graph for this function:

◆ countLetters()

assTextQuestion::countLetters (   $text)

Definition at line 1011 of file class.assTextQuestion.php.

References ilStr\strLen().

1011  : int
1012  {
1013  $text = strip_tags($text);
1014 
1015  $text = str_replace('&gt;', '>', $text);
1016  $text = str_replace('&lt;', '<', $text);
1017  $text = str_replace('&nbsp;', ' ', $text);
1018  $text = str_replace('&amp;', '&', $text);
1019 
1020  $text = str_replace("\r\n", "\n", $text);
1021  $text = str_replace("\n", "", $text);
1022 
1023  return ilStr::strLen($text);
1024  }
static strLen(string $a_string)
Definition: class.ilStr.php:63
+ Here is the call graph for this function:

◆ countWords()

assTextQuestion::countWords (   $text)

Definition at line 1026 of file class.assTextQuestion.php.

1026  : int
1027  {
1028  if ($text === '') {
1029  return 0;
1030  }
1031  $text = str_replace('&nbsp;', ' ', $text);
1032 
1033  $text = preg_replace('/[.,:;!?\-_#\'"+*\\/=()&%§$]/m', '', $text);
1034 
1035  $text = preg_replace('/^\s*/m', '', $text);
1036  $text = preg_replace('/\s*$/m', '', $text);
1037  $text = preg_replace('/\s+/m', ' ', $text);
1038 
1039  return count(explode(' ', $text));
1040  }

◆ createNewOriginalFromThisDuplicate()

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

Definition at line 294 of file class.assTextQuestion.php.

References assQuestion\$id, assQuestion\getId(), and assQuestion\getObjId().

294  : int
295  {
296  if ($this->getId() <= 0) {
297  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
298  }
299 
300  $sourceQuestionId = $this->id;
301  $sourceParentId = $this->getObjId();
302 
303  // duplicate the question in database
304  $clone = $this;
305  $clone->id = -1;
306 
307  $clone->setObjId($targetParentId);
308 
309  if ($targetQuestionTitle) {
310  $clone->setTitle($targetQuestionTitle);
311  }
312 
313  $clone->saveToDb();
314  // copy question page content
315  $clone->copyPageOfQuestion($sourceQuestionId);
316  // copy XHTML media objects
317  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
318  // duplicate answers
319  #$clone->duplicateAnswers($sourceQuestionId);
320 
321  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
322 
323  return $clone->id;
324  }
+ Here is the call graph for this function:

◆ deleteAnswer()

assTextQuestion::deleteAnswer (   $index = 0)

Deletes an answer with a given index.

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

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

Definition at line 881 of file class.assTextQuestion.php.

References ILIAS\UI\Implementation\Component\Table\getOrder().

881  : void
882  {
883  if ($index < 0) {
884  return;
885  }
886  if (count($this->answers) < 1) {
887  return;
888  }
889  if ($index >= count($this->answers)) {
890  return;
891  }
892  $answer = $this->answers[$index];
893  //if (strlen($answer->getImage())) {
894  // $this->deleteImage($answer->getImage());
895  //}
896  unset($this->answers[$index]);
897  $this->answers = array_values($this->answers);
898  for ($i = 0, $iMax = count($this->answers); $i < $iMax; $i++) {
899  if ($this->answers[$i]->getOrder() > $index) {
900  $this->answers[$i]->setOrder($i);
901  }
902  }
903  }
+ Here is the call graph for this function:

◆ duplicate()

assTextQuestion::duplicate ( bool  $for_test = true,
string  $title = "",
string  $author = "",
int  $owner = -1,
  $testObjId = null 
)

Duplicates an assTextQuestion.

public

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

References assQuestion\$author, assQuestion\$original_id, assQuestion\$owner, assQuestion\$title, assQuestion\getId(), and assQuestion\getObjId().

214  : int
215  {
216  if ($this->id <= 0) {
217  // The question has not been saved. It cannot be duplicated
218  return -1;
219  }
220  // duplicate the question in database
221  $this_id = $this->getId();
222  $thisObjId = $this->getObjId();
223 
224  $clone = $this;
225 
226  $original_id = $this->questioninfo->getOriginalId($this->id);
227  $clone->id = -1;
228 
229  if ((int) $testObjId > 0) {
230  $clone->setObjId($testObjId);
231  }
232 
233  if ($title) {
234  $clone->setTitle($title);
235  }
236 
237  if ($author) {
238  $clone->setAuthor($author);
239  }
240  if ($owner) {
241  $clone->setOwner($owner);
242  }
243 
244  if ($for_test) {
245  $clone->saveToDb($original_id);
246  } else {
247  $clone->saveToDb();
248  }
249 
250  // copy question page content
251  $clone->copyPageOfQuestion($this_id);
252  // copy XHTML media objects
253  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
254  #$clone->duplicateAnswers($this_id);
255 
256  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
257 
258  return $clone->id;
259  }
+ Here is the call graph for this function:

◆ duplicateAnswers()

assTextQuestion::duplicateAnswers (   $original_id)

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

References $DIC, $ilDB, assQuestion\$original_id, and assQuestion\getId().

942  : void
943  {
944  global $DIC;
945  $ilDB = $DIC['ilDB'];
946 
947  $result = $ilDB->queryF(
948  "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
949  ['integer'],
950  [$original_id]
951  );
952  if ($result->numRows()) {
953  while ($row = $ilDB->fetchAssoc($result)) {
954  $next_id = $ilDB->nextId('qpl_a_essay');
955  $affectedRows = $ilDB->manipulateF(
956  "INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points)
957  VALUES (%s, %s, %s, %s)",
958  ['integer','integer','text','float'],
959  [$next_id, $this->getId(), $row["answertext"], $row["points"]]
960  );
961  }
962  }
963  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ flushAnswers()

assTextQuestion::flushAnswers ( )

Deletes all answers.

public

See also
$answers

Definition at line 916 of file class.assTextQuestion.php.

Referenced by loadFromDb(), and setAnswers().

916  : void
917  {
918  $this->answers = [];
919  }
+ Here is the caller graph for this function:

◆ getAdditionalTableName()

assTextQuestion::getAdditionalTableName ( )

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

Returns
string The additional table name public

Definition at line 756 of file class.assTextQuestion.php.

Referenced by getSolutionSubmit(), and loadFromDb().

756  : string
757  {
758  return "qpl_qst_essay";
759  }
+ Here is the caller graph for this function:

◆ getAnswer()

assTextQuestion::getAnswer (   $index = 0)

Returns an answer with a given index.

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

Parameters
integer$indexA nonnegative index of the n-th answer
Returns
object ASS_AnswerBinaryStateImage-Object containing the answer public
See also
$answers

Definition at line 858 of file class.assTextQuestion.php.

858  : ?object
859  {
860  if ($index < 0) {
861  return null;
862  }
863  if (count($this->answers) < 1) {
864  return null;
865  }
866  if ($index >= count($this->answers)) {
867  return null;
868  }
869 
870  return $this->answers[$index];
871  }

◆ getAnswerCount()

assTextQuestion::getAnswerCount ( )

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

815  : int
816  {
817  return count($this->answers);
818  }

◆ getAnswers()

assTextQuestion::getAnswers ( )

Definition at line 844 of file class.assTextQuestion.php.

References $answers.

Referenced by calculateReachedPointsForSolution().

844  : array
845  {
846  return $this->answers;
847  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assTextQuestion::getAnswerTableName ( )

Definition at line 905 of file class.assTextQuestion.php.

905  : string
906  {
907  return 'qpl_a_essay';
908  }

◆ getKeywordRelation()

assTextQuestion::getKeywordRelation ( )

Definition at line 965 of file class.assTextQuestion.php.

References $keyword_relation.

Referenced by calculateReachedPointsForSolution(), getMaximumPoints(), getMinimumPoints(), and getSolutionSubmit().

966  {
968  }
+ Here is the caller graph for this function:

◆ getLatestAutosaveContent()

assTextQuestion::getLatestAutosaveContent ( int  $active_id,
int  $pass 
)

Definition at line 1042 of file class.assTextQuestion.php.

References assQuestion\getId().

1042  : ?string
1043  {
1044  $question_fi = $this->getId();
1045 
1046  // Do we have an unauthorized result?
1047  $cntresult = $this->db->query(
1048  '
1049  SELECT count(solution_id) cnt
1050  FROM tst_solutions
1051  WHERE active_fi = ' . $this->db->quote($active_id, 'int') . '
1052  AND question_fi = ' . $this->db->quote($this->getId(), 'int') . '
1053  AND authorized = ' . $this->db->quote(0, 'int')
1054  . ' AND pass = ' . $this->db->quote($pass, 'int')
1055  );
1056  $row = $this->db->fetchAssoc($cntresult);
1057  if ($row['cnt'] > 0) {
1058  $tresult = $this->db->query(
1059  '
1060  SELECT value1
1061  FROM tst_solutions
1062  WHERE active_fi = ' . $this->db->quote($active_id, 'int') . '
1063  AND question_fi = ' . $this->db->quote($this->getId(), 'int') . '
1064  AND authorized = ' . $this->db->quote(0, 'int')
1065  . ' AND pass = ' . $this->db->quote($pass, 'int')
1066  );
1067  $trow = $this->db->fetchAssoc($tresult);
1068  return $trow['value1'];
1069  }
1070  return null;
1071  }
+ Here is the call graph for this function:

◆ getMatchcondition()

assTextQuestion::getMatchcondition ( )

Definition at line 102 of file class.assTextQuestion.php.

References $matchcondition.

Referenced by getSolutionSubmit().

102  : int
103  {
104  return $this->matchcondition;
105  }
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assTextQuestion::getMaximumPoints ( )

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

public

See also
$points

Definition at line 372 of file class.assTextQuestion.php.

References assQuestion\$points, and getKeywordRelation().

Referenced by calculateReachedPointsForSolution(), and isComplete().

372  : float
373  {
374  if (in_array($this->getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
375  return parent::getPoints();
376  }
377 
378  $points = 0;
379 
380  foreach ($this->answers as $answer) {
381  if ($answer->getPoints() > 0) {
382  $points = $points + $answer->getPoints();
383  }
384  }
385 
386  return $points;
387  }
float $points
The maximum available points for the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMaxNumOfChars()

assTextQuestion::getMaxNumOfChars ( )

Gets the maximum number of characters for the text solution.

Returns
integer The maximum number of characters for the text solution public
See also
$maxNumOfChars

Definition at line 333 of file class.assTextQuestion.php.

References $maxNumOfChars.

Referenced by getSolutionSubmit(), and toJSON().

333  : int
334  {
335  return $this->maxNumOfChars;
336  }
+ Here is the caller graph for this function:

◆ getMinimumPoints()

assTextQuestion::getMinimumPoints ( )

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

References assQuestion\$points, and getKeywordRelation().

Referenced by calculateReachedPoints(), and calculateReachedPointsForSolution().

390  {
391  if (in_array($this->getKeywordRelation(), self::getScoringModesWithPointsByQuestion())) {
392  return 0;
393  }
394 
395  $points = 0;
396 
397  foreach ($this->answers as $answer) {
398  if ($answer->getPoints() < 0) {
399  $points = $points + $answer->getPoints();
400  }
401  }
402 
403  return $points;
404  }
float $points
The maximum available points for the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionType()

assTextQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

Definition at line 708 of file class.assTextQuestion.php.

Referenced by toJSON().

708  : string
709  {
710  return "assTextQuestion";
711  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assTextQuestion::getRTETextWithMediaObjects ( )

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

Definition at line 765 of file class.assTextQuestion.php.

765  : string
766  {
767  return parent::getRTETextWithMediaObjects();
768  }

◆ getScoringModesWithPointsByKeyword()

static assTextQuestion::getScoringModesWithPointsByKeyword ( )
static

Definition at line 991 of file class.assTextQuestion.php.

Referenced by assTextQuestionGUI\getBestAnswer().

991  : array
992  {
993  return ['any'];
994  }
+ Here is the caller graph for this function:

◆ getScoringModesWithPointsByQuestion()

static assTextQuestion::getScoringModesWithPointsByQuestion ( )
static

Definition at line 986 of file class.assTextQuestion.php.

986  : array
987  {
988  return ['non', 'all', 'one'];
989  }

◆ getSolutionSubmit()

assTextQuestion::getSolutionSubmit ( )
Returns
mixed|string

Definition at line 635 of file class.assTextQuestion.php.

References $DIC, $ilDB, ilObjAdvancedEditing\_getRichTextEditor(), getAdditionalTableName(), assQuestion\getHtmlUserSolutionPurifier(), assQuestion\getId(), getKeywordRelation(), getMatchcondition(), getMaxNumOfChars(), getTextRating(), ILIAS\Repository\int(), ilUtil\isHTML(), isWordCounterEnabled(), ilObjQuestionScoringAdjustable\saveAdditionalQuestionDataToDb(), ilObjAnswerScoringAdjustable\saveAnswerSpecificDataToDb(), and ilUtil\stripSlashes().

Referenced by saveWorkingData().

636  {
637  if (ilObjAdvancedEditing::_getRichTextEditor() === 'tinymce') {
638  $text = ilUtil::stripSlashes($_POST["TEXT"], false);
639  } else {
640  $text = htmlentities($_POST["TEXT"]);
641  }
642 
643  if (ilUtil::isHTML($text)) {
644  $text = $this->getHtmlUserSolutionPurifier()->purify($text);
645  }
646 
647  return $text;
648  }
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
static isHTML(string $a_text)
Checks if a given string contains HTML or not.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextRating()

assTextQuestion::getTextRating ( )

Returns the rating option for text comparisons.

Returns
string The rating option for text comparisons
See also
$text_rating public

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

References $text_rating.

Referenced by getSolutionSubmit(), and isKeywordMatching().

720  : string
721  {
722  return $this->text_rating;
723  }
+ Here is the caller graph for this function:

◆ getValidScoringModes()

static assTextQuestion::getValidScoringModes ( )
static

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

981  : array
982  {
983  return array_merge(self::getScoringModesWithPointsByQuestion(), self::getScoringModesWithPointsByKeyword());
984  }

◆ isComplete()

assTextQuestion::isComplete ( )

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

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

Definition at line 117 of file class.assTextQuestion.php.

References getMaximumPoints().

117  : bool
118  {
119  if (strlen($this->title)
120  && $this->author
121  && $this->question
122  && $this->getMaximumPoints() > 0
123  ) {
124  return true;
125  }
126  return false;
127  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ isKeywordMatching()

assTextQuestion::isKeywordMatching (   $answertext,
  $a_keyword 
)

Checks if one of the keywords matches the answertext.

Parameters
string$answertextThe answertext of the user
string$a_keywordThe keyword which should be checked
Returns
boolean TRUE if the keyword matches, FALSE otherwise private

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

References $DIC, assQuestion\$refinery, getTextRating(), ilStr\strPos(), ilStr\strToLower(), TEXTGAP_RATING_CASEINSENSITIVE, TEXTGAP_RATING_CASESENSITIVE, TEXTGAP_RATING_LEVENSHTEIN1, TEXTGAP_RATING_LEVENSHTEIN2, TEXTGAP_RATING_LEVENSHTEIN3, TEXTGAP_RATING_LEVENSHTEIN4, and TEXTGAP_RATING_LEVENSHTEIN5.

Referenced by calculateReachedPointsForSolution().

430  : bool
431  {
432  global $DIC;
433  $refinery = $DIC->refinery();
434  $result = false;
435  $textrating = $this->getTextRating();
436 
437  switch ($textrating) {
439  if (ilStr::strPos(ilStr::strToLower($answertext), ilStr::strToLower($a_keyword), 0) !== false) {
440  return true;
441  }
442  break;
444  if (ilStr::strPos($answertext, $a_keyword) !== false) {
445  return true;
446  }
447  break;
448  }
449 
450  // "<p>red</p>" would not match "red" even with distance of 5
451  $answertext = strip_tags($answertext);
452  $answerwords = [];
453  if (preg_match_all("/([^\s.]+)/", $answertext, $matches)) {
454  foreach ($matches[1] as $answerword) {
455  array_push($answerwords, trim($answerword));
456  }
457  }
458 
459  // create correct transformation
460  switch ($textrating) {
462  $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 1);
463  break;
465  $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 2);
466  break;
468  $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 3);
469  break;
471  $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 4);
472  break;
474  $transformation = $refinery->string()->levenshtein()->standard($a_keyword, 5);
475  break;
476  }
477 
478  // run answers against Levenshtein methods
479  foreach ($answerwords as $a_original) {
480  if (isset($transformation) && $transformation->transform($a_original) >= 0) {
481  return true;
482  }
483  }
484  return $result;
485  }
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
static strPos(string $a_haystack, string $a_needle, int $a_offset=0)
Definition: class.ilStr.php:42
global $DIC
Definition: feed.php:28
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN4
static strToLower(string $a_string)
Definition: class.ilStr.php:72
getTextRating()
Returns the rating option for text comparisons.
ILIAS Refinery Factory $refinery
const TEXTGAP_RATING_CASEINSENSITIVE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isObligationPossible()

static assTextQuestion::isObligationPossible ( int  $questionId)
static

returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration

(overwrites method in class assQuestion)

Parameters
integer$questionId
Returns
boolean $obligationPossible

Definition at line 1006 of file class.assTextQuestion.php.

1006  : bool
1007  {
1008  return true;
1009  }

◆ isValidTextRating()

assTextQuestion::isValidTextRating (   $textRating)
private

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

References TEXTGAP_RATING_CASEINSENSITIVE, TEXTGAP_RATING_CASESENSITIVE, TEXTGAP_RATING_LEVENSHTEIN1, TEXTGAP_RATING_LEVENSHTEIN2, TEXTGAP_RATING_LEVENSHTEIN3, TEXTGAP_RATING_LEVENSHTEIN4, and TEXTGAP_RATING_LEVENSHTEIN5.

Referenced by loadFromDb().

406  : bool
407  {
408  switch ($textRating) {
416  return true;
417  }
418 
419  return false;
420  }
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_CASEINSENSITIVE
+ Here is the caller graph for this function:

◆ isWordCounterEnabled()

assTextQuestion::isWordCounterEnabled ( )
Returns
bool

Definition at line 353 of file class.assTextQuestion.php.

References $wordCounterEnabled.

Referenced by getSolutionSubmit().

353  : bool
354  {
356  }
+ Here is the caller graph for this function:

◆ loadFromDb()

assTextQuestion::loadFromDb (   $question_id)

Loads a assTextQuestion object from a database.

Parameters
object$dbA pear DB object
integer$question_idA unique key which defines the text question in the database public

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

References $data, $DIC, Vendor\Package\$e, $ilDB, ilRTE\_replaceMediaObjectImageSrc(), addAnswer(), flushAnswers(), getAdditionalTableName(), ilAssQuestionLifecycle\getDraftInstance(), assQuestion\getId(), ilAssQuestionLifecycle\getInstance(), isValidTextRating(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setId(), setKeywordRelation(), assQuestion\setLifecycle(), setMaxNumOfChars(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), assQuestion\setShuffle(), setTextRating(), assQuestion\setTitle(), setWordCounterEnabled(), and TEXTGAP_RATING_CASEINSENSITIVE.

154  : void
155  {
156  global $DIC;
157  $ilDB = $DIC['ilDB'];
158 
159  $result = $ilDB->queryF(
160  "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",
161  ["integer"],
162  [$question_id]
163  );
164  if ($ilDB->numRows($result) == 1) {
165  $data = $ilDB->fetchAssoc($result);
166  $this->setId($question_id);
167  $this->setObjId($data["obj_fi"]);
168  $this->setTitle((string) $data["title"]);
169  $this->setComment((string) $data["description"]);
170  $this->setOriginalId($data["original_id"]);
171  $this->setNrOfTries($data['nr_of_tries']);
172  $this->setAuthor($data["author"]);
173  $this->setPoints((float) $data["points"]);
174  $this->setOwner($data["owner"]);
175  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
176  $this->setShuffle(false);
177  $this->setWordCounterEnabled((bool) $data['word_cnt_enabled']);
178  $this->setMaxNumOfChars($data["maxnumofchars"] ?? 0);
179  $this->setTextRating($this->isValidTextRating($data["textgap_rating"]) ? $data["textgap_rating"] : TEXTGAP_RATING_CASEINSENSITIVE);
180  $this->matchcondition = (isset($data['matchcondition'])) ? (int) $data['matchcondition'] : 0;
181  $this->setKeywordRelation(($data['keyword_relation']));
182 
183  try {
187  }
188 
189  try {
190  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
191  } catch (ilTestQuestionPoolException $e) {
192  }
193  }
194 
195  $result = $ilDB->queryF(
196  "SELECT * FROM qpl_a_essay WHERE question_fi = %s",
197  ['integer'],
198  [$this->getId()]
199  );
200 
201  $this->flushAnswers();
202  while ($row = $ilDB->fetchAssoc($result)) {
203  $this->addAnswer($row['answertext'], $row['points']);
204  }
205 
206  parent::loadFromDb($question_id);
207  }
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)
setMaxNumOfChars(int $maxchars=0)
Sets the maximum number of characters for the text solution.
setComment(string $comment="")
setWordCounterEnabled($wordCounterEnabled)
global $DIC
Definition: feed.php:28
isValidTextRating($textRating)
flushAnswers()
Deletes all answers.
setTextRating($a_text_rating)
Sets the rating option for text comparisons.
setPoints(float $points)
setObjId(int $obj_id=0)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
addAnswer( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="")
Adds a possible answer for a multiple choice question.
setKeywordRelation(?string $relation)
This method implements a default behaviour.
setId(int $id=-1)
setOriginalId(?int $original_id)
setTitle(string $title="")
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setAuthor(string $author="")
setShuffle(?bool $shuffle=true)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
const TEXTGAP_RATING_CASEINSENSITIVE
setQuestion(string $question="")
+ Here is the call graph for this function:

◆ saveToDb()

assTextQuestion::saveToDb (   $original_id = "")

Saves a assTextQuestion object to a database.

Parameters
string$original_id

Definition at line 134 of file class.assTextQuestion.php.

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

134  : void
135  {
136  if ($original_id == '') {
137  $this->saveQuestionDataToDb();
138  } else {
140  }
141 
144  parent::saveToDb();
145  }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb(int $original_id=-1)
+ Here is the call graph for this function:

◆ saveWorkingData()

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

Saves the learners input of the question to the database.

public

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

Definition at line 589 of file class.assTextQuestion.php.

References $DIC, $ilDB, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), assQuestion\getId(), assQuestion\getProcessLocker(), getSolutionSubmit(), ILIAS\Repository\lng(), assQuestion\logAction(), assQuestion\removeCurrentSolution(), and assQuestion\saveCurrentSolution().

589  : bool
590  {
591  global $DIC;
592  $ilDB = $DIC['ilDB'];
593  $ilUser = $DIC['ilUser'];
594 
595  if (is_null($pass)) {
596  $pass = ilObjTest::_getPass($active_id);
597  }
598 
599  $entered_values = 0;
600  $text = $this->getSolutionSubmit();
601 
602  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $active_id, $pass, $authorized, $text) {
603  $this->removeCurrentSolution($active_id, $pass, $authorized);
604 
605  if (strlen($text)) {
606  $this->saveCurrentSolution($active_id, $pass, trim($text), null, $authorized);
607  $entered_values++;
608  }
609  });
610 
611  if ($entered_values) {
613  assQuestion::logAction($this->lng->txtlng(
614  "assessment",
615  "log_user_entered_values",
617  ), $active_id, $this->getId());
618  }
619  } else {
621  assQuestion::logAction($this->lng->txtlng(
622  "assessment",
623  "log_user_not_entered_values",
625  ), $active_id, $this->getId());
626  }
627  }
628 
629  return true;
630  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
global $DIC
Definition: feed.php:28
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
static logAction(string $logtext, int $active_id, int $question_id)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
+ Here is the call graph for this function:

◆ setAnswers()

assTextQuestion::setAnswers (   $answers)

Definition at line 921 of file class.assTextQuestion.php.

References $answers, addAnswer(), and flushAnswers().

921  : void
922  {
923  if (isset($answers['answer'])) {
924  $count = count($answers['answer']);
925  $withPoints = true;
926  } else {
927  $count = count($answers);
928  $withPoints = false;
929  }
930 
931  $this->flushAnswers();
932 
933  for ($i = 0; $i < $count; $i++) {
934  if ($withPoints) {
935  $this->addAnswer($answers['answer'][$i], $answers['points'][$i]);
936  } else {
937  $this->addAnswer($answers[$i], 0);
938  }
939  }
940  }
flushAnswers()
Deletes all answers.
addAnswer( $answertext="", $points=0.0, $points_unchecked=0.0, $order=0, $answerimage="")
Adds a possible answer for a multiple choice question.
+ Here is the call graph for this function:

◆ setExportDetailsXLSX()

assTextQuestion::setExportDetailsXLSX ( ilAssExcelFormatHelper  $worksheet,
int  $startrow,
int  $col,
int  $active_id,
int  $pass 
)

{}

Definition at line 773 of file class.assTextQuestion.php.

References ilExcel\getColumnCoord(), assQuestion\getSolutionValues(), ilAssExcelFormatHelper\getStringEscaping(), ILIAS\Repository\lng(), ilExcel\setBold(), ilAssExcelFormatHelper\setCell(), and ilAssExcelFormatHelper\setStringEscaping().

773  : int
774  {
775  parent::setExportDetailsXLSX($worksheet, $startrow, $col, $active_id, $pass);
776 
777  $solutions = $this->getSolutionValues($active_id, $pass);
778 
779  $i = 1;
780  $worksheet->setCell($startrow + $i, $col, $this->lng->txt("result"));
781  $worksheet->setBold($worksheet->getColumnCoord($col) . ($startrow + $i));
782 
783  $assessment_folder = new ilObjAssessmentFolder();
784 
785  $string_escaping_org_value = $worksheet->getStringEscaping();
786  if ($assessment_folder->getExportEssayQuestionsWithHtml()) {
787  $worksheet->setStringEscaping(false);
788  }
789 
790  if (array_key_exists(0, $solutions) && strlen($solutions[0]["value1"])) {
791  $worksheet->setCell($startrow + $i, $col + 2, html_entity_decode($solutions[0]["value1"]));
792  }
793  $i++;
794 
795  $worksheet->setStringEscaping($string_escaping_org_value);
796  return $startrow + $i + 1;
797  }
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
getColumnCoord(int $a_col)
Get column "name" from number.
setCell($a_row, $a_col, $a_value, $datatype=null)
setBold(string $a_coords)
Set cell(s) to bold.
Class ilObjAssessmentFolder.
+ Here is the call graph for this function:

◆ setKeywordRelation()

assTextQuestion::setKeywordRelation ( ?string  $relation)

This method implements a default behaviour.

During the creation of a text question, the record which holds the keyword relation is not existing, so keyword_relation defaults to 'one'.

Definition at line 974 of file class.assTextQuestion.php.

References $relation.

Referenced by loadFromDb().

974  : void
975  {
976  if ($relation !== null) {
977  $this->keyword_relation = $relation;
978  }
979  }
$relation
+ Here is the caller graph for this function:

◆ setMatchcondition()

assTextQuestion::setMatchcondition ( int  $matchcondition)

Definition at line 107 of file class.assTextQuestion.php.

References $matchcondition.

107  : void
108  {
109  $this->matchcondition = $matchcondition;
110  }

◆ setMaxNumOfChars()

assTextQuestion::setMaxNumOfChars ( int  $maxchars = 0)

Sets the maximum number of characters for the text solution.

Parameters
integer$maxcharsThe maximum number of characters for the text solution public
See also
$maxNumOfChars

Definition at line 345 of file class.assTextQuestion.php.

Referenced by loadFromDb().

345  : void
346  {
347  $this->maxNumOfChars = $maxchars;
348  }
+ Here is the caller graph for this function:

◆ setTextRating()

assTextQuestion::setTextRating (   $a_text_rating)

Sets the rating option for text comparisons.

Parameters
string$a_textgap_ratingThe rating option for text comparisons
See also
$textgap_rating public

Definition at line 732 of file class.assTextQuestion.php.

References TEXTGAP_RATING_CASEINSENSITIVE, TEXTGAP_RATING_CASESENSITIVE, TEXTGAP_RATING_LEVENSHTEIN1, TEXTGAP_RATING_LEVENSHTEIN2, TEXTGAP_RATING_LEVENSHTEIN3, TEXTGAP_RATING_LEVENSHTEIN4, and TEXTGAP_RATING_LEVENSHTEIN5.

Referenced by loadFromDb().

732  : void
733  {
734  switch ($a_text_rating) {
742  $this->text_rating = $a_text_rating;
743  break;
744  default:
745  $this->text_rating = TEXTGAP_RATING_CASEINSENSITIVE;
746  break;
747  }
748  }
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_CASEINSENSITIVE
+ Here is the caller graph for this function:

◆ setWordCounterEnabled()

assTextQuestion::setWordCounterEnabled (   $wordCounterEnabled)
Parameters
bool$wordCounterEnabled

Definition at line 361 of file class.assTextQuestion.php.

References $wordCounterEnabled.

Referenced by loadFromDb().

361  : void
362  {
363  $this->wordCounterEnabled = $wordCounterEnabled;
364  }
+ Here is the caller graph for this function:

◆ toJSON()

assTextQuestion::toJSON ( )

Returns a JSON representation of the question.

Implements ilAssQuestionLMExportable.

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

References assQuestion\formatSAQuestion(), assQuestion\getId(), getMaxNumOfChars(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), and assQuestion\getTitleForHTMLOutput().

802  : string
803  {
804  $result = [];
805  $result['id'] = $this->getId();
806  $result['type'] = (string) $this->getQuestionType();
807  $result['title'] = $this->getTitleForHTMLOutput();
808  $result['question'] = $this->formatSAQuestion($this->getQuestion());
809  $result['nr_of_tries'] = $this->getNrOfTries();
810  $result['shuffle'] = $this->getShuffle();
811  $result['maxlength'] = $this->getMaxNumOfChars();
812  return json_encode($result);
813  }
getQuestionType()
Returns the question type of the question.
getMaxNumOfChars()
Gets the maximum number of characters for the text solution.
+ Here is the call graph for this function:

Field Documentation

◆ $answers

assTextQuestion::$answers

◆ $keyword_relation

assTextQuestion::$keyword_relation = 'non'

Definition at line 73 of file class.assTextQuestion.php.

Referenced by getKeywordRelation().

◆ $keywords

assTextQuestion::$keywords

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

◆ $matchcondition

assTextQuestion::$matchcondition
private

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

Referenced by getMatchcondition(), and setMatchcondition().

◆ $maxNumOfChars

assTextQuestion::$maxNumOfChars

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

Referenced by getMaxNumOfChars().

◆ $text_rating

assTextQuestion::$text_rating

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

Referenced by getTextRating().

◆ $wordCounterEnabled

assTextQuestion::$wordCounterEnabled
protected

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

Referenced by isWordCounterEnabled(), and setWordCounterEnabled().

◆ HAS_SPECIFIC_FEEDBACK

const assTextQuestion::HAS_SPECIFIC_FEEDBACK = false
protected

Definition at line 36 of file class.assTextQuestion.php.


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