ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
assImagemapQuestion Class Reference

Class for image map questions. 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 ()
 
 saveToDb (?int $original_id=null)
 
 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...
 
 copyImagemapFiles (int $source_question_id, int $source_parent_id, int $target_question_id, int $target_parent_id)
 
 loadFromDb (int $question_id)
 
 uploadImagemap (array $shapes)
 
 getImageFilename ()
 
 setImageFilename (string $image_filename, string $image_tempfilename='')
 
 get_imagemap_contents (string $href='#')
 
 addAnswer (string $answertext='', float $points=0.0, int $order=0, string $coords='', string $area='', float $points_unchecked=0.0)
 
 getAnswerCount ()
 
 getAnswer (int $index=0)
 
getAnswers ()
 
 deleteArea (int $index=0)
 
 flushAnswers ()
 
 getMaximumPoints ()
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 Saves the learners input of the question to the database. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 deleteImage ()
 Deletes the image file. More...
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 getOperators (string $expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getUserQuestionResult (int $active_id, int $pass)
 Get the user solution for a question by active_id and the test pass. More...
 
 getAvailableAnswerOptions ($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)
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 solutionValuesToText (array $solution_values)
 MUST convert the given solution values into text. More...
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
- Public Member Functions inherited from assQuestion
 getQuestionType ()
 
 isComplete ()
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 getCurrentUser ()
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML (string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping)
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 setShuffle (?bool $shuffle=true)
 
 setAuthor (string $author="")
 
 setOwner (int $owner=-1)
 
 getTitle ()
 
 getTitleForHTMLOutput ()
 
 getTitleFilenameCompliant ()
 
 getId ()
 
 getShuffle ()
 
 getTestId ()
 
 getComment ()
 
 getDescriptionForHTMLOutput ()
 
 getThumbSize ()
 
 setThumbSize (int $a_size)
 
 getMinimumThumbSize ()
 
 getMaximumThumbSize ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorized_solution=true)
 
 calculateResultsFromSolution (int $active_id, int $pass)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $preview_session)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 getSuggestedSolutionPath ()
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 getSuggestedSolutionPathWeb ()
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getTestOutputSolutions (int $activeId, int $pass)
 
 getUserSolutionPreferingIntermediate (int $active_id, ?int $pass=null)
 
 getSolutionValues (int $active_id, ?int $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 cloneXHTMLMediaObjectsOfQuestion (int $source_question_id)
 
 createPageObject ()
 
 clonePageOfQuestion (int $a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
 fixSvgToPng (string $imageFilenameContainingString)
 
 fixUnavailableSkinImageSources (string $html)
 
 loadFromDb (int $question_id)
 
 createNewQuestion (bool $a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb (?int $original_id=null)
 
 duplicate (bool $for_test=true, string $title='', string $author='', int $owner=-1, $test_obj_id=null)
 
 copyObject (int $target_parent_id, string $title='')
 
 createNewOriginalFromThisDuplicate (int $target_parent_id, string $target_question_title='')
 
 saveToDb (?int $original_id=null)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 
 resolveInternalLink (string $internal_link)
 
 resolveSuggestedSolutionLinks ()
 
 getInternalLinkHref (string $target)
 
 syncWithOriginal ()
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 isWriteable ()
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $preview_session)
 
 adjustReachedPointsByScoringOptions (float $points, int $active_id)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionTypeID ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 getNrOfTries ()
 
 setNrOfTries (int $a_nr_of_tries)
 
 setExportImagePath (string $path)
 
 formatSAQuestion ($a_q)
 
 setPreventRteUsage (bool $prevent_rte_usage)
 
 getPreventRteUsage ()
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode (bool $selfassessmenteditingmode)
 
 getSelfAssessmentEditingMode ()
 
 setDefaultNrOfTries (int $defaultnroftries)
 
 getDefaultNrOfTries ()
 
 syncSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 isAnswered (int $active_id, int $pass)
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange (int $lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 removeCurrentSolution (int $active_id, int $pass, bool $authorized=true)
 
 saveCurrentSolution (int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
 updateCurrentSolution (int $solutionId, $value1, $value2, bool $authorized=true)
 
 updateCurrentSolutionsAuthorization (int $activeId, int $pass, bool $authorized, bool $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 intermediateSolutionExists (int $active_id, int $pass)
 
 authorizedSolutionExists (int $active_id, ?int $pass)
 
 authorizedOrIntermediateSolutionExists (int $active_id, int $pass)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions (int $activeId, int $pass)
 
 resetUsersAnswer (int $activeId, int $pass)
 
 removeResultRecord (int $activeId, int $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $value_pairs)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
 hasWritableOriginalInQuestionPool ()
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 getSolutionForTextOutput (int $active_id, int $pass)
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
 getVariablesAsTextArray (int $active_id, int $pass)
 
 validateSolutionSubmit ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 
- Public Member Functions inherited from iQuestionCondition
 getOperators (string $expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getUserQuestionResult (int $active_id, int $pass)
 Get the user solution for a question by active_id and the test pass. More...
 
 getAvailableAnswerOptions (?int $index=null)
 If index is null, the function returns an array with all anwser options else it returns the specific answer option. More...
 
 toJSON ()
 

Data Fields

 $currentSolution = []
 
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 ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
const TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
ilAssQuestionFeedback $feedbackOBJ
 
bool $prevent_rte_usage = false
 
bool $selfassessmenteditingmode = false
 
int $defaultnroftries = 0
 
string $questionActionCmd = 'handleQuestionAction'
 
const KEY_VALUES_IMPLOSION_SEPARATOR = ':'
 
- Data Fields inherited from iQuestionCondition
const StringResultExpression = '~TEXT~'
 
const PercentageResultExpression = '%n%'
 
const NumericResultExpression = '#n#'
 
const MatchingResultExpression = ';n:m;'
 
const OrderingResultExpression = '$n,m,o,p$'
 
const NumberOfResultExpression = '+n+'
 
const ExclusiveResultExpression = '*n,m,o,p*'
 
const EmptyAnswerExpression = "?"
 

Protected Member Functions

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

Protected Attributes

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

Private Attributes

RequestDataCollector $request
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $force_pass_results_update_enabled)
 
static isForcePassResultUpdateEnabled ()
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static isFileAvailable (string $file)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $question_id)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
static extendedTrim (string $value)
 Trim non-printable characters from the beginning and end of a string. More...
 
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 
- Static Protected Attributes inherited from assQuestion
static $force_pass_results_update_enabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

Class for 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 39 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 83 of file class.assImagemapQuestion.php.

90 {
92 $this->image_filename = $image_filename;
93 $this->answers = [];
94 $this->coords = [];
95
96 $local_dic = QuestionPoolDIC::dic();
97 $this->request = $local_dic['request_data_collector'];
98 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswer()

assImagemapQuestion::addAnswer ( string  $answertext = '',
float  $points = 0.0,
int  $order = 0,
string  $coords = '',
string  $area = '',
float  $points_unchecked = 0.0 
)

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

346 : void {
347 if (array_key_exists($order, $this->answers)) {
348 // Insert answer
349 $answer = new ASS_AnswerImagemap($answertext, $points, $order, 0, -1);
350 $answer->setCoords($coords);
351 $answer->setArea($area);
352 $answer->setPointsUnchecked($points_unchecked);
353 for ($i = count($this->answers) - 1; $i >= $order; $i--) {
354 $this->answers[$i + 1] = $this->answers[$i];
355 $this->answers[$i + 1]->setOrder($i + 1);
356 }
357 $this->answers[$order] = $answer;
358 } else {
359 // Append answer
360 $answer = new ASS_AnswerImagemap($answertext, $points, count($this->answers), 0, -1);
361 $answer->setCoords($coords);
362 $answer->setArea($area);
363 $answer->setPointsUnchecked($points_unchecked);
364 array_push($this->answers, $answer);
365 }
366 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ calculateReachedPoints()

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

Reimplemented from assQuestion.

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

440 : float {
441 if ($pass === null) {
442 $pass = $this->getSolutionMaxPass($active_id);
443 }
444 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
445 $found_values = [];
446 while ($data = $this->db->fetchAssoc($result)) {
447 if ($data['value1'] !== '') {
448 $found_values[] = $data['value1'];
449 }
450 }
451
452 $points = $this->calculateReachedPointsForSolution($found_values);
453
454 return $points;
455 }
calculateReachedPointsForSolution(?array $found_values)
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
getSolutionMaxPass(int $active_id)

◆ calculateReachedPointsForSolution()

assImagemapQuestion::calculateReachedPointsForSolution ( ?array  $found_values)
protected

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

665 : float
666 {
667 if ($found_values === null) {
668 $found_values = [];
669 }
670 $points = 0;
671 if (count($found_values) > 0) {
672 foreach ($this->answers as $key => $answer) {
673 if (in_array($key, $found_values)) {
674 $points += $answer->getPoints();
675 } elseif ($this->getIsMultipleChoice()) {
676 $points += $answer->getPointsUnchecked();
677 }
678 }
679 return $points;
680 }
681 return $points;
682 }
getIsMultipleChoice()
Returns true, if the imagemap question is a multiplechoice question.

◆ calculateReachedPointsFromPreviewSession()

assImagemapQuestion::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $preview_session)

Reimplemented from assQuestion.

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

457 : float
458 {
459 $solution_data = $preview_session->getParticipantsSolution();
460
461 $reached_points = $this->calculateReachedPointsForSolution(is_array($solution_data) ? array_values($solution_data) : []);
462
463 return $this->ensureNonNegativePoints($reached_points);
464 }
ensureNonNegativePoints(float $points)

◆ cloneQuestionTypeSpecificProperties()

assImagemapQuestion::cloneQuestionTypeSpecificProperties ( \assQuestion  $target)
protected

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

188 : \assQuestion {
189 $this->copyImagemapFiles($this->getId(), $this->getObjId(), $target->getId(), $target->getObjId());
190 return $target;
191 }
copyImagemapFiles(int $source_question_id, int $source_parent_id, int $target_question_id, int $target_parent_id)

◆ copyImagemapFiles()

assImagemapQuestion::copyImagemapFiles ( int  $source_question_id,
int  $source_parent_id,
int  $target_question_id,
int  $target_parent_id 
)

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

198 : void {
199 $image_source_path = $this->getImagePath($source_question_id, $source_parent_id);
200 $image_target_path = $this->getImagePath($target_question_id, $target_parent_id);
201
202 if (!file_exists($image_target_path)) {
203 ilFileUtils::makeDirParents($image_target_path);
204 } else {
205 $this->removeAllImageFiles($image_target_path);
206 }
207
208 if (!file_exists($image_source_path) || !is_readable($image_source_path)) {
209 $this->log->root()->alert(
210 "Could not copy imagemap question files: Source path '{$image_source_path}' does not exist or is not readable.",
211 [
212 'source_question_id' => $source_question_id,
213 'source_parent_id' => $source_parent_id,
214 'target_question_id' => $target_question_id,
215 'target_parent_id' => $target_parent_id,
216 'image_source_path' => $image_source_path,
217 'image_target_path' => $image_target_path
218 ]
219 );
220 return;
221 }
222
223 $src = opendir($image_source_path);
224 while ($src_file = readdir($src)) {
225 if ($src_file === '.' || $src_file === '..') {
226 continue;
227 }
228 copy(
229 $image_source_path . DIRECTORY_SEPARATOR . $src_file,
230 $image_target_path . DIRECTORY_SEPARATOR . $src_file
231 );
232 }
233 }
removeAllImageFiles(string $image_target_path)
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.

◆ deleteArea()

assImagemapQuestion::deleteArea ( int  $index = 0)

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

392 : void
393 {
394 if ($index < 0) {
395 return;
396 }
397 if (count($this->answers) < 1) {
398 return;
399 }
400 if ($index >= count($this->answers)) {
401 return;
402 }
403 unset($this->answers[$index]);
404 $this->answers = array_values($this->answers);
405 for ($i = 0; $i < count($this->answers); $i++) {
406 if ($this->answers[$i]->getOrder() > $index) {
407 $this->answers[$i]->setOrder($i);
408 }
409 }
410 }

◆ deleteImage()

assImagemapQuestion::deleteImage ( )

Deletes the image file.

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

613 : void
614 {
615 $file = $this->getImagePath() . $this->getImageFilename();
616 @unlink($file);
617 $this->flushAnswers();
618 $this->image_filename = '';
619 }

◆ flushAnswers()

assImagemapQuestion::flushAnswers ( )

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

412 : void
413 {
414 $this->answers = [];
415 }

◆ get_imagemap_contents()

assImagemapQuestion::get_imagemap_contents ( string  $href = '#')

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

326 : string
327 {
328 $imagemap_contents = '<map name=\'' . $this->title . '\'> ';
329 for ($i = 0; $i < count($this->answers); $i++) {
330 $imagemap_contents .= '<area alt=\'' . $this->answers[$i]->getAnswertext() . '\' ';
331 $imagemap_contents .= 'shape=\'' . $this->answers[$i]->getArea() . '\' ';
332 $imagemap_contents .= 'coords=\'' . $this->answers[$i]->getCoords() . '\' ';
333 $imagemap_contents .= "href=\"{$href}&selimage=" . $this->answers[$i]->getOrder() . "\" /> ";
334 }
335 $imagemap_contents .= '</map>';
336 return $imagemap_contents;
337 }

◆ 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 @access public

Reimplemented from assQuestion.

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

579 : string
580 {
581 return 'qpl_qst_imagemap';
582 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAddSolutionSelectionParameter()

assImagemapQuestion::getAddSolutionSelectionParameter ( )
protected

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

760 {
761 if (!$this->isAddSolutionSelectionRequest()) {
762 return null;
763 }
764
765 return $this->request->raw('selImage');
766 }

◆ getAnswer()

assImagemapQuestion::getAnswer ( int  $index = 0)

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

374 {
375 if ($index < 0) {
376 return null;
377 }
378 if (count($this->answers) < 1) {
379 return null;
380 }
381 if ($index >= count($this->answers)) {
382 return null;
383 }
384 return $this->answers[$index];
385 }

◆ getAnswerCount()

assImagemapQuestion::getAnswerCount ( )

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

368 : int
369 {
370 return count($this->answers);
371 }

◆ getAnswers()

& assImagemapQuestion::getAnswers ( )

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

387 : array
388 {
389 return $this->answers;
390 }

◆ 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 @access public

Reimplemented from assQuestion.

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

592 : string
593 {
594 return 'qpl_a_imagemap';
595 }

◆ 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

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

740 {
741 if ($index !== null) {
742 return $this->getAnswer($index);
743 } else {
744 return $this->getAnswers();
745 }
746 }

◆ getCorrectSolutionForTextOutput()

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

Reimplemented from assQuestion.

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

908 : array
909 {
910 return array_map(
911 fn(ASS_AnswerImagemap $v): string => "{$v->getArea()}: {$v->getCoords()}"
912 . "({$this->lng->txt('points')} "
913 . "{$this->lng->txt('checked')}: {$v->getPoints()}, "
914 . "{$this->lng->txt('unchecked')}: {$v->getPointsUnchecked()})",
915 $this->getAnswers()
916 );
917 }

◆ getExpressionTypes()

assImagemapQuestion::getExpressionTypes ( )

◆ getImageFilename()

assImagemapQuestion::getImageFilename ( )

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

300 : string
301 {
303 }

◆ getIsMultipleChoice()

assImagemapQuestion::getIsMultipleChoice ( )

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

Returns
bool

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

115 : bool
116 {
118 }

References $is_multiple_choice.

◆ getMaximumPoints()

assImagemapQuestion::getMaximumPoints ( )

Reimplemented from assQuestion.

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

417 : float
418 {
419 $points = 0;
420 foreach ($this->answers as $key => $value) {
421 if ($this->is_multiple_choice) {
422 if ($value->getPoints() > $value->getPointsUnchecked()) {
423 $points += $value->getPoints();
424 } else {
425 $points += $value->getPointsUnchecked();
426 }
427 } else {
428 if ($value->getPoints() > $points) {
429 $points = $value->getPoints();
430 }
431 }
432 }
433 return $points;
434 }

Referenced by isComplete().

+ Here is the caller graph for this function:

◆ getOperators()

assImagemapQuestion::getOperators ( string  $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

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

684 : array
685 {
687 }
static getOperatorsByExpression(string $expression)

◆ 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 @access public

Reimplemented from assQuestion.

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

566 : string
567 {
568 return 'assImagemapQuestion';
569 }

◆ getRemoveSolutionSelectionParameter()

assImagemapQuestion::getRemoveSolutionSelectionParameter ( )
protected

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

780 {
781 if (!$this->isRemoveSolutionSelectionRequest()) {
782 return null;
783 }
784
785 return $this->request->raw('remImage');
786 }

◆ getReuseSolutionSelectionParameter()

assImagemapQuestion::getReuseSolutionSelectionParameter ( )
protected

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

803 : ?array
804 {
805 if (!$this->isReuseSolutionSelectionRequest()) {
806 return null;
807 }
808
809 return assQuestion::explodeKeyValues($this->request->raw('reuseSelection'));
810 }
static explodeKeyValues(string $keyValues)

◆ getRTETextWithMediaObjects()

assImagemapQuestion::getRTETextWithMediaObjects ( )

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

Reimplemented from assQuestion.

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

601 : string
602 {
603 $text = parent::getRTETextWithMediaObjects();
604 foreach ($this->answers as $index => $answer) {
605 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->getId(), 0, $index);
606 }
607 return $text;
608 }
$text
Definition: xapiexit.php:21

◆ getTestOutputSolutions()

assImagemapQuestion::getTestOutputSolutions (   $activeId,
  $pass 
)

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

748 : array
749 {
750 $solution = parent::getTestOutputSolutions($activeId, $pass);
751
752 $this->currentSolution = [];
753 foreach ($solution as $record) {
754 $this->currentSolution[] = $record['value1'];
755 }
756
757 return $solution;
758 }

◆ getUserQuestionResult()

assImagemapQuestion::getUserQuestionResult ( int  $active_id,
int  $pass 
)

Get the user solution for a question by active_id and the test pass.

Implements iQuestionCondition.

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

703 $result = new ilUserQuestionResult($this, $active_id, $pass);
704
705 $maxStep = $this->lookupMaxStep($active_id, $pass);
706 if ($maxStep > 0) {
707 $data = $this->db->queryF(
708 'SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s',
709 ['integer', 'integer', 'integer', 'integer'],
710 [$active_id, $pass, $this->getId(), $maxStep]
711 );
712 } else {
713 $data = $this->db->queryF(
714 'SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step IS NULL',
715 ['integer', 'integer', 'integer'],
716 [$active_id, $pass, $this->getId()]
717 );
718 }
719
720 while ($row = $this->db->fetchAssoc($data)) {
721 $result->addKeyValue($row['value1'], $row['value1']);
722 }
723
724 $points = $this->calculateReachedPoints($active_id, $pass);
725 $max_points = $this->getMaximumPoints();
726
727 $result->setReachedPercentage(($points / $max_points) * 100);
728
729 return $result;
730 }
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
lookupMaxStep(int $active_id, int $pass)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ isAddSolutionSelectionRequest()

assImagemapQuestion::isAddSolutionSelectionRequest ( )
protected

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

767 : bool
768 {
769 if (!$this->request->isset('selImage')) {
770 return false;
771 }
772
773 if (!strlen($this->request->raw('selImage'))) {
774 return false;
775 }
776
777 return true;
778 }

◆ isComplete()

assImagemapQuestion::isComplete ( )

Reimplemented from assQuestion.

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

120 : bool
121 {
122 if ($this->title !== ''
123 && $this->author
124 && $this->question
125 && $this->image_filename
126 && $this->answers !== []
127 && $this->getMaximumPoints() > 0
128 ) {
129 return true;
130 }
131 return false;
132 }

References getMaximumPoints().

+ Here is the call graph for this function:

◆ isRemoveSolutionSelectionRequest()

assImagemapQuestion::isRemoveSolutionSelectionRequest ( )
protected

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

787 : bool
788 {
789 if (!$this->is_multiple_choice) {
790 return false;
791 }
792
793 if (!$this->request->isset('remImage')) {
794 return false;
795 }
796
797 if (!strlen($this->request->raw('remImage'))) {
798 return false;
799 }
800
801 return true;
802 }

◆ isReuseSolutionSelectionRequest()

assImagemapQuestion::isReuseSolutionSelectionRequest ( )
protected

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

811 : bool
812 {
813 if (!$this->getTestPresentationConfig()->isPreviousPassSolutionReuseAllowed()) {
814 return false;
815 }
816
817 if (!$this->request->isset('reuseSelection')) {
818 return false;
819 }
820
821 if (!strlen($this->request->raw('reuseSelection'))) {
822 return false;
823 }
824
825 if (!preg_match('/\d(,\d)*/', $this->request->raw('reuseSelection'))) {
826 return false;
827 }
828
829 return true;
830 }

◆ loadFromDb()

assImagemapQuestion::loadFromDb ( int  $question_id)

Reimplemented from assQuestion.

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

235 : void
236 {
237 $result = $this->db->queryF(
238 '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',
239 ['integer'],
240 [$question_id]
241 );
242 if ($result->numRows() == 1) {
243 $data = $this->db->fetchAssoc($result);
244 $this->setId($question_id);
245 $this->setObjId($data['obj_fi']);
246 $this->setTitle((string) $data['title']);
247 $this->setComment((string) $data['description']);
248 $this->setOriginalId($data['original_id']);
249 $this->setNrOfTries($data['nr_of_tries']);
250 $this->setAuthor($data['author']);
251 $this->setPoints($data['points']);
252 $this->setOwner($data['owner']);
253 $this->setIsMultipleChoice($data['is_multiple_choice'] == self::MODE_MULTIPLE_CHOICE);
254 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data['question_text'], 1));
255 $this->setImageFilename($data['image_file'] ?? '');
256
257 try {
261 }
262
263 try {
264 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
266 }
267
268 $result = $this->db->queryF(
269 'SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC',
270 ['integer'],
271 [$question_id]
272 );
273 if ($result->numRows() > 0) {
274 while ($data = $this->db->fetchAssoc($result)) {
275 $image_map_question = new ASS_AnswerImagemap($data['answertext'] ?? '', $data['points'], $data['aorder']);
276 $image_map_question->setCoords($data['coords']);
277 $image_map_question->setArea($data['area']);
278 $image_map_question->setPointsUnchecked($data['points_unchecked']);
279 array_push($this->answers, $image_map_question);
280 }
281 }
282 }
283 parent::loadFromDb($question_id);
284 }
setIsMultipleChoice($is_multiple_choice)
Set true if the Imagemapquestion is a multiplechoice Question.
setImageFilename(string $image_filename, string $image_tempfilename='')
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setOriginalId(?int $original_id)
setId(int $id=-1)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
setAuthor(string $author="")
setComment(string $comment="")
setObjId(int $obj_id=0)
setOwner(int $owner=-1)
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
setPoints(float $points)
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...

References $data, Vendor\Package\$e, ilRTE\_replaceMediaObjectImageSrc(), ilAssQuestionLifecycle\getDraftInstance(), and ilAssQuestionLifecycle\getInstance().

+ 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 166 of file class.assImagemapQuestion.php.

166 : void
167 {
168 $this->db->manipulateF(
169 'DELETE FROM ' . $this->getAdditionalTableName() . ' WHERE question_fi = %s',
170 [ 'integer' ],
171 [ $this->getId() ]
172 );
173
174 $this->db->manipulateF(
175 'INSERT INTO ' . $this->getAdditionalTableName(
176 ) . ' (question_fi, image_file, is_multiple_choice) VALUES (%s, %s, %s)',
177 [ 'integer', 'text', 'integer' ],
178 [
179 $this->getId(),
180 $this->image_filename,
181 (int) $this->is_multiple_choice
182 ]
183 );
184 }

References getAdditionalTableName(), and assQuestion\getId().

Referenced by saveToDb().

+ 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 142 of file class.assImagemapQuestion.php.

142 : void
143 {
144 $this->db->manipulateF(
145 'DELETE FROM qpl_a_imagemap WHERE question_fi = %s',
146 [ 'integer' ],
147 [ $this->getId() ]
148 );
149
150 // Anworten wegschreiben
151 foreach ($this->answers as $key => $value) {
152 $answer_obj = $this->answers[$key];
153 $answer_obj->setOrder($key);
154 $next_id = $this->db->nextId('qpl_a_imagemap');
155 $this->db->manipulateF(
156 '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)',
157 [ 'integer', 'integer', 'text', 'float', 'integer', 'text', 'text', 'float' ],
158 [ $next_id, $this->id, $answer_obj->getAnswertext(
159 ), $answer_obj->getPoints(), $answer_obj->getOrder(
160 ), $answer_obj->getCoords(), $answer_obj->getArea(
161 ), $answer_obj->getPointsUnchecked() ]
162 );
163 }
164 }

References assQuestion\getId().

Referenced by saveToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePreviewData()

assImagemapQuestion::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

Reimplemented from assQuestion.

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

538 : void
539 {
540 $solution = $previewSession->getParticipantsSolution();
541
542 if ($this->is_multiple_choice
543 && $this->request->isset('remImage')) {
544 unset($solution[$this->request->int('remImage')]);
545 }
546
547 if ($this->request->isset('selImage')) {
548 if (!$this->is_multiple_choice) {
549 $solution = [];
550 }
551
552 $solution[$this->request->int('selImage')] = $this->request->int('selImage');
553 }
554
555 $previewSession->setParticipantsSolution($solution);
556 }

◆ saveToDb()

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

Reimplemented from assQuestion.

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

134 : void
135 {
139 parent::saveToDb($original_id);
140 }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb(?int $original_id=null)

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

+ Here is the call graph for this function:

◆ saveWorkingData()

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

Saves the learners input of the question to the database.

@access public

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

Reimplemented from assQuestion.

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

478 : bool {
479 if (is_null($pass)) {
480 $pass = ilObjTest::_getPass($active_id);
481 }
482
483 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
484 function () use ($active_id, $pass, $authorized) {
485 if ($authorized) {
486 // remove the dummy record of the intermediate solution
487 $this->deleteDummySolutionRecord($active_id, $pass);
488
489 // delete the authorized solution and make the intermediate solution authorized (keeping timestamps)
490 $this->removeCurrentSolution($active_id, $pass, true);
491 $this->updateCurrentSolutionsAuthorization($active_id, $pass, true, true);
492 return;
493 }
494
496 $active_id,
497 $pass,
498 $this->is_multiple_choice
499 );
500
501 if ($this->isReuseSolutionSelectionRequest()) {
502 $selection = $this->getReuseSolutionSelectionParameter();
503
504 foreach ($selection as $selectedIndex) {
505 $this->saveCurrentSolution($active_id, $pass, (int) $selectedIndex, null, $authorized);
506 }
507 return;
508 }
509
511 $selection = $this->getRemoveSolutionSelectionParameter();
512 $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, [
513 'value1' => (int) $selection
514 ]);
515 return;
516 }
517
518 if (!$this->isAddSolutionSelectionRequest()) {
519 return;
520 }
521 $selection = $this->getAddSolutionSelectionParameter();
522
523 if ($this->is_multiple_choice) {
524 $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, [
525 'value1' => (int) $this->request->raw('selImage')
526 ]);
527 } else {
528 $this->removeCurrentSolution($active_id, $pass, $authorized);
529 }
530
531 $this->saveCurrentSolution($active_id, $pass, $this->request->raw('selImage'), null, $authorized);
532 }
533 );
534
535 return true;
536 }
updateCurrentSolutionsAuthorization(int $activeId, int $pass, bool $authorized, bool $keepTime=false)
deleteSolutionRecordByValues(int $activeId, int $passIndex, bool $authorized, array $matchValues)
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
deleteDummySolutionRecord(int $activeId, int $passIndex)
forceExistingIntermediateSolution(int $activeId, int $passIndex, bool $considerDummyRecordCreation)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.

◆ setImageFilename()

assImagemapQuestion::setImageFilename ( string  $image_filename,
string  $image_tempfilename = '' 
)

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

308 : void {
309 if (!empty($image_filename)) {
310 $image_filename = str_replace(' ', '_', $image_filename);
311 $this->image_filename = $image_filename;
312 }
313 if (!empty($image_tempfilename)) {
314 $imagepath = $this->getImagePath();
315 if (!file_exists($imagepath)) {
316 ilFileUtils::makeDirParents($imagepath);
317 }
318 if (!ilFileUtils::moveUploadedFile($image_tempfilename, $image_filename, $imagepath . $image_filename)) {
319 $this->tpl->setOnScreenMessage('failure', 'The image could not be uploaded!');
320 return;
321 }
322 $this->log->write('gespeichert: ' . $imagepath . $image_filename);
323 }
324 }
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file

◆ setIsMultipleChoice()

assImagemapQuestion::setIsMultipleChoice (   $is_multiple_choice)

Set true if the Imagemapquestion is a multiplechoice Question.

Parameters
bool$is_multiple_choice

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

105 : void
106 {
107 $this->is_multiple_choice = $is_multiple_choice;
108 }

References $is_multiple_choice.

◆ solutionValuesToLog()

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

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.

Reimplemented from assQuestion.

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

