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

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

+ Inheritance diagram for assImagemapQuestion:
+ Collaboration diagram for assImagemapQuestion:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="", $image_filename="")
 assImagemapQuestion constructor More...
 
 setIsMultipleChoice ($is_multiple_choice)
 Set true if the Imagemapquestion is a multiplechoice Question. More...
 
 getIsMultipleChoice ()
 Returns true, if the imagemap question is a multiplechoice question. More...
 
 isComplete ()
 Returns true, if a imagemap question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves an assImagemapQuestion object to a database. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 duplicate (bool $for_test=true, string $title="", string $author="", int $owner=-1, $testObjId=null)
 Duplicates an assImagemapQuestion. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assImagemapQuestion object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 duplicateImage ($question_id, $objectId=null)
 
 copyImage ($question_id, $source_questionpool)
 
 loadFromDb ($question_id)
 Loads a assImagemapQuestion object from a database. More...
 
 uploadImagemap (array $shapes)
 Uploads an image map and takes over the areas. More...
 
 getImageFilename ()
 
 setImageFilename ($image_filename, $image_tempfilename="")
 Sets the image file name. More...
 
 get_imagemap_contents ($href="#")
 Gets the imagemap file contents. More...
 
 addAnswer ( $answertext="", $points=0.0, $order=0, $coords="", $area="", $points_unchecked=0.0)
 Adds a possible answer for a imagemap question. More...
 
 getAnswerCount ()
 Returns the number of answers. More...
 
 getAnswer ($index=0)
 Returns an answer. More...
 
getAnswers ()
 Returns the answer array. More...
 
 deleteArea ($index=0)
 Deletes an answer. More...
 
 flushAnswers ()
 Deletes all answers. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 syncWithOriginal ()
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 setExportDetailsXLSX (ilAssExcelFormatHelper $worksheet, int $startrow, int $col, int $active_id, int $pass)
 {} More...
 
 deleteImage ()
 Deletes the image file. More...
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 
 getTestOutputSolutions ($activeId, $pass)
 
- Public Member Functions inherited from assQuestion
 __construct (string $title="", string $comment="", string $author="", int $owner=-1, string $question="")
 assQuestion constructor More...
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML ($item, int $questionpool_id, ?int $tst_id, &$tst_object, int &$question_counter, array $import_mapping, array &$solutionhints=[])
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 isComplete ()
 Returns true, if a question is complete for use. More...
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 setShuffle (?bool $shuffle=true)
 
 setAuthor (string $author="")
 
 setOwner (int $owner=-1)
 
 getTitle ()
 
 getTitleForHTMLOutput ()
 
 getTitleFilenameCompliant ()
 
 getId ()
 
 getShuffle ()
 
 getTestId ()
 
 getComment ()
 
 getDescriptionForHTMLOutput ()
 
 getThumbSize ()
 
 setThumbSize (int $a_size)
 
 getMinimumThumbSize ()
 
 getMaximumThumbSize ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution (int $active_id, int $pass, bool $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $obligationsEnabled=false, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 saveWorkingData (int $active_id, int $pass, bool $authorized=true)
 Saves the learners input of the question to the database. More...
 
 getSuggestedSolutionPath ()
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 getSuggestedSolutionPathWeb ()
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getTestOutputSolutions (int $activeId, int $pass)
 
 getUserSolutionPreferingIntermediate (int $active_id, $pass=null)
 
 getSolutionValues ($active_id, $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 copyXHTMLMediaObjectsOfQuestion (int $a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 
 copyPageOfQuestion (int $a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
 fixSvgToPng (string $imageFilenameContainingString)
 
 fixUnavailableSkinImageSources (string $html)
 
 loadFromDb (int $question_id)
 
 createNewQuestion (bool $a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb (int $original_id=-1)
 
 saveToDb ()
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 
 resolveInternalLink (string $internal_link)
 
 resolveSuggestedSolutionLinks ()
 
 syncWithOriginal ()
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 deductHintPointsFromReachedPoints (ilAssQuestionPreviewSession $previewSession, $reachedPoints)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=null)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 
 syncHints ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 setExportDetailsXLSX (ilAssExcelFormatHelper $worksheet, int $startrow, int $col, int $active_id, int $pass)
 
 getNrOfTries ()
 
 setNrOfTries (int $a_nr_of_tries)
 
 setExportImagePath (string $path)
 
 formatSAQuestion ($a_q)
 
 setPreventRteUsage (bool $prevent_rte_usage)
 
 getPreventRteUsage ()
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode (bool $selfassessmenteditingmode)
 
 getSelfAssessmentEditingMode ()
 
 setDefaultNrOfTries (int $defaultnroftries)
 
 getDefaultNrOfTries ()
 
 syncSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 ensureHintPageObjectExists ($pageObjectId)
 
 isAnswered (int $active_id, int $pass)
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 removeCurrentSolution (int $active_id, int $pass, bool $authorized=true)
 
 saveCurrentSolution (int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
 updateCurrentSolution (int $solutionId, $value1, $value2, bool $authorized=true)
 
 updateCurrentSolutionsAuthorization (int $activeId, int $pass, bool $authorized, bool $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate (bool $for_test=true, string $title="", string $author="", int $owner=-1, $testObjId=null)
 
 intermediateSolutionExists (int $active_id, int $pass)
 
 authorizedSolutionExists (int $active_id, ?int $pass)
 
 authorizedOrIntermediateSolutionExists (int $active_id, int $pass)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions (int $activeId, int $pass)
 
 resetUsersAnswer (int $activeId, int $pass)
 
 removeResultRecord (int $activeId, int $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered (bool $obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 
- Public Member Functions inherited from assQuestionInterface
 validateSolutionSubmit ()
 

Data Fields

 $currentSolution = array()
 
const MODE_SINGLE_CHOICE = 0
 
const MODE_MULTIPLE_CHOICE = 1
 
const AVAILABLE_SHAPES
 
 $answers
 
 $image_filename
 
 $imagemap_contents
 
 $coords
 
- Data Fields inherited from assQuestion
const TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
ilAssQuestionFeedback $feedbackOBJ
 
bool $prevent_rte_usage = false
 
bool $selfassessmenteditingmode = false
 
int $defaultnroftries = 0
 
string $questionActionCmd = 'handleQuestionAction'
 
const KEY_VALUES_IMPLOSION_SEPARATOR = ':'
 
- Data Fields inherited from iQuestionCondition
const StringResultExpression = '~TEXT~'
 
const PercentageResultExpression = '%n%'
 
const NumericResultExpression = '#n#'
 
const MatchingResultExpression = ';n:m;'
 
const OrderingResultExpression = '$n,m,o,p$'
 
const NumberOfResultExpression = '+n+'
 
const ExclusiveResultExpression = '*n,m,o,p*'
 
const EmptyAnswerExpression = "?"
 

Protected Member Functions

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

Protected Attributes

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

Private Attributes

ILIAS TestQuestionPool InternalRequestService $request
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $forcePassResultsUpdateEnabled)
 
static isForcePassResultUpdateEnabled ()
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static logAction (string $logtext, int $active_id, int $question_id)
 
static isFileAvailable (string $file)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static _getInternalLinkHref (string $target="")
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static _isWriteable (int $question_id, int $user_id)
 
static _setReachedPoints (int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring, bool $obligationsEnabled, ?int $test_id=null)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static _needsManualScoring (int $question_id)
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static instantiateQuestionGUI (int $a_question_id)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $questionId)
 
static isObligationPossible (int $questionId)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
static extendedTrim (string $value)
 Trim non-printable characters from the beginning and end of a string. More...
 
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 
- Static Protected Attributes inherited from assQuestion
static $forcePassResultsUpdateEnabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

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

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

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

assImagemapQuestion is a class for imagemap question.

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

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

Constructor & Destructor Documentation

◆ __construct()

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

assImagemapQuestion constructor

The constructor takes possible arguments an creates an instance of the assImagemapQuestion object.

Parameters
string$titleA title string to describe the question.
string$commentA comment string to describe the question.
string$authorA string containing the name of the questions author.
integer$ownerA numerical ID to identify the owner/creator.
string$questionThe question string of the imagemap question.
string$image_filename

Definition at line 78 of file class.assImagemapQuestion.php.

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

85  {
87  $this->image_filename = $image_filename;
88  $this->answers = array();
89  $this->coords = array();
90 
91  global $DIC;
92  $this->request = $DIC->testQuestionPool()->internal()->request();
93  }
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
string $question
The question text.
+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswer()

assImagemapQuestion::addAnswer (   $answertext = "",
  $points = 0.0,
  $order = 0,
  $coords = "",
  $area = "",
  $points_unchecked = 0.0 
)

Adds a possible answer for a imagemap question.

Adds a possible answer for a imagemap question. A ASS_AnswerImagemap object will be created and assigned to the array $this->answers.

Parameters
string$answertextThe answer text
double$pointsThe points for selecting the answer (even negative points can be used)
integer$statusThe state of the answer (set = 1 or unset = 0)
integer$orderA possible display order of the answer public
See also
$answers
ASS_AnswerImagemap

Definition at line 518 of file class.assImagemapQuestion.php.

References $coords, and assQuestion\$points.

Referenced by uploadImagemap().

525  : void {
526  if (array_key_exists($order, $this->answers)) {
527  // Insert answer
528  $answer = new ASS_AnswerImagemap($answertext, $points, $order, 0, -1);
529  $answer->setCoords($coords);
530  $answer->setArea($area);
531  $answer->setPointsUnchecked($points_unchecked);
532  for ($i = count($this->answers) - 1; $i >= $order; $i--) {
533  $this->answers[$i + 1] = $this->answers[$i];
534  $this->answers[$i + 1]->setOrder($i + 1);
535  }
536  $this->answers[$order] = $answer;
537  } else {
538  // Append answer
539  $answer = new ASS_AnswerImagemap($answertext, $points, count($this->answers), 0, -1);
540  $answer->setCoords($coords);
541  $answer->setArea($area);
542  $answer->setPointsUnchecked($points_unchecked);
543  array_push($this->answers, $answer);
544  }
545  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
float $points
The maximum available points for the question.
+ Here is the caller graph for this function:

◆ calculateReachedPoints()

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

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

The points are calculated from the given answers.

public

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

Definition at line 680 of file class.assImagemapQuestion.php.

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

Referenced by getExpressionTypes().

680  : float
681  {
682  if ($returndetails) {
683  throw new ilTestException('return details not implemented for ' . __METHOD__);
684  }
685 
686  global $DIC;
687  $ilDB = $DIC['ilDB'];
688 
689  $found_values = array();
690  if (is_null($pass)) {
691  $pass = $this->getSolutionMaxPass($active_id);
692  }
693  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
694  while ($data = $ilDB->fetchAssoc($result)) {
695  if (strcmp($data["value1"], "") != 0) {
696  array_push($found_values, $data["value1"]);
697  }
698  }
699 
700  $points = $this->calculateReachedPointsForSolution($found_values);
701 
702  return $points;
703  }
calculateReachedPointsForSolution($found_values)
float $points
The maximum available points for the question.
Base Exception for all Exceptions relating to Modules/Test.
global $DIC
Definition: feed.php:28
getSolutionMaxPass(int $active_id)
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsForSolution()

assImagemapQuestion::calculateReachedPointsForSolution (   $found_values)
protected
Parameters
$found_values
Returns
float

Definition at line 971 of file class.assImagemapQuestion.php.

References ILIAS\LTI\ToolProvider\$key, assQuestion\$points, and getIsMultipleChoice().

Referenced by calculateReachedPoints(), and calculateReachedPointsFromPreviewSession().

971  : float
972  {
973  if ($found_values == null) {
974  $found_values = [];
975  }
976  $points = 0;
977  if (count($found_values) > 0) {
978  foreach ($this->answers as $key => $answer) {
979  if (in_array($key, $found_values)) {
980  $points += $answer->getPoints();
981  } elseif ($this->getIsMultipleChoice()) {
982  $points += $answer->getPointsUnchecked();
983  }
984  }
985  return $points;
986  }
987  return $points;
988  }
float $points
The maximum available points for the question.
getIsMultipleChoice()
Returns true, if the imagemap question is a multiplechoice question.
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assImagemapQuestion::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

Definition at line 705 of file class.assImagemapQuestion.php.

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

706  {
707  $solutionData = $previewSession->getParticipantsSolution();
708 
709  $reachedPoints = $this->calculateReachedPointsForSolution(is_array($solutionData) ? array_values($solutionData) : array());
710  $reachedPoints = $this->deductHintPointsFromReachedPoints($previewSession, $reachedPoints);
711 
712  return $this->ensureNonNegativePoints($reachedPoints);
713  }
calculateReachedPointsForSolution($found_values)
ensureNonNegativePoints($points)
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
+ Here is the call graph for this function:

◆ copyImage()

assImagemapQuestion::copyImage (   $question_id,
  $source_questionpool 
)

Definition at line 352 of file class.assImagemapQuestion.php.

References $filename, getImageFilename(), assQuestion\getImagePath(), and ilFileUtils\makeDirParents().

352  : void
353  {
354  $imagepath = $this->getImagePath();
355  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
356  $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
357  if (!file_exists($imagepath)) {
358  ilFileUtils::makeDirParents($imagepath);
359  }
360  $filename = $this->getImageFilename();
361  if (!copy($imagepath_original . $filename, $imagepath . $filename)) {
362  print "image could not be copied!!!! ";
363  }
364  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:

◆ copyObject()

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

Copies an assImagemapQuestion object.

Copies an assImagemapQuestion object

public

Definition at line 262 of file class.assImagemapQuestion.php.

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

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

◆ createNewOriginalFromThisDuplicate()

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

Definition at line 291 of file class.assImagemapQuestion.php.

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

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

◆ deleteArea()

assImagemapQuestion::deleteArea (   $index = 0)

Deletes an answer.

Deletes an area with a given index. The index of the first area is 0, the index of the second area is 1 and so on.

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

Definition at line 610 of file class.assImagemapQuestion.php.

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

610  : void
611  {
612  if ($index < 0) {
613  return;
614  }
615  if (count($this->answers) < 1) {
616  return;
617  }
618  if ($index >= count($this->answers)) {
619  return;
620  }
621  unset($this->answers[$index]);
622  $this->answers = array_values($this->answers);
623  for ($i = 0; $i < count($this->answers); $i++) {
624  if ($this->answers[$i]->getOrder() > $index) {
625  $this->answers[$i]->setOrder($i);
626  }
627  }
628  }
+ Here is the call graph for this function:

◆ deleteImage()

assImagemapQuestion::deleteImage ( )

Deletes the image file.

Definition at line 915 of file class.assImagemapQuestion.php.

References flushAnswers(), getImageFilename(), and assQuestion\getImagePath().

915  : void
916  {
917  $file = $this->getImagePath() . $this->getImageFilename();
918  @unlink($file);
919  $this->flushAnswers();
920  $this->image_filename = "";
921  }
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
flushAnswers()
Deletes all answers.
+ Here is the call graph for this function:

◆ duplicate()

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

Duplicates an assImagemapQuestion.

public

Definition at line 210 of file class.assImagemapQuestion.php.

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

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

◆ duplicateImage()

assImagemapQuestion::duplicateImage (   $question_id,
  $objectId = null 
)

Definition at line 323 of file class.assImagemapQuestion.php.

References $DIC, $filename, assQuestion\$ilLog, getImageFilename(), assQuestion\getImagePath(), and ilFileUtils\makeDirParents().

323  : void
324  {
325  global $DIC;
326  $ilLog = $DIC['ilLog'];
327 
328  $imagepath = $this->getImagePath();
329  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
330 
331  if ((int) $objectId > 0) {
332  $imagepath_original = str_replace("/$this->obj_id/", "/$objectId/", $imagepath_original);
333  }
334 
335  if (!file_exists($imagepath)) {
336  ilFileUtils::makeDirParents($imagepath);
337  }
338  $filename = $this->getImageFilename();
339 
340  // #18755
341  if (!file_exists($imagepath_original . $filename)) {
342  $ilLog->write("Could not find an image map file when trying to duplicate image: " . $imagepath_original . $filename);
343  $imagepath_original = str_replace("/$this->obj_id/", "/$objectId/", $imagepath_original);
344  $ilLog->write("Using fallback source directory:" . $imagepath_original);
345  }
346 
347  if (!file_exists($imagepath_original . $filename) || !copy($imagepath_original . $filename, $imagepath . $filename)) {
348  $ilLog->write("Could not duplicate image for image map question: " . $imagepath_original . $filename);
349  }
350  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
global $DIC
Definition: feed.php:28
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
$filename
Definition: buildRTE.php:78
ILIAS DI LoggingServices $ilLog
+ Here is the call graph for this function:

◆ flushAnswers()

assImagemapQuestion::flushAnswers ( )

Deletes all answers.

Deletes all answers

public

See also
$answers

Definition at line 638 of file class.assImagemapQuestion.php.

Referenced by deleteImage().

638  : void
639  {
640  $this->answers = array();
641  }
+ Here is the caller graph for this function:

◆ get_imagemap_contents()

assImagemapQuestion::get_imagemap_contents (   $href = "#")

Gets the imagemap file contents.

Gets the imagemap file contents

Returns
string The imagemap file contents of the assImagemapQuestion object public
See also
$imagemap_contents

Definition at line 491 of file class.assImagemapQuestion.php.

References $imagemap_contents.

491  : string
492  {
493  $imagemap_contents = "<map name=\"" . $this->title . "\"> ";
494  for ($i = 0; $i < count($this->answers); $i++) {
495  $imagemap_contents .= "<area alt=\"" . $this->answers[$i]->getAnswertext() . "\" ";
496  $imagemap_contents .= "shape=\"" . $this->answers[$i]->getArea() . "\" ";
497  $imagemap_contents .= "coords=\"" . $this->answers[$i]->getCoords() . "\" ";
498  $imagemap_contents .= "href=\"$href&selimage=" . $this->answers[$i]->getOrder() . "\" /> ";
499  }
500  $imagemap_contents .= "</map>";
501  return $imagemap_contents;
502  }

◆ getAdditionalTableName()

assImagemapQuestion::getAdditionalTableName ( )

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

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

Returns
string The additional table name public

Definition at line 851 of file class.assImagemapQuestion.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

851  : string
852  {
853  return "qpl_qst_imagemap";
854  }
+ Here is the caller graph for this function:

◆ getAddSolutionSelectionParameter()

assImagemapQuestion::getAddSolutionSelectionParameter ( )
protected

Definition at line 1088 of file class.assImagemapQuestion.php.

References isAddSolutionSelectionRequest().

Referenced by saveWorkingData().

1089  {
1090  if (!$this->isAddSolutionSelectionRequest()) {
1091  return null;
1092  }
1093 
1094  return $this->request->raw('selImage');
1095  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAnswer()

assImagemapQuestion::getAnswer (   $index = 0)

Returns an answer.

Returns an answer with a given index. The index of the first answer is 0, the index of the second answer is 1 and so on.

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

Definition at line 572 of file class.assImagemapQuestion.php.

Referenced by getAvailableAnswerOptions().

572  : ?object
573  {
574  if ($index < 0) {
575  return null;
576  }
577  if (count($this->answers) < 1) {
578  return null;
579  }
580  if ($index >= count($this->answers)) {
581  return null;
582  }
583  return $this->answers[$index];
584  }
+ Here is the caller graph for this function:

◆ getAnswerCount()

assImagemapQuestion::getAnswerCount ( )

Returns the number of answers.

Returns the number of answers

Returns
integer The number of answers of the multiple choice question public
See also
$answers

Definition at line 556 of file class.assImagemapQuestion.php.

556  : int
557  {
558  return count($this->answers);
559  }

◆ getAnswers()

& assImagemapQuestion::getAnswers ( )

Returns the answer array.

Returns the answer array

Returns
array The answer array public
See also
$answers

Definition at line 595 of file class.assImagemapQuestion.php.

References $answers.

Referenced by getAvailableAnswerOptions(), setExportDetailsXLSX(), and toJSON().

595  : array
596  {
597  return $this->answers;
598  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assImagemapQuestion::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns the name of the answer table in the database

Returns
string The answer table name public

Definition at line 864 of file class.assImagemapQuestion.php.

864  : string
865  {
866  return "qpl_a_imagemap";
867  }

◆ getAvailableAnswerOptions()

assImagemapQuestion::getAvailableAnswerOptions (   $index = null)

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

Parameters
null | int$index

Implements iQuestionCondition.

Definition at line 1067 of file class.assImagemapQuestion.php.

References getAnswer(), and getAnswers().

1068  {
1069  if ($index !== null) {
1070  return $this->getAnswer($index);
1071  } else {
1072  return $this->getAnswers();
1073  }
1074  }
getAnswer($index=0)
Returns an answer.
& getAnswers()
Returns the answer array.
+ Here is the call graph for this function:

◆ getExpressionTypes()

◆ getImageFilename()

assImagemapQuestion::getImageFilename ( )

Definition at line 449 of file class.assImagemapQuestion.php.

References $image_filename.

Referenced by copyImage(), deleteImage(), duplicateImage(), and toJSON().

449  : string
450  {
451  return $this->image_filename;
452  }
+ Here is the caller graph for this function:

◆ getIsMultipleChoice()

assImagemapQuestion::getIsMultipleChoice ( )

Returns true, if the imagemap question is a multiplechoice question.

Returns
bool

Definition at line 110 of file class.assImagemapQuestion.php.

References $is_multiple_choice.

Referenced by calculateReachedPointsForSolution(), and toJSON().

110  : bool
111  {
113  }
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assImagemapQuestion::getMaximumPoints ( )

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

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

public

See also
$points

Definition at line 651 of file class.assImagemapQuestion.php.

References ILIAS\LTI\ToolProvider\$key, and assQuestion\$points.

Referenced by getExpressionTypes(), and isComplete().

651  : float
652  {
653  $points = 0;
654  foreach ($this->answers as $key => $value) {
655  if ($this->is_multiple_choice) {
656  if ($value->getPoints() > $value->getPointsUnchecked()) {
657  $points += $value->getPoints();
658  } else {
659  $points += $value->getPointsUnchecked();
660  }
661  } else {
662  if ($value->getPoints() > $points) {
663  $points = $value->getPoints();
664  }
665  }
666  }
667  return $points;
668  }
float $points
The maximum available points for the question.
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the caller graph for this function:

◆ getOperators()

assImagemapQuestion::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

Definition at line 998 of file class.assImagemapQuestion.php.

References ilOperatorsExpressionMapping\getOperatorsByExpression().

998  : array
999  {
1001  }
+ Here is the call graph for this function:

◆ getQuestionType()

assImagemapQuestion::getQuestionType ( )

Returns the question type of the question.

Returns the question type of the question

Returns
integer The question type of the question public

Definition at line 838 of file class.assImagemapQuestion.php.

Referenced by toJSON().

838  : string
839  {
840  return "assImagemapQuestion";
841  }
+ Here is the caller graph for this function:

◆ getRemoveSolutionSelectionParameter()

assImagemapQuestion::getRemoveSolutionSelectionParameter ( )
protected

Definition at line 1108 of file class.assImagemapQuestion.php.

References isRemoveSolutionSelectionRequest().

Referenced by saveWorkingData().

1109  {
1110  if (!$this->isRemoveSolutionSelectionRequest()) {
1111  return null;
1112  }
1113 
1114  return $this->request->raw('remImage');
1115  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getReuseSolutionSelectionParameter()

assImagemapQuestion::getReuseSolutionSelectionParameter ( )
protected

Definition at line 1132 of file class.assImagemapQuestion.php.

References assQuestion\explodeKeyValues(), and isReuseSolutionSelectionRequest().

Referenced by saveWorkingData().

1132  : ?array
1133  {
1134  if (!$this->isReuseSolutionSelectionRequest()) {
1135  return null;
1136  }
1137 
1138  return assQuestion::explodeKeyValues($this->request->raw("reuseSelection"));
1139  }
static explodeKeyValues(string $keyValues)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assImagemapQuestion::getRTETextWithMediaObjects ( )

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

Definition at line 873 of file class.assImagemapQuestion.php.

References assQuestion\getId().

873  : string
874  {
875  $text = parent::getRTETextWithMediaObjects();
876  foreach ($this->answers as $index => $answer) {
877  $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->getId(), 0, $index);
878  }
879  return $text;
880  }
+ Here is the call graph for this function:

◆ getTestOutputSolutions()

assImagemapQuestion::getTestOutputSolutions (   $activeId,
  $pass 
)

Definition at line 1077 of file class.assImagemapQuestion.php.

1077  : array
1078  {
1079  $solution = parent::getTestOutputSolutions($activeId, $pass);
1080 
1081  $this->currentSolution = array();
1082  foreach ($solution as $record) {
1083  $this->currentSolution[] = $record['value1'];
1084  }
1085 
1086  return $solution;
1087  }

◆ isAddSolutionSelectionRequest()

assImagemapQuestion::isAddSolutionSelectionRequest ( )
protected

Definition at line 1096 of file class.assImagemapQuestion.php.

Referenced by getAddSolutionSelectionParameter(), and saveWorkingData().

1096  : bool
1097  {
1098  if (!$this->request->isset("selImage")) {
1099  return false;
1100  }
1101 
1102  if (!strlen($this->request->raw('selImage'))) {
1103  return false;
1104  }
1105 
1106  return true;
1107  }
+ Here is the caller graph for this function:

◆ isComplete()

assImagemapQuestion::isComplete ( )

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

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

Definition at line 121 of file class.assImagemapQuestion.php.

References getMaximumPoints().

121  : bool
122  {
123  if (strlen($this->title)
124  && ($this->author)
125  && ($this->question)
126  && ($this->image_filename)
127  && (count($this->answers))
128  && ($this->getMaximumPoints() > 0)
129  ) {
130  return true;
131  }
132  return false;
133  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ isRemoveSolutionSelectionRequest()

assImagemapQuestion::isRemoveSolutionSelectionRequest ( )
protected

Definition at line 1116 of file class.assImagemapQuestion.php.

Referenced by getRemoveSolutionSelectionParameter(), and saveWorkingData().

1116  : bool
1117  {
1118  if (!$this->is_multiple_choice) {
1119  return false;
1120  }
1121 
1122  if (!$this->request->isset("remImage")) {
1123  return false;
1124  }
1125 
1126  if (!strlen($this->request->raw('remImage'))) {
1127  return false;
1128  }
1129 
1130  return true;
1131  }
+ Here is the caller graph for this function:

◆ isReuseSolutionSelectionRequest()

assImagemapQuestion::isReuseSolutionSelectionRequest ( )
protected

Definition at line 1140 of file class.assImagemapQuestion.php.

References assQuestion\getTestPresentationConfig().

Referenced by getReuseSolutionSelectionParameter(), and saveWorkingData().

1140  : bool
1141  {
1142  if (!$this->getTestPresentationConfig()->isPreviousPassSolutionReuseAllowed()) {
1143  return false;
1144  }
1145 
1146  if (!$this->request->isset("reuseSelection")) {
1147  return false;
1148  }
1149 
1150  if (!strlen($this->request->raw("reuseSelection"))) {
1151  return false;
1152  }
1153 
1154  if (!preg_match('/\d(,\d)*/', $this->request->raw("reuseSelection"))) {
1155  return false;
1156  }
1157 
1158  return true;
1159  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadFromDb()

assImagemapQuestion::loadFromDb (   $question_id)

Loads a assImagemapQuestion object from a database.

Loads a assImagemapQuestion object from a database (experimental)

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

Definition at line 375 of file class.assImagemapQuestion.php.

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

375  : void
376  {
377  global $DIC;
378  $ilDB = $DIC['ilDB'];
379 
380  $result = $ilDB->queryF(
381  "SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s",
382  array("integer"),
383  array($question_id)
384  );
385  if ($result->numRows() == 1) {
386  $data = $ilDB->fetchAssoc($result);
387  $this->setId($question_id);
388  $this->setObjId($data["obj_fi"]);
389  $this->setTitle((string) $data["title"]);
390  $this->setComment((string) $data["description"]);
391  $this->setOriginalId($data["original_id"]);
392  $this->setNrOfTries($data['nr_of_tries']);
393  $this->setAuthor($data["author"]);
394  $this->setPoints($data["points"]);
395  $this->setOwner($data["owner"]);
396  $this->setIsMultipleChoice($data["is_multiple_choice"] == self::MODE_MULTIPLE_CHOICE);
397  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
398  $this->setImageFilename($data["image_file"]);
399 
400  try {
404  }
405 
406  try {
407  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
408  } catch (ilTestQuestionPoolException $e) {
409  }
410 
411  $result = $ilDB->queryF(
412  "SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
413  array("integer"),
414  array($question_id)
415  );
416  if ($result->numRows() > 0) {
417  while ($data = $ilDB->fetchAssoc($result)) {
418  $image_map_question = new ASS_AnswerImagemap($data["answertext"] ?? '', $data["points"], $data["aorder"]);
419  $image_map_question->setCoords($data["coords"]);
420  $image_map_question->setArea($data["area"]);
421  $image_map_question->setPointsUnchecked($data['points_unchecked']);
422  array_push($this->answers, $image_map_question);
423  }
424  }
425  }
426  parent::loadFromDb($question_id);
427  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setNrOfTries(int $a_nr_of_tries)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setOwner(int $owner=-1)
setComment(string $comment="")
global $DIC
Definition: feed.php:28
setPoints(float $points)
setObjId(int $obj_id=0)
setIsMultipleChoice($is_multiple_choice)
Set true if the Imagemapquestion is a multiplechoice Question.
setId(int $id=-1)
setOriginalId(?int $original_id)
setImageFilename($image_filename, $image_tempfilename="")
Sets the image file name.
setTitle(string $title="")
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setAuthor(string $author="")
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setQuestion(string $question="")
+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assImagemapQuestion::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

Definition at line 182 of file class.assImagemapQuestion.php.

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

Referenced by saveToDb().

183  {
184  global $DIC;
185  $ilDB = $DIC['ilDB'];
186 
187  $ilDB->manipulateF(
188  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
189  array( "integer" ),
190  array( $this->getId() )
191  );
192 
193  $ilDB->manipulateF(
194  "INSERT INTO " . $this->getAdditionalTableName(
195  ) . " (question_fi, image_file, is_multiple_choice) VALUES (%s, %s, %s)",
196  array( "integer", "text", 'integer' ),
197  array(
198  $this->getId(),
199  $this->image_filename,
200  (int) $this->is_multiple_choice
201  )
202  );
203  }
global $DIC
Definition: feed.php:28
getAdditionalTableName()
Returns the name of the additional question data table in the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAnswerSpecificDataToDb()

assImagemapQuestion::saveAnswerSpecificDataToDb ( )

Saves the answer specific records into a question types answer table.

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

Definition at line 156 of file class.assImagemapQuestion.php.

References $DIC, $ilDB, ILIAS\LTI\ToolProvider\$key, and assQuestion\getId().

Referenced by saveToDb().

157  {
158  global $DIC;
159  $ilDB = $DIC['ilDB'];
160  $ilDB->manipulateF(
161  "DELETE FROM qpl_a_imagemap WHERE question_fi = %s",
162  array( "integer" ),
163  array( $this->getId() )
164  );
165 
166  // Anworten wegschreiben
167  foreach ($this->answers as $key => $value) {
168  $answer_obj = $this->answers[$key];
169  $answer_obj->setOrder($key);
170  $next_id = $ilDB->nextId('qpl_a_imagemap');
171  $ilDB->manipulateF(
172  "INSERT INTO qpl_a_imagemap (answer_id, question_fi, answertext, points, aorder, coords, area, points_unchecked) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
173  array( "integer", "integer", "text", "float", "integer", "text", "text", "float" ),
174  array( $next_id, $this->id, $answer_obj->getAnswertext(
175  ), $answer_obj->getPoints(), $answer_obj->getOrder(
176  ), $answer_obj->getCoords(), $answer_obj->getArea(
177  ), $answer_obj->getPointsUnchecked() )
178  );
179  }
180  }
global $DIC
Definition: feed.php:28
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePreviewData()

assImagemapQuestion::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

Definition at line 803 of file class.assImagemapQuestion.php.

References ilAssQuestionPreviewSession\getParticipantsSolution(), and ilAssQuestionPreviewSession\setParticipantsSolution().

803  : void
804  {
805  $solution = $previewSession->getParticipantsSolution();
806 
807  if ($this->is_multiple_choice
808  && $this->request->isset('remImage')) {
809  unset($solution[$this->request->int('remImage')]);
810  }
811 
812  if ($this->request->isset('selImage')) {
813  if (!$this->is_multiple_choice) {
814  $solution = array();
815  }
816 
817  $solution[$this->request->int('selImage')] = $this->request->int('selImage');
818  }
819 
820  $previewSession->setParticipantsSolution($solution);
821  }
+ Here is the call graph for this function:

◆ saveToDb()

assImagemapQuestion::saveToDb (   $original_id = "")

Saves an assImagemapQuestion object to a database.

Saves an assImagemapQuestion object to a database

Parameters
string$original_id
Returns
mixed|void

Definition at line 144 of file class.assImagemapQuestion.php.

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

144  : void
145  {
146  if ($original_id == '') {
147  $this->saveQuestionDataToDb();
148  } else {
150  }
153  parent::saveToDb($original_id);
154  }
saveQuestionDataToDb(int $original_id=-1)
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
+ Here is the call graph for this function:

◆ saveWorkingData()

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

Saves the learners input of the question to the database.

public

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

Definition at line 723 of file class.assImagemapQuestion.php.

References $DIC, $ilDB, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), assQuestion\deleteDummySolutionRecord(), assQuestion\deleteSolutionRecordByValues(), assQuestion\forceExistingIntermediateSolution(), getAddSolutionSelectionParameter(), assQuestion\getId(), assQuestion\getProcessLocker(), getRemoveSolutionSelectionParameter(), getReuseSolutionSelectionParameter(), isAddSolutionSelectionRequest(), isRemoveSolutionSelectionRequest(), isReuseSolutionSelectionRequest(), ILIAS\Repository\lng(), assQuestion\logAction(), assQuestion\removeCurrentSolution(), assQuestion\saveCurrentSolution(), and assQuestion\updateCurrentSolutionsAuthorization().

723  : bool
724  {
725  global $DIC;
726  $ilDB = $DIC['ilDB'];
727 
728  if (is_null($pass)) {
729  $pass = ilObjTest::_getPass($active_id);
730  }
731 
732  $solutionSelectionChanged = false;
733 
734  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$solutionSelectionChanged, $ilDB, $active_id, $pass, $authorized) {
735  if ($authorized) {
736  // remove the dummy record of the intermediate solution
737  $this->deleteDummySolutionRecord($active_id, $pass);
738 
739  // delete the authorized solution and make the intermediate solution authorized (keeping timestamps)
740  $this->removeCurrentSolution($active_id, $pass, true);
741  $this->updateCurrentSolutionsAuthorization($active_id, $pass, true, true);
742 
743  $solutionSelectionChanged = true;
744  } else {
746  $active_id,
747  $pass,
748  $this->is_multiple_choice
749  );
750 
751  if ($this->isReuseSolutionSelectionRequest()) {
752  $selection = $this->getReuseSolutionSelectionParameter();
753 
754  foreach ($selection as $selectedIndex) {
755  $this->saveCurrentSolution($active_id, $pass, (int) $selectedIndex, null, $authorized);
756  $solutionSelectionChanged = true;
757  }
758  } elseif ($this->isRemoveSolutionSelectionRequest()) {
759  $selection = $this->getRemoveSolutionSelectionParameter();
760 
761  $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, array(
762  'value1' => (int) $selection
763  ));
764 
765  $solutionSelectionChanged = true;
766  } elseif ($this->isAddSolutionSelectionRequest()) {
767  $selection = $this->getAddSolutionSelectionParameter();
768 
769  if ($this->is_multiple_choice) {
770  $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, array(
771  'value1' => (int) $this->request->raw('selImage')
772  ));
773  } else {
774  $this->removeCurrentSolution($active_id, $pass, $authorized);
775  }
776 
777  $this->saveCurrentSolution($active_id, $pass, $this->request->raw('selImage'), null, $authorized);
778 
779  $solutionSelectionChanged = true;
780  }
781  }
782  });
783 
785  if ($solutionSelectionChanged) {
786  assQuestion::logAction($this->lng->txtlng(
787  "assessment",
788  "log_user_entered_values",
790  ), $active_id, $this->getId());
791  } else {
792  assQuestion::logAction($this->lng->txtlng(
793  "assessment",
794  "log_user_not_entered_values",
796  ), $active_id, $this->getId());
797  }
798  }
799 
800  return true;
801  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
updateCurrentSolutionsAuthorization(int $activeId, int $pass, bool $authorized, bool $keepTime=false)
deleteDummySolutionRecord(int $activeId, int $passIndex)
global $DIC
Definition: feed.php:28
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
static logAction(string $logtext, int $active_id, int $question_id)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
deleteSolutionRecordByValues(int $activeId, int $passIndex, bool $authorized, array $matchValues)
forceExistingIntermediateSolution(int $activeId, int $passIndex, bool $considerDummyRecordCreation)
+ Here is the call graph for this function:

◆ setExportDetailsXLSX()

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

{}

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

References assQuestion\$id, getAnswers(), ilExcel\getColumnCoord(), assQuestion\getSolutionValues(), ilExcel\setBold(), and ilAssExcelFormatHelper\setCell().

885  : int
886  {
887  parent::setExportDetailsXLSX($worksheet, $startrow, $col, $active_id, $pass);
888 
889  $solution = $this->getSolutionValues($active_id, $pass);
890 
891  $i = 1;
892  foreach ($this->getAnswers() as $id => $answer) {
893  $worksheet->setCell($startrow + $i, $col, $answer->getArea() . ": " . $answer->getCoords());
894  $worksheet->setBold($worksheet->getColumnCoord($col) . ($startrow + $i));
895 
896  $cellValue = 0;
897  foreach ($solution as $solIndex => $sol) {
898  if ($sol['value1'] == $id) {
899  $cellValue = 1;
900  break;
901  }
902  }
903 
904  $worksheet->setCell($startrow + $i, $col + 2, $cellValue);
905 
906  $i++;
907  }
908 
909  return $startrow + $i + 1;
910  }
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
getColumnCoord(int $a_col)
Get column "name" from number.
setCell($a_row, $a_col, $a_value, $datatype=null)
setBold(string $a_coords)
Set cell(s) to bold.
& getAnswers()
Returns the answer array.
+ Here is the call graph for this function:

◆ setImageFilename()

assImagemapQuestion::setImageFilename (   $image_filename,
  $image_tempfilename = "" 
)

Sets the image file name.

Parameters
string$image_filename. public
See also
$image_filename

Definition at line 461 of file class.assImagemapQuestion.php.

References $DIC, assQuestion\$ilLog, $image_filename, assQuestion\getImagePath(), ilFileUtils\makeDirParents(), and ilFileUtils\moveUploadedFile().

Referenced by loadFromDb().

461  : void
462  {
463  if (!empty($image_filename)) {
464  $image_filename = str_replace(" ", "_", $image_filename);
465  $this->image_filename = $image_filename;
466  }
467  if (!empty($image_tempfilename)) {
468  $imagepath = $this->getImagePath();
469  if (!file_exists($imagepath)) {
470  ilFileUtils::makeDirParents($imagepath);
471  }
472  if (!ilFileUtils::moveUploadedFile($image_tempfilename, $image_filename, $imagepath . $image_filename)) {
473  $this->tpl->setOnScreenMessage('failure', 'The image could not be uploaded!');
474  return;
475  }
476  global $DIC;
477  $ilLog = $DIC['ilLog'];
478  $ilLog->write("gespeichert: " . $imagepath . $image_filename);
479  }
480  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
global $DIC
Definition: feed.php:28
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
ILIAS DI LoggingServices $ilLog
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setIsMultipleChoice()

assImagemapQuestion::setIsMultipleChoice (   $is_multiple_choice)

Set true if the Imagemapquestion is a multiplechoice Question.

Parameters
bool$is_multiple_choice

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

References $is_multiple_choice.

Referenced by loadFromDb().

100  : void
101  {
102  $this->is_multiple_choice = $is_multiple_choice;
103  }
+ Here is the caller graph for this function:

◆ syncWithOriginal()

assImagemapQuestion::syncWithOriginal ( )

Definition at line 823 of file class.assImagemapQuestion.php.

823  : void
824  {
825  if ($this->questioninfo->getOriginalId($this->getId())) {
826  parent::syncWithOriginal();
827  }
828  }

◆ toJSON()

assImagemapQuestion::toJSON ( )

Returns a JSON representation of the question.

Implements ilAssQuestionLMExportable.

Definition at line 926 of file class.assImagemapQuestion.php.

References $answers, ILIAS\LTI\ToolProvider\$key, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getAnswers(), assQuestion\getId(), getImageFilename(), assQuestion\getImagePathWeb(), getIsMultipleChoice(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), and assQuestion\getTitleForHTMLOutput().

926  : string
927  {
928  $result = array();
929  $result['id'] = $this->getId();
930  $result['type'] = (string) $this->getQuestionType();
931  $result['title'] = $this->getTitleForHTMLOutput();
932  $result['question'] = $this->formatSAQuestion($this->getQuestion());
933  $result['nr_of_tries'] = $this->getNrOfTries();
934  $result['shuffle'] = $this->getShuffle();
935  $result['is_multiple'] = $this->getIsMultipleChoice();
936  $result['feedback'] = array(
937  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
938  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
939  );
940  $result['image'] = $this->getImagePathWeb() . $this->getImageFilename();
941 
942  $answers = array();
943  $order = 0;
944  foreach ($this->getAnswers() as $key => $answer_obj) {
945  array_push($answers, array(
946  "answertext" => (string) $answer_obj->getAnswertext(),
947  "points" => (float) $answer_obj->getPoints(),
948  "points_unchecked" => (float) $answer_obj->getPointsUnchecked(),
949  "order" => $order,
950  "coords" => $answer_obj->getCoords(),
951  "state" => $answer_obj->getState(),
952  "area" => $answer_obj->getArea(),
953  "feedback" => $this->formatSAQuestion(
954  $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
955  )
956  ));
957  $order++;
958  }
959  $result['answers'] = $answers;
960 
961  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
962  $result['mobs'] = $mobs;
963 
964  return json_encode($result);
965  }
getImagePathWeb()
Returns the web image path for web accessable images of a question.
getIsMultipleChoice()
Returns true, if the imagemap question is a multiplechoice question.
string $key
Consumer key/client ID value.
Definition: System.php:193
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
& getAnswers()
Returns the answer array.
getQuestionType()
Returns the question type of the question.
+ Here is the call graph for this function:

◆ uploadImagemap()

assImagemapQuestion::uploadImagemap ( array  $shapes)

Uploads an image map and takes over the areas.

Parameters
ASS_AnswerImagemap[]$shapes
Returns
integer number of areas added

Definition at line 435 of file class.assImagemapQuestion.php.

References addAnswer().

435  : int
436  {
437  $added = 0;
438 
439  if (count($shapes) > 0) {
440  foreach ($shapes as $shape) {
441  $this->addAnswer($shape->getAnswertext(), 0.0, count($this->answers), $shape->getCoords(), $shape->getArea());
442  $added++;
443  }
444  }
445 
446  return $added;
447  }
addAnswer( $answertext="", $points=0.0, $order=0, $coords="", $area="", $points_unchecked=0.0)
Adds a possible answer for a imagemap question.
+ Here is the call graph for this function:

Field Documentation

◆ $answers

assImagemapQuestion::$answers

Definition at line 51 of file class.assImagemapQuestion.php.

Referenced by getAnswers(), and toJSON().

◆ $coords

assImagemapQuestion::$coords

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

Referenced by addAnswer().

◆ $currentSolution

assImagemapQuestion::$currentSolution = array()

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

◆ $image_filename

assImagemapQuestion::$image_filename

Definition at line 54 of file class.assImagemapQuestion.php.

Referenced by __construct(), getImageFilename(), and setImageFilename().

◆ $imagemap_contents

assImagemapQuestion::$imagemap_contents

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

Referenced by get_imagemap_contents().

◆ $is_multiple_choice

assImagemapQuestion::$is_multiple_choice = false
protected

Definition at line 63 of file class.assImagemapQuestion.php.

Referenced by getIsMultipleChoice(), and setIsMultipleChoice().

◆ $request

ILIAS TestQuestionPool InternalRequestService assImagemapQuestion::$request
private

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

◆ AVAILABLE_SHAPES

const assImagemapQuestion::AVAILABLE_SHAPES
Initial value:
= [
'RECT' => 'rect'

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

Referenced by assImagemapQuestionGUI\saveShape(), and ilHtmlImageMapFileInputGUI\verifyArea().

◆ MODE_MULTIPLE_CHOICE

const assImagemapQuestion::MODE_MULTIPLE_CHOICE = 1

◆ MODE_SINGLE_CHOICE

const assImagemapQuestion::MODE_SINGLE_CHOICE = 0

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