ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 ()
 
 copyImagemapFiles (int $source_question_id, int $source_parent_id, int $target_question_id, int $target_parent_id)
 
 loadFromDb (int $question_id)
 
 uploadImagemap (array $shapes)
 
 uploadImageFile (string $upload_file_name, string $upload_tmp_name)
 
 getImageFilename ()
 
 setImageFilename (string $image_filename)
 
 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)
 
 toNormalized (Transformations $transformations, array $context=[])
 
 fromNormalized (array $normalized, Transformations $transformations)
 
- 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)
 
 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)
 
 updateOriginalId (?int $original_id=null)
 
 duplicate (bool $set_original_id=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)
 
 toNormalized (Transformations $transformations, array $context=[])
 
 fromNormalized (array $normalized, Transformations $transformations)
 
 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)
 
 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 ()
 
 toNormalized (Transformations $transformations, array $context=[])
 Convert the internal state of the implementing object into a language-neutral array structure. More...
 
 fromNormalized (array $normalized, Transformations $transformations)
 Restore the object from its normalized representation. More...
 

Data Fields

 $currentSolution = []
 
const MODE_SINGLE_CHOICE = 0
 
const MODE_MULTIPLE_CHOICE = 1
 
const AVAILABLE_SHAPES
 
array $answers
 
string $image_filename
 
string $imagemap_contents
 
array $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

bool $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 43 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 87 of file class.assImagemapQuestion.php.

94 {
96 $this->image_filename = $image_filename;
97 $this->answers = [];
98 $this->coords = [];
99
100 $local_dic = QuestionPoolDIC::dic();
101 $this->request = $local_dic['request_data_collector'];
102 }
__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 355 of file class.assImagemapQuestion.php.

362 : void {
363 if (array_key_exists($order, $this->answers)) {
364 // Insert answer
365 $answer = new ASS_AnswerImagemap($answertext, $points, $order, 0, -1);
366 $answer->setCoords($coords);
367 $answer->setArea($area);
368 $answer->setPointsUnchecked($points_unchecked);
369 for ($i = count($this->answers) - 1; $i >= $order; $i--) {
370 $this->answers[$i + 1] = $this->answers[$i];
371 $this->answers[$i + 1]->setOrder($i + 1);
372 }
373 $this->answers[$order] = $answer;
374 } else {
375 // Append answer
376 $answer = new ASS_AnswerImagemap($answertext, $points, count($this->answers), 0, -1);
377 $answer->setCoords($coords);
378 $answer->setArea($area);
379 $answer->setPointsUnchecked($points_unchecked);
380 array_push($this->answers, $answer);
381 }
382 }
Class for true/false or yes/no answers.

◆ calculateReachedPoints()

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

Reimplemented from assQuestion.

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

456 : float {
457 if ($pass === null) {
458 $pass = $this->getSolutionMaxPass($active_id);
459 }
460 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
461 $found_values = [];
462 while ($data = $this->db->fetchAssoc($result)) {
463 if ($data['value1'] !== '') {
464 $found_values[] = $data['value1'];
465 }
466 }
467
468 $points = $this->calculateReachedPointsForSolution($found_values);
469
470 return $points;
471 }
calculateReachedPointsForSolution(?array $found_values)
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
getSolutionMaxPass(int $active_id)
$data
Definition: storeScorm.php:45

◆ calculateReachedPointsForSolution()

assImagemapQuestion::calculateReachedPointsForSolution ( ?array  $found_values)
protected

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

681 : float
682 {
683 if ($found_values === null) {
684 $found_values = [];
685 }
686 $points = 0;
687 if (count($found_values) > 0) {
688 foreach ($this->answers as $key => $answer) {
689 if (in_array($key, $found_values)) {
690 $points += $answer->getPoints();
691 } elseif ($this->getIsMultipleChoice()) {
692 $points += $answer->getPointsUnchecked();
693 }
694 }
695 return $points;
696 }
697 return $points;
698 }
getIsMultipleChoice()
Returns true, if the imagemap question is a multiplechoice question.

◆ calculateReachedPointsFromPreviewSession()

assImagemapQuestion::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $preview_session)

Reimplemented from assQuestion.

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