877 : array {
878 $parsed_solution = [];
879 foreach ($this->getAnswers() as $id => $answer) {
880 $value = $additional_info->getTagForLangVar('unchecked');
881 foreach ($solution_values as $solution) {
882 if ($solution['value1'] == $id) {
883 $value = $additional_info->getTagForLangVar('checked');
884 break;
885 }
886 }
887 $parsed_solution["{$answer->getArea()}: {$answer->getCoords()}"] = $value;
888 }
889 return $parsed_solution;
890 }

◆ solutionValuesToText()

assImagemapQuestion::solutionValuesToText ( array  $solution_values)

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.

Reimplemented from assQuestion.

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

892 : array
893 {
894 $parsed_solution = [];
895 foreach ($this->getAnswers() as $id => $answer) {
896 $value = $this->lng->txt('unchecked');
897 foreach ($solution_values as $solution) {
898 if ($solution['value1'] == $id) {
899 $value = $this->lng->txt('checked');
900 break;
901 }
902 }
903 $parsed_solution[] = "{$answer->getArea()}: {$answer->getCoords()} ({$value})";
904 }
905 return $parsed_solution;
906 }

◆ toJSON()

assImagemapQuestion::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

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

624 : string
625 {
626 $result = [];
627 $result['id'] = $this->getId();
628 $result['type'] = (string) $this->getQuestionType();
629 $result['title'] = $this->getTitleForHTMLOutput();
630 $result['question'] = $this->formatSAQuestion($this->getQuestion());
631 $result['nr_of_tries'] = $this->getNrOfTries();
632 $result['shuffle'] = $this->getShuffle();
633 $result['is_multiple'] = $this->getIsMultipleChoice();
634 $result['feedback'] = [
635 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
636 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
637 ];
638 $result['image'] = $this->getImagePathWeb() . $this->getImageFilename();
639
640 $answers = [];
641 $order = 0;
642 foreach ($this->getAnswers() as $key => $answer_obj) {
643 array_push($answers, [
644 'answertext' => (string) $answer_obj->getAnswertext(),
645 'points' => (float) $answer_obj->getPoints(),
646 'points_unchecked' => (float) $answer_obj->getPointsUnchecked(),
647 'order' => $order,
648 'coords' => $answer_obj->getCoords(),
649 'state' => $answer_obj->getState(),
650 'area' => $answer_obj->getArea(),
651 'feedback' => $this->formatSAQuestion(
652 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
653 )
654 ]);
655 $order++;
656 }
657 $result['answers'] = $answers;
658
659 $mobs = ilObjMediaObject::_getMobsOfObject('qpl:html', $this->getId());
660 $result['mobs'] = $mobs;
661
662 return json_encode($result);
663 }
getQuestionType()
Returns the question type of the question.
getImagePathWeb()
Returns the web image path for web accessable images of a question.
static _getMobsOfObject(string $a_type, int $a_id, int|false $a_usage_hist_nr=0, string $a_lang="-")

◆ toLog()

assImagemapQuestion::toLog ( AdditionalInformationGenerator  $additional_info)

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.

Reimplemented from assQuestion.

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

832 : array
833 {
834 $result = [
835 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
836 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
837 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
838 AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS => $additional_info
840 AdditionalInformationGenerator::KEY_QUESTION_IMAGEMAP_MODE => $this->getIsMultipleChoice()
841 ? $additional_info->getTagForLangVar('tst_imap_qst_mode_mc')
842 : $additional_info->getTagForLangVar('tst_imap_qst_mode_sc'),
843 AdditionalInformationGenerator::KEY_QUESTION_IMAGEMAP_IMAGE => $this->getImagePathWeb() . $this->getImageFilename(),
844 AdditionalInformationGenerator::KEY_FEEDBACK => [
845 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion(
846 $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)
847 ),
848 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion(
849 $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)
850 )
851 ]
852 ];
853
854 $answers = [];
855 $order = 0;
856 foreach ($this->getAnswers() as $key => $answer_obj) {
857 array_push($answers, [
858 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION => (string) $answer_obj->getAnswertext(),
859 AdditionalInformationGenerator::KEY_QUESTION_POINTS_CHECKED => (float) $answer_obj->getPoints(),
860 AdditionalInformationGenerator::KEY_QUESTION_POINTS_UNCHECKED => (float) $answer_obj->getPointsUnchecked(),
861 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION_ORDER => $order,
862 AdditionalInformationGenerator::KEY_QUESTION_IMAGEMAP_ANSWER_OPTION_COORDS => $answer_obj->getCoords(),
863 AdditionalInformationGenerator::KEY_FEEDBACK => $this->formatSAQuestion(
864 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
865 )
866 ]);
867 $order++;
868 }
869 $result[AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTIONS] = $answers;
870
871 return $result;
872 }

