ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
assQuestion Class Reference
+ Inheritance diagram for assQuestion:
+ Collaboration diagram for assQuestion:

Public Member Functions

 getQuestionType ()
 
 isComplete ()
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 getCurrentUser ()
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML (string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping, array $solutionhints=[])
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 setShuffle (?bool $shuffle=true)
 
 setAuthor (string $author="")
 
 setOwner (int $owner=-1)
 
 getTitle ()
 
 getTitleForHTMLOutput ()
 
 getTitleFilenameCompliant ()
 
 getId ()
 
 getShuffle ()
 
 getTestId ()
 
 getComment ()
 
 getDescriptionForHTMLOutput ()
 
 getThumbSize ()
 
 setThumbSize (int $a_size)
 
 getMinimumThumbSize ()
 
 getMaximumThumbSize ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorized_solution=true)
 
 calculateResultsFromSolution (int $active_id, int $pass)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $preview_session)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 getSuggestedSolutionPath ()
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 getSuggestedSolutionPathWeb ()
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getTestOutputSolutions (int $activeId, int $pass)
 
 getUserSolutionPreferingIntermediate (int $active_id, ?int $pass=null)
 
 getSolutionValues (int $active_id, ?int $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 cloneXHTMLMediaObjectsOfQuestion (int $source_question_id)
 
 createPageObject ()
 
 clonePageOfQuestion (int $a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
static fixSvgToPng (string $imageFilenameContainingString)
 
 fixUnavailableSkinImageSources (string $html)
 
 loadFromDb (int $question_id)
 
 createNewQuestion (bool $a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb (?int $original_id=null)
 
 duplicate (bool $for_test=true, string $title='', string $author='', int $owner=-1, $test_obj_id=null)
 
 copyObject (int $target_parent_id, string $title='')
 
 createNewOriginalFromThisDuplicate (int $target_parent_id, string $target_question_title='')
 
 saveToDb (?int $original_id=null)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 
 resolveInternalLink (string $internal_link)
 
 resolveSuggestedSolutionLinks ()
 
 getInternalLinkHref (string $target)
 
 syncWithOriginal ()
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 isWriteable ()
 
 deductHintPointsFromReachedPoints (ilAssQuestionPreviewSession $preview_session, $reached_points)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $preview_session)
 
 adjustReachedPointsByScoringOptions (float $points, int $active_id)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionTypeID ()
 
 cloneHints (int $source_question_id, int $target_question_id)
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 getNrOfTries ()
 
 setNrOfTries (int $a_nr_of_tries)
 
 setExportImagePath (string $path)
 
 formatSAQuestion ($a_q)
 
 setPreventRteUsage (bool $prevent_rte_usage)
 
 getPreventRteUsage ()
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode (bool $selfassessmenteditingmode)
 
 getSelfAssessmentEditingMode ()
 
 setDefaultNrOfTries (int $defaultnroftries)
 
 getDefaultNrOfTries ()
 
 syncSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 ensureHintPageObjectExists ($pageObjectId)
 
 isAnswered (int $active_id, int $pass)
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange (int $lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 removeCurrentSolution (int $active_id, int $pass, bool $authorized=true)
 
 saveCurrentSolution (int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
 updateCurrentSolution (int $solutionId, $value1, $value2, bool $authorized=true)
 
 updateCurrentSolutionsAuthorization (int $activeId, int $pass, bool $authorized, bool $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 intermediateSolutionExists (int $active_id, int $pass)
 
 authorizedSolutionExists (int $active_id, ?int $pass)
 
 authorizedOrIntermediateSolutionExists (int $active_id, int $pass)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions (int $activeId, int $pass)
 
 resetUsersAnswer (int $activeId, int $pass)
 
 removeResultRecord (int $activeId, int $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $value_pairs)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
 hasWritableOriginalInQuestionPool ()
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 getSolutionForTextOutput (int $active_id, int $pass)
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
 getVariablesAsTextArray (int $active_id, int $pass)
 

Static Public Member Functions

static setForcePassResultUpdateEnabled (bool $force_pass_results_update_enabled)
 
static isForcePassResultUpdateEnabled ()
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static isFileAvailable (string $file)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static _setReachedPoints (int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $question_id)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
static extendedTrim (string $value)
 Trim non-printable characters from the beginning and end of a string. More...
 

Data Fields

const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
const TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
ilAssQuestionFeedback $feedbackOBJ
 
bool $prevent_rte_usage = false
 
bool $selfassessmenteditingmode = false
 
int $defaultnroftries = 0
 
string $questionActionCmd = 'handleQuestionAction'
 
const KEY_VALUES_IMPLOSION_SEPARATOR = ':'
 

Protected Member Functions

 solutionValuesToLog (AdditionalInformationGenerator $additional_info, array $solution_values)
 MUST convert the given solution values into an array or a string that can be stored in the log. More...
 
 solutionValuesToText (array $solution_values)
 MUST convert the given solution values into text. More...
 
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $post_submission_field_name)
 
 savePreviewData (ilAssQuestionPreviewSession $preview_session)
 
 deletePageOfQuestion (int $question_id)
 
 cloneQuestionTypeSpecificProperties (self $target)
 
 removeAllImageFiles (string $image_target_path)
 
 onDuplicate (int $original_parent_id, int $original_question_id, int $duplicate_parent_id, int $duplicate_question_id)
 
 afterSyncWithOriginal (int $original_question_id, int $clone_question_id, int $original_parent_id, int $clone_parent_id)
 
 onCopy (int $sourceParentId, int $sourceQuestionId, int $targetParentId, int $targetQuestionId)
 
 duplicateComments (int $parent_source_id, int $source_id, int $parent_target_id, int $target_id)
 
 deleteComments ()
 
 getNotesManager ()
 
 getNotesDataService ()
 
 getNotesRepo ()
 
 cloneSuggestedSolutions (int $source_question_id, int $target_question_id)
 
 duplicateSuggestedSolutionFiles (int $parent_id, int $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 cloneSuggestedSolutionFiles (int $source_question_id, int $target_question_id)
 
 copySuggestedSolutions (int $target_question_id)
 
 ensureNonNegativePoints (float $points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints (int $original_question_id, int $duplicate_question_id)
 
 duplicateSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet (int $active_id, int $pass, bool $authorized=true)
 
 removeSolutionRecordById (int $solutionId)
 
 getSolutionRecordById (int $solutionId)
 
 deleteDummySolutionRecord (int $activeId, int $passIndex)
 
 isDummySolutionRecord (array $solutionRecord)
 
 deleteSolutionRecordByValues (int $activeId, int $passIndex, bool $authorized, array $matchValues)
 
 duplicateIntermediateSolutionAuthorized (int $activeId, int $passIndex)
 
 forceExistingIntermediateSolution (int $activeId, int $passIndex, bool $considerDummyRecordCreation)
 
 lookupMaxStep (int $active_id, int $pass)
 
 buildTestPresentationConfig ()
 
 getSuggestedSolutionsRepo ()
 
 loadSuggestedSolutions ()
 
 answerToLog (AdditionalInformationGenerator $additional_info, int $active_id, int $pass)
 

Static Protected Member Functions

static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 

Protected Attributes

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

Static Protected Attributes

static $force_pass_results_update_enabled = false
 
static $imageSourceFixReplaceMap
 

Private Member Functions

 importHint (int $question_id, array $hint_array)
 
 deleteTaxonomyAssignments ()
 

Private Attributes

const DEFAULT_THUMB_SIZE = 150
 
const MINIMUM_THUMB_SIZE = 20
 
const MAXIMUM_THUMB_SIZE = 8192
 
ilTestQuestionConfig $test_question_config = null
 
int $nr_of_tries
 
string $export_image_path
 
string $additionalContentEditingMode = ''
 

Detailed Description

Member Function Documentation

◆ _getReachedPoints()

static assQuestion::_getReachedPoints ( int  $active_id,
int  $question_id,
int  $pass 
)
static

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

References $DIC, $ilDB, and $points.

Referenced by ILIAS\Test\Scoring\Manual\TestScoringByParticipantGUI\buildManScoringParticipantForm(), and ILIAS\Test\Scoring\Manual\TestScoringByParticipantGUI\saveManScoringParticipantScreen().

533  : float
534  {
535  global $DIC;
536  $ilDB = $DIC['ilDB'];
537 
538  $points = 0.0;
539 
540  $result = $ilDB->queryF(
541  "SELECT * FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
542  ['integer','integer','integer'],
543  [$active_id, $question_id, $pass]
544  );
545  if ($result->numRows() == 1) {
546  $row = $ilDB->fetchAssoc($result);
547  $points = (float) $row["points"];
548  }
549  return $points;
550  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ _getSolutionMaxPass()

static assQuestion::_getSolutionMaxPass ( int  $question_id,
int  $active_id 
)
static

Returns the maximum pass a users question solution.

Definition at line 1812 of file class.assQuestion.php.

References $DIC, $ilDB, and null.

Referenced by _setReachedPoints(), and ilObjTest\getTextAnswer().

1812  : ?int
1813  {
1814  // the following code was the old solution which added the non answered
1815  // questions of a pass from the answered questions of the previous pass
1816  // with the above solution, only the answered questions of the last pass are counted
1817  global $DIC;
1818  $ilDB = $DIC['ilDB'];
1819 
1820  $result = $ilDB->queryF(
1821  "SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
1822  ['integer','integer'],
1823  [$active_id, $question_id]
1824  );
1825  if ($result->numRows() === 1) {
1826  $row = $ilDB->fetchAssoc($result);
1827  return $row["maxpass"];
1828  }
1829 
1830  return null;
1831  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ _getSuggestedSolutionOutput()

static assQuestion::_getSuggestedSolutionOutput ( int  $question_id)
static

Definition at line 478 of file class.assQuestion.php.

Referenced by ILIAS\Test\Scoring\Manual\TestScoringByQuestionGUI\buildFeedbackModal(), and ilObjTest\getTestResult().

478  : string
479  {
480  $question = self::instantiateQuestion($question_id);
481  if (!is_object($question)) {
482  return "";
483  }
484  return $question->getSuggestedSolutionOutput();
485  }
+ Here is the caller graph for this function:

◆ _questionExistsInTest()

static assQuestion::_questionExistsInTest ( int  $question_id,
int  $test_id 
)
static

Definition at line 2211 of file class.assQuestion.php.

References $DIC, and $ilDB.

2211  : bool
2212  {
2213  global $DIC;
2214  $ilDB = $DIC['ilDB'];
2215 
2216  if ($question_id < 1) {
2217  return false;
2218  }
2219 
2220  $result = $ilDB->queryF(
2221  "SELECT question_fi FROM tst_test_question WHERE question_fi = %s AND test_fi = %s",
2222  ['integer', 'integer'],
2223  [$question_id, $test_id]
2224  );
2225  return $ilDB->numRows($result) == 1;
2226  }
global $DIC
Definition: shib_login.php:22

◆ _setReachedPoints()

static assQuestion::_setReachedPoints ( int  $active_id,
int  $question_id,
float  $points,
float  $maxpoints,
int  $pass,
bool  $manualscoring 
)
static

Sets the points, a learner has reached answering the question Additionally objective results are updated.

Parameters
integer$user_idThe database ID of the learner
integer$test_idThe database Id of the test containing the question
integer$pointsThe points the user has reached answering the question
Returns
boolean true on success, otherwise false public

Definition at line 1919 of file class.assQuestion.php.

References $DIC, $ilDB, _getSolutionMaxPass(), ilObjTest\_getUserIdFromActiveId(), ilObjTest\_lookupTestObjIdForQuestionId(), ilCourseObjectiveResult\_updateObjectiveResult(), and null.

Referenced by ILIAS\Test\Scoring\Manual\TestScoringByQuestionGUI\saveManScoringByQuestion(), and ILIAS\Test\Scoring\Manual\TestScoringByParticipantGUI\saveManScoringParticipantScreen().

1926  : void {
1927  global $DIC;
1928  $ilDB = $DIC['ilDB'];
1929 
1930  if ($points > $maxpoints) {
1931  return;
1932  }
1933 
1934  if ($pass === null) {
1935  $pass = assQuestion::_getSolutionMaxPass($question_id, $active_id);
1936  }
1937 
1938  $old_points = 0;
1939  $result = $ilDB->queryF(
1940  "SELECT points FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
1941  ['integer','integer','integer'],
1942  [$active_id, $question_id, $pass]
1943  );
1944  $manual = ($manualscoring) ? 1 : 0;
1945  $rowsnum = $result->numRows();
1946  if ($rowsnum > 0) {
1947  $row = $ilDB->fetchAssoc($result);
1948  $old_points = $row['points'];
1949  if ($old_points !== $points) {
1950  $affectedRows = $ilDB->manipulateF(
1951  "UPDATE tst_test_result SET points = %s, manual = %s, tstamp = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
1952  ['float', 'integer', 'integer', 'integer', 'integer', 'integer'],
1953  [$points, $manual, time(), $active_id, $question_id, $pass]
1954  );
1955  }
1956  } else {
1957  $next_id = $ilDB->nextId('tst_test_result');
1958  $affectedRows = $ilDB->manipulateF(
1959  "INSERT INTO tst_test_result (test_result_id, active_fi, question_fi, points, pass, manual, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
1960  ['integer', 'integer','integer', 'float', 'integer', 'integer','integer'],
1961  [$next_id, $active_id, $question_id, $points, $pass, $manual, time()]
1962  );
1963  }
1964 
1965  if (!self::isForcePassResultUpdateEnabled() && $old_points === $points && $rowsnum !== 0) {
1966  return;
1967  }
1968 
1970  if ($test_id === null) {
1971  return;
1972  }
1973  $test = new ilObjTest(
1974  $test_id,
1975  false
1976  );
1977  $test->updateTestPassResults($active_id, $pass);
1979  }
static _lookupTestObjIdForQuestionId(int $q_id)
Get test Object ID for question ID.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getUserIdFromActiveId(int $active_id)
static _getSolutionMaxPass(int $question_id, int $active_id)
Returns the maximum pass a users question solution.
global $DIC
Definition: shib_login.php:22
static _updateObjectiveResult(int $a_user_id, int $a_active_id, int $a_question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addAnswerOptionValue()

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

Definition at line 2866 of file class.assQuestion.php.

2866  : void
2867  {
2868  }

◆ adjustReachedPointsByScoringOptions()

assQuestion::adjustReachedPointsByScoringOptions ( float  $points,
int  $active_id 
)
final

Adjust the given reached points by checks for all special scoring options in the test container.

public

Parameters
integer$points
integer$active_id
integer$pass

Definition at line 1878 of file class.assQuestion.php.

References $points, ilObjTest\_getCountSystem(), ilObjTest\_getScoreCutting(), and getMaximumPoints().

Referenced by calculateResultsFromSolution(), and getAdjustedReachedPoints().

1878  : float
1879  {
1880  $count_system = ilObjTest::_getCountSystem($active_id);
1881  if ($count_system == 1) {
1882  if (abs($this->getMaximumPoints() - $points) > 0.0000000001) {
1883  $points = 0;
1884  }
1885  }
1886  $score_cutting = ilObjTest::_getScoreCutting($active_id);
1887  if ($score_cutting == 0) {
1888  if ($points < 0) {
1889  $points = 0;
1890  }
1891  }
1892  return $points;
1893  }
static _getCountSystem($active_id)
static _getScoreCutting(int $active_id)
Determines if the score of a question should be cut at 0 points or the score of the whole test...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ afterSyncWithOriginal()

assQuestion::afterSyncWithOriginal ( int  $original_question_id,
int  $clone_question_id,
int  $original_parent_id,
int  $clone_parent_id 
)
protected

Definition at line 1454 of file class.assQuestion.php.

Referenced by syncWithOriginal().

1459  : void {
1460  $this->feedbackOBJ->cloneFeedback($original_question_id, $clone_question_id);
1461  }
+ Here is the caller graph for this function:

◆ answerToLog()

assQuestion::answerToLog ( AdditionalInformationGenerator  $additional_info,
int  $active_id,
int  $pass 
)
protected

Definition at line 3049 of file class.assQuestion.php.

References getReachedPoints(), getSolutionValues(), and solutionValuesToLog().

Referenced by answerToParticipantInteraction().

3053  : array {
3054  return [
3055  AdditionalInformationGenerator::KEY_PASS => $pass,
3056  AdditionalInformationGenerator::KEY_REACHED_POINTS => $this->getReachedPoints($active_id, $pass),
3057  AdditionalInformationGenerator::KEY_PAX_ANSWER => $this->solutionValuesToLog(
3058  $additional_info,
3059  $this->getSolutionValues($active_id, $pass)
3060  )
3061  ];
3062  }
getSolutionValues(int $active_id, ?int $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
solutionValuesToLog(AdditionalInformationGenerator $additional_info, array $solution_values)
MUST convert the given solution values into an array or a string that can be stored in the log...
getReachedPoints(int $active_id, int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ answerToParticipantInteraction()

assQuestion::answerToParticipantInteraction ( AdditionalInformationGenerator  $additional_info,
int  $test_ref_id,
int  $active_id,
int  $pass,
string  $source_ip,
TestParticipantInteractionTypes  $interaction_type 
)

Implements ILIAS\TestQuestionPool\Questions\Question.

Definition at line 3015 of file class.assQuestion.php.

References answerToLog().

Referenced by ilTestPlayerAbstractGUI\save().

3023  return new TestParticipantInteraction(
3024  $test_ref_id,
3025  $this->id,
3026  $this->current_user->getId(),
3027  $source_ip,
3028  $interaction_type,
3029  time(),
3030  $this->answerToLog($additional_info, $active_id, $pass)
3031  );
3032  }
answerToLog(AdditionalInformationGenerator $additional_info, int $active_id, int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ authorizedOrIntermediateSolutionExists()

assQuestion::authorizedOrIntermediateSolutionExists ( int  $active_id,
int  $pass 
)

Definition at line 2800 of file class.assQuestion.php.

References lookupForExistingSolutions().

2800  : bool
2801  {
2802  $solutionAvailability = $this->lookupForExistingSolutions($active_id, $pass);
2803  return $solutionAvailability['authorized'] || $solutionAvailability['intermediate'];
2804  }
lookupForExistingSolutions(int $activeId, int $pass)
Lookup if an authorized or intermediate solution exists.
+ Here is the call graph for this function:

◆ authorizedSolutionExists()

assQuestion::authorizedSolutionExists ( int  $active_id,
?int  $pass 
)

Definition at line 2791 of file class.assQuestion.php.

References lookupForExistingSolutions(), and null.

2791  : bool
2792  {
2793  if ($pass === null) {
2794  return false;
2795  }
2796  $solutionAvailability = $this->lookupForExistingSolutions($active_id, $pass);
2797  return (bool) $solutionAvailability['authorized'];
2798  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
lookupForExistingSolutions(int $activeId, int $pass)
Lookup if an authorized or intermediate solution exists.
+ Here is the call graph for this function:

◆ buildHashedImageFilename()

assQuestion::buildHashedImageFilename ( string  $plain_image_filename,
bool  $unique = false 
)

Definition at line 1894 of file class.assQuestion.php.

Referenced by assKprimChoice\handleFileUpload(), assMatchingQuestion\rebuildThumbnails(), assOrderingQuestion\storeImageFile(), and assOrderingQuestion\updateImageFile().

1894  : string
1895  {
1896  $extension = "";
1897 
1898  if (preg_match("/.*\.(png|jpg|gif|jpeg)$/i", $plain_image_filename, $matches)) {
1899  $extension = "." . $matches[1];
1900  }
1901 
1902  if ($unique) {
1903  $plain_image_filename = uniqid($plain_image_filename . microtime(true), true);
1904  }
1905 
1906  return md5($plain_image_filename) . $extension;
1907  }
+ Here is the caller graph for this function:

◆ buildQuestionDataQuery()

assQuestion::buildQuestionDataQuery ( )
protected

Definition at line 2461 of file class.assQuestion.php.

Referenced by assKprimChoice\loadFromDb().

2461  : string
2462  {
2463  return "
2464  SELECT qpl_questions.*,
2465  {$this->getAdditionalTableName()}.*
2466  FROM qpl_questions
2467  LEFT JOIN {$this->getAdditionalTableName()}
2468  ON {$this->getAdditionalTableName()}.question_fi = qpl_questions.question_id
2469  WHERE qpl_questions.question_id = %s
2470  ";
2471  }
+ Here is the caller graph for this function:

◆ buildTestPresentationConfig()

assQuestion::buildTestPresentationConfig ( )
protected

Definition at line 2973 of file class.assQuestion.php.

Referenced by getTestPresentationConfig().

2974  {
2975  return new ilTestQuestionConfig();
2976  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ calculateReachedPoints()

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

Referenced by calculateResultsFromSolution(), and getAdjustedReachedPoints().

+ Here is the caller graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assQuestion::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $preview_session)

Definition at line 1845 of file class.assQuestion.php.

References deductHintPointsFromReachedPoints(), ensureNonNegativePoints(), and ilAssQuestionPreviewSession\getParticipantsSolution().

Referenced by isPreviewSolutionCorrect().

1846  {
1847  $reached_points = $this->deductHintPointsFromReachedPoints(
1848  $preview_session,
1849  $this->calculateReachedPointsForSolution($preview_session->getParticipantsSolution())
1850  );
1851 
1852  return $this->ensureNonNegativePoints($reached_points);
1853  }
ensureNonNegativePoints(float $points)
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $preview_session, $reached_points)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateResultsFromSolution()

assQuestion::calculateResultsFromSolution ( int  $active_id,
int  $pass 
)
final

Calculates the question results from a previously saved question solution.

Definition at line 579 of file class.assQuestion.php.

References ilCourseObjectiveResult\_updateObjectiveResult(), adjustReachedPointsByScoringOptions(), calculateReachedPoints(), getId(), getObjId(), getProcessLocker(), getStep(), lookupForExistingSolutions(), and null.

Referenced by persistWorkingState().

579  : void
580  {
581  // determine reached points for submitted solution
582  $reached_points = $this->calculateReachedPoints($active_id, $pass);
583  $questionHintTracking = new ilAssQuestionHintTracking($this->getId(), $active_id, $pass);
584  $requests_statistic_data = $questionHintTracking->getRequestStatisticDataByQuestionAndTestpass();
585  $reached_points = $reached_points - $requests_statistic_data->getRequestsPoints();
586 
587  // adjust reached points regarding to tests scoring options
588  $reached_points = $this->adjustReachedPointsByScoringOptions($reached_points, $active_id);
589 
590  if (is_null($reached_points)) {
591  $reached_points = 0.0;
592  }
593 
594  // fau: testNav - check for existing authorized solution to know if a result record should be written
595  $existing_solutions = $this->lookupForExistingSolutions($active_id, $pass);
596 
597  $this->getProcessLocker()->executeUserQuestionResultUpdateOperation(
598  function () use ($active_id, $pass, $reached_points, $requests_statistic_data, $existing_solutions) {
599  $query = "
600  DELETE FROM tst_test_result
601 
602  WHERE active_fi = %s
603  AND question_fi = %s
604  AND pass = %s
605  ";
606 
607  $types = ['integer', 'integer', 'integer'];
608  $values = [$active_id, $this->getId(), $pass];
609 
610  if ($this->getStep() !== null) {
611  $query .= "
612  AND step = %s
613  ";
614 
615  $types[] = 'integer';
616  $values[] = $this->getStep();
617  }
618  $this->db->manipulateF($query, $types, $values);
619 
620  if ($existing_solutions['authorized']) {
621  $next_id = $this->db->nextId("tst_test_result");
622  $fieldData = [
623  'test_result_id' => ['integer', $next_id],
624  'active_fi' => ['integer', $active_id],
625  'question_fi' => ['integer', $this->getId()],
626  'pass' => ['integer', $pass],
627  'points' => ['float', $reached_points],
628  'tstamp' => ['integer', time()],
629  'hint_count' => ['integer', $requests_statistic_data->getRequestsCount()],
630  'hint_points' => ['float', $requests_statistic_data->getRequestsPoints()],
631  'answered' => ['integer', true]
632  ];
633 
634  if ($this->getStep() !== null) {
635  $fieldData['step'] = ['integer', $this->getStep()];
636  }
637 
638  $this->db->insert('tst_test_result', $fieldData);
639  }
640  }
641  );
642 
643  // update test pass results
644  $test = new ilObjTest(
645  $this->getObjId(),
646  false
647  );
648  $test->updateTestPassResults($active_id, $pass, $this->getProcessLocker());
649  ilCourseObjectiveResult::_updateObjectiveResult($this->current_user->getId(), $active_id, $this->getId());
650  }
adjustReachedPointsByScoringOptions(float $points, int $active_id)
Adjust the given reached points by checks for all special scoring options in the test container...
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
lookupForExistingSolutions(int $activeId, int $pass)
Lookup if an authorized or intermediate solution exists.
static _updateObjectiveResult(int $a_user_id, int $a_active_id, int $a_question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cleanupMediaObjectUsage()

assQuestion::cleanupMediaObjectUsage ( )

Definition at line 2080 of file class.assQuestion.php.

References ilRTE\_cleanupMediaObjectUsage(), getId(), and getRTETextWithMediaObjects().

Referenced by saveToDb().

2080  : void
2081  {
2082  $combinedtext = $this->getRTETextWithMediaObjects();
2083  ilRTE::_cleanupMediaObjectUsage($combinedtext, "qpl:html", $this->getId());
2084  }
static _cleanupMediaObjectUsage(string $a_text, string $a_usage_type, int $a_usage_id)
Synchronises appearances of media objects in $a_text with media object usage table.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneHints()

assQuestion::cloneHints ( int  $source_question_id,
int  $target_question_id 
)

Definition at line 2024 of file class.assQuestion.php.

Referenced by syncWithOriginal().

2027  : void {
2028  // delete hints of the original
2029  $this->db->manipulateF(
2030  "DELETE FROM qpl_hints WHERE qht_question_fi = %s",
2031  ['integer'],
2032  [$target_question_id]
2033  );
2034 
2035  // get hints of the actual question
2036  $result = $this->db->queryF(
2037  "SELECT * FROM qpl_hints WHERE qht_question_fi = %s",
2038  ['integer'],
2039  [$source_question_id]
2040  );
2041 
2042  // save hints to the original
2043  if ($this->db->numRows($result) < 1) {
2044  return;
2045  }
2046 
2047  while ($row = $this->db->fetchAssoc($result)) {
2048  $next_id = $this->db->nextId('qpl_hints');
2049  $this->db->insert(
2050  'qpl_hints',
2051  [
2052  'qht_hint_id' => ['integer', $next_id],
2053  'qht_question_fi' => ['integer', $target_question_id],
2054  'qht_hint_index' => ['integer', $row["qht_hint_index"]],
2055  'qht_hint_points' => ['float', $row["qht_hint_points"]],
2056  'qht_hint_text' => ['text', $row["qht_hint_text"]],
2057  ]
2058  );
2059  }
2060  }
+ Here is the caller graph for this function:

◆ clonePageOfQuestion()

assQuestion::clonePageOfQuestion ( int  $a_q_id)

Definition at line 1063 of file class.assQuestion.php.

1063  : void
1064  {
1065  if ($a_q_id > 0) {
1066  $page = new ilAssQuestionPage($a_q_id);
1067  $page->buildDom();
1068  ilPCPlugged::handleCopiedPluggedContent($page, $page->getDomDoc());
1069  $xml = str_replace("il__qst_" . $a_q_id, "il__qst_" . $this->id, $page->getXMLFromDom());
1070  $this->page->setXMLContent($xml);
1071  $this->page->updateFromXML();
1072  }
1073  }
buildDom(bool $a_force=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDomDoc()
Get dom doc (DOMDocument)
ilAssQuestionPage $page
getXMLFromDom(bool $a_incl_head=false, bool $a_append_mobs=false, bool $a_append_bib=false, string $a_append_str="", bool $a_omit_pageobject_tag=false, int $style_id=0, bool $offline=false)
get xml content of page from dom (use this, if any changes are made to the document) ...

◆ cloneQuestionTypeSpecificProperties()

assQuestion::cloneQuestionTypeSpecificProperties ( self  $target)
protected

Definition at line 1367 of file class.assQuestion.php.

Referenced by copyObject(), createNewOriginalFromThisDuplicate(), duplicate(), and syncWithOriginal().

1369  : self {
1370  return $target;
1371  }
+ Here is the caller graph for this function:

◆ cloneSuggestedSolutionFiles()

assQuestion::cloneSuggestedSolutionFiles ( int  $source_question_id,
int  $target_question_id 
)
protected

Definition at line 1593 of file class.assQuestion.php.

References ilFileUtils\delDir(), getSuggestedSolutionPath(), and ilFileUtils\makeDirParents().

Referenced by cloneSuggestedSolutions(), and onDuplicate().

1596  : void {
1597  $filepath_target = $this->getSuggestedSolutionPath();
1598  $filepath_original = str_replace("/$target_question_id/solution", "/$source_question_id/solution", $filepath_target);
1599  ilFileUtils::delDir($filepath_original);
1600  foreach ($this->suggested_solutions as $solution) {
1601  if (!$solution->isOfTypeFile()
1602  || $solution->getFilename() === '') {
1603  continue;
1604  }
1605 
1606  if (!file_exists($filepath_original)) {
1607  ilFileUtils::makeDirParents($filepath_original);
1608  }
1609 
1610  if (!is_file($filepath_original . $solution->getFilename())
1611  || copy($filepath_target . $solution->getFilename(), $filepath_target . $solution->getFilename())) {
1612  $this->log->root()->error('File for suggested solutions could not be cloned:');
1613  $this->log->root()->error("Question-Id: {$this->id}; Question-Title: {$this->title}; File: {$filepath_original}{$solution->getFilename()}");
1614  }
1615  }
1616  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneSuggestedSolutions()

assQuestion::cloneSuggestedSolutions ( int  $source_question_id,
int  $target_question_id 
)
protected

Definition at line 1557 of file class.assQuestion.php.

References cloneSuggestedSolutionFiles(), and getSuggestedSolutionsRepo().

Referenced by syncWithOriginal().

1560  : void {
1561  $this->getSuggestedSolutionsRepo()->clone($source_question_id, $target_question_id);
1562  $this->cloneSuggestedSolutionFiles($source_question_id, $target_question_id);
1563  }
cloneSuggestedSolutionFiles(int $source_question_id, int $target_question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneXHTMLMediaObjectsOfQuestion()

assQuestion::cloneXHTMLMediaObjectsOfQuestion ( int  $source_question_id)

Definition at line 1043 of file class.assQuestion.php.

References ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_saveUsage(), and getId().

Referenced by syncWithOriginal().

1043  : void
1044  {
1045  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $source_question_id);
1046  foreach ($mobs as $mob) {
1047  ilObjMediaObject::_saveUsage($mob, "qpl:html", $this->getId());
1048  }
1049  }
static _saveUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Save usage of mob within another container (e.g.
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:
+ Here is the caller graph for this function:

◆ convertISO8601FormatH_i_s_ExtendedToSeconds()

static assQuestion::convertISO8601FormatH_i_s_ExtendedToSeconds ( string  $time)
static

Definition at line 2767 of file class.assQuestion.php.

References ILIAS\Repository\int().

2767  : int
2768  {
2769  $sec = 0;
2770  $time_array = explode(':', $time);
2771  if (count($time_array) == 3) {
2772  $sec += (int) $time_array[0] * 3600;
2773  $sec += (int) $time_array[1] * 60;
2774  $sec += (int) $time_array[2];
2775  }
2776  return $sec;
2777  }
+ Here is the call graph for this function:

◆ copyObject()

assQuestion::copyObject ( int  $target_parent_id,
string  $title = '' 
)
final

Definition at line 1310 of file class.assQuestion.php.

References cloneQuestionTypeSpecificProperties(), getId(), and getObjId().

1313  : int {
1314  if ($this->getId() <= 0) {
1315  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
1316  }
1317  // duplicate the question in database
1318  $clone = clone $this;
1319  $clone->id = -1;
1320  $source_parent_id = $this->getObjId();
1321  $clone->setObjId($target_parent_id);
1322  if ($title) {
1323  $clone->setTitle($title);
1324  }
1325  $clone->saveToDb();
1326  $clone->clonePageOfQuestion($this->id);
1327  $clone->cloneXHTMLMediaObjectsOfQuestion($this->id);
1328  $clone = $this->cloneQuestionTypeSpecificProperties($clone);
1329 
1330  $clone->onCopy($source_parent_id, $this->id, $clone->getObjId(), $clone->getId());
1331 
1332  return $clone->id;
1333  }
cloneQuestionTypeSpecificProperties(self $target)
+ Here is the call graph for this function:

◆ copySuggestedSolutions()

assQuestion::copySuggestedSolutions ( int  $target_question_id)
protected

Definition at line 1618 of file class.assQuestion.php.

References getSuggestedSolutions(), and getSuggestedSolutionsRepo().

Referenced by onCopy(), and onDuplicate().

1618  : void
1619  {
1620  $update = [];
1621  foreach ($this->getSuggestedSolutions() as $index => $solution) {
1622  $solution = $solution->withQuestionId($target_question_id);
1623  $update[] = $solution;
1624  }
1625  $this->getSuggestedSolutionsRepo()->update($update);
1626  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createNewOriginalFromThisDuplicate()

assQuestion::createNewOriginalFromThisDuplicate ( int  $target_parent_id,
string  $target_question_title = '' 
)
final

Definition at line 1335 of file class.assQuestion.php.

References $id, cloneQuestionTypeSpecificProperties(), getId(), and getObjId().

1338  : int {
1339  if ($this->getId() <= 0) {
1340  throw new RuntimeException('The question has not been saved. It cannot be duplicated');
1341  }
1342 
1343  $source_question_id = $this->id;
1344  $source_parent_id = $this->getObjId();
1345 
1346  // duplicate the question in database
1347  $clone = clone $this;
1348  $clone->id = -1;
1349 
1350  $clone->setObjId($target_parent_id);
1351 
1352  if ($target_question_title) {
1353  $clone->setTitle($target_question_title);
1354  }
1355 
1356  $clone->saveToDb();
1357  $clone->clonePageOfQuestion($source_question_id);
1358  $clone->cloneXHTMLMediaObjectsOfQuestion($source_question_id);
1359 
1360  $clone = $this->cloneQuestionTypeSpecificProperties($clone);
1361 
1362  $clone->onCopy($source_parent_id, $source_question_id, $clone->getObjId(), $clone->getId());
1363 
1364  return $clone->id;
1365  }
cloneQuestionTypeSpecificProperties(self $target)
+ Here is the call graph for this function:

◆ createNewQuestion()

assQuestion::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.

Returns
integer ID of the new question

Definition at line 1171 of file class.assQuestion.php.

References createPageObject(), getAdditionalContentEditingMode(), getAuthor(), getDefaultNrOfTries(), getExternalId(), getId(), getObjId(), getQuestionTypeID(), null, and setId().

1171  : int
1172  {
1173  $complete = '0';
1174  $obj_id = $this->getObjId();
1175  if ($obj_id <= 0
1176  && $this->questionpool_request->hasRefId()) {
1177  $obj_id = $this->questionpool_request->getRefId();
1178  }
1179 
1180  if ($obj_id <= 0) {
1181  $obj_id = $this->questionpool_request->int('sel_qpl');
1182  }
1183 
1184  if ($obj_id <= 0) {
1185  return $this->getId();
1186  }
1187 
1188  $tstamp = time();
1189  if ($a_create_page) {
1190  $tstamp = 0;
1191  }
1192 
1193  $next_id = $this->db->nextId('qpl_questions');
1194  $this->db->insert("qpl_questions", [
1195  "question_id" => ["integer", $next_id],
1196  "question_type_fi" => ["integer", $this->getQuestionTypeID()],
1197  "obj_fi" => ["integer", $obj_id],
1198  "title" => ["text", ''],
1199  "description" => ["text", ''],
1200  "author" => ["text", $this->getAuthor()],
1201  "owner" => ["integer", $this->current_user->getId()],
1202  "question_text" => ["clob", ''],
1203  "points" => ["float", "0.0"],
1204  "nr_of_tries" => ["integer", $this->getDefaultNrOfTries()], // #10771
1205  "complete" => ["text", $complete],
1206  "created" => ["integer", time()],
1207  "original_id" => ["integer", null],
1208  "tstamp" => ["integer", $tstamp],
1209  "external_id" => ["text", $this->getExternalId()],
1210  'add_cont_edit_mode' => ['text', $this->getAdditionalContentEditingMode()]
1211  ]);
1212  $this->setId($next_id);
1213 
1214  if ($a_create_page) {
1215  // create page object of question
1216  $this->createPageObject();
1217  }
1218 
1219  return $this->getId();
1220  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setId(int $id=-1)
+ Here is the call graph for this function:

◆ createPageObject()

assQuestion::createPageObject ( )

Definition at line 1051 of file class.assQuestion.php.

References getId(), and getObjId().

Referenced by createNewQuestion(), and saveQuestionDataToDb().

1051  : void
1052  {
1053  $qpl_id = $this->getObjId();
1054  $this->page = new ilAssQuestionPage(0);
1055  $this->page->setId($this->getId());
1056  $this->page->setParentId($qpl_id);
1057  $this->page->setXMLContent("<PageObject><PageContent>" .
1058  "<Question QRef=\"il__qst_" . $this->getId() . "\"/>" .
1059  "</PageContent></PageObject>");
1060  $this->page->create(false);
1061  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deductHintPointsFromReachedPoints()

assQuestion::deductHintPointsFromReachedPoints ( ilAssQuestionPreviewSession  $preview_session,
  $reached_points 
)

Definition at line 1838 of file class.assQuestion.php.

Referenced by assNumeric\calculateReachedPointsFromPreviewSession(), assErrorText\calculateReachedPointsFromPreviewSession(), assSingleChoice\calculateReachedPointsFromPreviewSession(), assOrderingQuestion\calculateReachedPointsFromPreviewSession(), assFormulaQuestion\calculateReachedPointsFromPreviewSession(), assClozeTest\calculateReachedPointsFromPreviewSession(), and calculateReachedPointsFromPreviewSession().

1838  : ?float
1839  {
1840  $hint_tracking = new ilAssQuestionPreviewHintTracking($this->db, $preview_session);
1841  $requests_statistic_data = $hint_tracking->getRequestStatisticData();
1842  return $reached_points - $requests_statistic_data->getRequestsPoints();
1843  }
+ Here is the caller graph for this function:

◆ delete()

assQuestion::delete ( int  $question_id)

Definition at line 877 of file class.assQuestion.php.

References Vendor\Package\$e, ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilObjQuestionPool\_updateQuestionCount(), CLIENT_WEB_DIR, ilFileUtils\delDir(), deleteAdditionalTableData(), deleteAnswers(), deleteComments(), ilAssQuestionHintList\deleteHintsByQuestionIds(), deletePageOfQuestion(), deleteTaxonomyAssignments(), getObjId(), getSuggestedSolutionsRepo(), and isAdditionalContentEditingModePageObject().

877  : void
878  {
879  if ($question_id < 1) {
880  return;
881  }
882 
883  $result = $this->db->queryF(
884  "SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
885  ['integer'],
886  [$question_id]
887  );
888  if ($this->db->numRows($result) !== 1) {
889  return;
890  }
891 
892  $row = $this->db->fetchAssoc($result);
893  $obj_id = $row["obj_fi"];
894 
895  try {
896  $this->deletePageOfQuestion($question_id);
897  } catch (Exception $e) {
898  $this->log->root()->error("EXCEPTION: Could not delete page of question $question_id: $e");
899  return;
900  }
901 
902  $affectedRows = $this->db->manipulateF(
903  "DELETE FROM qpl_questions WHERE question_id = %s",
904  ['integer'],
905  [$question_id]
906  );
907  if ($affectedRows == 0) {
908  return;
909  }
910 
911  try {
912  $this->deleteAdditionalTableData($question_id);
913  $this->deleteAnswers($question_id);
914  $this->feedbackOBJ->deleteGenericFeedbacks($question_id, $this->isAdditionalContentEditingModePageObject());
915  $this->feedbackOBJ->deleteSpecificAnswerFeedbacks($question_id, $this->isAdditionalContentEditingModePageObject());
916  } catch (Exception $e) {
917  $this->log->root()->error("EXCEPTION: Could not delete additional table data of question {$question_id}: {$e}");
918  }
919 
920  try {
921  // delete the question in the tst_test_question table (list of test questions)
922  $affectedRows = $this->db->manipulateF(
923  "DELETE FROM tst_test_question WHERE question_fi = %s",
924  ['integer'],
925  [$question_id]
926  );
927  } catch (Exception $e) {
928  $this->log->root()->error("EXCEPTION: Could not delete delete question {$question_id} from a test: {$e}");
929  }
930 
931  try {
932  $this->getSuggestedSolutionsRepo()->deleteForQuestion($question_id);
933  } catch (Exception $e) {
934  $this->log->root()->error("EXCEPTION: Could not delete suggested solutions of question {$question_id}: {$e}");
935  }
936 
937  $directory = CLIENT_WEB_DIR . "/assessment/" . $obj_id . "/$question_id";
938  try {
939  if (is_dir($directory)) {
940  ilFileUtils::delDir($directory);
941  }
942  } catch (Exception $e) {
943  $this->log->root()->error("EXCEPTION: Could not delete question file directory {$directory} of question {$question_id}: {$e}");
944  }
945 
946  try {
947  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id);
948  // remaining usages are not in text anymore -> delete them
949  // and media objects (note: delete method of ilObjMediaObject
950  // checks whether object is used in another context; if yes,
951  // the object is not deleted!)
952  foreach ($mobs as $mob) {
953  ilObjMediaObject::_removeUsage($mob, "qpl:html", $question_id);
954  if (ilObjMediaObject::_exists($mob)) {
955  $mob_obj = new ilObjMediaObject($mob);
956  $mob_obj->delete();
957  }
958  }
959  } catch (Exception $e) {
960  $this->log->root()->error("EXCEPTION: Error deleting the media objects of question {$question_id}: {$e}");
961  }
962  ilAssQuestionHintTracking::deleteRequestsByQuestionIds([$question_id]);
964  $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
965  $assignmentList->setParentObjId($obj_id);
966  $assignmentList->setQuestionIdFilter($question_id);
967  $assignmentList->loadFromDb();
968  foreach ($assignmentList->getAssignmentsByQuestionId($question_id) as $assignment) {
969  /* @var ilAssQuestionSkillAssignment $assignment */
970  $assignment->deleteFromDb();
971 
972  // remove skill usage
973  if (!$assignment->isSkillUsed()) {
974  $this->skillUsageService->removeUsage(
975  $assignment->getParentObjId(),
976  $assignment->getSkillBaseId(),
977  $assignment->getSkillTrefId()
978  );
979  }
980  }
981 
982  $this->deleteTaxonomyAssignments();
983  $this->deleteComments();
984 
985  try {
987  } catch (Exception $e) {
988  $this->log->root()->error(
989  "EXCEPTION: Error updating the question pool question count of"
990  . " question pool {$this->getObjId()} when deleting question {$question_id}: {$e}"
991  );
992  }
993  }
deletePageOfQuestion(int $question_id)
deleteAdditionalTableData(int $question_id)
deleteAnswers(int $question_id)
static deleteHintsByQuestionIds(array $questionIds)
Deletes all question hints relating to questions included in given question ids.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
const CLIENT_WEB_DIR
Definition: constants.php:47
static _exists(int $id, bool $reference=false, ?string $type=null)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
static _updateQuestionCount(int $object_id)
isAdditionalContentEditingModePageObject()
+ Here is the call graph for this function:

◆ deleteAdditionalTableData()

assQuestion::deleteAdditionalTableData ( int  $question_id)

Definition at line 850 of file class.assQuestion.php.

References getAdditionalTableName().

Referenced by delete().

850  : void
851  {
852  $additional_table_name = $this->getAdditionalTableName();
853 
854  if (!is_array($additional_table_name)) {
855  $additional_table_name = [$additional_table_name];
856  }
857 
858  foreach ($additional_table_name as $table) {
859  if (strlen($table)) {
860  $this->db->manipulateF(
861  "DELETE FROM $table WHERE question_fi = %s",
862  ['integer'],
863  [$question_id]
864  );
865  }
866  }
867  }
getAdditionalTableName()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAnswers()

assQuestion::deleteAnswers ( int  $question_id)

Definition at line 831 of file class.assQuestion.php.

References getAnswerTableName().

Referenced by delete().

831  : void
832  {
833  $answer_table_name = $this->getAnswerTableName();
834 
835  if (!is_array($answer_table_name)) {
836  $answer_table_name = [$answer_table_name];
837  }
838 
839  foreach ($answer_table_name as $table) {
840  if (strlen($table)) {
841  $this->db->manipulateF(
842  "DELETE FROM $table WHERE question_fi = %s",
843  ['integer'],
844  [$question_id]
845  );
846  }
847  }
848  }
getAnswerTableName()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteComments()

assQuestion::deleteComments ( )
protected

Definition at line 1507 of file class.assQuestion.php.

References getId(), getNotesManager(), getNotesRepo(), and getObjId().

Referenced by delete().

1507  : void
1508  {
1509  $repo = $this->getNotesRepo();
1510  $manager = $this->getNotesManager();
1511  $source_id = $this->getId();
1512  $notes = $manager->getNotesForRepositoryObjIds([$this->getObjId()], Note::PUBLIC);
1513  $notes = array_filter(
1514  $notes,
1515  fn($n) => $n->getContext()->getSubObjId() === $source_id
1516  );
1517  foreach ($notes as $note) {
1518  $repo->deleteNote($note->getId());
1519  }
1520  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteDummySolutionRecord()

assQuestion::deleteDummySolutionRecord ( int  $activeId,
int  $passIndex 
)
protected

Definition at line 2671 of file class.assQuestion.php.

References getSolutionValues(), and removeSolutionRecordById().

Referenced by assFileUpload\saveWorkingData().

2671  : void
2672  {
2673  foreach ($this->getSolutionValues($activeId, $passIndex, false) as $solutionRec) {
2674  if ($solutionRec['value1'] == '' && $solutionRec['value2'] == '') {
2675  $this->removeSolutionRecordById($solutionRec['solution_id']);
2676  }
2677  }
2678  }
getSolutionValues(int $active_id, ?int $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
removeSolutionRecordById(int $solutionId)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deletePageOfQuestion()

assQuestion::deletePageOfQuestion ( int  $question_id)
protected

Definition at line 869 of file class.assQuestion.php.

References ilPageObject\_exists().

Referenced by delete().

869  : void
870  {
871  if (ilAssQuestionPage::_exists('qpl', $question_id, "", true)) {
872  $page = new ilAssQuestionPage($question_id);
873  $page->delete();
874  }
875  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilAssQuestionPage $page
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteSolutionRecordByValues()

assQuestion::deleteSolutionRecordByValues ( int  $activeId,
int  $passIndex,
bool  $authorized,
array  $matchValues 
)
protected

Definition at line 2685 of file class.assQuestion.php.

References getId(), getStep(), ILIAS\Repository\int(), and null.

2685  : void
2686  {
2687  $types = ["integer", "integer", "integer", "integer"];
2688  $values = [$activeId, $this->getId(), $passIndex, (int) $authorized];
2689  $valuesCondition = [];
2690 
2691  foreach ($matchValues as $valueField => $value) {
2692  switch ($valueField) {
2693  case 'value1':
2694  case 'value2':
2695  $valuesCondition[] = "{$valueField} = %s";
2696  $types[] = 'text';
2697  $values[] = $value;
2698  break;
2699 
2700  default:
2701  throw new ilTestQuestionPoolException('invalid value field given: ' . $valueField);
2702  }
2703  }
2704 
2705  $valuesCondition = implode(' AND ', $valuesCondition);
2706 
2707  $query = "
2708  DELETE FROM tst_solutions
2709  WHERE active_fi = %s
2710  AND question_fi = %s
2711  AND pass = %s
2712  AND authorized = %s
2713  AND $valuesCondition
2714  ";
2715 
2716  if ($this->getStep() !== null) {
2717  $query .= " AND step = %s ";
2718  $types[] = 'integer';
2719  $values[] = $this->getStep();
2720  }
2721 
2722  $this->db->manipulateF($query, $types, $values);
2723  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ deleteSuggestedSolutions()

assQuestion::deleteSuggestedSolutions ( )

Definition at line 1540 of file class.assQuestion.php.

References ilInternalLink\_deleteAllLinksOfSource(), ilFileUtils\delDir(), getId(), getSuggestedSolutionPath(), and getSuggestedSolutionsRepo().

1540  : void
1541  {
1542  $this->getSuggestedSolutionsRepo()->deleteForQuestion($this->getId());
1545  $this->suggested_solutions = [];
1546  }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ deleteTaxonomyAssignments()

assQuestion::deleteTaxonomyAssignments ( )
private

Definition at line 995 of file class.assQuestion.php.

References getId(), getObjId(), and ilObjTaxonomy\getUsageOfObject().

Referenced by delete().

995  : void
996  {
997  $taxIds = ilObjTaxonomy::getUsageOfObject($this->getObjId());
998 
999  foreach ($taxIds as $taxId) {
1000  $taxNodeAssignment = new ilTaxNodeAssignment('qpl', $this->getObjId(), 'quest', $taxId);
1001  $taxNodeAssignment->deleteAssignmentsOfItem($this->getId());
1002  }
1003  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duplicate()

assQuestion::duplicate ( bool  $for_test = true,
string  $title = '',
string  $author = '',
int  $owner = -1,
  $test_obj_id = null 
)

Definition at line 1266 of file class.assQuestion.php.

References cloneQuestionTypeSpecificProperties(), getId(), and getObjId().

1272  : int {
1273  if ($this->id <= 0) {
1274  // The question has not been saved. It cannot be duplicated
1275  return -1;
1276  }
1277 
1278  $clone = clone $this;
1279  $clone->id = -1;
1280 
1281  if ((int) $test_obj_id > 0) {
1282  $clone->setObjId($test_obj_id);
1283  }
1284 
1285  if ($title) {
1286  $clone->setTitle($title);
1287  }
1288  if ($author) {
1289  $clone->setAuthor($author);
1290  }
1291  if ($owner) {
1292  $clone->setOwner($owner);
1293  }
1294  if ($for_test) {
1295  $clone->saveToDb($this->id);
1296  } else {
1297  $clone->saveToDb();
1298  }
1299 
1300  $clone->clonePageOfQuestion($this->getId());
1301  $clone->cloneXHTMLMediaObjectsOfQuestion($this->getId());
1302 
1303  $clone = $this->cloneQuestionTypeSpecificProperties($clone);
1304 
1305  $clone->onDuplicate($this->getObjId(), $this->getId(), $clone->getObjId(), $clone->getId());
1306 
1307  return $clone->id;
1308  }
cloneQuestionTypeSpecificProperties(self $target)
+ Here is the call graph for this function:

◆ duplicateComments()

assQuestion::duplicateComments ( int  $parent_source_id,
int  $source_id,
int  $parent_target_id,
int  $target_id 
)
protected

Definition at line 1473 of file class.assQuestion.php.

References getNotesDataService(), and getNotesManager().

Referenced by onCopy(), and onDuplicate().

1478  : void {
1479  $manager = $this->getNotesManager();
1480  $data_service = $this->getNotesDataService();
1481  $notes = $manager->getNotesForRepositoryObjIds([$parent_source_id], Note::PUBLIC);
1482  $notes = array_filter(
1483  $notes,
1484  fn($n) => $n->getContext()->getSubObjId() === $source_id
1485  );
1486 
1487  foreach ($notes as $note) {
1488  $new_context = $data_service->context(
1489  $parent_target_id,
1490  $target_id,
1491  $note->getContext()->getType()
1492  );
1493  $new_note = $data_service->note(
1494  -1,
1495  $new_context,
1496  $note->getText(),
1497  $note->getAuthor(),
1498  $note->getType(),
1499  $note->getCreationDate(),
1500  $note->getUpdateDate(),
1501  $note->getRecipient()
1502  );
1503  $manager->createNote($new_note, [], true);
1504  }
1505  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duplicateIntermediateSolutionAuthorized()

assQuestion::duplicateIntermediateSolutionAuthorized ( int  $activeId,
int  $passIndex 
)
protected

Definition at line 2725 of file class.assQuestion.php.

References getSolutionValues(), and saveCurrentSolution().

Referenced by forceExistingIntermediateSolution().

2725  : void
2726  {
2727  foreach ($this->getSolutionValues($activeId, $passIndex, false) as $rec) {
2728  $this->saveCurrentSolution($activeId, $passIndex, $rec['value1'], $rec['value2'], true, $rec['tstamp']);
2729  }
2730  }
getSolutionValues(int $active_id, ?int $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duplicateQuestionHints()

assQuestion::duplicateQuestionHints ( int  $original_question_id,
int  $duplicate_question_id 
)
protected

Definition at line 2304 of file class.assQuestion.php.

References ilAssQuestionHintList\duplicateListForQuestion(), ensureHintPageObjectExists(), getId(), and isAdditionalContentEditingModePageObject().

Referenced by onCopy(), and onDuplicate().

2304  : void
2305  {
2306  $hintIds = ilAssQuestionHintList::duplicateListForQuestion($original_question_id, $duplicate_question_id);
2307 
2309  foreach ($hintIds as $originalHintId => $duplicateHintId) {
2310  $this->ensureHintPageObjectExists($originalHintId);
2311  $originalPageObject = new ilAssHintPage($originalHintId);
2312  $originalXML = $originalPageObject->getXMLContent();
2313 
2314  $duplicatePageObject = new ilAssHintPage();
2315  $duplicatePageObject->setId($duplicateHintId);
2316  $duplicatePageObject->setParentId($this->getId());
2317  $duplicatePageObject->setXMLContent($originalXML);
2318  $duplicatePageObject->createFromXML();
2319  }
2320  }
2321  }
ensureHintPageObjectExists($pageObjectId)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static duplicateListForQuestion($originalQuestionId, $duplicateQuestionId)
duplicates a hint list from given original question id to given duplicate question id and returns an ...
isAdditionalContentEditingModePageObject()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duplicateSkillAssignments()

assQuestion::duplicateSkillAssignments ( int  $srcParentId,
int  $srcQuestionId,
int  $trgParentId,
int  $trgQuestionId 
)
protected

Definition at line 2323 of file class.assQuestion.php.

Referenced by onCopy(), onDuplicate(), and syncSkillAssignments().

2323  : void
2324  {
2325  $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
2326  $assignmentList->setParentObjId($srcParentId);
2327  $assignmentList->setQuestionIdFilter($srcQuestionId);
2328  $assignmentList->loadFromDb();
2329 
2330  foreach ($assignmentList->getAssignmentsByQuestionId($srcQuestionId) as $assignment) {
2331  $assignment->setParentObjId($trgParentId);
2332  $assignment->setQuestionId($trgQuestionId);
2333  $assignment->saveToDb();
2334 
2335  // add skill usage
2336  $this->skillUsageService->addUsage(
2337  $trgParentId,
2338  $assignment->getSkillBaseId(),
2339  $assignment->getSkillTrefId()
2340  );
2341  }
2342  }
+ Here is the caller graph for this function:

◆ duplicateSuggestedSolutionFiles()

assQuestion::duplicateSuggestedSolutionFiles ( int  $parent_id,
int  $question_id 
)
protected

Duplicates the files of a suggested solution if the question is duplicated.

Definition at line 1568 of file class.assQuestion.php.

References getSuggestedSolutionPath(), and ilFileUtils\makeDirParents().

Referenced by onCopy().

1568  : void
1569  {
1570  foreach ($this->suggested_solutions as $solution) {
1571  if (!$solution->isOfTypeFile()
1572  || $solution->getFilename() === '') {
1573  continue;
1574  }
1575 
1576  $filepath = $this->getSuggestedSolutionPath();
1577  $filepath_original = str_replace(
1578  "/{$this->obj_id}/{$this->id}/solution",
1579  "/{$parent_id}/{$question_id}/solution",
1580  $filepath
1581  );
1582  if (!file_exists($filepath)) {
1583  ilFileUtils::makeDirParents($filepath);
1584  }
1585  if (!is_file($filepath_original . $solution->getFilename())
1586  || !copy($filepath_original . $solution->getFilename(), $filepath . $solution->getFilename())) {
1587  $this->log->root()->error('File for suggested solutions could not be duplicated:');
1588  $this->log->root()->error("Question-Id: {$this->id}; Question-Title: {$this->title}; File: {$filepath_original}{$solution->getFilename()}");
1589  }
1590  }
1591  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureHintPageObjectExists()

assQuestion::ensureHintPageObjectExists (   $pageObjectId)

Definition at line 2367 of file class.assQuestion.php.

References ilPageObject\_exists(), and getId().

Referenced by duplicateQuestionHints().

2367  : void
2368  {
2369  if (!ilAssHintPage::_exists('qht', $pageObjectId)) {
2370  $pageObject = new ilAssHintPage();
2371  $pageObject->setParentId($this->getId());
2372  $pageObject->setId($pageObjectId);
2373  $pageObject->createFromXML();
2374  }
2375  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureNonNegativePoints()

◆ explodeKeyValues()

static assQuestion::explodeKeyValues ( string  $keyValues)
static

Definition at line 2666 of file class.assQuestion.php.

References KEY_VALUES_IMPLOSION_SEPARATOR.

2666  : array
2667  {
2668  return explode(assQuestion::KEY_VALUES_IMPLOSION_SEPARATOR, $keyValues);
2669  }
const KEY_VALUES_IMPLOSION_SEPARATOR

◆ extendedTrim()

static assQuestion::extendedTrim ( string  $value)
static

Trim non-printable characters from the beginning and end of a string.

Note: The PHP trim() function is not fully Unicode-compatible and may not handle non-printable characters effectively. As a result, it may not trim certain Unicode characters, such as control characters, zero width characters or ideographic space as expected.

This method provides a workaround for trimming non-printable characters until PHP 8.4, where the mb_trim() function is introduced. Users are encouraged to migrate to mb_trim() for proper Unicode and non-printable character handling.

Parameters
string$valueThe string to trim.
Returns
string The trimmed string.

Definition at line 3003 of file class.assQuestion.php.

Referenced by assTextSubset\getSolutionSubmit(), and assTextSubsetGUI\writeAnswerSpecificPostData().

3003  : string
3004  {
3005  return preg_replace(self::TRIM_PATTERN, '', $value);
3006  }
+ Here is the caller graph for this function:

◆ fetchIndexedValuesFromValuePairs()

assQuestion::fetchIndexedValuesFromValuePairs ( array  $value_pairs)

Definition at line 2944 of file class.assQuestion.php.

Referenced by assOrderingQuestion\calculateReachedPoints(), assOrderingQuestion\getOrderingElementListForSolutionOutput(), assOrderingQuestion\getSolutionOrderingElementListForTestOutput(), assOrderingQuestion\solutionValuesToLog(), and assOrderingQuestion\solutionValuesToText().

2944  : array
2945  {
2946  $indexed_values = [];
2947 
2948  foreach ($value_pairs as $valuePair) {
2949  $indexed_values[$valuePair['value1']] = $valuePair['value2'];
2950  }
2951 
2952  return $indexed_values;
2953  }
+ Here is the caller graph for this function:

◆ fetchValuePairsFromIndexedValues()

assQuestion::fetchValuePairsFromIndexedValues ( array  $indexedValues)

Definition at line 2933 of file class.assQuestion.php.

2933  : array
2934  {
2935  $valuePairs = [];
2936 
2937  foreach ($indexedValues as $value1 => $value2) {
2938  $valuePairs[] = ['value1' => $value1, 'value2' => $value2];
2939  }
2940 
2941  return $valuePairs;
2942  }

◆ fixSvgToPng()

static assQuestion::fixSvgToPng ( string  $imageFilenameContainingString)

Definition at line 1100 of file class.assQuestion.php.

1100  : string
1101  {
1102  $needles = array_keys(self::$imageSourceFixReplaceMap);
1103  $replacements = array_values(self::$imageSourceFixReplaceMap);
1104  return str_replace($needles, $replacements, $imageFilenameContainingString);
1105  }

◆ fixUnavailableSkinImageSources()

assQuestion::fixUnavailableSkinImageSources ( string  $html)

Definition at line 1107 of file class.assQuestion.php.

References ilUtil\getImagePath(), null, and ilFileUtils\removeTrailingPathSeparators().

1107  : string
1108  {
1109  $matches = null;
1110  if (preg_match_all('/src="(.*?)"/m', $html, $matches)) {
1111  $sources = $matches[1];
1112 
1113  $needleReplacementMap = [];
1114 
1115  foreach ($sources as $src) {
1116  $file = ilFileUtils::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH) . DIRECTORY_SEPARATOR . $src;
1117 
1118  if (file_exists($file)) {
1119  continue;
1120  }
1121 
1122  $levels = explode(DIRECTORY_SEPARATOR, $src);
1123  if (count($levels) < 5 || $levels[0] !== 'Customizing' || $levels[2] !== 'skin') {
1124  continue;
1125  }
1126 
1127  $component = '';
1128 
1129  if ($levels[4] === 'components/ILIAS' || $levels[4] === 'components/ILIAS') {
1130  $component = $levels[4] . DIRECTORY_SEPARATOR . $levels[5];
1131  }
1132 
1133  $needleReplacementMap[$src] = ilUtil::getImagePath(basename($src), $component);
1134  }
1135 
1136  if (count($needleReplacementMap)) {
1137  $html = str_replace(array_keys($needleReplacementMap), array_values($needleReplacementMap), $html);
1138  }
1139  }
1140 
1141  return $html;
1142  }
static removeTrailingPathSeparators(string $path)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:

◆ forceExistingIntermediateSolution()

assQuestion::forceExistingIntermediateSolution ( int  $activeId,
int  $passIndex,
bool  $considerDummyRecordCreation 
)
protected

Definition at line 2732 of file class.assQuestion.php.

References duplicateIntermediateSolutionAuthorized(), getSolutionValues(), null, saveCurrentSolution(), and updateCurrentSolutionsAuthorization().

Referenced by assFileUpload\saveWorkingData().

2732  : void
2733  {
2734  $intermediateSolution = $this->getSolutionValues($activeId, $passIndex, false);
2735 
2736  if (!count($intermediateSolution)) {
2737  $this->updateCurrentSolutionsAuthorization($activeId, $passIndex, false, true);
2738 
2739  // create a backup as authorized solution again (keeping timestamps)
2740  $this->duplicateIntermediateSolutionAuthorized($activeId, $passIndex);
2741 
2742  if ($considerDummyRecordCreation) {
2743  // create an additional dummy record to indicate the existence of an intermediate solution
2744  // even if all entries are deleted from the intermediate solution later
2745  $this->saveCurrentSolution($activeId, $passIndex, null, null, false);
2746  }
2747  }
2748  }
getSolutionValues(int $active_id, ?int $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
updateCurrentSolutionsAuthorization(int $activeId, int $pass, bool $authorized, bool $keepTime=false)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
duplicateIntermediateSolutionAuthorized(int $activeId, int $passIndex)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ formatSAQuestion()

◆ fromXML()

assQuestion::fromXML ( string  $importdirectory,
int  $user_id,
ilQTIItem  $item,
int  $questionpool_id,
?int  $tst_id,
?ilObject $tst_object,
int &  $question_counter,
array  $import_mapping,
array  $solutionhints = [] 
)
final

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

References getQuestionType(), and importHint().

267  : array {
268  $classname = $this->getQuestionType() . "Import";
269  $import = new $classname($this);
270  $new_import_mapping = $import->fromXML(
271  $importdirectory,
272  $user_id,
273  $item,
274  $questionpool_id,
275  $tst_id,
276  $tst_object,
277  $question_counter,
278  $import_mapping
279  );
280 
281  foreach ($solutionhints as $hint) {
282  $this->importHint($import->getQuestionId(), $hint);
283  }
284 
285  return $new_import_mapping;
286  }
importHint(int $question_id, array $hint_array)
+ Here is the call graph for this function:

◆ getActiveUserData()

assQuestion::getActiveUserData ( int  $active_id)

Returns the user id and the test id for a given active id.

Parameters
integer$active_idActive id for a test/user
Returns
array Result array containing the user_id and test_id

Definition at line 2130 of file class.assQuestion.php.

2130  : array
2131  {
2132  $result = $this->db->queryF(
2133  "SELECT * FROM tst_active WHERE active_id = %s",
2134  ['integer'],
2135  [$active_id]
2136  );
2137  if ($this->db->numRows($result)) {
2138  $row = $this->db->fetchAssoc($result);
2139  return ["user_id" => $row["user_fi"], "test_id" => $row["test_fi"]];
2140  }
2141 
2142  return [];
2143  }

◆ getAdditionalContentEditingMode()

assQuestion::getAdditionalContentEditingMode ( )

◆ getAdditionalTableName()

assQuestion::getAdditionalTableName ( )
abstract

Referenced by deleteAdditionalTableData().

+ Here is the caller graph for this function:

◆ getAdjustedReachedPoints()

assQuestion::getAdjustedReachedPoints ( int  $active_id,
int  $pass,
bool  $authorized_solution = true 
)
final

Definition at line 562 of file class.assQuestion.php.

References adjustReachedPointsByScoringOptions(), calculateReachedPoints(), and getId().

562  : float
563  {
564  // determine reached points for submitted solution
565  $reached_points = $this->calculateReachedPoints($active_id, $pass, $authorized_solution);
566  $hint_tracking = new ilAssQuestionHintTracking($this->getId(), $active_id, $pass);
567  $requests_statistic_data = $hint_tracking->getRequestStatisticDataByQuestionAndTestpass();
568  $reached_points = $reached_points - $requests_statistic_data->getRequestsPoints();
569 
570  // adjust reached points regarding to tests scoring options
571  $reached_points = $this->adjustReachedPointsByScoringOptions($reached_points, $active_id);
572 
573  return $reached_points;
574  }
adjustReachedPointsByScoringOptions(float $points, int $active_id)
Adjust the given reached points by checks for all special scoring options in the test container...
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
+ Here is the call graph for this function:

◆ getAnswerTableName()

assQuestion::getAnswerTableName ( )
abstract

Referenced by deleteAnswers().

+ Here is the caller graph for this function:

◆ getAuthor()

assQuestion::getAuthor ( )

Definition at line 427 of file class.assQuestion.php.

References $author.

Referenced by createNewQuestion(), assOrderingQuestion\isComplete(), assClozeTest\isComplete(), and saveQuestionDataToDb().

427  : string
428  {
429  return $this->author;
430  }
+ Here is the caller graph for this function:

◆ getAuthorForHTMLOutput()

assQuestion::getAuthorForHTMLOutput ( )

Definition at line 432 of file class.assQuestion.php.

References ILIAS\Repository\refinery().

432  : string
433  {
434  return $this->refinery->string()->stripTags()->transform($this->author);
435  }
+ Here is the call graph for this function:

◆ getComment()

assQuestion::getComment ( )

Definition at line 393 of file class.assQuestion.php.

References $comment.

Referenced by saveQuestionDataToDb().

393  : string
394  {
395  return $this->comment;
396  }
+ Here is the caller graph for this function:

◆ getCorrectSolutionForTextOutput()

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

Definition at line 3073 of file class.assQuestion.php.

References getSolutionValues(), and solutionValuesToText().

3076  : array|string {
3077  return $this->solutionValuesToText(
3078  $this->getSolutionValues($active_id, $pass)
3079  );
3080  }
getSolutionValues(int $active_id, ?int $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
solutionValuesToText(array $solution_values)
MUST convert the given solution values into text.
+ Here is the call graph for this function:

◆ getCurrentSolutionResultSet()

assQuestion::getCurrentSolutionResultSet ( int  $active_id,
int  $pass,
bool  $authorized = true 
)
protected

Definition at line 2483 of file class.assQuestion.php.

References getId(), getStep(), and null.

Referenced by assOrderingHorizontal\calculateReachedPoints(), assNumeric\calculateReachedPoints(), assFileUpload\calculateReachedPoints(), assErrorText\calculateReachedPoints(), assSingleChoice\calculateReachedPoints(), assTextSubset\calculateReachedPoints(), assMultipleChoice\calculateReachedPoints(), assTextQuestion\calculateReachedPoints(), assKprimChoice\calculateReachedPoints(), assLongMenu\calculateReachedPoints(), assMatchingQuestion\calculateReachedPoints(), assClozeTest\fetchUserResult(), assNumeric\saveWorkingData(), and assSingleChoice\saveWorkingData().

2483  : \ilDBStatement
2484  {
2485  if ($this->getStep() !== null) {
2486  $query = "
2487  SELECT *
2488  FROM tst_solutions
2489  WHERE active_fi = %s
2490  AND question_fi = %s
2491  AND pass = %s
2492  AND step = %s
2493  AND authorized = %s
2494  ";
2495 
2496  return $this->db->queryF(
2497  $query,
2498  ['integer', 'integer', 'integer', 'integer', 'integer'],
2499  [$active_id, $this->getId(), $pass, $this->getStep(), (int) $authorized]
2500  );
2501  }
2502 
2503  $query = "
2504  SELECT *
2505  FROM tst_solutions
2506  WHERE active_fi = %s
2507  AND question_fi = %s
2508  AND pass = %s
2509  AND authorized = %s
2510  ";
2511 
2512  return $this->db->queryF(
2513  $query,
2514  ['integer', 'integer', 'integer', 'integer'],
2515  [$active_id, $this->getId(), $pass, (int) $authorized]
2516  );
2517  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Interface ilDBStatement.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentUser()

assQuestion::getCurrentUser ( )

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

References $current_user.

Referenced by isWriteable().

232  : ilObjUser
233  {
234  return $this->current_user;
235  }
ilObjUser $current_user
+ Here is the caller graph for this function:

◆ getDefaultNrOfTries()

assQuestion::getDefaultNrOfTries ( )

Definition at line 2284 of file class.assQuestion.php.

References $defaultnroftries.

Referenced by createNewQuestion().

2284  : int
2285  {
2286  return $this->defaultnroftries;
2287  }
+ Here is the caller graph for this function:

◆ getDescriptionForHTMLOutput()

assQuestion::getDescriptionForHTMLOutput ( )

Definition at line 398 of file class.assQuestion.php.

References ILIAS\UI\examples\Symbol\Glyph\Comment\comment(), and ILIAS\Repository\refinery().

398  : string
399  {
400  return $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($this->comment);
401  }
comment()
description: > Example for rendring a comment glyph.
Definition: comment.php:41
+ Here is the call graph for this function:

◆ getExternalId()

assQuestion::getExternalId ( )

Definition at line 467 of file class.assQuestion.php.

References $external_id, getId(), IL_INST_ID, and null.

Referenced by createNewQuestion(), and saveQuestionDataToDb().

467  : string
468  {
469  if ($this->external_id === null || $this->external_id === '') {
470  if ($this->getId() > 0) {
471  return 'il_' . IL_INST_ID . '_qst_' . $this->getId();
472  }
473  return uniqid('', true);
474  }
475  return $this->external_id;
476  }
const IL_INST_ID
Definition: constants.php:40
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFeedbackClassNameByQuestionType()

static assQuestion::getFeedbackClassNameByQuestionType ( string  $questionType)
static

Definition at line 2150 of file class.assQuestion.php.

References $DIC, $ilDB, ILIAS\TestQuestionPool\Questions\GeneralQuestionPropertiesRepository\getForQuestionId(), and null.

Referenced by assQuestionGUI\_getQuestionGUI().

2150  : string
2151  {
2152  return str_replace('ass', 'ilAss', $questionType) . 'Feedback';
2153  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHtmlQuestionContentPurifier()

assQuestion::getHtmlQuestionContentPurifier ( )
Returns
ilHtmlPurifierInterface|ilAssHtmlUserSolutionPurifier

Definition at line 2456 of file class.assQuestion.php.

References ilHtmlPurifierFactory\getInstanceByType().

Referenced by assSingleChoice\addAnswer(), assKprimChoice\addAnswer(), assMultipleChoice\addAnswer(), assClozeTest\getClozeTextForHTMLOutput(), purifyAndPrepareTextAreaOutput(), assKprimChoice\setAnswers(), and assLongMenu\setLongMenuTextValue().

2457  {
2458  return ilHtmlPurifierFactory::getInstanceByType('qpl_usersolution');
2459  }
Interface for html sanitizing functionality.
static getInstanceByType(string $type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHtmlUserSolutionPurifier()

assQuestion::getHtmlUserSolutionPurifier ( )
Returns
ilHtmlPurifierInterface|ilAssHtmlUserSolutionPurifier

Definition at line 2448 of file class.assQuestion.php.

References ilHtmlPurifierFactory\getInstanceByType().

Referenced by assTextQuestion\getSolutionSubmit(), and assTextSubset\getSolutionSubmit().

2449  {
2450  return ilHtmlPurifierFactory::getInstanceByType('qpl_usersolution');
2451  }
Interface for html sanitizing functionality.
static getInstanceByType(string $type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

assQuestion::getId ( )

Definition at line 378 of file class.assQuestion.php.

References $id.

Referenced by ilQuestionUsagesTableGUI\__construct(), ilQuestionCumulatedStatisticsTableGUI\__construct(), ilAssQuestionHintsOrderingClipboard\__construct(), assLongMenu\buildFolderName(), assOrderingQuestion\buildNestedOrderingElementInputGui(), assClozeTest\calculateCombinationResult(), calculateResultsFromSolution(), cleanupMediaObjectUsage(), assOrderingQuestion\cloneQuestionTypeSpecificProperties(), assSingleChoice\cloneQuestionTypeSpecificProperties(), assMultipleChoice\cloneQuestionTypeSpecificProperties(), assImagemapQuestion\cloneQuestionTypeSpecificProperties(), assMatchingQuestion\cloneQuestionTypeSpecificProperties(), assKprimChoice\cloneQuestionTypeSpecificProperties(), assFormulaQuestion\cloneQuestionTypeSpecificProperties(), assClozeTest\cloneQuestionTypeSpecificProperties(), cloneXHTMLMediaObjectsOfQuestion(), copyObject(), createNewOriginalFromThisDuplicate(), createNewQuestion(), createPageObject(), deleteComments(), deleteSolutionRecordByValues(), deleteSuggestedSolutions(), deleteTaxonomyAssignments(), duplicate(), assTextQuestion\duplicateAnswers(), duplicateQuestionHints(), ensureHintPageObjectExists(), assOrderingQuestion\fetchSolutionListFromFormSubmissionData(), getAdjustedReachedPoints(), assFormulaQuestion\getBestSolution(), assLongMenu\getCorrectAnswersAsJson(), getCurrentSolutionResultSet(), assErrorText\getErrorDataAsArrayForJS(), getExternalId(), assFileUpload\getFileUploadPath(), assFileUpload\getFileUploadPathWeb(), getInstances(), assTextQuestion\getLatestAutosaveContent(), assClozeTest\getMaximumPoints(), assOrderingQuestion\getOrderingElementList(), assErrorText\getParsedErrorTextForJS(), getReachedPoints(), assMultipleChoice\getRTETextWithMediaObjects(), assSingleChoice\getRTETextWithMediaObjects(), getRTETextWithMediaObjects(), getSolutionMaxPass(), assOrderingQuestion\getSolutionOrderingElementList(), getSolutionValues(), assFileUpload\getUploadedFiles(), assNumeric\getUserQuestionResult(), assOrderingHorizontal\getUserQuestionResult(), assTextSubset\getUserQuestionResult(), assErrorText\getUserQuestionResult(), assSingleChoice\getUserQuestionResult(), assMultipleChoice\getUserQuestionResult(), assOrderingQuestion\getUserQuestionResult(), assFormulaQuestion\getUserQuestionResult(), assMatchingQuestion\getUserQuestionResult(), assClozeTest\getUserQuestionResult(), assFormulaQuestion\getVariableSolutionValuesForPass(), assFileUpload\hasFileUploads(), isAnswered(), isWriteable(), assTextQuestion\loadFromDb(), loadSuggestedSolutions(), assLongMenu\lookupForExistingSolutions(), assFormulaQuestion\lookupForExistingSolutions(), lookupForExistingSolutions(), lookupMaxStep(), migrateContentForLearningModule(), ilAssNestedOrderingElementsInputGUI\prepareReprintable(), removeAllExistingSolutions(), removeCurrentSolution(), assFormulaQuestion\removeExistingSolutions(), removeExistingSolutions(), removeResultRecord(), ilAssOrderingQuestionAuthoringFormGUI\renewOrderingElementInput(), resolveSuggestedSolutionLinks(), assFileUpload\saveAdditionalQuestionDataToDb(), assErrorText\saveAdditionalQuestionDataToDb(), assImagemapQuestion\saveAdditionalQuestionDataToDb(), assMatchingQuestion\saveAdditionalQuestionDataToDb(), assOrderingHorizontal\saveAdditionalQuestionDataToDb(), assLongMenu\saveAdditionalQuestionDataToDb(), assClozeTest\saveAdditionalQuestionDataToDb(), assNumeric\saveAdditionalQuestionDataToDb(), assKprimChoice\saveAdditionalQuestionDataToDb(), assTextSubset\saveAdditionalQuestionDataToDb(), assSingleChoice\saveAdditionalQuestionDataToDb(), assMultipleChoice\saveAdditionalQuestionDataToDb(), assTextQuestion\saveAdditionalQuestionDataToDb(), assOrderingQuestion\saveAdditionalQuestionDataToDb(), assErrorText\saveAnswerSpecificDataToDb(), assMatchingQuestion\saveAnswerSpecificDataToDb(), assImagemapQuestion\saveAnswerSpecificDataToDb(), assClozeTest\saveAnswerSpecificDataToDb(), assLongMenu\saveAnswerSpecificDataToDb(), assNumeric\saveAnswerSpecificDataToDb(), assKprimChoice\saveAnswerSpecificDataToDb(), assTextSubset\saveAnswerSpecificDataToDb(), assMultipleChoice\saveAnswerSpecificDataToDb(), assClozeTest\saveClozeNumericGapRecordToDb(), assClozeTest\saveClozeSelectGapRecordToDb(), assClozeTest\saveClozeTextGapRecordToDb(), assFormulaQuestion\saveCurrentSolution(), saveCurrentSolution(), assSingleChoice\savePreviewData(), saveQuestionDataToDb(), assFormulaQuestion\saveToDb(), saveToDb(), assFormulaQuestion\saveWorkingData(), assFormulaQuestion\setId(), assOrderingQuestion\setOrderingElementList(), syncWithOriginal(), assOrderingHorizontal\toJSON(), assTextQuestion\toJSON(), assTextSubset\toJSON(), assMultipleChoice\toJSON(), assSingleChoice\toJSON(), assLongMenu\toJSON(), assKprimChoice\toJSON(), assErrorText\toJSON(), assOrderingQuestion\toJSON(), assMatchingQuestion\toJSON(), assClozeTest\toJSON(), updateCurrentSolutionsAuthorization(), ilLOTestQuestionAdapter\updateQuestionResult(), and updateTimestamp().

378  : int
379  {
380  return $this->id;
381  }
+ Here is the caller graph for this function:

◆ getImagePath()

assQuestion::getImagePath (   $question_id = null,
  $object_id = null 
)

Returns the image path for web accessable images of a question.

The image path is under the CLIENT_WEB_DIR in assessment/REFERENCE_ID_OF_QUESTION_POOL/ID_OF_QUESTION/images

Definition at line 711 of file class.assQuestion.php.

References $id, $obj_id, and null.

Referenced by assOrderingQuestion\buildOrderingImagesFormDataConverter(), assOrderingQuestion\cleanImagefiles(), assOrderingQuestion\cloneImages(), assMatchingQuestion\cloneImages(), assImagemapQuestion\copyImagemapFiles(), assMatchingQuestion\deleteImagefile(), assOrderingQuestion\dropImageFile(), assOrderingQuestion\ensureImagePathExists(), assKprimChoice\handleFileUpload(), assOrderingQuestion\isImageFileStored(), assKprimChoice\loadAnswerData(), assSingleChoice\loadFromDb(), assMultipleChoice\loadFromDb(), assOrderingQuestion\rebuildThumbnails(), assMatchingQuestion\rebuildThumbnails(), assSingleChoice\saveAdditionalQuestionDataToDb(), assMultipleChoice\saveAdditionalQuestionDataToDb(), assMultipleChoice\setImageFile(), assSingleChoice\setImageFile(), assMatchingQuestion\setImageFile(), assImagemapQuestion\setImageFilename(), assOrderingQuestion\storeImageFile(), and assOrderingQuestion\updateImageFile().

711  : string
712  {
713  if ($question_id === null) {
714  $question_id = $this->id;
715  }
716 
717  if ($object_id === null) {
718  $object_id = $this->obj_id;
719  }
720 
721  return $this->question_files->buildImagePath($question_id, $object_id);
722  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getImagePathWeb()

assQuestion::getImagePathWeb ( )

Returns the web image path for web accessable images of a question.

The image path is under the web accessable data dir in assessment/REFERENCE_ID_OF_QUESTION_POOL/ID_OF_QUESTION/images TODO: in use? refactor and ask for a supported path in all cases, not for THE dynamic highlander path ^^

Definition at line 740 of file class.assQuestion.php.

References $export_image_path, CLIENT_WEB_DIR, and ilFileUtils\removeTrailingPathSeparators().

Referenced by assOrderingQuestion\buildNestedOrderingElementInputGui(), assOrderingQuestion\buildNestedOrderingFormDataConverter(), assOrderingQuestion\buildOrderingImagesFormDataConverter(), assKprimChoice\loadAnswerData(), assMultipleChoice\toJSON(), assSingleChoice\toJSON(), assKprimChoice\toJSON(), and assOrderingQuestion\toJSON().

740  : string
741  {
742  if (!$this->export_image_path) {
744  . "/assessment/{$this->obj_id}/{$this->id}/images/";
745  return str_replace(
746  ilFileUtils::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH . '/public'),
748  $webdir
749  );
750  }
752  }
static removeTrailingPathSeparators(string $path)
const CLIENT_WEB_DIR
Definition: constants.php:47
string $export_image_path
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstances()

assQuestion::getInstances ( )

Definition at line 2086 of file class.assQuestion.php.

References ilObject\_getAllReferences(), ilObjTest\_lookupAuthor(), ilObject\_lookupTitle(), and getId().

2086  : array
2087  {
2088  $result = $this->db->queryF(
2089  "SELECT question_id FROM qpl_questions WHERE original_id = %s",
2090  ["integer"],
2091  [$this->getId()]
2092  );
2093  $instances = [];
2094  $ids = [];
2095  while ($row = $this->db->fetchAssoc($result)) {
2096  $ids[] = $row["question_id"];
2097  }
2098  foreach ($ids as $question_id) {
2099  // check non random tests
2100  $result = $this->db->queryF(
2101  "SELECT tst_tests.obj_fi FROM tst_tests, tst_test_question WHERE tst_test_question.question_fi = %s AND tst_test_question.test_fi = tst_tests.test_id",
2102  ["integer"],
2103  [$question_id]
2104  );
2105  while ($row = $this->db->fetchAssoc($result)) {
2106  $instances[$row['obj_fi']] = ilObject::_lookupTitle($row['obj_fi']);
2107  }
2108  // check random tests
2109  $result = $this->db->queryF(
2110  "SELECT tst_tests.obj_fi FROM tst_tests, tst_test_rnd_qst, tst_active WHERE tst_test_rnd_qst.active_fi = tst_active.active_id AND tst_test_rnd_qst.question_fi = %s AND tst_tests.test_id = tst_active.test_fi",
2111  ["integer"],
2112  [$question_id]
2113  );
2114  while ($row = $this->db->fetchAssoc($result)) {
2115  $instances[$row['obj_fi']] = ilObject::_lookupTitle($row['obj_fi']);
2116  }
2117  }
2118  foreach ($instances as $key => $value) {
2119  $instances[$key] = ["obj_id" => $key, "title" => $value, "author" => ilObjTest::_lookupAuthor($key), "refs" => ilObject::_getAllReferences($key)];
2120  }
2121  return $instances;
2122  }
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
static _lookupAuthor($obj_id)
Gets the authors name of the ilObjTest object.
+ Here is the call graph for this function:

◆ getInternalLinkHref()

assQuestion::getInternalLinkHref ( string  $target)

Definition at line 1707 of file class.assQuestion.php.

Referenced by getSuggestedSolutionOutput().

1707  : string
1708  {
1709  $linktypes = [
1710  "lm" => "LearningModule",
1711  "pg" => "PageObject",
1712  "st" => "StructureObject",
1713  "git" => "GlossaryItem",
1714  "mob" => "MediaObject"
1715  ];
1716  $href = "";
1717  if (preg_match("/il__(\w+)_(\d+)/", $target, $matches)) {
1718  $type = $matches[1];
1719  $target_id = $matches[2];
1720  switch ($linktypes[$matches[1]]) {
1721  case "MediaObject":
1722  $href = "./ilias.php?baseClass=ilLMPresentationGUI&obj_type=" . $linktypes[$type]
1723  . "&cmd=media&ref_id=" . $this->questionpool_request->getRefId()
1724  . "&mob_id=" . $target_id;
1725  break;
1726  case "StructureObject":
1727  case "GlossaryItem":
1728  case "PageObject":
1729  case "LearningModule":
1730  default:
1731  $href = "./goto.php?target=" . $type . "_" . $target_id;
1732  break;
1733  }
1734  }
1735  return $href;
1736  }
+ Here is the caller graph for this function:

◆ getLastChange()

assQuestion::getLastChange ( )

Definition at line 2478 of file class.assQuestion.php.

References $lastChange.

2478  : ?int
2479  {
2480  return $this->lastChange;
2481  }

◆ getLifecycle()

assQuestion::getLifecycle ( )

Definition at line 452 of file class.assQuestion.php.

References $lifecycle.

Referenced by saveToDb().

453  {
454  return $this->lifecycle;
455  }
ilAssQuestionLifecycle $lifecycle
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assQuestion::getMaximumPoints ( )

Definition at line 557 of file class.assQuestion.php.

References $points.

Referenced by adjustReachedPointsByScoringOptions(), isPreviewSolutionCorrect(), and saveQuestionDataToDb().

557  : float
558  {
559  return $this->points;
560  }
+ Here is the caller graph for this function:

◆ getMaximumThumbSize()

assQuestion::getMaximumThumbSize ( )

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

422  : int
423  {
424  return self::MAXIMUM_THUMB_SIZE;
425  }

◆ getMinimumThumbSize()

assQuestion::getMinimumThumbSize ( )

Definition at line 417 of file class.assQuestion.php.

Referenced by assSingleChoice\loadFromDb(), assMultipleChoice\loadFromDb(), and assOrderingQuestion\loadFromDb().

417  : int
418  {
419  return self::MINIMUM_THUMB_SIZE;
420  }
+ Here is the caller graph for this function:

◆ getNotesDataService()

assQuestion::getNotesDataService ( )
protected

Definition at line 1528 of file class.assQuestion.php.

References $service.

Referenced by duplicateComments().

1528  : NotesInternalDataService
1529  {
1530  $service = new NotesService($this->dic);
1531  return $service->internal()->data();
1532  }
$service
Definition: ltiservices.php:40
+ Here is the caller graph for this function:

◆ getNotesManager()

assQuestion::getNotesManager ( )
protected

Definition at line 1522 of file class.assQuestion.php.

References $service.

Referenced by deleteComments(), and duplicateComments().

1522  : NotesManager
1523  {
1524  $service = new NotesService($this->dic);
1525  return $service->internal()->domain()->notes();
1526  }
$service
Definition: ltiservices.php:40
+ Here is the caller graph for this function:

◆ getNotesRepo()

assQuestion::getNotesRepo ( )
protected

Definition at line 1534 of file class.assQuestion.php.

References $service.

Referenced by deleteComments().

1534  : NotesRepo
1535  {
1536  $service = new NotesService($this->dic);
1537  return $service->internal()->repo()->note();
1538  }
$service
Definition: ltiservices.php:40
+ Here is the caller graph for this function:

◆ getNrOfTries()

◆ getNumExistingSolutionRecords()

static assQuestion::getNumExistingSolutionRecords ( int  $activeId,
int  $pass,
int  $questionId 
)
staticprotected

Definition at line 2383 of file class.assQuestion.php.

References $DIC, $ilDB, and $res.

Referenced by isAnswered().

2383  : int
2384  {
2385  global $DIC;
2386  $ilDB = $DIC['ilDB'];
2387 
2388  $query = "
2389  SELECT count(active_fi) cnt
2390 
2391  FROM tst_solutions
2392 
2393  WHERE active_fi = %s
2394  AND question_fi = %s
2395  AND pass = %s
2396  ";
2397 
2398  $res = $ilDB->queryF(
2399  $query,
2400  ['integer','integer','integer'],
2401  [$activeId, $questionId, $pass]
2402  );
2403 
2404  $row = $ilDB->fetchAssoc($res);
2405 
2406  return (int) $row['cnt'];
2407  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ getObjId()

◆ getOriginalId()

assQuestion::getOriginalId ( )

Definition at line 1086 of file class.assQuestion.php.

References $original_id.

Referenced by syncWithOriginal().

1086  : ?int
1087  {
1088  return $this->original_id;
1089  }
+ Here is the caller graph for this function:

◆ getOwner()

assQuestion::getOwner ( )

Definition at line 437 of file class.assQuestion.php.

References $owner.

Referenced by saveQuestionDataToDb(), and saveToDb().

437  : int
438  {
439  return $this->owner;
440  }
+ Here is the caller graph for this function:

◆ getPageOfQuestion()

assQuestion::getPageOfQuestion ( )

Definition at line 1075 of file class.assQuestion.php.

1075  : string
1076  {
1077  $page = new ilAssQuestionPage($this->id);
1078  return $page->getXMLContent();
1079  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilAssQuestionPage $page
getXMLContent(bool $a_incl_head=false)
get xml content of page

◆ getPoints()

◆ getPreventRteUsage()

assQuestion::getPreventRteUsage ( )

Definition at line 2245 of file class.assQuestion.php.

References $prevent_rte_usage.

2245  : bool
2246  {
2247  return $this->prevent_rte_usage;
2248  }

◆ getProcessLocker()

◆ getQuestion()

◆ getQuestionAction()

assQuestion::getQuestionAction ( )
protected

Definition at line 222 of file class.assQuestion.php.

Referenced by assFileUpload\isFileDeletionAction().

222  : string
223  {
224  return $this->questionpool_request->getCmdIndex($this->questionActionCmd) ?? '';
225  }
+ Here is the caller graph for this function:

◆ getQuestionForHTMLOutput()

assQuestion::getQuestionForHTMLOutput ( )

Definition at line 1986 of file class.assQuestion.php.

References purifyAndPrepareTextAreaOutput().

1986  : string
1987  {
1988  return $this->purifyAndPrepareTextAreaOutput($this->question);
1989  }
purifyAndPrepareTextAreaOutput(string $content)
+ Here is the call graph for this function:

◆ getQuestionType()

assQuestion::getQuestionType ( )
abstract

Referenced by fromXML(), getQuestionTypeID(), and toXML().

+ Here is the caller graph for this function:

◆ getQuestionTypeID()

assQuestion::getQuestionTypeID ( )

Definition at line 2010 of file class.assQuestion.php.

References getQuestionType().

Referenced by createNewQuestion(), and saveQuestionDataToDb().

2010  : int
2011  {
2012  $result = $this->db->queryF(
2013  "SELECT question_type_id FROM qpl_qst_type WHERE type_tag = %s",
2014  ['text'],
2015  [$this->getQuestionType()]
2016  );
2017  if ($this->db->numRows($result) == 1) {
2018  $row = $this->db->fetchAssoc($result);
2019  return (int) $row["question_type_id"];
2020  }
2021  return 0;
2022  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getReachedPoints()

assQuestion::getReachedPoints ( int  $active_id,
int  $pass 
)

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

References getId().

Referenced by answerToLog(), and ilLOTestQuestionAdapter\updateQuestionResult().

552  : float
553  {
554  return round(self::_getReachedPoints($active_id, $this->getId(), $pass), 2);
555  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assQuestion::getRTETextWithMediaObjects ( )
protected

Definition at line 2062 of file class.assQuestion.php.

References getId(), ilAssQuestionHintList\getListByQuestionId(), and getQuestion().

Referenced by cleanupMediaObjectUsage().

2062  : string
2063  {
2064  // must be called in parent classes. add additional RTE text in the parent
2065  // classes and call this method to add the standard RTE text
2066  $collected = $this->getQuestion();
2067  $collected .= $this->feedbackOBJ->getGenericFeedbackContent($this->getId(), false);
2068  $collected .= $this->feedbackOBJ->getGenericFeedbackContent($this->getId(), true);
2069  $collected .= $this->feedbackOBJ->getAllSpecificAnswerFeedbackContents($this->getId());
2070 
2071  $questionHintList = ilAssQuestionHintList::getListByQuestionId($this->getId());
2072  foreach ($questionHintList as $questionHint) {
2073  /* @var $questionHint ilAssQuestionHint */
2074  $collected .= $questionHint->getText();
2075  }
2076 
2077  return $collected;
2078  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSelfAssessmentEditingMode()

assQuestion::getSelfAssessmentEditingMode ( )

Definition at line 2274 of file class.assQuestion.php.

References $selfassessmenteditingmode.

Referenced by ilAssQuestionAuthoringFormGUI\addGenericAssessmentQuestionCommandButtons().

2274  : bool
2275  {
2277  }
bool $selfassessmenteditingmode
+ Here is the caller graph for this function:

◆ getSelfAssessmentFormatter()

assQuestion::getSelfAssessmentFormatter ( )
protected

Definition at line 2233 of file class.assQuestion.php.

Referenced by formatSAQuestion().

2234  {
2235  return new \ilAssSelfAssessmentQuestionFormatter();
2236  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getShuffle()

◆ getShuffler()

assQuestion::getShuffler ( )

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

References $shuffler.

Referenced by assOrderingHorizontal\getRandomOrderingElements(), assOrderingQuestion\getShuffledOrderingElementList(), assOrderingQuestion\toJSON(), and assMatchingQuestion\toJSON().

238  {
239  return $this->shuffler;
240  }
Transformation $shuffler
A transformation is a function from one datatype to another.
+ Here is the caller graph for this function:

◆ getSolutionForTextOutput()

assQuestion::getSolutionForTextOutput ( int  $active_id,
int  $pass 
)

Definition at line 3064 of file class.assQuestion.php.

References getSolutionValues(), and solutionValuesToText().

3067  : array|string {
3068  return $this->solutionValuesToText(
3069  $this->getSolutionValues($active_id, $pass)
3070  );
3071  }
getSolutionValues(int $active_id, ?int $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
solutionValuesToText(array $solution_values)
MUST convert the given solution values into text.
+ Here is the call graph for this function:

◆ getSolutionMaxPass()

◆ getSolutionRecordById()

assQuestion::getSolutionRecordById ( int  $solutionId)
protected
Returns
array tst_solutions.*

Definition at line 2532 of file class.assQuestion.php.

Referenced by assFileUpload\saveWorkingData().

2532  : array
2533  {
2534  $result = $this->db->queryF(
2535  "SELECT * FROM tst_solutions WHERE solution_id = %s",
2536  ['integer'],
2537  [$solutionId]
2538  );
2539 
2540  if ($this->db->numRows($result) > 0) {
2541  return $this->db->fetchAssoc($result);
2542  }
2543  return [];
2544  }
+ Here is the caller graph for this function:

◆ getSolutionValues()

assQuestion::getSolutionValues ( int  $active_id,
?int  $pass = null,
bool  $authorized = true 
)

Loads solutions of a given user from the database an returns it.

Definition at line 779 of file class.assQuestion.php.

References getId(), getSolutionMaxPass(), getStep(), and null.

Referenced by answerToLog(), assOrderingQuestion\calculateReachedPoints(), assFormulaQuestion\calculateReachedPoints(), deleteDummySolutionRecord(), duplicateIntermediateSolutionAuthorized(), forceExistingIntermediateSolution(), assFormulaQuestion\getCorrectSolutionForTextOutput(), getCorrectSolutionForTextOutput(), assOrderingQuestion\getOrderingElementListForSolutionOutput(), getSolutionForTextOutput(), ilTestCorrectionsGUI\getSolutions(), ilTestCorrectionsGUI\getSolutionsByParticipantResults(), getTestOutputSolutions(), assFileUpload\getUploadedFilesForWeb(), assFileUpload\getUserSolutionPreferingIntermediate(), and getUserSolutionPreferingIntermediate().

783  : array {
784  if ($pass === null && is_numeric($active_id)) {
785  $pass = $this->getSolutionMaxPass((int) $active_id);
786  }
787 
788  if ($this->getStep() !== null) {
789  $query = "
790  SELECT *
791  FROM tst_solutions
792  WHERE active_fi = %s
793  AND question_fi = %s
794  AND pass = %s
795  AND step = %s
796  AND authorized = %s
797  ORDER BY solution_id";
798 
799  $result = $this->db->queryF(
800  $query,
801  ['integer', 'integer', 'integer', 'integer', 'integer'],
802  [(int) $active_id, $this->getId(), $pass, $this->getStep(), (int) $authorized]
803  );
804  } else {
805  $query = "
806  SELECT *
807  FROM tst_solutions
808  WHERE active_fi = %s
809  AND question_fi = %s
810  AND pass = %s
811  AND authorized = %s
812  ORDER BY solution_id
813  ";
814 
815  $result = $this->db->queryF(
816  $query,
817  ['integer', 'integer', 'integer', 'integer'],
818  [(int) $active_id, $this->getId(), $pass, (int) $authorized]
819  );
820  }
821 
822  $values = [];
823 
824  while ($row = $this->db->fetchAssoc($result)) {
825  $values[] = $row;
826  }
827 
828  return $values;
829  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getSolutionMaxPass(int $active_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStep()

◆ getSuggestedSolution()

assQuestion::getSuggestedSolution ( int  $subquestion_index = 0)

Definition at line 1549 of file class.assQuestion.php.

References null.

1550  {
1551  if (array_key_exists($subquestion_index, $this->suggested_solutions)) {
1552  return $this->suggested_solutions[$subquestion_index];
1553  }
1554  return null;
1555  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getSuggestedSolutionOutput()

assQuestion::getSuggestedSolutionOutput ( )

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

References getInternalLinkHref(), getSuggestedSolutionPathWeb(), ILIAS\Repository\lng(), ilLegacyFormElementsUtil\prepareFormOutput(), ilWACSignedPath\setTokenMaxLifetimeInSeconds(), and ilWACSignedPath\signFile().

487  : string
488  {
489  $output = [];
490  foreach ($this->suggested_solutions as $solution) {
491  switch ($solution->getType()) {
492  case SuggestedSolution::TYPE_LM:
493  case SuggestedSolution::TYPE_LM_CHAPTER:
494  case SuggestedSolution::TYPE_LM_PAGE:
495  case SuggestedSolution::TYPE_GLOSARY_TERM:
496  $output[] = '<a href="'
497  . $this->getInternalLinkHref($solution->getInternalLink())
498  . '">'
499  . $this->lng->txt("solution_hint")
500  . '</a>';
501  break;
502 
503  case SuggestedSolution::TYPE_FILE:
504  $possible_texts = array_values(
505  array_filter(
506  [
507  ilLegacyFormElementsUtil::prepareFormOutput($solution->getTitle()),
508  ilLegacyFormElementsUtil::prepareFormOutput($solution->getFilename()),
509  $this->lng->txt('tst_show_solution_suggested')
510  ]
511  )
512  );
513 
515  $output[] = '<a href="'
517  $this->getSuggestedSolutionPathWeb() . $solution->getFilename()
518  )
519  . '">'
520  . $possible_texts[0]
521  . '</a>';
522  break;
523  }
524  }
525  return implode("<br />", $output);
526  }
static prepareFormOutput($a_str, bool $a_strip=false)
static setTokenMaxLifetimeInSeconds(int $token_max_lifetime_in_seconds)
static signFile(string $path_to_file)
getInternalLinkHref(string $target)
+ Here is the call graph for this function:

◆ getSuggestedSolutionPath()

assQuestion::getSuggestedSolutionPath ( )

Definition at line 702 of file class.assQuestion.php.

References CLIENT_WEB_DIR.

Referenced by cloneSuggestedSolutionFiles(), deleteSuggestedSolutions(), and duplicateSuggestedSolutionFiles().

702  : string
703  {
704  return CLIENT_WEB_DIR . "/assessment/$this->obj_id/$this->id/solution/";
705  }
const CLIENT_WEB_DIR
Definition: constants.php:47
+ Here is the caller graph for this function:

◆ getSuggestedSolutionPathWeb()

assQuestion::getSuggestedSolutionPathWeb ( )

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

References CLIENT_WEB_DIR, and ilFileUtils\removeTrailingPathSeparators().

Referenced by getSuggestedSolutionOutput().

724  : string
725  {
727  . "/assessment/{$this->obj_id}/{$this->id}/solution/";
728  return str_replace(
729  ilFileUtils::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH . '/public'),
731  $webdir
732  );
733  }
static removeTrailingPathSeparators(string $path)
const CLIENT_WEB_DIR
Definition: constants.php:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSuggestedSolutions()

assQuestion::getSuggestedSolutions ( )

Definition at line 528 of file class.assQuestion.php.

References $suggested_solutions.

Referenced by copySuggestedSolutions().

528  : array
529  {
531  }
array $suggested_solutions
+ Here is the caller graph for this function:

◆ getSuggestedSolutionsRepo()

assQuestion::getSuggestedSolutionsRepo ( )
protected

Definition at line 2978 of file class.assQuestion.php.

References $suggestedsolution_repo.

Referenced by cloneSuggestedSolutions(), copySuggestedSolutions(), delete(), deleteSuggestedSolutions(), and loadSuggestedSolutions().

+ Here is the caller graph for this function:

◆ getTestId()

assQuestion::getTestId ( )

Definition at line 388 of file class.assQuestion.php.

References $test_id.

Referenced by resetUsersAnswer().

388  : int
389  {
390  return $this->test_id;
391  }
+ Here is the caller graph for this function:

◆ getTestOutputSolutions()

assQuestion::getTestOutputSolutions ( int  $activeId,
int  $pass 
)

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

References getSolutionValues(), getTestPresentationConfig(), and getUserSolutionPreferingIntermediate().

Referenced by assOrderingQuestion\getSolutionOrderingElementListForTestOutput().

754  : array
755  {
756  if ($this->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
757  return $this->getSolutionValues($activeId, $pass, true);
758  }
759  return $this->getUserSolutionPreferingIntermediate($activeId, $pass);
760  }
getSolutionValues(int $active_id, ?int $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
getUserSolutionPreferingIntermediate(int $active_id, ?int $pass=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTestPresentationConfig()

assQuestion::getTestPresentationConfig ( )

Definition at line 2964 of file class.assQuestion.php.

References $test_question_config, buildTestPresentationConfig(), and null.

Referenced by getTestOutputSolutions(), ilTestPlayerAbstractGUI\initTestQuestionConfig(), and assFileUpload\isFileReuseHandlingRequired().

2965  {
2966  if ($this->test_question_config === null) {
2967  $this->test_question_config = $this->buildTestPresentationConfig();
2968  }
2969 
2971  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilTestQuestionConfig $test_question_config
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getThumbSize()

◆ getTitle()

assQuestion::getTitle ( )

Definition at line 363 of file class.assQuestion.php.

References $title.

Referenced by getTitleFilenameCompliant(), assOrderingQuestion\isComplete(), assClozeTest\isComplete(), and saveQuestionDataToDb().

363  : string
364  {
365  return $this->title;
366  }
+ Here is the caller graph for this function:

◆ getTitleFilenameCompliant()

assQuestion::getTitleFilenameCompliant ( )

Definition at line 373 of file class.assQuestion.php.

References ilFileUtils\getASCIIFilename(), and getTitle().

373  : string
374  {
375  return ilFileUtils::getASCIIFilename($this->getTitle());
376  }
static getASCIIFilename(string $a_filename)
+ Here is the call graph for this function:

◆ getTitleForHTMLOutput()

◆ getTotalAnswers()

assQuestion::getTotalAnswers ( )

Definition at line 1005 of file class.assQuestion.php.

1005  : int
1006  {
1007  // get all question references to the question id
1008  $result = $this->db->queryF(
1009  "SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
1010  ['integer','integer'],
1011  [$this->id, $this->id]
1012  );
1013  if ($this->db->numRows($result) == 0) {
1014  return 0;
1015  }
1016  $found_id = [];
1017  while ($row = $this->db->fetchAssoc($result)) {
1018  $found_id[] = $row["question_id"];
1019  }
1020 
1021  $result = $this->db->query("SELECT * FROM tst_test_result WHERE " . $this->db->in('question_fi', $found_id, false, 'integer'));
1022 
1023  return $this->db->numRows($result);
1024  }

◆ getUserSolutionPreferingIntermediate()

assQuestion::getUserSolutionPreferingIntermediate ( int  $active_id,
?int  $pass = null 
)

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

References getSolutionValues().

Referenced by getTestOutputSolutions().

766  : array {
767  $solution = $this->getSolutionValues($active_id, $pass, false);
768 
769  if (!count($solution)) {
770  $solution = $this->getSolutionValues($active_id, $pass, true);
771  }
772 
773  return $solution;
774  }
getSolutionValues(int $active_id, ?int $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidAdditionalContentEditingModes()

assQuestion::getValidAdditionalContentEditingModes ( )

Definition at line 2437 of file class.assQuestion.php.

Referenced by isValidAdditionalContentEditingMode(), and setAdditionalContentEditingMode().

2437  : array
2438  {
2439  return [
2440  self::ADDITIONAL_CONTENT_EDITING_MODE_RTE,
2441  self::ADDITIONAL_CONTENT_EDITING_MODE_IPE
2442  ];
2443  }
+ Here is the caller graph for this function:

◆ getVariablesAsTextArray()

assQuestion::getVariablesAsTextArray ( int  $active_id,
int  $pass 
)

Definition at line 3082 of file class.assQuestion.php.

3085  : array {
3086  return [];
3087  }

◆ hasSpecificFeedback()

assQuestion::hasSpecificFeedback ( )

Definition at line 2145 of file class.assQuestion.php.

2145  : bool
2146  {
2147  return static::HAS_SPECIFIC_FEEDBACK;
2148  }

◆ hasWritableOriginalInQuestionPool()

assQuestion::hasWritableOriginalInQuestionPool ( )

Definition at line 3008 of file class.assQuestion.php.

References instantiateQuestion().

3008  : bool
3009  {
3010  return !is_null($this->original_id)
3011  && $this->questionrepository->questionExistsInPool($this->original_id)
3012  && assQuestion::instantiateQuestion($this->original_id)->isWriteable();
3013  }
static instantiateQuestion(int $question_id)
+ Here is the call graph for this function:

◆ implodeKeyValues()

static assQuestion::implodeKeyValues ( array  $keyValues)
static

Definition at line 2661 of file class.assQuestion.php.

References KEY_VALUES_IMPLOSION_SEPARATOR.

Referenced by assImagemapQuestionGUI\buildSelectionParameter().

2661  : string
2662  {
2663  return implode(assQuestion::KEY_VALUES_IMPLOSION_SEPARATOR, $keyValues);
2664  }
const KEY_VALUES_IMPLOSION_SEPARATOR
+ Here is the caller graph for this function:

◆ importHint()

assQuestion::importHint ( int  $question_id,
array  $hint_array 
)
private

Definition at line 288 of file class.assQuestion.php.

References getAdditionalContentEditingMode().

Referenced by fromXML().

288  : void
289  {
290  $hint = new ilAssQuestionHint();
291  $hint->setQuestionId($question_id);
292  $hint->setIndex($hint_array['index'] ?? '');
293  $hint->setPoints($hint_array['points'] ?? '');
294  if ($this->getAdditionalContentEditingMode() === self::ADDITIONAL_CONTENT_EDITING_MODE_IPE) {
295  $hint->save();
296  $hint_page = (new ilAssHintPage());
297  $hint_page->setParentId($question_id);
298  $hint_page->setId($hint->getId());
299  $hint_page->setXMLContent($hint_array['txt']);
300  $hint_page->createFromXML();
301  return;
302  }
303 
304  $hint->setText($hint_array['txt'] ?? '');
305  $hint->save();
306  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instantiateQuestion()

static assQuestion::instantiateQuestion ( int  $question_id)
static
Parameters
int$question_id
Returns
assQuestion
Exceptions
InvalidArgumentException

Definition at line 1773 of file class.assQuestion.php.

References $DIC, $ilDB, $question, and ILIAS\TestQuestionPool\Questions\GeneralQuestionPropertiesRepository\getForQuestionId().

Referenced by ilObjTest\_instanciateQuestion(), ILIAS\Test\ExportImport\ResultsExportExcel\addUserContent(), ilTestFixedQuestionSetConfig\cloneQuestionSetRelatedData(), ilObjTestGUI\copyAndLinkQuestionsToPoolObject(), ilPCQuestion\copyPoolQuestionIntoPage(), ilObjQuestionPool\deleteQuestion(), ilAssLacQuestionProvider\getQuestion(), ilTestPlayerAbstractGUI\getQuestionInstance(), ILIAS\Test\ExportImport\Export\getQuestionQtiXml(), ilBulkEditQuestionsGUI\getQuestions(), ilTestRandomQuestionSetPoolDeriver\getQuestionsForPool(), ilTestSequence\getSequenceSummary(), ILIAS\Test\Questions\Presentation\QuestionsTableActions\handleCommand(), ilPCQuestion\handleCopiedContent(), hasWritableOriginalInQuestionPool(), ilObjTest\insertQuestion(), ilQuestionPageParser\processPagesToParse(), ilAssIncompleteQuestionPurger\purgeQuestionIds(), ilObjTest\removeQuestionWithResults(), ilTestRandomQuestionSetStagingPoolBuilder\removeStagedQuestions(), ilSoapTestAdministration\saveQuestion(), ilSoapTestAdministration\saveQuestionSolution(), ilTestRandomQuestionSetStagingPoolBuilder\stageQuestionsFromSourcePool(), ilTestRandomQuestionSetStagingPoolBuilder\stageQuestionsFromSourcePoolCheap(), and ilAssQuestionSkillAssignmentsGUI\syncOriginalCmd().

1773  : assQuestion
1774  {
1775  global $DIC;
1776  $ilCtrl = $DIC['ilCtrl'];
1777  $ilDB = $DIC['ilDB'];
1778  $lng = $DIC['lng'];
1779  $questionrepository = QuestionPoolDIC::dic()['question.general_properties.repository'];
1780  $question_type = $questionrepository->getForQuestionId($question_id)?->getClassName() ?? '';
1781  if ($question_type === '') {
1782  throw new InvalidArgumentException('No question with ID ' . $question_id . ' exists');
1783  }
1784 
1785  $question = new $question_type();
1786  $question->loadFromDb($question_id);
1787 
1788  $feedbackObjectClassname = self::getFeedbackClassNameByQuestionType($question_type);
1789  $question->feedbackOBJ = new $feedbackObjectClassname($question, $ilCtrl, $ilDB, $lng);
1790 
1791  return $question;
1792  }
ilLanguage $lng
global $DIC
Definition: shib_login.php:22
GeneralQuestionPropertiesRepository $questionrepository
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ intermediateSolutionExists()

assQuestion::intermediateSolutionExists ( int  $active_id,
int  $pass 
)

Definition at line 2785 of file class.assQuestion.php.

References lookupForExistingSolutions().

Referenced by assFileUpload\saveWorkingData().

2785  : bool
2786  {
2787  $solutionAvailability = $this->lookupForExistingSolutions($active_id, $pass);
2788  return (bool) $solutionAvailability['intermediate'];
2789  }
lookupForExistingSolutions(int $activeId, int $pass)
Lookup if an authorized or intermediate solution exists.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAddableAnswerOptionValue()

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

Definition at line 2861 of file class.assQuestion.php.

2861  : bool
2862  {
2863  return false;
2864  }

◆ isAdditionalContentEditingModePageObject()

assQuestion::isAdditionalContentEditingModePageObject ( )

Definition at line 2423 of file class.assQuestion.php.

References ADDITIONAL_CONTENT_EDITING_MODE_IPE, and getAdditionalContentEditingMode().

Referenced by delete(), duplicateQuestionHints(), assClozeTest\getClozeTextForHTMLOutput(), and purifyAndPrepareTextAreaOutput().

2423  : bool
2424  {
2426  }
const ADDITIONAL_CONTENT_EDITING_MODE_IPE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAnswered()

assQuestion::isAnswered ( int  $active_id,
int  $pass 
)

Definition at line 2377 of file class.assQuestion.php.

References getId(), and getNumExistingSolutionRecords().

2377  : bool
2378  {
2379  $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
2380  return $numExistingSolutionRecords > 0;
2381  }
static getNumExistingSolutionRecords(int $activeId, int $pass, int $questionId)
+ Here is the call graph for this function:

◆ isComplete()

assQuestion::isComplete ( )
abstract

Referenced by saveQuestionDataToDb(), and saveToDb().

+ Here is the caller graph for this function:

◆ isDummySolutionRecord()

assQuestion::isDummySolutionRecord ( array  $solutionRecord)
protected

Definition at line 2680 of file class.assQuestion.php.

Referenced by assFileUpload\calculateReachedPoints().

2680  : bool
2681  {
2682  return !strlen($solutionRecord['value1']) && !strlen($solutionRecord['value2']);
2683  }
+ Here is the caller graph for this function:

◆ isFileAvailable()

static assQuestion::isFileAvailable ( string  $file)
static

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

1026  : bool
1027  {
1028  if (!file_exists($file)) {
1029  return false;
1030  }
1031 
1032  if (!is_file($file)) {
1033  return false;
1034  }
1035 
1036  if (!is_readable($file)) {
1037  return false;
1038  }
1039 
1040  return true;
1041  }

◆ isForcePassResultUpdateEnabled()

static assQuestion::isForcePassResultUpdateEnabled ( )
static

Definition at line 217 of file class.assQuestion.php.

217  : bool
218  {
219  return self::$force_pass_results_update_enabled;
220  }

◆ isNonEmptyItemListPostSubmission()

assQuestion::isNonEmptyItemListPostSubmission ( string  $post_submission_field_name)
protected

Definition at line 227 of file class.assQuestion.php.

Referenced by assFileUpload\isFileDeletionSubmitAvailable(), and assFileUpload\isFileReuseSubmitAvailable().

227  : bool
228  {
229  return !empty($this->questionpool_request->strArray($post_submission_field_name));
230  }
+ Here is the caller graph for this function:

◆ isPreviewSolutionCorrect()

assQuestion::isPreviewSolutionCorrect ( ilAssQuestionPreviewSession  $preview_session)

Definition at line 1860 of file class.assQuestion.php.

References calculateReachedPointsFromPreviewSession(), and getMaximumPoints().

1860  : bool
1861  {
1862  $reached_points = $this->calculateReachedPointsFromPreviewSession($preview_session);
1863 
1864  return !($reached_points < $this->getMaximumPoints());
1865  }
calculateReachedPointsFromPreviewSession(ilAssQuestionPreviewSession $preview_session)
+ Here is the call graph for this function:

◆ isValidAdditionalContentEditingMode()

assQuestion::isValidAdditionalContentEditingMode ( string  $additionalContentEditingMode)

Definition at line 2428 of file class.assQuestion.php.

References getValidAdditionalContentEditingModes().

2428  : bool
2429  {
2431  return true;
2432  }
2433 
2434  return false;
2435  }
getValidAdditionalContentEditingModes()
string $additionalContentEditingMode
+ Here is the call graph for this function:

◆ isWriteable()

assQuestion::isWriteable ( )

Definition at line 1833 of file class.assQuestion.php.

References ilObjQuestionPool\_isWriteable(), getCurrentUser(), getId(), and getObjId().

1833  : bool
1834  {
1835  return ilObjQuestionPool::_isWriteable($this->getObjId(), $this->getCurrentUser()->getId());
1836  }
static _isWriteable($object_id, $user_id)
Returns true, if the question pool is writeable by a given user.
+ Here is the call graph for this function:

◆ lmMigrateQuestionTypeGenericContent()

assQuestion::lmMigrateQuestionTypeGenericContent ( ilAssSelfAssessmentMigrator  $migrator)
protected

Definition at line 2259 of file class.assQuestion.php.

References ilAssSelfAssessmentMigrator\migrateToLmContent(), and setQuestion().

Referenced by migrateContentForLearningModule().

2259  : void
2260  {
2261  $this->setQuestion($migrator->migrateToLmContent($this->getQuestion()));
2262  }
setQuestion(string $question="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lmMigrateQuestionTypeSpecificContent()

assQuestion::lmMigrateQuestionTypeSpecificContent ( ilAssSelfAssessmentMigrator  $migrator)
protected

Definition at line 2264 of file class.assQuestion.php.

Referenced by migrateContentForLearningModule().

2264  : void
2265  {
2266  // overwrite if any question type specific content except feedback needs to be migrated
2267  }
+ Here is the caller graph for this function:

◆ loadFromDb()

assQuestion::loadFromDb ( int  $question_id)

Definition at line 1144 of file class.assQuestion.php.

References $data, and loadSuggestedSolutions().

1144  : void
1145  {
1146  $result = $this->db->queryF(
1147  'SELECT external_id FROM qpl_questions WHERE question_id = %s',
1148  ['integer'],
1149  [$question_id]
1150  );
1151  if ($this->db->numRows($result) === 1) {
1152  $data = $this->db->fetchAssoc($result);
1153  $this->external_id = $data['external_id'];
1154  }
1155 
1157  $this->suggested_solutions = [];
1158  if ($suggested_solutions) {
1159  foreach ($suggested_solutions as $solution) {
1160  $this->suggested_solutions[$solution->getSubquestionIndex()] = $solution;
1161  }
1162  }
1163  }
array $suggested_solutions
+ Here is the call graph for this function:

◆ loadSuggestedSolutions()

assQuestion::loadSuggestedSolutions ( )
protected

Definition at line 2983 of file class.assQuestion.php.

References getId(), and getSuggestedSolutionsRepo().

Referenced by loadFromDb().

2983  : array
2984  {
2985  $question_id = $this->getId();
2986  return $this->getSuggestedSolutionsRepo()->selectFor($question_id);
2987  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupForExistingSolutions()

assQuestion::lookupForExistingSolutions ( int  $activeId,
int  $pass 
)

Lookup if an authorized or intermediate solution exists.

Returns
array ['authorized' => bool, 'intermediate' => bool]

Definition at line 2825 of file class.assQuestion.php.

References getId(), getStep(), and null.

Referenced by authorizedOrIntermediateSolutionExists(), authorizedSolutionExists(), calculateResultsFromSolution(), and intermediateSolutionExists().

2825  : array
2826  {
2827  $return = [
2828  'authorized' => false,
2829  'intermediate' => false
2830  ];
2831 
2832  $query = "
2833  SELECT authorized, COUNT(*) cnt
2834  FROM tst_solutions
2835  WHERE active_fi = %s
2836  AND question_fi = %s
2837  AND pass = %s
2838  ";
2839 
2840  if ($this->getStep() !== null) {
2841  $query .= " AND step = " . $this->db->quote((int) $this->getStep(), 'integer') . " ";
2842  }
2843 
2844  $query .= "
2845  GROUP BY authorized
2846  ";
2847 
2848  $result = $this->db->queryF($query, ['integer', 'integer', 'integer'], [$activeId, $this->getId(), $pass]);
2849 
2850  while ($row = $this->db->fetchAssoc($result)) {
2851  if ($row['authorized']) {
2852  $return['authorized'] = $row['cnt'] > 0;
2853  } else {
2854  $return['intermediate'] = $row['cnt'] > 0;
2855  }
2856  }
2857  return $return;
2858  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupMaxStep()

assQuestion::lookupMaxStep ( int  $active_id,
int  $pass 
)
protected

Definition at line 2807 of file class.assQuestion.php.

References getId().

Referenced by assNumeric\getUserQuestionResult(), assOrderingHorizontal\getUserQuestionResult(), assTextSubset\getUserQuestionResult(), assSingleChoice\getUserQuestionResult(), assMultipleChoice\getUserQuestionResult(), assOrderingQuestion\getUserQuestionResult(), assFormulaQuestion\getUserQuestionResult(), assMatchingQuestion\getUserQuestionResult(), and assClozeTest\getUserQuestionResult().

2807  : int
2808  {
2809  $result = $this->db->queryF(
2810  "SELECT MAX(step) max_step FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
2811  ["integer", "integer", "integer"],
2812  [$active_id, $pass, $this->getId()]
2813  );
2814 
2815  $row = $this->db->fetchAssoc($result);
2816 
2817  return (int) $row['max_step'];
2818  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupParentObjId()

static assQuestion::lookupParentObjId ( int  $question_id)
static

Definition at line 2291 of file class.assQuestion.php.

References $DIC, $ilDB, $res, and null.

Referenced by ILIAS\Test\Questions\Presentation\QuestionsTableActions\checkQuestionParametersForCopyToPool(), and ilAssQuestionSkillAssignmentsGUI\isSyncOriginalPossibleAndAllowed().

2291  : ?int
2292  {
2293  global $DIC;
2294  $ilDB = $DIC['ilDB'];
2295 
2296  $query = "SELECT obj_fi FROM qpl_questions WHERE question_id = %s";
2297 
2298  $res = $ilDB->queryF($query, ['integer'], [$question_id]);
2299  $row = $ilDB->fetchAssoc($res);
2300 
2301  return $row['obj_fi'] ?? null;
2302  }
$res
Definition: ltiservices.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ migrateContentForLearningModule()

assQuestion::migrateContentForLearningModule ( ilAssSelfAssessmentMigrator  $migrator)

Definition at line 2250 of file class.assQuestion.php.

References getId(), lmMigrateQuestionTypeGenericContent(), lmMigrateQuestionTypeSpecificContent(), and saveToDb().

Referenced by ilAssSelfAssessmentQuestionFormatter\prepareQuestionForLearningModule().

2250  : void
2251  {
2252  $this->lmMigrateQuestionTypeGenericContent($migrator);
2253  $this->lmMigrateQuestionTypeSpecificContent($migrator);
2254  $this->saveToDb();
2255 
2256  $this->feedbackOBJ->migrateContentForLearningModule($migrator, $this->getId());
2257  }
lmMigrateQuestionTypeSpecificContent(ilAssSelfAssessmentMigrator $migrator)
saveToDb(?int $original_id=null)
lmMigrateQuestionTypeGenericContent(ilAssSelfAssessmentMigrator $migrator)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onCopy()

assQuestion::onCopy ( int  $sourceParentId,
int  $sourceQuestionId,
int  $targetParentId,
int  $targetQuestionId 
)
protected

Definition at line 1463 of file class.assQuestion.php.

References copySuggestedSolutions(), duplicateComments(), duplicateQuestionHints(), duplicateSkillAssignments(), and duplicateSuggestedSolutionFiles().

1463  : void
1464  {
1465  $this->copySuggestedSolutions($targetQuestionId);
1466  $this->duplicateSuggestedSolutionFiles($sourceParentId, $sourceQuestionId);
1467  $this->feedbackOBJ->duplicateFeedback($sourceQuestionId, $targetQuestionId);
1468  $this->duplicateQuestionHints($sourceQuestionId, $targetQuestionId);
1469  $this->duplicateSkillAssignments($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId);
1470  $this->duplicateComments($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId);
1471  }
duplicateSkillAssignments(int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
duplicateQuestionHints(int $original_question_id, int $duplicate_question_id)
duplicateComments(int $parent_source_id, int $source_id, int $parent_target_id, int $target_id)
duplicateSuggestedSolutionFiles(int $parent_id, int $question_id)
Duplicates the files of a suggested solution if the question is duplicated.
copySuggestedSolutions(int $target_question_id)
+ Here is the call graph for this function:

◆ onDuplicate()

assQuestion::onDuplicate ( int  $original_parent_id,
int  $original_question_id,
int  $duplicate_parent_id,
int  $duplicate_question_id 
)
protected

Definition at line 1440 of file class.assQuestion.php.

References cloneSuggestedSolutionFiles(), copySuggestedSolutions(), duplicateComments(), duplicateQuestionHints(), and duplicateSkillAssignments().

1445  : void {
1446  $this->copySuggestedSolutions($duplicate_question_id);
1447  $this->cloneSuggestedSolutionFiles($original_parent_id, $original_question_id);
1448  $this->feedbackOBJ->duplicateFeedback($original_question_id, $duplicate_question_id);
1449  $this->duplicateQuestionHints($original_question_id, $duplicate_question_id);
1450  $this->duplicateSkillAssignments($original_parent_id, $original_question_id, $duplicate_parent_id, $duplicate_question_id);
1451  $this->duplicateComments($original_parent_id, $original_question_id, $duplicate_parent_id, $duplicate_question_id);
1452  }
cloneSuggestedSolutionFiles(int $source_question_id, int $target_question_id)
duplicateSkillAssignments(int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
duplicateQuestionHints(int $original_question_id, int $duplicate_question_id)
duplicateComments(int $parent_source_id, int $source_id, int $parent_target_id, int $target_id)
copySuggestedSolutions(int $target_question_id)
+ Here is the call graph for this function:

◆ persistPreviewState()

assQuestion::persistPreviewState ( ilAssQuestionPreviewSession  $preview_session)
final

persists the preview state for current user and question

Definition at line 686 of file class.assQuestion.php.

References savePreviewData(), and validateSolutionSubmit().

686  : bool
687  {
688  $this->savePreviewData($preview_session);
689  return $this->validateSolutionSubmit();
690  }
savePreviewData(ilAssQuestionPreviewSession $preview_session)
+ Here is the call graph for this function:

◆ persistWorkingState()

assQuestion::persistWorkingState ( int  $active_id,
  $pass,
bool  $authorized = true 
)
final

persists the working state for current testactive and testpass

Returns
bool if saving happened

Definition at line 656 of file class.assQuestion.php.

References ilObjTest\_getPass(), calculateResultsFromSolution(), getProcessLocker(), null, removeIntermediateSolution(), saveWorkingData(), and validateSolutionSubmit().

Referenced by ilTestPlayerAbstractGUI\save().

656  : bool
657  {
658  if (!$this instanceof QuestionPartiallySaveable && !$this->validateSolutionSubmit()) {
659  return false;
660  }
661 
662  $saveStatus = false;
663 
664  $this->getProcessLocker()->executePersistWorkingStateLockOperation(function () use ($active_id, $pass, $authorized, &$saveStatus) {
665  if ($pass === null) {
666  $pass = ilObjTest::_getPass($active_id);
667  }
668 
669  $saveStatus = $this->saveWorkingData($active_id, $pass, $authorized);
670 
671  if ($authorized) {
672  // fau: testNav - remove an intermediate solution if the authorized solution is saved
673  // the intermediate solution would set the displayed question status as "editing ..."
674  $this->removeIntermediateSolution($active_id, $pass);
675  // fau.
676  $this->calculateResultsFromSolution($active_id, $pass);
677  }
678  });
679 
680  return $saveStatus;
681  }
calculateResultsFromSolution(int $active_id, int $pass)
Calculates the question results from a previously saved question solution.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
removeIntermediateSolution(int $active_id, int $pass)
saveWorkingData(int $active_id, ?int $pass=null, bool $authorized=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ purifyAndPrepareTextAreaOutput()

assQuestion::purifyAndPrepareTextAreaOutput ( string  $content)
protected

Definition at line 1991 of file class.assQuestion.php.

References getHtmlQuestionContentPurifier(), isAdditionalContentEditingModePageObject(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

Referenced by getQuestionForHTMLOutput(), and assFormulaQuestion\substituteVariables().

1991  : string
1992  {
1993  $purified_content = $this->getHtmlQuestionContentPurifier()->purify($content);
1995  || !(new ilSetting('advanced_editing'))->get('advanced_editing_javascript_editor') === 'tinymce') {
1996  $purified_content = nl2br($purified_content);
1997  }
1999  $purified_content,
2000  true,
2001  true
2002  );
2003  }
isAdditionalContentEditingModePageObject()
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAllExistingSolutions()

assQuestion::removeAllExistingSolutions ( )

Definition at line 2870 of file class.assQuestion.php.

References getId().

2870  : void
2871  {
2872  $query = "DELETE FROM tst_solutions WHERE question_fi = %s";
2873  $this->db->manipulateF($query, ['integer'], [$this->getId()]);
2874  }
+ Here is the call graph for this function:

◆ removeAllImageFiles()

assQuestion::removeAllImageFiles ( string  $image_target_path)
protected

Definition at line 1399 of file class.assQuestion.php.

Referenced by assOrderingQuestion\cloneImages(), assMatchingQuestion\cloneImages(), and assImagemapQuestion\copyImagemapFiles().

1399  : void
1400  {
1401  $target = opendir($image_target_path);
1402  while ($target_file = readdir($target)) {
1403  if ($target_file === '.' || $target_file === '..') {
1404  continue;
1405  }
1406  copy(
1407  $image_target_path . DIRECTORY_SEPARATOR . $target_file,
1408  $image_target_path . DIRECTORY_SEPARATOR . $target_file
1409  );
1410  }
1411  }
+ Here is the caller graph for this function:

◆ removeCurrentSolution()

assQuestion::removeCurrentSolution ( int  $active_id,
int  $pass,
bool  $authorized = true 
)
Returns
int Affected rows

Definition at line 2557 of file class.assQuestion.php.

References getId(), getStep(), and null.

Referenced by removeIntermediateSolution(), assOrderingHorizontal\saveWorkingData(), assErrorText\saveWorkingData(), assTextSubset\saveWorkingData(), assKprimChoice\saveWorkingData(), assTextQuestion\saveWorkingData(), assMultipleChoice\saveWorkingData(), assLongMenu\saveWorkingData(), assFileUpload\saveWorkingData(), assOrderingQuestion\saveWorkingData(), assMatchingQuestion\saveWorkingData(), and assClozeTest\saveWorkingData().

2557  : int
2558  {
2559  if ($this->getStep() !== null) {
2560  $query = '
2561  DELETE FROM tst_solutions
2562  WHERE active_fi = %s
2563  AND question_fi = %s
2564  AND pass = %s
2565  AND step = %s
2566  AND authorized = %s
2567  ';
2568 
2569  return $this->db->manipulateF(
2570  $query,
2571  ['integer', 'integer', 'integer', 'integer', 'integer'],
2572  [$active_id, $this->getId(), $pass, $this->getStep(), (int) $authorized]
2573  );
2574  }
2575 
2576  $query = "
2577  DELETE FROM tst_solutions
2578  WHERE active_fi = %s
2579  AND question_fi = %s
2580  AND pass = %s
2581  AND authorized = %s
2582  ";
2583 
2584  return $this->db->manipulateF(
2585  $query,
2586  ['integer', 'integer', 'integer', 'integer'],
2587  [$active_id, $this->getId(), $pass, (int) $authorized]
2588  );
2589  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeExistingSolutions()

assQuestion::removeExistingSolutions ( int  $activeId,
int  $pass 
)

Definition at line 2876 of file class.assQuestion.php.

References getId(), getStep(), and null.

Referenced by resetUsersAnswer().

2876  : int
2877  {
2878  $query = "
2879  DELETE FROM tst_solutions
2880  WHERE active_fi = %s
2881  AND question_fi = %s
2882  AND pass = %s
2883  ";
2884 
2885  if ($this->getStep() !== null) {
2886  $query .= " AND step = " . $this->db->quote((int) $this->getStep(), 'integer') . " ";
2887  }
2888 
2889  return $this->db->manipulateF(
2890  $query,
2891  ['integer', 'integer', 'integer'],
2892  [$activeId, $this->getId(), $pass]
2893  );
2894  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeIntermediateSolution()

assQuestion::removeIntermediateSolution ( int  $active_id,
int  $pass 
)

Definition at line 2547 of file class.assQuestion.php.

References getProcessLocker(), and removeCurrentSolution().

Referenced by persistWorkingState().

2547  : void
2548  {
2549  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use ($active_id, $pass) {
2550  $this->removeCurrentSolution($active_id, $pass, false);
2551  });
2552  }
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeResultRecord()

assQuestion::removeResultRecord ( int  $activeId,
int  $pass 
)

Definition at line 2913 of file class.assQuestion.php.

References getId(), getStep(), and null.

Referenced by resetUsersAnswer().

2913  : int
2914  {
2915  $query = "
2916  DELETE FROM tst_test_result
2917  WHERE active_fi = %s
2918  AND question_fi = %s
2919  AND pass = %s
2920  ";
2921 
2922  if ($this->getStep() !== null) {
2923  $query .= " AND step = " . $this->db->quote((int) $this->getStep(), 'integer') . " ";
2924  }
2925 
2926  return $this->db->manipulateF(
2927  $query,
2928  ['integer', 'integer', 'integer'],
2929  [$activeId, $this->getId(), $pass]
2930  );
2931  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeSolutionRecordById()

assQuestion::removeSolutionRecordById ( int  $solutionId)
protected

Definition at line 2519 of file class.assQuestion.php.

Referenced by deleteDummySolutionRecord(), assNumeric\saveWorkingData(), and assSingleChoice\saveWorkingData().

2519  : int
2520  {
2521  return $this->db->manipulateF(
2522  "DELETE FROM tst_solutions WHERE solution_id = %s",
2523  ['integer'],
2524  [$solutionId]
2525  );
2526  }
+ Here is the caller graph for this function:

◆ resetOriginalId()

static assQuestion::resetOriginalId ( int  $questionId)
static

Definition at line 1426 of file class.assQuestion.php.

References $DIC, and $ilDB.

Referenced by ilTestRandomQuestionSetPoolDeriver\updateTestQuestionStage().

1426  : void
1427  {
1428  global $DIC;
1429  $ilDB = $DIC->database();
1430 
1431  $query = "UPDATE qpl_questions SET tstamp = %s, original_id = NULL WHERE question_id = %s";
1432 
1433  $ilDB->manipulateF(
1434  $query,
1435  ['integer', 'text'],
1436  [time(), $questionId]
1437  );
1438  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ resetUsersAnswer()

assQuestion::resetUsersAnswer ( int  $activeId,
int  $pass 
)

Definition at line 2896 of file class.assQuestion.php.

References getProcessLocker(), getTestId(), removeExistingSolutions(), and removeResultRecord().

2896  : void
2897  {
2898  $this->removeExistingSolutions($activeId, $pass);
2899  $this->removeResultRecord($activeId, $pass);
2900 
2901  $test = new ilObjTest(
2902  $this->test_id,
2903  false
2904  );
2905  $test->updateTestPassResults(
2906  $activeId,
2907  $pass,
2908  $this->getProcessLocker(),
2909  $this->getTestId()
2910  );
2911  }
removeResultRecord(int $activeId, int $pass)
removeExistingSolutions(int $activeId, int $pass)
+ Here is the call graph for this function:

◆ resolveInternalLink()

assQuestion::resolveInternalLink ( string  $internal_link)

Definition at line 1628 of file class.assQuestion.php.

References ilInternalLink\_getIdForImportId(), ilLMObject\_getIdForImportId(), and null.

Referenced by resolveSuggestedSolutionLinks().

1628  : string
1629  {
1630  if (preg_match("/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches) === false) {
1631  return $internal_link;
1632  }
1633  switch ($matches[2]) {
1634  case "lm":
1635  $resolved_link = ilLMObject::_getIdForImportId($internal_link);
1636  break;
1637  case "pg":
1638  $resolved_link = ilInternalLink::_getIdForImportId("PageObject", $internal_link);
1639  break;
1640  case "st":
1641  $resolved_link = ilInternalLink::_getIdForImportId("StructureObject", $internal_link);
1642  break;
1643  case "git":
1644  $resolved_link = ilInternalLink::_getIdForImportId("GlossaryItem", $internal_link);
1645  break;
1646  case "mob":
1647  $resolved_link = ilInternalLink::_getIdForImportId("MediaObject", $internal_link);
1648  break;
1649  }
1650  if ($resolved_link === null) {
1651  return "il__{$matches[2]}_{$matches[3]}";
1652  }
1653  return $internal_link;
1654  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getIdForImportId(string $a_import_id)
get current object id for import id (static)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resolveSuggestedSolutionLinks()

assQuestion::resolveSuggestedSolutionLinks ( )

Definition at line 1659 of file class.assQuestion.php.

References ilInternalLink\_deleteAllLinksOfSource(), ilInternalLink\_saveLink(), getId(), and resolveInternalLink().

1659  : void
1660  {
1661  $resolvedlinks = 0;
1662  $result_pre = $this->db->queryF(
1663  "SELECT internal_link, suggested_solution_id FROM qpl_sol_sug WHERE question_fi = %s",
1664  ['integer'],
1665  [$this->getId()]
1666  );
1667  if ($this->db->numRows($result_pre) < 1) {
1668  return;
1669  }
1670 
1671  while ($row = $this->db->fetchAssoc($result_pre)) {
1672  $internal_link = $row["internal_link"];
1673  $resolved_link = $this->resolveInternalLink($internal_link);
1674  if ($internal_link === $resolved_link) {
1675  continue;
1676  }
1677  // internal link was resolved successfully
1678  $this->db->manipulateF(
1679  "UPDATE qpl_sol_sug SET internal_link = %s WHERE suggested_solution_id = %s",
1680  ['text','integer'],
1681  [$resolved_link, $row["suggested_solution_id"]]
1682  );
1683  $resolvedlinks++;
1684  }
1685  if ($resolvedlinks === 0) {
1686  return;
1687  }
1688 
1690 
1691  $result_post = $this->db->queryF(
1692  "SELECT internal_link FROM qpl_sol_sug WHERE question_fi = %s",
1693  ['integer'],
1694  [$this->getId()]
1695  );
1696  if ($this->db->numRows($result_post) < 1) {
1697  return;
1698  }
1699 
1700  while ($row = $this->db->fetchAssoc($result_post)) {
1701  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $row["internal_link"], $matches)) {
1702  ilInternalLink::_saveLink("qst", $this->getId(), $matches[2], $matches[3], $matches[1]);
1703  }
1704  }
1705  }
resolveInternalLink(string $internal_link)
+ Here is the call graph for this function:

◆ saveCurrentSolution()

assQuestion::saveCurrentSolution ( int  $active_id,
int  $pass,
  $value1,
  $value2,
bool  $authorized = true,
  $tstamp = 0 
)

Definition at line 2592 of file class.assQuestion.php.

References getId(), getStep(), ILIAS\Repository\int(), and null.

Referenced by duplicateIntermediateSolutionAuthorized(), forceExistingIntermediateSolution(), assOrderingHorizontal\saveWorkingData(), assNumeric\saveWorkingData(), assErrorText\saveWorkingData(), assSingleChoice\saveWorkingData(), assTextSubset\saveWorkingData(), assKprimChoice\saveWorkingData(), assTextQuestion\saveWorkingData(), assMultipleChoice\saveWorkingData(), assFileUpload\saveWorkingData(), assLongMenu\saveWorkingData(), assOrderingQuestion\saveWorkingData(), assMatchingQuestion\saveWorkingData(), and assClozeTest\saveWorkingData().

2592  : int
2593  {
2594  $next_id = $this->db->nextId("tst_solutions");
2595 
2596  $fieldData = [
2597  "solution_id" => ["integer", $next_id],
2598  "active_fi" => ["integer", $active_id],
2599  "question_fi" => ["integer", $this->getId()],
2600  "value1" => ["clob", $value1],
2601  "value2" => ["clob", $value2],
2602  "pass" => ["integer", $pass],
2603  "tstamp" => ["integer", ((int) $tstamp > 0) ? (int) $tstamp : time()],
2604  'authorized' => ['integer', (int) $authorized]
2605  ];
2606 
2607  if ($this->getStep() !== null) {
2608  $fieldData['step'] = ["integer", $this->getStep()];
2609  }
2610 
2611  return $this->db->insert("tst_solutions", $fieldData);
2612  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveOriginalId()

static assQuestion::saveOriginalId ( int  $questionId,
int  $originalId 
)
static

Definition at line 1413 of file class.assQuestion.php.

References $DIC, and $ilDB.

Referenced by ilObjTestGUI\copyAndLinkQuestionsToPoolObject(), ilObjTestGUI\executeAfterQuestionCreationTasks(), and ilTestRandomQuestionSetPoolDeriver\updateTestQuestionStage().

1413  : void
1414  {
1415  global $DIC;
1416  $ilDB = $DIC->database();
1417  $query = "UPDATE qpl_questions SET tstamp = %s, original_id = %s WHERE question_id = %s";
1418 
1419  $ilDB->manipulateF(
1420  $query,
1421  ['integer','integer', 'text'],
1422  [time(), $originalId, $questionId]
1423  );
1424  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ savePreviewData()

assQuestion::savePreviewData ( ilAssQuestionPreviewSession  $preview_session)
protected

Definition at line 697 of file class.assQuestion.php.

References ilAssQuestionPreviewSession\setParticipantsSolution().

Referenced by persistPreviewState().

697  : void
698  {
699  $preview_session->setParticipantsSolution($this->getSolutionSubmit());
700  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveQuestionDataToDb()

assQuestion::saveQuestionDataToDb ( ?int  $original_id = null)

Definition at line 1222 of file class.assQuestion.php.

References ilRTE\_replaceMediaObjectImageSrc(), createPageObject(), getAdditionalContentEditingMode(), getAuthor(), getComment(), getExternalId(), getId(), getMaximumPoints(), getNrOfTries(), getObjId(), getOwner(), getQuestion(), getQuestionTypeID(), getTitle(), isComplete(), and setId().

Referenced by assNumeric\saveToDb(), assTextSubset\saveToDb(), assErrorText\saveToDb(), assOrderingHorizontal\saveToDb(), assSingleChoice\saveToDb(), assMultipleChoice\saveToDb(), assOrderingQuestion\saveToDb(), assTextQuestion\saveToDb(), assFileUpload\saveToDb(), assMatchingQuestion\saveToDb(), assImagemapQuestion\saveToDb(), assLongMenu\saveToDb(), assClozeTest\saveToDb(), assKprimChoice\saveToDb(), and assFormulaQuestion\saveToDb().

1222  : void
1223  {
1224  if ($this->getId() === -1) {
1225  $next_id = $this->db->nextId('qpl_questions');
1226  $this->db->insert("qpl_questions", [
1227  "question_id" => ["integer", $next_id],
1228  "question_type_fi" => ["integer", $this->getQuestionTypeID()],
1229  "obj_fi" => ["integer", $this->getObjId()],
1230  "title" => ["text", mb_substr($this->getTitle(), 0, 124)],
1231  "description" => ["text", mb_substr($this->getComment(), 0, 1000)],
1232  "author" => ["text", mb_substr($this->getAuthor(), 0, 512)],
1233  "owner" => ["integer", $this->getOwner()],
1234  "question_text" => ["clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestion(), 0)],
1235  "points" => ["float", $this->getMaximumPoints()],
1236  "nr_of_tries" => ["integer", $this->getNrOfTries()],
1237  "created" => ["integer", time()],
1238  "original_id" => ["integer", $original_id],
1239  "tstamp" => ["integer", time()],
1240  "external_id" => ["text", $this->getExternalId()],
1241  'add_cont_edit_mode' => ['text', $this->getAdditionalContentEditingMode()]
1242  ]);
1243  $this->setId($next_id);
1244  // create page object of question
1245  $this->createPageObject();
1246  return;
1247  }
1248 
1249  // Vorhandenen Datensatz aktualisieren
1250  $this->db->update("qpl_questions", [
1251  "obj_fi" => ["integer", $this->getObjId()],
1252  "title" => ["text", mb_substr($this->getTitle(), 0, 124)],
1253  "description" => ["text", mb_substr($this->getComment(), 0, 1000)],
1254  "author" => ["text", mb_substr($this->getAuthor(), 0, 512)],
1255  "question_text" => ["clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestion(), 0)],
1256  "points" => ["float", $this->getMaximumPoints()],
1257  "nr_of_tries" => ["integer", $this->getNrOfTries()],
1258  "tstamp" => ["integer", time()],
1259  'complete' => ['integer', $this->isComplete()],
1260  "external_id" => ["text", $this->getExternalId()]
1261  ], [
1262  "question_id" => ["integer", $this->getId()]
1263  ]);
1264  }
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...
setId(int $id=-1)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

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

Definition at line 1373 of file class.assQuestion.php.

References ilObjQuestionPool\_updateQuestionCount(), cleanupMediaObjectUsage(), getId(), getLifecycle(), getObjId(), getOwner(), and isComplete().

Referenced by migrateContentForLearningModule().

1373  : void
1374  {
1375  // remove unused media objects from ILIAS
1376  $this->cleanupMediaObjectUsage();
1377 
1378  $complete = "0";
1379  if ($this->isComplete()) {
1380  $complete = "1";
1381  }
1382 
1383  $this->db->update(
1384  'qpl_questions',
1385  [
1386  'tstamp' => ['integer', time()],
1387  'owner' => ['integer', $this->getOwner()],
1388  'complete' => ['integer', $complete],
1389  'lifecycle' => ['text', $this->getLifecycle()->getIdentifier()],
1390  ],
1391  [
1392  'question_id' => ['integer', $this->getId()]
1393  ]
1394  );
1395 
1397  }
static _updateQuestionCount(int $object_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveWorkingData()

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

Referenced by persistWorkingState().

+ Here is the caller graph for this function:

◆ setAdditionalContentEditingMode()

assQuestion::setAdditionalContentEditingMode ( ?string  $additionalContentEditingMode)

◆ setAuthor()

◆ setComment()

◆ setDefaultNrOfTries()

assQuestion::setDefaultNrOfTries ( int  $defaultnroftries)

Definition at line 2279 of file class.assQuestion.php.

References $defaultnroftries.

2279  : void
2280  {
2281  $this->defaultnroftries = $defaultnroftries;
2282  }

◆ setExportImagePath()

assQuestion::setExportImagePath ( string  $path)

Definition at line 2206 of file class.assQuestion.php.

References $path.

2206  : void
2207  {
2208  $this->export_image_path = $path;
2209  }
$path
Definition: ltiservices.php:29

◆ setExternalId()

assQuestion::setExternalId ( ?string  $external_id)

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

References $external_id.

462  : void
463  {
464  $this->external_id = $external_id;
465  }

◆ setForcePassResultUpdateEnabled()

static assQuestion::setForcePassResultUpdateEnabled ( bool  $force_pass_results_update_enabled)
static

Definition at line 212 of file class.assQuestion.php.

References $force_pass_results_update_enabled.

212  : void
213  {
214  self::$force_pass_results_update_enabled = $force_pass_results_update_enabled;
215  }
static $force_pass_results_update_enabled

◆ setId()

◆ setLastChange()

assQuestion::setLastChange ( int  $lastChange)

Definition at line 2473 of file class.assQuestion.php.

References $lastChange.

Referenced by assKprimChoice\loadFromDb().

2473  : void
2474  {
2475  $this->lastChange = $lastChange;
2476  }
+ Here is the caller graph for this function:

◆ setLifecycle()

◆ setNrOfTries()

◆ setObjId()

◆ setOriginalId()

◆ setOwner()

◆ setPoints()

◆ setPreventRteUsage()

assQuestion::setPreventRteUsage ( bool  $prevent_rte_usage)

Definition at line 2240 of file class.assQuestion.php.

References $prevent_rte_usage.

2240  : void
2241  {
2242  $this->prevent_rte_usage = $prevent_rte_usage;
2243  }

◆ setProcessLocker()

assQuestion::setProcessLocker ( ilAssQuestionProcessLocker  $processLocker)

Definition at line 247 of file class.assQuestion.php.

References $processLocker.

247  : void
248  {
249  $this->processLocker = $processLocker;
250  }
ilAssQuestionProcessLocker $processLocker

◆ setQuestion()

◆ setSelfAssessmentEditingMode()

assQuestion::setSelfAssessmentEditingMode ( bool  $selfassessmenteditingmode)

Definition at line 2269 of file class.assQuestion.php.

References $selfassessmenteditingmode.

2269  : void
2270  {
2271  $this->selfassessmenteditingmode = $selfassessmenteditingmode;
2272  }
bool $selfassessmenteditingmode

◆ setShuffle()

assQuestion::setShuffle ( ?bool  $shuffle = true)

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

Referenced by assSingleChoice\loadFromDb(), assMultipleChoice\loadFromDb(), and assTextQuestion\loadFromDb().

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

◆ setShuffler()

assQuestion::setShuffler ( Transformation  $shuffler)

Definition at line 242 of file class.assQuestion.php.

References $shuffler.

Referenced by assMatchingQuestion\toJSON().

242  : void
243  {
244  $this->shuffler = $shuffler;
245  }
Transformation $shuffler
+ Here is the caller graph for this function:

◆ setStep()

assQuestion::setStep (   $step)
Parameters
int | null$step

Definition at line 2754 of file class.assQuestion.php.

References $step.

Referenced by assFileUpload\getUploadedFilesForWeb().

2754  : void
2755  {
2756  $this->step = $step;
2757  }
+ Here is the caller graph for this function:

◆ setTestId()

assQuestion::setTestId ( int  $id = -1)

Definition at line 335 of file class.assQuestion.php.

References $id.

335  : void
336  {
337  $this->test_id = $id;
338  }

◆ setThumbSize()

assQuestion::setThumbSize ( int  $a_size)

Definition at line 408 of file class.assQuestion.php.

Referenced by assSingleChoice\loadFromDb(), assMultipleChoice\loadFromDb(), assOrderingQuestion\loadFromDb(), and assOrderingQuestion\setContentType().

408  : void
409  {
410  if ($a_size >= self::MINIMUM_THUMB_SIZE) {
411  $this->thumb_size = $a_size;
412  } else {
413  throw new ilException("Thumb size must be at least " . self::MINIMUM_THUMB_SIZE . "px");
414  }
415  }
+ Here is the caller graph for this function:

◆ setTitle()

◆ solutionValuesToLog()

assQuestion::solutionValuesToLog ( AdditionalInformationGenerator  $additional_info,
array  $solution_values 
)
abstractprotected

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

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

Referenced by answerToLog().

+ Here is the caller graph for this function:

◆ solutionValuesToText()

assQuestion::solutionValuesToText ( array  $solution_values)
abstractprotected

MUST convert the given solution values into text.

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

Referenced by getCorrectSolutionForTextOutput(), and getSolutionForTextOutput().

+ Here is the caller graph for this function:

◆ syncSkillAssignments()

assQuestion::syncSkillAssignments ( int  $srcParentId,
int  $srcQuestionId,
int  $trgParentId,
int  $trgQuestionId 
)

Definition at line 2344 of file class.assQuestion.php.

References duplicateSkillAssignments().

2344  : void
2345  {
2346  $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
2347  $assignmentList->setParentObjId($trgParentId);
2348  $assignmentList->setQuestionIdFilter($trgQuestionId);
2349  $assignmentList->loadFromDb();
2350 
2351  foreach ($assignmentList->getAssignmentsByQuestionId($trgQuestionId) as $assignment) {
2352  $assignment->deleteFromDb();
2353 
2354  // remove skill usage
2355  if (!$assignment->isSkillUsed()) {
2356  $this->skillUsageService->removeUsage(
2357  $assignment->getParentObjId(),
2358  $assignment->getSkillBaseId(),
2359  $assignment->getSkillTrefId()
2360  );
2361  }
2362  }
2363 
2364  $this->duplicateSkillAssignments($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId);
2365  }
duplicateSkillAssignments(int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
+ Here is the call graph for this function:

◆ syncWithOriginal()

assQuestion::syncWithOriginal ( )

Definition at line 1738 of file class.assQuestion.php.

References afterSyncWithOriginal(), cloneHints(), cloneQuestionTypeSpecificProperties(), cloneSuggestedSolutions(), cloneXHTMLMediaObjectsOfQuestion(), getId(), getObjId(), getOriginalId(), and null.

1738  : void
1739  {
1740  if ($this->getOriginalId() === null) {
1741  return;
1742  }
1743 
1744  $original_parent_id = self::lookupParentObjId($this->getOriginalId());
1745 
1746  if ($original_parent_id === null) {
1747  return;
1748  }
1749 
1750  $this->cloneSuggestedSolutions($this->getId(), $this->getOriginalId());
1751  $original = clone $this;
1752  // Now we become the original
1753  $original->setId($this->getOriginalId());
1754  $original->setOriginalId(null);
1755  $original->setObjId($original_parent_id);
1756 
1757  $original->saveToDb();
1758 
1759  $original->deletePageOfQuestion($this->getOriginalId());
1760  $original->createPageObject();
1761  $original->clonePageOfQuestion($this->getId());
1762  $original = $this->cloneQuestionTypeSpecificProperties($original);
1763  $this->cloneXHTMLMediaObjectsOfQuestion($original->getId());
1764  $this->afterSyncWithOriginal($this->getOriginalId(), $this->getId(), $this->getObjId(), $original_parent_id);
1765  $this->cloneHints($this->id, $this->original_id);
1766  }
cloneXHTMLMediaObjectsOfQuestion(int $source_question_id)
cloneHints(int $source_question_id, int $target_question_id)
cloneQuestionTypeSpecificProperties(self $target)
cloneSuggestedSolutions(int $source_question_id, int $target_question_id)
afterSyncWithOriginal(int $original_question_id, int $clone_question_id, int $original_parent_id, int $clone_parent_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ toJSON()

assQuestion::toJSON ( )

Definition at line 2779 of file class.assQuestion.php.

2779  : string
2780  {
2781  return json_encode([]);
2782  }

◆ toLog()

assQuestion::toLog ( AdditionalInformationGenerator  $additional_info)
abstract

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

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

Implements ILIAS\TestQuestionPool\Questions\Question.

Referenced by toQuestionAdministrationInteraction().

+ Here is the caller graph for this function:

◆ toQuestionAdministrationInteraction()

assQuestion::toQuestionAdministrationInteraction ( AdditionalInformationGenerator  $additional_info,
int  $test_ref_id,
TestQuestionAdministrationInteractionTypes  $interaction_type 
)

Implements ILIAS\TestQuestionPool\Questions\Question.

Definition at line 3034 of file class.assQuestion.php.

References toLog().

3040  $test_ref_id,
3041  $this->id,
3042  $this->current_user->getId(),
3043  $interaction_type,
3044  time(),
3045  $this->toLog($additional_info)
3046  );
3047  }
toLog(AdditionalInformationGenerator $additional_info)
MUST return an array of the question settings that can be stored in the log.
+ Here is the call graph for this function:

◆ toXML()

assQuestion::toXML ( bool  $a_include_header = true,
bool  $a_include_binary = true,
bool  $a_shuffle = false,
bool  $test_output = false,
bool  $force_image_references = false 
)
final

Returns a QTI xml representation of the question.

Returns
string The QTI xml representation of the question

Definition at line 313 of file class.assQuestion.php.

References getQuestionType().

319  : string {
320  $classname = $this->getQuestionType() . "Export";
321  $export = new $classname($this);
322  return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
323  }
+ Here is the call graph for this function:

◆ updateCurrentSolution()

assQuestion::updateCurrentSolution ( int  $solutionId,
  $value1,
  $value2,
bool  $authorized = true 
)

Definition at line 2615 of file class.assQuestion.php.

References getStep(), ILIAS\Repository\int(), and null.

Referenced by assNumeric\saveWorkingData(), and assSingleChoice\saveWorkingData().

2615  : int
2616  {
2617  $fieldData = [
2618  "value1" => ["clob", $value1],
2619  "value2" => ["clob", $value2],
2620  "tstamp" => ["integer", time()],
2621  'authorized' => ['integer', (int) $authorized]
2622  ];
2623 
2624  if ($this->getStep() !== null) {
2625  $fieldData['step'] = ["integer", $this->getStep()];
2626  }
2627 
2628  return $this->db->update("tst_solutions", $fieldData, [
2629  'solution_id' => ['integer', $solutionId]
2630  ]);
2631  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateCurrentSolutionsAuthorization()

assQuestion::updateCurrentSolutionsAuthorization ( int  $activeId,
int  $pass,
bool  $authorized,
bool  $keepTime = false 
)

Definition at line 2634 of file class.assQuestion.php.

References getId(), getStep(), ILIAS\Repository\int(), and null.

Referenced by forceExistingIntermediateSolution(), and assFileUpload\saveWorkingData().

2634  : int
2635  {
2636  $fieldData = [
2637  'authorized' => ['integer', (int) $authorized]
2638  ];
2639 
2640  if (!$keepTime) {
2641  $fieldData['tstamp'] = ['integer', time()];
2642  }
2643 
2644  $whereData = [
2645  'question_fi' => ['integer', $this->getId()],
2646  'active_fi' => ['integer', $activeId],
2647  'pass' => ['integer', $pass]
2648  ];
2649 
2650  if ($this->getStep() !== null) {
2651  $whereData['step'] = ["integer", $this->getStep()];
2652  }
2653 
2654  return $this->db->update('tst_solutions', $fieldData, $whereData);
2655  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateTimestamp()

assQuestion::updateTimestamp ( )

Definition at line 2955 of file class.assQuestion.php.

References getId().

2955  : void
2956  {
2957  $this->db->manipulateF(
2958  "UPDATE qpl_questions SET tstamp = %s WHERE question_id = %s",
2959  ['integer', 'integer'],
2960  [time(), $this->getId()]
2961  );
2962  }
+ Here is the call graph for this function:

◆ validateSolutionSubmit()

assQuestion::validateSolutionSubmit ( )

Implements ILIAS\TestQuestionPool\Questions\Question.

Definition at line 692 of file class.assQuestion.php.

Referenced by persistPreviewState(), and persistWorkingState().

692  : bool
693  {
694  return true;
695  }
+ Here is the caller graph for this function:

Field Documentation

◆ $additionalContentEditingMode

string assQuestion::$additionalContentEditingMode = ''
private

◆ $author

◆ $comment

◆ $current_user

ilObjUser assQuestion::$current_user
protected

Definition at line 75 of file class.assQuestion.php.

Referenced by getCurrentUser().

◆ $db

ilDBInterface assQuestion::$db
protected

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

◆ $defaultnroftries

int assQuestion::$defaultnroftries = 0

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

Referenced by getDefaultNrOfTries(), and setDefaultNrOfTries().

◆ $dic

Container assQuestion::$dic
protected

Definition at line 81 of file class.assQuestion.php.

◆ $export_image_path

string assQuestion::$export_image_path
private

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

Referenced by getImagePathWeb().

◆ $external_id

string assQuestion::$external_id = null
protected

Definition at line 103 of file class.assQuestion.php.

Referenced by getExternalId(), and setExternalId().

◆ $feedbackOBJ

ilAssQuestionFeedback assQuestion::$feedbackOBJ

Definition at line 85 of file class.assQuestion.php.

◆ $force_pass_results_update_enabled

assQuestion::$force_pass_results_update_enabled = false
staticprotected

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

Referenced by setForcePassResultUpdateEnabled().

◆ $http

HTTPServices assQuestion::$http
protected

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

◆ $id

◆ $ilias

ILIAS assQuestion::$ilias
protected

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

◆ $imageSourceFixReplaceMap

assQuestion::$imageSourceFixReplaceMap
staticprotected
Initial value:
= [
'ok.svg' => 'ok.png'

Definition at line 1091 of file class.assQuestion.php.

◆ $lastChange

int assQuestion::$lastChange = null
protected

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

Referenced by getLastChange(), and setLastChange().

◆ $lifecycle

ilAssQuestionLifecycle assQuestion::$lifecycle
protected

Definition at line 84 of file class.assQuestion.php.

Referenced by getLifecycle(), and setLifecycle().

◆ $lng

ilLanguage assQuestion::$lng
protected

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

◆ $log

LoggingServices assQuestion::$log
protected

Definition at line 80 of file class.assQuestion.php.

◆ $nr_of_tries

int assQuestion::$nr_of_tries
private

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

Referenced by getNrOfTries().

◆ $obj_id

int assQuestion::$obj_id = 0
protected

Definition at line 98 of file class.assQuestion.php.

Referenced by getImagePath(), getObjId(), and setObjId().

◆ $original_id

◆ $owner

◆ $page

ilAssQuestionPage assQuestion::$page
protected

Definition at line 86 of file class.assQuestion.php.

◆ $points

float assQuestion::$points = 0.0
protected

Definition at line 95 of file class.assQuestion.php.

Referenced by _getReachedPoints(), assTextSubset\addAnswer(), assSingleChoice\addAnswer(), assMultipleChoice\addAnswer(), assTextQuestion\addAnswer(), assMatchingQuestion\addMatchingPair(), adjustReachedPointsByScoringOptions(), assClozeTest\calculateCombinationResult(), assOrderingHorizontal\calculateReachedPoints(), assNumeric\calculateReachedPoints(), assErrorText\calculateReachedPoints(), assSingleChoice\calculateReachedPoints(), assKprimChoice\calculateReachedPoints(), assMatchingQuestion\calculateReachedPoints(), assFormulaQuestion\calculateReachedPoints(), assTextQuestion\calculateReachedPointsForSolution(), assLongMenu\calculateReachedPointsForSolution(), assOrderingHorizontal\calculateReachedPointsForSolution(), assTextSubset\calculateReachedPointsForSolution(), assKprimChoice\calculateReachedPointsForSolution(), assMultipleChoice\calculateReachedPointsForSolution(), assMatchingQuestion\calculateReachedPointsForSolution(), assClozeTest\calculateReachedPointsForSolution(), assNumeric\calculateReachedPointsFromPreviewSession(), assSingleChoice\calculateReachedPointsFromPreviewSession(), assFormulaQuestion\calculateReachedPointsFromPreviewSession(), assLongMenu\checkQuestionCustomPart(), assMatchingQuestion\createMatchingPair(), ensureNonNegativePoints(), assClozeTest\getMaximumGapPoints(), assTextQuestion\getMaximumPoints(), assTextSubset\getMaximumPoints(), assLongMenu\getMaximumPoints(), assSingleChoice\getMaximumPoints(), getMaximumPoints(), assMatchingQuestion\getMaximumPoints(), assClozeTest\getMaximumPoints(), assFormulaQuestion\getMaximumPoints(), assTextQuestion\getMinimumPoints(), getPoints(), assLongMenu\getPointsForGap(), assErrorText\getPointsForSelectedPositions(), assNumeric\getUserQuestionResult(), assOrderingHorizontal\getUserQuestionResult(), assTextSubset\getUserQuestionResult(), assLongMenu\getUserQuestionResult(), assErrorText\getUserQuestionResult(), assSingleChoice\getUserQuestionResult(), assMultipleChoice\getUserQuestionResult(), assOrderingQuestion\getUserQuestionResult(), assFormulaQuestion\getUserQuestionResult(), assMatchingQuestion\getUserQuestionResult(), assClozeTest\getUserQuestionResult(), assMatchingQuestion\insertMatchingPair(), assLongMenu\saveAnswerSpecificDataToDb(), assErrorText\setErrorsFromParsedErrorText(), assClozeTest\setGapAnswerPoints(), and setPoints().

◆ $prevent_rte_usage

bool assQuestion::$prevent_rte_usage = false

Definition at line 105 of file class.assQuestion.php.

Referenced by getPreventRteUsage(), and setPreventRteUsage().

◆ $processLocker

ilAssQuestionProcessLocker assQuestion::$processLocker
protected

Definition at line 67 of file class.assQuestion.php.

Referenced by getProcessLocker(), and setProcessLocker().

◆ $question

◆ $question_files

QuestionFiles assQuestion::$question_files
protected

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

◆ $questionActionCmd

string assQuestion::$questionActionCmd = 'handleQuestionAction'

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

◆ $questionpool_request

RequestDataCollector assQuestion::$questionpool_request
protected

Definition at line 65 of file class.assQuestion.php.

◆ $questionrepository

GeneralQuestionPropertiesRepository assQuestion::$questionrepository
protected

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

◆ $refinery

Refinery assQuestion::$refinery
protected

◆ $selfassessmenteditingmode

bool assQuestion::$selfassessmenteditingmode = false

◆ $shuffle

◆ $shuffler

Transformation assQuestion::$shuffler
protected

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

Referenced by getShuffler(), and setShuffler().

◆ $skillUsageService

SkillUsageService assQuestion::$skillUsageService
protected

Definition at line 76 of file class.assQuestion.php.

◆ $step

int assQuestion::$step = null
protected

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

Referenced by getStep(), assFileUpload\getUploadedFilesForWeb(), and setStep().

◆ $suggested_solutions

array assQuestion::$suggested_solutions
protected

Definition at line 114 of file class.assQuestion.php.

Referenced by getSuggestedSolutions().

◆ $suggestedsolution_repo

SuggestedSolutionsDatabaseRepository assQuestion::$suggestedsolution_repo
protected

Definition at line 69 of file class.assQuestion.php.

Referenced by getSuggestedSolutionsRepo().

◆ $test_id

◆ $test_question_config

ilTestQuestionConfig assQuestion::$test_question_config = null
private

Definition at line 83 of file class.assQuestion.php.

Referenced by getTestPresentationConfig().

◆ $testQuestionConfig

ilTestQuestionConfig assQuestion::$testQuestionConfig
protected

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

◆ $thumb_size

int assQuestion::$thumb_size
protected

Definition at line 93 of file class.assQuestion.php.

Referenced by getThumbSize().

◆ $title

◆ $tpl

ilGlobalPageTemplate assQuestion::$tpl
protected

Definition at line 72 of file class.assQuestion.php.

◆ ADDITIONAL_CONTENT_EDITING_MODE_IPE

◆ ADDITIONAL_CONTENT_EDITING_MODE_RTE

◆ DEFAULT_THUMB_SIZE

const assQuestion::DEFAULT_THUMB_SIZE = 150
private

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

◆ HAS_SPECIFIC_FEEDBACK

const assQuestion::HAS_SPECIFIC_FEEDBACK = true
protected

Definition at line 52 of file class.assQuestion.php.

◆ KEY_VALUES_IMPLOSION_SEPARATOR

const assQuestion::KEY_VALUES_IMPLOSION_SEPARATOR = ':'

Definition at line 2659 of file class.assQuestion.php.

Referenced by explodeKeyValues(), and implodeKeyValues().

◆ MAXIMUM_THUMB_SIZE

const assQuestion::MAXIMUM_THUMB_SIZE = 8192
private

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

◆ MINIMUM_THUMB_SIZE

const assQuestion::MINIMUM_THUMB_SIZE = 20
private

Definition at line 58 of file class.assQuestion.php.

◆ TRIM_PATTERN

const assQuestion::TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'

Definition at line 60 of file class.assQuestion.php.


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