473 : float
474 {
475 $solution_data = $preview_session->getParticipantsSolution();
476
477 $reached_points = $this->calculateReachedPointsForSolution(is_array($solution_data) ? array_values($solution_data) : []);
478
479 return $this->ensureNonNegativePoints($reached_points);
480 }
ensureNonNegativePoints(float $points)

◆ cloneQuestionTypeSpecificProperties()

assImagemapQuestion::cloneQuestionTypeSpecificProperties ( \assQuestion  $target)
protected

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

192 : \assQuestion {
193 $this->copyImagemapFiles($this->getId(), $this->getObjId(), $target->getId(), $target->getObjId());
194 return $target;
195 }
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 197 of file class.assImagemapQuestion.php.

202 : void {
203 $image_source_path = $this->getImagePath($source_question_id, $source_parent_id);
204 $image_target_path = $this->getImagePath($target_question_id, $target_parent_id);
205
206 if (!file_exists($image_target_path)) {
207 ilFileUtils::makeDirParents($image_target_path);
208 } else {
209 $this->removeAllImageFiles($image_target_path);
210 }
211
212 if (!file_exists($image_source_path) || !is_readable($image_source_path)) {
213 $this->log->forComponent('qpl')->alert(
214 "Could not copy imagemap question files: Source path '{$image_source_path}' does not exist or is not readable.",
215 [
216 'source_question_id' => $source_question_id,
217 'source_parent_id' => $source_parent_id,
218 'target_question_id' => $target_question_id,
219 'target_parent_id' => $target_parent_id,
220 'image_source_path' => $image_source_path,
221 'image_target_path' => $image_target_path
222 ]
223 );
224 return;
225 }
226
227 $src = opendir($image_source_path);
228 while ($src_file = readdir($src)) {
229 if ($src_file === '.' || $src_file === '..') {
230 continue;
231 }
232 copy(
233 $image_source_path . DIRECTORY_SEPARATOR . $src_file,
234 $image_target_path . DIRECTORY_SEPARATOR . $src_file
235 );
236 }
237 }
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 408 of file class.assImagemapQuestion.php.

408 : void
409 {
410 if ($index < 0) {
411 return;
412 }
413 if (count($this->answers) < 1) {
414 return;
415 }
416 if ($index >= count($this->answers)) {
417 return;
418 }
419 unset($this->answers[$index]);
420 $this->answers = array_values($this->answers);
421 for ($i = 0; $i < count($this->answers); $i++) {
422 if ($this->answers[$i]->getOrder() > $index) {
423 $this->answers[$i]->setOrder($i);
424 }
425 }
426 }

◆ deleteImage()

assImagemapQuestion::deleteImage ( )

Deletes the image file.

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

629 : void
630 {
631 $file = $this->getImagePath() . $this->getImageFilename();
632 @unlink($file);
633 $this->flushAnswers();
634 $this->image_filename = '';
635 }

◆ flushAnswers()

assImagemapQuestion::flushAnswers ( )

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

428 : void
429 {
430 $this->answers = [];
431 }

◆ fromNormalized()

assImagemapQuestion::fromNormalized ( array  $normalized,
Transformations  $transformations 
)
Parameters
array<array-key,mixed>$normalized

Reimplemented from assQuestion.

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

953 : static
954 {
955 $clone = parent::fromNormalized($normalized, $transformations);
956 $clone->image_filename = $transformations->denormalize($normalized['image'], QuestionImage::class)->getFilename();
957 $clone->is_multiple_choice = $transformations->bool($normalized['multiple_choice']);
958 $clone->answers = array_map(
959 static fn(array $answer): ASS_AnswerImagemap => $transformations->denormalize($answer, new ASS_AnswerImagemap()),
960 $normalized['answers']
961 );
962
963 return $clone;
964 }
denormalize(array|float|bool|int|string|null $normalized, string|object $expected)

◆ get_imagemap_contents()

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

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

342 : string
343 {
344 $imagemap_contents = '<map name=\'' . $this->title . '\'> ';
345 for ($i = 0; $i < count($this->answers); $i++) {
346 $imagemap_contents .= '<area alt=\'' . $this->answers[$i]->getAnswertext() . '\' ';
347 $imagemap_contents .= 'shape=\'' . $this->answers[$i]->getArea() . '\' ';
348 $imagemap_contents .= 'coords=\'' . $this->answers[$i]->getCoords() . '\' ';
349 $imagemap_contents .= "href=\"{$href}&selimage=" . $this->answers[$i]->getOrder() . "\" /> ";
350 }
351 $imagemap_contents .= '</map>';
352 return $imagemap_contents;
353 }

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

595 : string
596 {
597 return 'qpl_qst_imagemap';
598 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAddSolutionSelectionParameter()

assImagemapQuestion::getAddSolutionSelectionParameter ( )
protected

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

776 {
777 if (!$this->isAddSolutionSelectionRequest()) {
778 return null;
779 }
780
781 return $this->request->raw('selImage');
782 }

◆ getAnswer()

assImagemapQuestion::getAnswer ( int  $index = 0)

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

390 {
391 if ($index < 0) {
392 return null;
393 }
394 if (count($this->answers) < 1) {
395 return null;
396 }
397 if ($index >= count($this->answers)) {
398 return null;
399 }
400 return $this->answers[$index];
401 }

◆ getAnswerCount()

assImagemapQuestion::getAnswerCount ( )

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

384 : int
385 {
386 return count($this->answers);
387 }

◆ getAnswers()

& assImagemapQuestion::getAnswers ( )

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

403 : array
404 {
405 return $this->answers;
406 }

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

608 : string
609 {
610 return 'qpl_a_imagemap';
611 }

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

756 {
757 if ($index !== null) {
758 return $this->getAnswer($index);
759 } else {
760 return $this->getAnswers();
761 }
762 }

◆ getCorrectSolutionForTextOutput()

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

Reimplemented from assQuestion.

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

924 : array
925 {
926 return array_map(
927 fn(ASS_AnswerImagemap $v): string => "{$v->getArea()}: {$v->getCoords()}"
928 . "({$this->lng->txt('points')} "
929 . "{$this->lng->txt('checked')}: {$v->getPoints()}, "
930 . "{$this->lng->txt('unchecked')}: {$v->getPointsUnchecked()})",
931 $this->getAnswers()
932 );
933 }

◆ getExpressionTypes()

assImagemapQuestion::getExpressionTypes ( )

◆ getImageFilename()

assImagemapQuestion::getImageFilename ( )

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

331 : string
332 {
334 }

◆ getIsMultipleChoice()

assImagemapQuestion::getIsMultipleChoice ( )

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

Returns
bool

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

119 : bool
120 {
122 }

References $is_multiple_choice.

◆ getMaximumPoints()

assImagemapQuestion::getMaximumPoints ( )

Reimplemented from assQuestion.

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

433 : float
434 {
435 $points = 0;
436 foreach ($this->answers as $key => $value) {
437 if ($this->is_multiple_choice) {
438 if ($value->getPoints() > $value->getPointsUnchecked()) {
439 $points += $value->getPoints();
440 } else {
441 $points += $value->getPointsUnchecked();
442 }
443 } else {
444 if ($value->getPoints() > $points) {
445 $points = $value->getPoints();
446 }
447 }
448 }
449 return $points;
450 }

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

700 : array
701 {
703 }
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 582 of file class.assImagemapQuestion.php.

582 : string
583 {
584 return 'assImagemapQuestion';
585 }

◆ getRemoveSolutionSelectionParameter()

assImagemapQuestion::getRemoveSolutionSelectionParameter ( )
protected

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

796 {
797 if (!$this->isRemoveSolutionSelectionRequest()) {
798 return null;
799 }
800
801 return $this->request->raw('remImage');
802 }

◆ getReuseSolutionSelectionParameter()

assImagemapQuestion::getReuseSolutionSelectionParameter ( )
protected

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

819 : ?array
820 {
821 if (!$this->isReuseSolutionSelectionRequest()) {
822 return null;
823 }
824
825 return assQuestion::explodeKeyValues($this->request->raw('reuseSelection'));
826 }
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 617 of file class.assImagemapQuestion.php.

617 : string
618 {
619 $text = parent::getRTETextWithMediaObjects();
620 foreach ($this->answers as $index => $answer) {
621 $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->getId(), 0, $index);
622 }
623 return $text;
624 }
$text
Definition: xapiexit.php:21

◆ getTestOutputSolutions()

assImagemapQuestion::getTestOutputSolutions (   $activeId,
  $pass 
)

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

764 : array
765 {
766 $solution = parent::getTestOutputSolutions($activeId, $pass);
767
768 $this->currentSolution = [];
769 foreach ($solution as $record) {
770 $this->currentSolution[] = $record['value1'];
771 }
772
773 return $solution;
774 }

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

719 $result = new ilUserQuestionResult($this, $active_id, $pass);
720
721 $maxStep = $this->lookupMaxStep($active_id, $pass);
722 if ($maxStep > 0) {
723 $data = $this->db->queryF(
724 'SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s',
725 ['integer', 'integer', 'integer', 'integer'],
726 [$active_id, $pass, $this->getId(), $maxStep]
727 );
728 } else {
729 $data = $this->db->queryF(
730 'SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step IS NULL',
731 ['integer', 'integer', 'integer'],
732 [$active_id, $pass, $this->getId()]
733 );
734 }
735
736 while ($row = $this->db->fetchAssoc($data)) {
737 $result->addKeyValue($row['value1'], $row['value1']);
738 }
739
740 $points = $this->calculateReachedPoints($active_id, $pass);
741 $max_points = $this->getMaximumPoints();
742
743 $result->setReachedPercentage(($points / $max_points) * 100);
744
745 return $result;
746 }
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 783 of file class.assImagemapQuestion.php.

783 : bool
784 {
785 if (!$this->request->isset('selImage')) {
786 return false;
787 }
788
789 if (!strlen($this->request->raw('selImage'))) {
790 return false;
791 }
792
793 return true;
794 }

◆ isComplete()

assImagemapQuestion::isComplete ( )

Reimplemented from assQuestion.

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

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

References getMaximumPoints().

+ Here is the call graph for this function:

◆ isRemoveSolutionSelectionRequest()

assImagemapQuestion::isRemoveSolutionSelectionRequest ( )
protected

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

803 : bool
804 {
805 if (!$this->is_multiple_choice) {
806 return false;
807 }
808
809 if (!$this->request->isset('remImage')) {
810 return false;
811 }
812
813 if (!strlen($this->request->raw('remImage'))) {
814 return false;
815 }
816
817 return true;
818 }

◆ isReuseSolutionSelectionRequest()

assImagemapQuestion::isReuseSolutionSelectionRequest ( )
protected

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

827 : bool
828 {
829 if (!$this->getTestPresentationConfig()->isPreviousPassSolutionReuseAllowed()) {
830 return false;
831 }
832
833 if (!$this->request->isset('reuseSelection')) {
834 return false;
835 }
836
837 if (!strlen($this->request->raw('reuseSelection'))) {
838 return false;
839 }
840
841 if (!preg_match('/\d(,\d)*/', $this->request->raw('reuseSelection'))) {
842 return false;
843 }
844
845 return true;
846 }

◆ loadFromDb()

assImagemapQuestion::loadFromDb ( int  $question_id)

Reimplemented from assQuestion.

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

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

+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assImagemapQuestion::saveAdditionalQuestionDataToDb ( )

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

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

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

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

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

554 : void
555 {
556 $solution = $previewSession->getParticipantsSolution();
557
558 if ($this->is_multiple_choice
559 && $this->request->isset('remImage')) {
560 unset($solution[$this->request->int('remImage')]);
561 }
562
563 if ($this->request->isset('selImage')) {
564 if (!$this->is_multiple_choice) {
565 $solution = [];
566 }
567
568 $solution[$this->request->int('selImage')] = $this->request->int('selImage');
569 }
570
571 $previewSession->setParticipantsSolution($solution);
572 }

◆ saveToDb()

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

Reimplemented from assQuestion.

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

138 : void
139 {
143 parent::saveToDb($original_id);
144 }
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 490 of file class.assImagemapQuestion.php.

494 : bool {
495 if (is_null($pass)) {
496 $pass = ilObjTest::_getPass($active_id);
497 }
498
499 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
500 function () use ($active_id, $pass, $authorized) {
501 if ($authorized) {
502 // remove the dummy record of the intermediate solution
503 $this->deleteDummySolutionRecord($active_id, $pass);
504
505 // delete the authorized solution and make the intermediate solution authorized (keeping timestamps)
506 $this->removeCurrentSolution($active_id, $pass, true);
507 $this->updateCurrentSolutionsAuthorization($active_id, $pass, true, true);
508 return;
509 }
510
512 $active_id,
513 $pass,
514 $this->is_multiple_choice
515 );
516
517 if ($this->isReuseSolutionSelectionRequest()) {
518 $selection = $this->getReuseSolutionSelectionParameter();
519
520 foreach ($selection as $selectedIndex) {
521 $this->saveCurrentSolution($active_id, $pass, (int) $selectedIndex, null, $authorized);
522 }
523 return;
524 }
525
527 $selection = $this->getRemoveSolutionSelectionParameter();
528 $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, [
529 'value1' => (int) $selection
530 ]);
531 return;
532 }
533
534 if (!$this->isAddSolutionSelectionRequest()) {
535 return;
536 }
537 $selection = $this->getAddSolutionSelectionParameter();
538
539 if ($this->is_multiple_choice) {
540 $this->deleteSolutionRecordByValues($active_id, $pass, $authorized, [
541 'value1' => (int) $this->request->raw('selImage')
542 ]);
543 } else {
544 $this->removeCurrentSolution($active_id, $pass, $authorized);
545 }
546
547 $this->saveCurrentSolution($active_id, $pass, $this->request->raw('selImage'), null, $authorized);
548 }
549 );
550
551 return true;
552 }
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)

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

338 : void {
339 $this->image_filename = $image_filename;
340 }

◆ setIsMultipleChoice()

assImagemapQuestion::setIsMultipleChoice (   $is_multiple_choice)

Set true if the Imagemapquestion is a multiplechoice Question.

Parameters
bool$is_multiple_choice

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

109 : void
110 {
111 $this->is_multiple_choice = $is_multiple_choice;
112 }

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

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

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

908 : array
909 {
910 $parsed_solution = [];
911 foreach ($this->getAnswers() as $id => $answer) {
912 $value = $this->lng->txt('unchecked');
913 foreach ($solution_values as $solution) {
914 if ($solution['value1'] == $id) {
915 $value = $this->lng->txt('checked');
916 break;
917 }
918 }
919 $parsed_solution[] = "{$answer->getArea()}: {$answer->getCoords()} ({$value})";
920 }
921 return $parsed_solution;
922 }

◆ toJSON()

assImagemapQuestion::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

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

640 : string
641 {
642 $result = [];
643 $result['id'] = $this->getId();
644 $result['type'] = (string) $this->getQuestionType();
645 $result['title'] = $this->getTitleForHTMLOutput();
646 $result['question'] = $this->formatSAQuestion($this->getQuestion());
647 $result['nr_of_tries'] = $this->getNrOfTries();
648 $result['shuffle'] = $this->getShuffle();
649 $result['is_multiple'] = $this->getIsMultipleChoice();
650 $result['feedback'] = [
651 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
652 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
653 ];
654 $result['image'] = $this->getImagePathWeb() . $this->getImageFilename();
655
656 $answers = [];
657 $order = 0;
658 foreach ($this->getAnswers() as $key => $answer_obj) {
659 array_push($answers, [
660 'answertext' => (string) $answer_obj->getAnswertext(),
661 'points' => (float) $answer_obj->getPoints(),
662 'points_unchecked' => (float) $answer_obj->getPointsUnchecked(),
663 'order' => $order,
664 'coords' => $answer_obj->getCoords(),
665 'state' => $answer_obj->getState(),
666 'area' => $answer_obj->getArea(),
667 'feedback' => $this->formatSAQuestion(
668 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
669 )
670 ]);
671 $order++;
672 }
673 $result['answers'] = $answers;
674
675 $mobs = ilObjMediaObject::_getMobsOfObject('qpl:html', $this->getId());
676 $result['mobs'] = $mobs;
677
678 return json_encode($result);
679 }
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 848 of file class.assImagemapQuestion.php.

848 : array
849 {
850 $result = [
851 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
852 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
853 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
854 AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS => $additional_info
856 AdditionalInformationGenerator::KEY_QUESTION_IMAGEMAP_MODE => $this->getIsMultipleChoice()
857 ? $additional_info->getTagForLangVar('tst_imap_qst_mode_mc')
858 : $additional_info->getTagForLangVar('tst_imap_qst_mode_sc'),
859 AdditionalInformationGenerator::KEY_QUESTION_IMAGEMAP_IMAGE => $this->getImagePathWeb() . $this->getImageFilename(),
860 AdditionalInformationGenerator::KEY_FEEDBACK => [
861 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion(
862 $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)
863 ),
864 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion(
865 $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)
866 )
867 ]
868 ];
869
870 $answers = [];
871 $order = 0;
872 foreach ($this->getAnswers() as $key => $answer_obj) {
873 array_push($answers, [
874 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION => (string) $answer_obj->getAnswertext(),
875 AdditionalInformationGenerator::KEY_QUESTION_POINTS_CHECKED => (float) $answer_obj->getPoints(),
876 AdditionalInformationGenerator::KEY_QUESTION_POINTS_UNCHECKED => (float) $answer_obj->getPointsUnchecked(),
877 AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTION_ORDER => $order,
878 AdditionalInformationGenerator::KEY_QUESTION_IMAGEMAP_ANSWER_OPTION_COORDS => $answer_obj->getCoords(),
879 AdditionalInformationGenerator::KEY_FEEDBACK => $this->formatSAQuestion(
880 $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
881 )
882 ]);
883 $order++;
884 }
885 $result[AdditionalInformationGenerator::KEY_QUESTION_ANSWER_OPTIONS] = $answers;
886
887 return $result;
888 }

◆ toNormalized()

assImagemapQuestion::toNormalized ( Transformations  $transformations,
array  $context = [] 
)
Parameters
array<string,mixed>$context
Returns
array<array-key, mixed>|float|bool|int|string|null

Reimplemented from assQuestion.

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

939 : array|float|bool|int|string|null
940 {
941 return [
942 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
943 'image' => $transformations->normalize(new QuestionImage($this->image_filename, $this->getId())),
944 'multiple_choice' => $this->is_multiple_choice,
945 'answers' => $transformations->normalize($this->answers),
946 ];
947 }
Wrapper object for an image file within a question (e.g.

◆ uploadImageFile()

assImagemapQuestion::uploadImageFile ( string  $upload_file_name,
string  $upload_tmp_name 
)

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

307 : void {
308 $path_parts = pathinfo($upload_file_name);
309 $suffix = $path_parts['extension'] ?? '';
310
311 if (!in_array($path_parts['extension'], ['jpg', 'jpeg', 'png', 'gif'])) {
312 $this->tpl->setOnScreenMessage('failure', 'The image could not be uploaded!');
313 return;
314 }
315
316 $image_filename = bin2hex(random_bytes(10)) . ".{$suffix}";
317
318 $imagepath = $this->getImagePath();
319 if (!file_exists($imagepath)) {
320 ilFileUtils::makeDirParents($imagepath);
321 }
322
323 if (!ilFileUtils::moveUploadedFile($upload_tmp_name, $image_filename, $imagepath . $image_filename)) {
324 $this->tpl->setOnScreenMessage('failure', 'The image could not be uploaded!');
325 return;
326 }
327
328 $this->setImageFilename($image_filename);
329 }
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file

◆ uploadImagemap()

assImagemapQuestion::uploadImagemap ( array  $shapes)

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

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

Field Documentation

◆ $answers

array assImagemapQuestion::$answers

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

◆ $coords

array assImagemapQuestion::$coords

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

◆ $currentSolution

assImagemapQuestion::$currentSolution = []

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

◆ $image_filename

string assImagemapQuestion::$image_filename

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

Referenced by __construct().

◆ $imagemap_contents

string assImagemapQuestion::$imagemap_contents

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

◆ $is_multiple_choice

bool assImagemapQuestion::$is_multiple_choice = false
protected

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

Referenced by getIsMultipleChoice(), and setIsMultipleChoice().

◆ $request

RequestDataCollector assImagemapQuestion::$request
private

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

◆ AVAILABLE_SHAPES

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

Definition at line 54 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: