ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
assTextSubset 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 assTextSubset:
+ Collaboration diagram for assTextSubset:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assTextSubset constructor More...
 
 isComplete ()
 Returns true, if a TextSubset question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a assTextSubset object to a database. More...
 
 loadFromDb ($question_id)
 Loads a assTextSubset object from a database. More...
 
 addAnswer ($answertext, $points, $order)
 Adds an answer to the question. More...
 
 duplicate (bool $for_test=true, string $title="", string $author="", int $owner=-1, $testObjId=null)
 Duplicates an assTextSubsetQuestion. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assTextSubset object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 getAnswerCount ()
 Returns the number of answers. More...
 
 getAnswer ($index=0)
 Returns an answer with a given index. More...
 
 deleteAnswer ($index=0)
 Deletes an answer with a given index. More...
 
 flushAnswers ()
 Deletes all answers. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
getAvailableAnswers ()
 Returns the available answers for the question. More...
 
 isAnswerCorrect ($answers, $answer)
 Returns the index of the found answer, if the given answer is in the set of correct answers and matchess the matching options, otherwise FALSE is returned. More...
 
 getTextRating ()
 Returns the rating option for text comparisons. More...
 
 setTextRating ($a_text_rating)
 Sets the rating option for text comparisons. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 setCorrectAnswers (int $a_correct_answers)
 Sets the number of correct answers needed to solve the question. More...
 
 getCorrectAnswers ()
 Returns the number of correct answers needed to solve the question. More...
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
joinAnswers ()
 Returns the answers of the question as a comma separated string. More...
 
 getMaxTextboxWidth ()
 Returns the maximum width needed for the answer textboxes. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 setExportDetailsXLSX (ilAssExcelFormatHelper $worksheet, int $startrow, int $col, int $active_id, int $pass)
 {} More...
 
 getAnswers ()
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
- 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 iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 
- Public Member Functions inherited from assQuestionInterface
 validateSolutionSubmit ()
 

Data Fields

 $answers
 
 $correctanswers
 
 $text_rating
 
- 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 = ':'
 
- Data Fields inherited from iQuestionCondition
const StringResultExpression = '~TEXT~'
 
const PercentageResultExpression = '%n%'
 
const NumericResultExpression = '#n#'
 
const MatchingResultExpression = ';n:m;'
 
const OrderingResultExpression = '$n,m,o,p$'
 
const NumberOfResultExpression = '+n+'
 
const ExclusiveResultExpression = '*n,m,o,p*'
 
const EmptyAnswerExpression = "?"
 

Protected Member Functions

 getSolutionSubmit ()
 
 calculateReachedPointsForSolution ($enteredTexts)
 
- 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 ()
 

Additional Inherited Members

- 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...
 
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 
- 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
 
- 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 TextSubset questions

assTextSubset is a class for TextSubset questions. To solve a TextSubset question, a learner has to enter a TextSubsetal value in a defined range

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
Nina Gharib nina@.nosp@m.wgse.nosp@m.rve.d.nosp@m.e
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.assTextSubset.php.

Constructor & Destructor Documentation

◆ __construct()

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

assTextSubset constructor

The constructor takes possible arguments an creates an instance of the assTextSubset 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 TextSubsetal ID to identify the owner/creator
string$questionThe question string of the TextSubset question

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

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

76  {
78  $this->answers = array();
79  $this->correctanswers = 0;
80  }
__construct(VocabulariesInterface $vocabularies)
string $question
The question text.
+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswer()

assTextSubset::addAnswer (   $answertext,
  $points,
  $order 
)

Adds an answer to the question.

public

Definition at line 186 of file class.assTextSubset.php.

References assQuestion\$points.

Referenced by addAnswerOptionValue().

186  : void
187  {
188  if (array_key_exists($order, $this->answers)) {
189  // insert answer
190  $answer = new ASS_AnswerBinaryStateImage($answertext, $points, $order);
191  $newchoices = array();
192  for ($i = 0; $i < $order; $i++) {
193  $newchoices[] = $this->answers[$i];
194  }
195  $newchoices[] = $answer;
196  for ($i = $order, $iMax = count($this->answers); $i < $iMax; $i++) {
197  $changed = $this->answers[$i];
198  $changed->setOrder($i + 1);
199  $newchoices[] = $changed;
200  }
201  $this->answers = $newchoices;
202  } else {
203  // add answer
204  $this->answers[] = new ASS_AnswerBinaryStateImage($answertext, $points, count($this->answers));
205  }
206  }
Class for answers with a binary state indicator.
float $points
The maximum available points for the question.
+ Here is the caller graph for this function:

◆ addAnswerOptionValue()

assTextSubset::addAnswerOptionValue ( int  $qIndex,
string  $answerOptionValue,
float  $points 
)

Definition at line 979 of file class.assTextSubset.php.

References addAnswer().

979  : void
980  {
981  $this->addAnswer($answerOptionValue, $points, $qIndex);
982  }
addAnswer($answertext, $points, $order)
Adds an answer to the question.
float $points
The maximum available points for the question.
+ Here is the call graph for this function:

◆ calculateReachedPoints()

assTextSubset::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 538 of file class.assTextSubset.php.

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

Referenced by getExpressionTypes().

538  : float
539  {
540  if ($returndetails) {
541  throw new ilTestException('return details not implemented for ' . __METHOD__);
542  }
543 
544  global $DIC;
545  $ilDB = $DIC['ilDB'];
546 
547 
548  if (is_null($pass)) {
549  $pass = $this->getSolutionMaxPass($active_id);
550  }
551  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
552 
553  $enteredTexts = array();
554  while ($data = $ilDB->fetchAssoc($result)) {
555  $enteredTexts[] = $data["value1"];
556  }
557 
558  return $this->calculateReachedPointsForSolution($enteredTexts);
559  }
calculateReachedPointsForSolution($enteredTexts)
Base Exception for all Exceptions relating to Modules/Test.
global $DIC
Definition: feed.php:28
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()

assTextSubset::calculateReachedPointsForSolution (   $enteredTexts)
protected
Parameters
$enteredTexts
Returns
int

Definition at line 862 of file class.assTextSubset.php.

References assQuestion\$points, getAvailableAnswers(), and isAnswerCorrect().

Referenced by calculateReachedPoints().

862  : float
863  {
864  $enteredTexts ??= [];
865  $available_answers = $this->getAvailableAnswers();
866  $points = 0;
867  foreach ($enteredTexts as $enteredtext) {
868  $index = $this->isAnswerCorrect($available_answers, html_entity_decode($enteredtext));
869  if ($index !== false) {
870  unset($available_answers[$index]);
871  $points += $this->answers[$index]->getPoints();
872  }
873  }
874  return $points;
875  }
float $points
The maximum available points for the question.
& getAvailableAnswers()
Returns the available answers for the question.
isAnswerCorrect($answers, $answer)
Returns the index of the found answer, if the given answer is in the set of correct answers and match...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyObject()

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

Copies an assTextSubset object.

public

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

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

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

◆ createNewOriginalFromThisDuplicate()

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

Definition at line 290 of file class.assTextSubset.php.

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

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

◆ deleteAnswer()

assTextSubset::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 364 of file class.assTextSubset.php.

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

364  : void
365  {
366  if ($index < 0) {
367  return;
368  }
369  if (count($this->answers) < 1) {
370  return;
371  }
372  if ($index >= count($this->answers)) {
373  return;
374  }
375  unset($this->answers[$index]);
376  $this->answers = array_values($this->answers);
377  for ($i = 0, $iMax = count($this->answers); $i < $iMax; $i++) {
378  if ($this->answers[$i]->getOrder() > $index) {
379  $this->answers[$i]->setOrder($i);
380  }
381  }
382  }
+ Here is the call graph for this function:

◆ duplicate()

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

Duplicates an assTextSubsetQuestion.

public

Definition at line 213 of file class.assTextSubset.php.

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

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

◆ flushAnswers()

assTextSubset::flushAnswers ( )

Deletes all answers.

public

See also
$answers

Definition at line 390 of file class.assTextSubset.php.

390  : void
391  {
392  $this->answers = array();
393  }

◆ getAdditionalTableName()

assTextSubset::getAdditionalTableName ( )

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

Returns
string The additional table name public

Definition at line 743 of file class.assTextSubset.php.

Referenced by loadFromDb(), and saveWorkingData().

743  : string
744  {
745  return "qpl_qst_textsubset";
746  }
+ Here is the caller graph for this function:

◆ getAnswer()

assTextSubset::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_assAnswerBinaryStateImage-Object containing the answer public
See also
$answers

Definition at line 341 of file class.assTextSubset.php.

Referenced by getAvailableAnswerOptions().

341  : ?object
342  {
343  if ($index < 0) {
344  return null;
345  }
346  if (count($this->answers) < 1) {
347  return null;
348  }
349  if ($index >= count($this->answers)) {
350  return null;
351  }
352 
353  return $this->answers[$index];
354  }
+ Here is the caller graph for this function:

◆ getAnswerCount()

assTextSubset::getAnswerCount ( )

Returns the number of answers.

Returns
integer The number of answers of the TextSubset question public
See also
$ranges

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

327  : int
328  {
329  return count($this->answers);
330  }

◆ getAnswers()

assTextSubset::getAnswers ( )

Definition at line 786 of file class.assTextSubset.php.

References $answers.

Referenced by getAvailableAnswerOptions(), getSolutionSubmit(), isAddableAnswerOptionValue(), and toJSON().

786  : array
787  {
788  return $this->answers;
789  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assTextSubset::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name public

Definition at line 754 of file class.assTextSubset.php.

754  : string
755  {
756  return "qpl_a_textsubset";
757  }

◆ getAvailableAnswerOptions()

assTextSubset::getAvailableAnswerOptions (   $index = null)

If index is null, the function returns an array with all anwser options Else it returns the specific answer option.

Parameters
null | int$index

Implements iQuestionCondition.

Definition at line 954 of file class.assTextSubset.php.

References getAnswer(), and getAnswers().

955  {
956  if ($index !== null) {
957  return $this->getAnswer($index);
958  } else {
959  return $this->getAnswers();
960  }
961  }
getAnswer($index=0)
Returns an answer with a given index.
+ Here is the call graph for this function:

◆ getAvailableAnswers()

& assTextSubset::getAvailableAnswers ( )

Returns the available answers for the question.

private

See also
$answers

Definition at line 425 of file class.assTextSubset.php.

Referenced by calculateReachedPointsForSolution().

425  : array
426  {
427  $available_answers = array();
428  foreach ($this->answers as $answer) {
429  $available_answers[] = $answer->getAnswertext();
430  }
431  return $available_answers;
432  }
+ Here is the caller graph for this function:

◆ getCorrectAnswers()

assTextSubset::getCorrectAnswers ( )

Returns the number of correct answers needed to solve the question.

Returns
integer The number of correct answers public

Definition at line 578 of file class.assTextSubset.php.

References $correctanswers.

Referenced by getMaximumPoints(), saveWorkingData(), and toJSON().

578  : int
579  {
580  return $this->correctanswers;
581  }
+ Here is the caller graph for this function:

◆ getExpressionTypes()

◆ getMaximumPoints()

assTextSubset::getMaximumPoints ( )

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

public

See also
$points

Definition at line 401 of file class.assTextSubset.php.

References assQuestion\$points, and getCorrectAnswers().

Referenced by getExpressionTypes(), and isComplete().

401  : float
402  {
403  $points = array();
404  foreach ($this->answers as $answer) {
405  if ($answer->getPoints() > 0) {
406  $points[] = $answer->getPoints();
407  }
408  }
409  rsort($points, SORT_NUMERIC);
410  $maxpoints = 0;
411  for ($counter = 0; $counter < $this->getCorrectAnswers(); $counter++) {
412  if (isset($points[$counter])) {
413  $maxpoints += $points[$counter];
414  }
415  }
416  return $maxpoints;
417  }
getCorrectAnswers()
Returns the number of correct answers needed to solve the question.
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:

◆ getMaxTextboxWidth()

assTextSubset::getMaxTextboxWidth ( )

Returns the maximum width needed for the answer textboxes.

Returns
integer Maximum textbox width public

Definition at line 725 of file class.assTextSubset.php.

725  : int
726  {
727  $maxwidth = 0;
728  foreach ($this->answers as $answer) {
729  $len = strlen($answer->getAnswertext());
730  if ($len > $maxwidth) {
731  $maxwidth = $len;
732  }
733  }
734  return $maxwidth + 3;
735  }

◆ getOperators()

assTextSubset::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

Definition at line 885 of file class.assTextSubset.php.

References ilOperatorsExpressionMapping\getOperatorsByExpression().

885  : array
886  {
888  }
+ Here is the call graph for this function:

◆ getQuestionType()

assTextSubset::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

Definition at line 694 of file class.assTextSubset.php.

Referenced by toJSON().

694  : string
695  {
696  return "assTextSubset";
697  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assTextSubset::getRTETextWithMediaObjects ( )

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

Definition at line 763 of file class.assTextSubset.php.

763  : string
764  {
765  return parent::getRTETextWithMediaObjects();
766  }

◆ getSolutionSubmit()

assTextSubset::getSolutionSubmit ( )
protected
Returns
array

Definition at line 835 of file class.assTextSubset.php.

References Vendor\Package\$a, $post, assQuestion\extendedTrim(), getAnswers(), and assQuestion\getHtmlUserSolutionPurifier().

Referenced by saveWorkingData().

835  : array
836  {
837  $purifier = $this->getHtmlUserSolutionPurifier();
838  $post = $this->dic->http()->wrapper()->post();
839 
840  $solutionSubmit = [];
841  foreach ($this->getAnswers() as $index => $a) {
842  if ($post->has("TEXTSUBSET_$index")) {
843  $value = $post->retrieve(
844  "TEXTSUBSET_$index",
845  $this->dic->refinery()->kindlyTo()->string()
846  );
847  if ($value) {
848  $value = $this->extendedTrim($value);
849  $value = $purifier->purify($value);
850  $solutionSubmit[] = $value;
851  }
852  }
853  }
854 
855  return $solutionSubmit;
856  }
static extendedTrim(string $value)
Trim non-printable characters from the beginning and end of a string.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$post
Definition: ltitoken.php:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextRating()

assTextSubset::getTextRating ( )

Returns the rating option for text comparisons.

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

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

References $text_rating.

Referenced by isAnswerCorrect(), saveWorkingData(), and toJSON().

498  : string
499  {
500  return $this->text_rating;
501  }
+ Here is the caller graph for this function:

◆ isAddableAnswerOptionValue()

assTextSubset::isAddableAnswerOptionValue ( int  $qIndex,
string  $answerOptionValue 
)

Definition at line 963 of file class.assTextSubset.php.

References getAnswers().

963  : bool
964  {
965  $found = false;
966 
967  foreach ($this->getAnswers() as $item) {
968  if ($answerOptionValue !== $item->getAnswerText()) {
969  continue;
970  }
971 
972  $found = true;
973  break;
974  }
975 
976  return !$found;
977  }
+ Here is the call graph for this function:

◆ isAnswerCorrect()

assTextSubset::isAnswerCorrect (   $answers,
  $answer 
)

Returns the index of the found answer, if the given answer is in the set of correct answers and matchess the matching options, otherwise FALSE is returned.

Parameters
array$answersAn array containing the correct answers
string$answerThe text of the given answer
Returns
mixed The index of the correct answer, FALSE otherwise public

Definition at line 444 of file class.assTextSubset.php.

References $answers, $DIC, ILIAS\LTI\ToolProvider\$key, assQuestion\$refinery, assQuestion\getPoints(), getTextRating(), 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().

445  {
446  global $DIC;
447  $refinery = $DIC->refinery();
448  $textrating = $this->getTextRating();
449 
450  foreach ($answers as $key => $value) {
451  if ($this->answers[$key]->getPoints() <= 0) {
452  continue;
453  }
454  $value = html_entity_decode($value); #SB
455  switch ($textrating) {
457  if (strcmp(ilStr::strToLower($value), ilStr::strToLower($answer)) == 0) { #SB
458  return $key;
459  }
460  break;
462  if (strcmp($value, $answer) == 0) {
463  return $key;
464  }
465  break;
467  $transformation = $refinery->string()->levenshtein()->standard($answer, 1);
468  break;
470  $transformation = $refinery->string()->levenshtein()->standard($answer, 2);
471  break;
473  $transformation = $refinery->string()->levenshtein()->standard($answer, 3);
474  break;
476  $transformation = $refinery->string()->levenshtein()->standard($answer, 4);
477  break;
479  $transformation = $refinery->string()->levenshtein()->standard($answer, 5);
480  break;
481  }
482 
483  // run answers against Levenshtein2 methods
484  if (isset($transformation) && $transformation->transform($value) >= 0) {
485  return $key;
486  }
487  }
488  return false;
489  }
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
getTextRating()
Returns the rating option for text comparisons.
global $DIC
Definition: feed.php:28
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
string $key
Consumer key/client ID value.
Definition: System.php:193
const TEXTGAP_RATING_LEVENSHTEIN4
static strToLower(string $a_string)
Definition: class.ilStr.php:72
ILIAS Refinery Factory $refinery
const TEXTGAP_RATING_CASEINSENSITIVE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isComplete()

assTextSubset::isComplete ( )

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

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

Definition at line 88 of file class.assTextSubset.php.

References getMaximumPoints().

88  : bool
89  {
90  if (
91  strlen($this->title)
92  && $this->author
93  && $this->question &&
94  count($this->answers) >= $this->correctanswers
95  && $this->getMaximumPoints() > 0
96  ) {
97  return true;
98  }
99  return false;
100  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ joinAnswers()

& assTextSubset::joinAnswers ( )

Returns the answers of the question as a comma separated string.

Definition at line 703 of file class.assTextSubset.php.

References ILIAS\LTI\ToolProvider\$key.

703  : array
704  {
705  $join = [];
706  foreach ($this->answers as $answer) {
707  $key = $answer->getPoints() . '';
708 
709  if (!isset($join[$key]) || !is_array($join[$key])) {
710  $join[$key] = [];
711  }
712 
713  $join[$key][] = $answer->getAnswertext();
714  }
715 
716  return $join;
717  }
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ loadFromDb()

assTextSubset::loadFromDb (   $question_id)

Loads a assTextSubset object from a database.

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

Definition at line 129 of file class.assTextSubset.php.

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

129  : void
130  {
131  global $DIC;
132  $ilDB = $DIC['ilDB'];
133 
134  $result = $ilDB->queryF(
135  "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",
136  array("integer"),
137  array($question_id)
138  );
139  if ($result->numRows() == 1) {
140  $data = $ilDB->fetchAssoc($result);
141  $this->setId($question_id);
142  $this->setObjId($data["obj_fi"]);
143  $this->setNrOfTries($data['nr_of_tries']);
144  $this->setTitle((string) $data["title"]);
145  $this->setComment((string) $data["description"]);
146  $this->setOriginalId($data["original_id"]);
147  $this->setAuthor($data["author"]);
148  $this->setPoints($data["points"]);
149  $this->setOwner($data["owner"]);
150  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
151  $this->setCorrectAnswers((int) $data["correctanswers"]);
152  $this->setTextRating($data["textgap_rating"]);
153 
154  try {
158  }
159 
160  try {
161  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
162  } catch (ilTestQuestionPoolException $e) {
163  }
164  }
165 
166 
167  $result = $ilDB->queryF(
168  "SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC",
169  array('integer'),
170  array($question_id)
171  );
172  if ($result->numRows() > 0) {
173  while ($data = $ilDB->fetchAssoc($result)) {
174  $this->answers[] = new ASS_AnswerBinaryStateImage($data["answertext"], $data["points"], $data["aorder"]);
175  }
176  }
177 
178  parent::loadFromDb($question_id);
179  }
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)
setCorrectAnswers(int $a_correct_answers)
Sets the number of correct answers needed to solve the question.
Class for answers with a binary state indicator.
setOwner(int $owner=-1)
setTextRating($a_text_rating)
Sets the rating option for text comparisons.
setComment(string $comment="")
global $DIC
Definition: feed.php:28
getAdditionalTableName()
Returns the name of the additional question data table in the database.
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:

◆ saveToDb()

assTextSubset::saveToDb (   $original_id = "")

Saves a assTextSubset object to a database.

Parameters
string$original_id

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

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

108  : void
109  {
110  if ($original_id == "") {
111  $this->saveQuestionDataToDb();
112  } else {
114  }
115 
118 
119  parent::saveToDb();
120  }
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()

assTextSubset::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 591 of file class.assTextSubset.php.

References $DIC, $ilDB, ILIAS\LTI\ToolProvider\$key, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), getAdditionalTableName(), getCorrectAnswers(), assQuestion\getId(), assQuestion\getProcessLocker(), getSolutionSubmit(), getTextRating(), ILIAS\Repository\lng(), assQuestion\logAction(), assQuestion\removeCurrentSolution(), ilObjQuestionScoringAdjustable\saveAdditionalQuestionDataToDb(), ilObjAnswerScoringAdjustable\saveAnswerSpecificDataToDb(), and assQuestion\saveCurrentSolution().

591  : bool
592  {
593  global $DIC;
594  $ilDB = $DIC['ilDB'];
595  $ilUser = $DIC['ilUser'];
596 
597  if (is_null($pass)) {
598  $pass = ilObjTest::_getPass($active_id);
599  }
600 
601  $entered_values = 0;
602  $solutionSubmit = $this->getSolutionSubmit();
603 
604  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $solutionSubmit, $active_id, $pass, $authorized) {
605  $this->removeCurrentSolution($active_id, $pass, $authorized);
606 
607  foreach ($solutionSubmit as $value) {
608  if (strlen($value)) {
609  $this->saveCurrentSolution($active_id, $pass, $value, null, $authorized);
610  $entered_values++;
611  }
612  }
613  });
614 
615  if ($entered_values) {
617  assQuestion::logAction($this->lng->txtlng(
618  "assessment",
619  "log_user_entered_values",
621  ), $active_id, $this->getId());
622  }
624  assQuestion::logAction($this->lng->txtlng(
625  "assessment",
626  "log_user_not_entered_values",
628  ), $active_id, $this->getId());
629  }
630 
631  return true;
632  }
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:

◆ setCorrectAnswers()

assTextSubset::setCorrectAnswers ( int  $a_correct_answers)

Sets the number of correct answers needed to solve the question.

Parameters
integer$a_correct_anwersThe number of correct answers public

Definition at line 567 of file class.assTextSubset.php.

Referenced by loadFromDb().

567  : void
568  {
569  $this->correctanswers = $a_correct_answers;
570  }
+ Here is the caller graph for this function:

◆ setExportDetailsXLSX()

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

{}

Definition at line 771 of file class.assTextSubset.php.

References assQuestion\getSolutionValues(), and ilAssExcelFormatHelper\setCell().

771  : int
772  {
773  parent::setExportDetailsXLSX($worksheet, $startrow, $col, $active_id, $pass);
774 
775  $solutions = $this->getSolutionValues($active_id, $pass);
776 
777  $i = 1;
778  foreach ($solutions as $solution) {
779  $worksheet->setCell($startrow + $i, $col + 2, $solution["value1"]);
780  $i++;
781  }
782 
783  return $startrow + $i + 1;
784  }
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
setCell($a_row, $a_col, $a_value, $datatype=null)
+ Here is the call graph for this function:

◆ setTextRating()

assTextSubset::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 510 of file class.assTextSubset.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().

510  : void
511  {
512  switch ($a_text_rating) {
520  $this->text_rating = $a_text_rating;
521  break;
522  default:
523  $this->text_rating = TEXTGAP_RATING_CASEINSENSITIVE;
524  break;
525  }
526  }
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:

◆ toJSON()

assTextSubset::toJSON ( )

Returns a JSON representation of the question.

Implements ilAssQuestionLMExportable.

Definition at line 794 of file class.assTextSubset.php.

References $answers, ILIAS\LTI\ToolProvider\$key, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getAnswers(), getCorrectAnswers(), assQuestion\getId(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), getTextRating(), assQuestion\getTitleForHTMLOutput(), and ILIAS\Repository\int().

794  : string
795  {
796  $result = array();
797  $result['id'] = $this->getId();
798  $result['type'] = (string) $this->getQuestionType();
799  $result['title'] = $this->getTitleForHTMLOutput();
800  $result['question'] = $this->formatSAQuestion($this->getQuestion());
801  $result['nr_of_tries'] = $this->getNrOfTries();
802  $result['matching_method'] = $this->getTextRating();
803  $result['feedback'] = array(
804  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
805  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
806  );
807 
808  $answers = array();
809  foreach ($this->getAnswers() as $key => $answer_obj) {
810  $answers[] = array(
811  "answertext" => (string) $answer_obj->getAnswertext(),
812  "points" => (float) $answer_obj->getPoints(),
813  "order" => (int) $answer_obj->getOrder()
814  );
815  }
816  $result['correct_answers'] = $answers;
817 
818  $answers = array();
819  for ($loop = 1; $loop <= $this->getCorrectAnswers(); $loop++) {
820  $answers[] = array(
821  "answernr" => $loop
822  );
823  }
824  $result['answers'] = $answers;
825 
826  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
827  $result['mobs'] = $mobs;
828 
829  return json_encode($result);
830  }
getCorrectAnswers()
Returns the number of correct answers needed to solve the question.
getTextRating()
Returns the rating option for text comparisons.
getQuestionType()
Returns the question type of the question.
string $key
Consumer key/client ID value.
Definition: System.php:193
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
+ Here is the call graph for this function:

Field Documentation

◆ $answers

assTextSubset::$answers

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

Referenced by getAnswers(), isAnswerCorrect(), and toJSON().

◆ $correctanswers

assTextSubset::$correctanswers

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

Referenced by getCorrectAnswers().

◆ $text_rating

assTextSubset::$text_rating

Definition at line 57 of file class.assTextSubset.php.

Referenced by getTextRating().


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