◆ uploadImagemap()

assImagemapQuestion::uploadImagemap ( array  $shapes)

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

286 : int
287 {
288 $added = 0;
289
290 if (count($shapes) > 0) {
291 foreach ($shapes as $shape) {
292 $this->addAnswer($shape->getAnswertext(), 0.0, count($this->answers), $shape->getCoords(), $shape->getArea());
293 $added++;
294 }
295 }
296
297 return $added;
298 }
addAnswer(string $answertext='', float $points=0.0, int $order=0, string $coords='', string $area='', float $points_unchecked=0.0)

Field Documentation

◆ $answers

assImagemapQuestion::$answers

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

◆ $coords

assImagemapQuestion::$coords

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

◆ $currentSolution

assImagemapQuestion::$currentSolution = []

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

◆ $image_filename

assImagemapQuestion::$image_filename

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

Referenced by __construct().

◆ $imagemap_contents

assImagemapQuestion::$imagemap_contents

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

◆ $is_multiple_choice

assImagemapQuestion::$is_multiple_choice = false
protected

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

Referenced by getIsMultipleChoice(), and setIsMultipleChoice().

◆ $request

RequestDataCollector assImagemapQuestion::$request
private

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

◆ AVAILABLE_SHAPES

const assImagemapQuestion::AVAILABLE_SHAPES
Initial value:
= [
'RECT' => 'rect',
'CIRCLE' => 'circle',
'POLY' => 'poly']

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

Referenced by assImagemapQuestionGUI\areaEditor(), 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: