ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 324 of file class.assImagemapQuestion.php.

331 : void {
332 if (array_key_exists($order, $this->answers)) {
333 // Insert answer
334 $answer = new ASS_AnswerImagemap($answertext, $points, $order, 0, -1);
335 $answer->setCoords($coords);
336 $answer->setArea($area);
337 $answer->setPointsUnchecked($points_unchecked);
338 for ($i = count($this->answers) - 1; $i >= $order; $i--) {
339 $this->answers[$i + 1] = $this->answers[$i];
340 $this->answers[$i + 1]->setOrder($i + 1);
341 }
342 $this->answers[$order] = $answer;
343 } else {
344 // Append answer
345 $answer = new ASS_AnswerImagemap($answertext, $points, count($this->answers), 0, -1);
346 $answer->setCoords($coords);
347 $answer->setArea($area);
348 $answer->setPointsUnchecked($points_unchecked);
349 array_push($this->answers, $answer);
350 }
351 }
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 421 of file class.assImagemapQuestion.php.

425 : float {
426 if ($pass === null) {
427 $pass = $this->getSolutionMaxPass($active_id);
428 }
429 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
430 $found_values = [];
431 while ($data = $this->db->fetchAssoc($result)) {
432 if ($data['value1'] !== '') {
433 $found_values[] = $data['value1'];
434 }
435 }
436
437 $points = $this->calculateReachedPointsForSolution($found_values);
438
439 return $points;
440 }
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 650 of file class.assImagemapQuestion.php.

650 : float
651 {
652 if ($found_values === null) {
653 $found_values = [];
654 }
655 $points = 0;
656 if (count($found_values) > 0) {
657 foreach ($this->answers as $key => $answer) {
658 if (in_array($key, $found_values)) {
659 $points += $answer->getPoints();
660 } elseif ($this->getIsMultipleChoice()) {
661 $points += $answer->getPointsUnchecked();
662 }
663 }
664 return $points;
665 }
666 return $points;
667 }
getIsMultipleChoice()
Returns true, if the imagemap question is a multiplechoice question.

◆ calculateReachedPointsFromPreviewSession()

assImagemapQuestion::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $preview_session)

Reimplemented from assQuestion.

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

442 : float
443 {
444 $solution_data = $preview_session->getParticipantsSolution();
445
446 $reached_points = $this->calculateReachedPointsForSolution(is_array($solution_data) ? array_values($solution_data) : []);
447
448 return $this->ensureNonNegativePoints($reached_points);
449 }
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 $src = opendir($image_source_path);
209 while ($src_file = readdir($src)) {
210 if ($src_file === '.' || $src_file === '..') {
211 continue;
212 }
213 copy(
214 $image_source_path . DIRECTORY_SEPARATOR . $src_file,
215 $image_target_path . DIRECTORY_SEPARATOR . $src_file
216 );
217 }
218 }
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 377 of file class.assImagemapQuestion.php.

377 : void
378 {
379 if ($index < 0) {
380 return;
381 }
382 if (count($this->answers) < 1) {
383 return;
384 }
385 if ($index >= count($this->answers)) {
386 return;
387 }
388 unset($this->answers[$index]);
389 $this->answers = array_values($this->answers);
390 for ($i = 0; $i < count($this->answers); $i++) {
391 if ($this->answers[$i]->getOrder() > $index) {
392 $this->answers[$i]->setOrder($i);
393 }
394 }
395 }

◆ deleteImage()

assImagemapQuestion::deleteImage ( )

Deletes the image file.

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

598 : void
599 {
600 $file = $this->getImagePath() . $this->getImageFilename();
601 @unlink($file);
602 $this->flushAnswers();
603 $this->image_filename = '';
604 }

◆ flushAnswers()

assImagemapQuestion::flushAnswers ( )

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

397 : void
398 {
399 $this->answers = [];
400 }

◆ get_imagemap_contents()

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

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

311 : string
312 {
313 $imagemap_contents = '<map name=\'' . $this->title . '\'> ';
314 for ($i = 0; $i < count($this->answers); $i++) {
315 $imagemap_contents .= '<area alt=\'' . $this->answers[$i]->getAnswertext() . '\' ';
316 $imagemap_contents .= 'shape=\'' . $this->answers[$i]->getArea() . '\' ';
317 $imagemap_contents .= 'coords=\'' . $this->answers[$i]->getCoords() . '\' ';
318 $imagemap_contents .= "href=\"{$href}&selimage=" . $this->answers[$i]->getOrder() . "\" /> ";
319 }
320 $imagemap_contents .= '</map>';
321 return $imagemap_contents;
322 }

◆ 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 564 of file class.assImagemapQuestion.php.

564 : string
565 {
566 return 'qpl_qst_imagemap';
567 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAddSolutionSelectionParameter()

assImagemapQuestion::getAddSolutionSelectionParameter ( )
protected

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

745 {
746 if (!$this->isAddSolutionSelectionRequest()) {
747 return null;
748 }
749
750 return $this->request->raw('selImage');
751 }

◆ getAnswer()

assImagemapQuestion::getAnswer ( int  $index = 0)

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

359 {
360 if ($index < 0) {
361 return null;
362 }
363 if (count($this->answers) < 1) {
364 return null;
365 }
366 if ($index >= count($this->answers)) {
367 return null;
368 }
369 return $this->answers[$index];
370 }

◆ getAnswerCount()

assImagemapQuestion::getAnswerCount ( )

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

353 : int
354 {
355 return count($this->answers);
356 }

◆ getAnswers()

& assImagemapQuestion::getAnswers ( )

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

372 : array
373 {
374 return $this->answers;
375 }

◆ 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 577 of file class.assImagemapQuestion.php.

577 : string
578 {
579 return 'qpl_a_imagemap';
580 }

◆ 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 724 of file class.assImagemapQuestion.php.

725 {
726 if ($index !== null) {
727 return $this->getAnswer($index);
728 } else {
729 return $this->getAnswers();
730 }
731 }

◆ getCorrectSolutionForTextOutput()

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

Reimplemented from assQuestion.

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

893 : array
894 {
895 return array_map(
896 fn(ASS_AnswerImagemap $v): string => "{$v->getArea()}: {$v->getCoords()}"
897 . "({$this->lng->txt('points')} "
898 . "{$this->lng->txt('checked')}: {$v->getPoints()}, "
899 . "{$this->lng->txt('unchecked')}: {$v->getPointsUnchecked()})",
900 $this->getAnswers()
901 );
902 }

◆ getExpressionTypes()

assImagemapQuestion::getExpressionTypes ( )

◆ getImageFilename()

assImagemapQuestion::getImageFilename ( )

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

285 : string
286 {
288 }

◆ 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 402 of file class.assImagemapQuestion.php.

402 : float
403 {
404 $points = 0;
405 foreach ($this->answers as $key => $value) {
406 if ($this->is_multiple_choice) {
407 if ($value->getPoints() > $value->getPointsUnchecked()) {
408 $points += $value->getPoints();
409 } else {
410 $points += $value->getPointsUnchecked();
411 }
412 } else {
413 if ($value->getPoints() > $points) {
414 $points = $value->getPoints();
415 }
416 }
417 }
418 return $points;
419 }

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

669 : array
670 {
672 }
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 551 of file class.assImagemapQuestion.php.

551 : string
552 {
553 return 'assImagemapQuestion';
554 }

◆ getRemoveSolutionSelectionParameter()

assImagemapQuestion::getRemoveSolutionSelectionParameter ( )
protected

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

765 {
766 if (!$this->isRemoveSolutionSelectionRequest()) {
767 return null;
768 }
769
770 return $this->request->raw('remImage');
771 }

◆ getReuseSolutionSelectionParameter()

assImagemapQuestion::getReuseSolutionSelectionParameter ( )
protected

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

788 : ?array
789 {
790 if (!$this->isReuseSolutionSelectionRequest()) {
791 return null;
792 }
793
794 return assQuestion::explodeKeyValues($this->request->raw('reuseSelection'));
795 }
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 586 of file class.assImagemapQuestion.php.

586 : string
587 {
588 $text = parent::getRTETextWithMediaObjects();
589 foreach ($this->answers as $index => $answer) {
590 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->getId(), 0, $index);
591 }
592 return $text;
593 }

◆ getTestOutputSolutions()

assImagemapQuestion::getTestOutputSolutions (   $activeId,
  $pass 
)

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

733 : array
734 {
735 $solution = parent::getTestOutputSolutions($activeId, $pass);
736
737 $this->currentSolution = [];
738 foreach ($solution as $record) {
739 $this->currentSolution[] = $record['value1'];
740 }
741
742 return $solution;
743 }

◆ 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 684 of file class.assImagemapQuestion.php.

688 $result = new ilUserQuestionResult($this, $active_id, $pass);
689
690 $maxStep = $this->lookupMaxStep($active_id, $pass);
691 if ($maxStep > 0) {
692 $data = $this->db->queryF(
693 'SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s',
694 ['integer', 'integer', 'integer', 'integer'],
695 [$active_id, $pass, $this->getId(), $maxStep]
696 );
697 } else {
698 $data = $this->db->queryF(
699 'SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step IS NULL',
700 ['integer', 'integer', 'integer'],
701 [$active_id, $pass, $this->getId()]
702 );
703 }
704
705 while ($row = $this->db->fetchAssoc($data)) {
706 $result->addKeyValue($row['value1'], $row['value1']);
707 }
708
709 $points = $this->calculateReachedPoints($active_id, $pass);
710 $max_points = $this->getMaximumPoints();
711
712 $result->setReachedPercentage(($points / $max_points) * 100);
713
714 return $result;
715 }
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 752 of file class.assImagemapQuestion.php.

752 : bool
753 {
754 if (!$this->request->isset('selImage')) {
755 return false;
756 }
757
758 if (!strlen($this->request->raw('selImage'))) {
759 return false;
760 }
761
762 return true;
763 }

◆ 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 772 of file class.assImagemapQuestion.php.

772 : bool
773 {
774 if (!$this->is_multiple_choice) {
775 return false;
776 }
777
778 if (!$this->request->isset('remImage')) {
779 return false;
780 }
781
782 if (!strlen($this->request->raw('remImage'))) {
783 return false;
784 }
785
786 return true;
787 }

◆ isReuseSolutionSelectionRequest()

assImagemapQuestion::isReuseSolutionSelectionRequest ( )
protected

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

796 : bool
797 {
798 if (!$this->getTestPresentationConfig()->isPreviousPassSolutionReuseAllowed()) {
799 return false;
800 }
801
802 if (!$this->request->isset('reuseSelection')) {
803 return false;
804 }
805
806 if (!strlen($this->request->raw('reuseSelection'))) {
807 return false;
808 }
809
810 if (!preg_match('/\d(,\d)*/', $this->request->raw('reuseSelection'))) {
811 return false;
812 }
813
814 return true;
815 }

◆ loadFromDb()

assImagemapQuestion::loadFromDb ( int  $question_id)

Reimplemented from assQuestion.

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

220 : void
221 {
222 $result = $this->db->queryF(
223 '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',
224 ['integer'],
225 [$question_id]
226 );
227 if ($result->numRows() == 1) {
228 $data = $this->db->fetchAssoc($result);
229 $this->setId($question_id);
230 $this->setObjId($data['obj_fi']);
231 $this->setTitle((string) $data['title']);
232 $this->setComment((string) $data['description']);
233 $this->setOriginalId($data['original_id']);
234 $this->setNrOfTries($data['nr_of_tries']);
235 $this->setAuthor($data['author']);
236 $this->setPoints($data['points']);
237 $this->setOwner($data['owner']);
238 $this->setIsMultipleChoice($data['is_multiple_choice'] == self::MODE_MULTIPLE_CHOICE);
239 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data['question_text'], 1));
240 $this->setImageFilename($data['image_file'] ?? '');
241
242 try {
246 }
247
248 try {
249 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
251 }
252
253 $result = $this->db->queryF(
254 'SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC',
255 ['integer'],
256 [$question_id]
257 );
258 if ($result->numRows() > 0) {
259 while ($data = $this->db->fetchAssoc($result)) {
260 $image_map_question = new ASS_AnswerImagemap($data['answertext'] ?? '', $data['points'], $data['aorder']);
261 $image_map_question->setCoords($data['coords']);
262 $image_map_question->setArea($data['area']);
263 $image_map_question->setPointsUnchecked($data['points_unchecked']);
264 array_push($this->answers, $image_map_question);
265 }
266 }
267 }
268 parent::loadFromDb($question_id);
269 }
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 523 of file class.assImagemapQuestion.php.

523 : void
524 {
525 $solution = $previewSession->getParticipantsSolution();
526
527 if ($this->is_multiple_choice
528 && $this->request->isset('remImage')) {
529 unset($solution[$this->request->int('remImage')]);
530 }
531
532 if ($this->request->isset('selImage')) {
533 if (!$this->is_multiple_choice) {
534 $solution = [];
535 }
536
537 $solution[$this->request->int('selImage')] = $this->request->int('selImage');
538 }
539
540 $previewSession->setParticipantsSolution($solution);
541 }

◆ 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 459 of file class.assImagemapQuestion.php.

463 : bool {
464 if (is_null($pass)) {
465 $pass = ilObjTest::_getPass($active_id);
466 }
467
468 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
469 function () use ($active_id, $pass, $authorized) {
470 if ($authorized) {
471 // remove the dummy record of the intermediate solution
472 $this->deleteDummySolutionRecord($active_id, $pass);
473
474 // delete the authorized solution and make the intermediate solution authorized (keeping timestamps)
475 $this->removeCurrentSolution($active_id, $pass, true);
476 $this->updateCurrentSolutionsAuthorization($active_id, $pass, true, true);
477 return;
478 }
479
481 $active_id,
482 $pass,
483 $this->is_multiple_choice
484 );
485
486 if ($this->isReuseSolutionSelectionRequest()) {
487 $selection = $this->getReuseSolutionSelectionParameter();
488
489 foreach ($selection as $selectedIndex) {
490 $this->saveCurrentSolution($active_id, $pass, (int) $selectedIndex, null, $authorized);
491 }
492 return;
493 }
494
496 $selection = $this->getRemoveSolutionSelectionParameter();
497 $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, [
498 'value1' => (int) $selection
499 ]);
500 return;
501 }
502
503 if (!$this->isAddSolutionSelectionRequest()) {
504 return;
505 }
506 $selection = $this->getAddSolutionSelectionParameter();
507
508 if ($this->is_multiple_choice) {
509 $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, [
510 'value1' => (int) $this->request->raw('selImage')
511 ]);
512 } else {
513 $this->removeCurrentSolution($active_id, $pass, $authorized);
514 }
515
516 $this->saveCurrentSolution($active_id, $pass, $this->request->raw('selImage'), null, $authorized);
517 }
518 );
519
520 return true;
521 }
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 290 of file class.assImagemapQuestion.php.

293 : void {
294 if (!empty($image_filename)) {
295 $image_filename = str_replace(' ', '_', $image_filename);
296 $this->image_filename = $image_filename;
297 }
298 if (!empty($image_tempfilename)) {
299 $imagepath = $this->getImagePath();
300 if (!file_exists($imagepath)) {
301 ilFileUtils::makeDirParents($imagepath);
302 }
303 if (!ilFileUtils::moveUploadedFile($image_tempfilename, $image_filename, $imagepath . $image_filename)) {
304 $this->tpl->setOnScreenMessage('failure', 'The image could not be uploaded!');
305 return;
306 }
307 $this->log->write('gespeichert: ' . $imagepath . $image_filename);
308 }
309 }
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 859 of file class.assImagemapQuestion.php.

862 : array {
863 $parsed_solution = [];
864 foreach ($this->getAnswers() as $id => $answer) {
865 $value = $additional_info->getTagForLangVar('unchecked');
866 foreach ($solution_values as $solution) {
867 if ($solution['value1'] == $id) {
868 $value = $additional_info->getTagForLangVar('checked');
869 break;
870 }
871 }
872 $parsed_solution["{$answer->getArea()}: {$answer->getCoords()}"] = $value;
873 }
874 return $parsed_solution;
875 }

◆ 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 877 of file class.assImagemapQuestion.php.

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

◆ toJSON()

assImagemapQuestion::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

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

609 : string
610 {
611 $result = [];
612 $result['id'] = $this->getId();
613 $result['type'] = (string) $this->getQuestionType();
614 $result['title'] = $this->getTitleForHTMLOutput();
615 $result['question'] = $this->formatSAQuestion($this->getQuestion());
616 $result['nr_of_tries'] = $this->getNrOfTries();
617 $result['shuffle'] = $this->getShuffle();
618 $result['is_multiple'] = $this->getIsMultipleChoice();
619 $result['feedback'] = [
620 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
621 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
622 ];
623 $result['image'] = $this->getImagePathWeb() . $this->getImageFilename();
624
625 $answers = [];
626 $order = 0;
627 foreach ($this->getAnswers() as $key => $answer_obj) {
628 array_push($answers, [
629 'answertext' => (string) $answer_obj->getAnswertext(),
630 'points' => (float) $answer_obj->getPoints(),
631 'points_unchecked' => (float) $answer_obj->getPointsUnchecked(),
632 'order' => $order,
633 'coords' => $answer_obj->getCoords(),
634 'state' => $answer_obj->getState(),
635 'area' => $answer_obj->getArea(),
636 'feedback' => $this->formatSAQuestion(
637 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
638 )
639 ]);
640 $order++;
641 }
642 $result['answers'] = $answers;
643
644 $mobs = ilObjMediaObject::_getMobsOfObject('qpl:html', $this->getId());
645 $result['mobs'] = $mobs;
646
647 return json_encode($result);
648 }
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 $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 817 of file class.assImagemapQuestion.php.

817 : array
818 {
819 $result = [
820 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
821 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
822 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
823 AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS => $additional_info
825 AdditionalInformationGenerator::KEY_QUESTION_IMAGEMAP_MODE => $this->getIsMultipleChoice()
826 ? $additional_info->getTagForLangVar('tst_imap_qst_mode_mc')
827 : $additional_info->getTagForLangVar('tst_imap_qst_mode_sc'),
828 AdditionalInformationGenerator::KEY_QUESTION_IMAGEMAP_IMAGE => $this->getImagePathWeb() . $this->getImageFilename(),
829 AdditionalInformationGenerator::KEY_FEEDBACK => [
830 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion(
831 $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)
832 ),
833 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion(
834 $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)
835 )
836 ]
837 ];
838
839 $answers = [];
840 $order = 0;
841 foreach ($this->getAnswers() as $key => $answer_obj) {
842 array_push($answers, [
843 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION => (string) $answer_obj->getAnswertext(),
844 AdditionalInformationGenerator::KEY_QUESTION_POINTS_CHECKED => (float) $answer_obj->getPoints(),
845 AdditionalInformationGenerator::KEY_QUESTION_POINTS_UNCHECKED => (float) $answer_obj->getPointsUnchecked(),
846 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION_ORDER => $order,
847 AdditionalInformationGenerator::KEY_QUESTION_IMAGEMAP_ANSWER_OPTION_COORDS => $answer_obj->getCoords(),
848 AdditionalInformationGenerator::KEY_FEEDBACK => $this->formatSAQuestion(
849 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
850 )
851 ]);
852 $order++;
853 }
854 $result[AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTIONS] = $answers;
855
856 return $result;
857 }

◆ uploadImagemap()

assImagemapQuestion::uploadImagemap ( array  $shapes)

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

271 : int
272 {
273 $added = 0;
274
275 if (count($shapes) > 0) {
276 foreach ($shapes as $shape) {
277 $this->addAnswer($shape->getAnswertext(), 0.0, count($this->answers), $shape->getCoords(), $shape->getArea());
278 $added++;
279 }
280 }
281
282 return $added;
283 }
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: