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

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)
 
- 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)
 
 duplicateQuestionHints (int $original_question_id, int $duplicate_question_id)
 
 duplicateSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet (int $active_id, int $pass, bool $authorized=true)
 
 removeSolutionRecordById (int $solutionId)
 
 getSolutionRecordById (int $solutionId)
 
 deleteDummySolutionRecord (int $activeId, int $passIndex)
 
 isDummySolutionRecord (array $solutionRecord)
 
 deleteSolutionRecordByValues (int $activeId, int $passIndex, bool $authorized, array $matchValues)
 
 duplicateIntermediateSolutionAuthorized (int $activeId, int $passIndex)
 
 forceExistingIntermediateSolution (int $activeId, int $passIndex, bool $considerDummyRecordCreation)
 
 lookupMaxStep (int $active_id, int $pass)
 
 buildTestPresentationConfig ()
 
 getSuggestedSolutionsRepo ()
 
 loadSuggestedSolutions ()
 
 answerToLog (AdditionalInformationGenerator $additional_info, int $active_id, int $pass)
 

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

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

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)
+ 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.

Referenced by uploadImagemap().

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...
+ Here is the caller graph for this function:

◆ calculateReachedPoints()

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

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)
getSolutionMaxPass(int $active_id)
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)

◆ calculateReachedPointsForSolution()

assImagemapQuestion::calculateReachedPointsForSolution ( ?array  $found_values)
protected

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

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

◆ calculateReachedPointsFromPreviewSession()

assImagemapQuestion::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $preview_session)

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(
449  $this->deductHintPointsFromReachedPoints($preview_session, $reached_points)
450  );
451  }
calculateReachedPointsForSolution(?array $found_values)
ensureNonNegativePoints(float $points)
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $preview_session, $reached_points)

◆ cloneQuestionTypeSpecificProperties()

assImagemapQuestion::cloneQuestionTypeSpecificProperties ( \assQuestion  $target)
protected

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

References copyImagemapFiles(), assQuestion\getId(), and assQuestion\getObjId().

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)
+ Here is the call graph for this function:

◆ 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.

References assQuestion\getImagePath(), ilFileUtils\makeDirParents(), and assQuestion\removeAllImageFiles().

Referenced by cloneQuestionTypeSpecificProperties().

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)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

600  : void
601  {
602  $file = $this->getImagePath() . $this->getImageFilename();
603  @unlink($file);
604  $this->flushAnswers();
605  $this->image_filename = '';
606  }
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.

◆ 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.

References $imagemap_contents.

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 public

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

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

566  : string
567  {
568  return 'qpl_qst_imagemap';
569  }
+ Here is the caller graph for this function:

◆ getAddSolutionSelectionParameter()

assImagemapQuestion::getAddSolutionSelectionParameter ( )
protected

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

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

◆ 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  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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

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

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

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

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

◆ getCorrectSolutionForTextOutput()

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

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

895  : array
896  {
897  return array_map(
898  fn(ASS_AnswerImagemap $v): string => "{$v->getArea()}: {$v->getCoords()}"
899  . "({$this->lng->txt('points')} "
900  . "{$this->lng->txt('checked')}: {$v->getPoints()}, "
901  . "{$this->lng->txt('unchecked')}: {$v->getPointsUnchecked()})",
902  $this->getAnswers()
903  );
904  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getExpressionTypes()

assImagemapQuestion::getExpressionTypes ( )

Get all available expression types for a specific question.

Returns
array

Implements iQuestionCondition.

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

◆ getImageFilename()

assImagemapQuestion::getImageFilename ( )

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

References $image_filename.

285  : string
286  {
287  return $this->image_filename;
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.

References $is_multiple_choice.

115  : bool
116  {
118  }

◆ getMaximumPoints()

assImagemapQuestion::getMaximumPoints ( )

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

Referenced by isComplete().

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

671  : array
672  {
673  return ilOperatorsExpressionMapping::getOperatorsByExpression($expression);
674  }

◆ getQuestionType()

assImagemapQuestion::getQuestionType ( )

Returns the question type of the question.

Returns the question type of the question

Returns
integer The question type of the question public

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

553  : string
554  {
555  return 'assImagemapQuestion';
556  }

◆ getRemoveSolutionSelectionParameter()

assImagemapQuestion::getRemoveSolutionSelectionParameter ( )
protected

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

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

◆ getReuseSolutionSelectionParameter()

assImagemapQuestion::getReuseSolutionSelectionParameter ( )
protected

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

790  : ?array
791  {
792  if (!$this->isReuseSolutionSelectionRequest()) {
793  return null;
794  }
795 
796  return assQuestion::explodeKeyValues($this->request->raw('reuseSelection'));
797  }
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.

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

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

◆ getTestOutputSolutions()

assImagemapQuestion::getTestOutputSolutions (   $activeId,
  $pass 
)

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

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

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

690  $result = new ilUserQuestionResult($this, $active_id, $pass);
691 
692  $maxStep = $this->lookupMaxStep($active_id, $pass);
693  if ($maxStep > 0) {
694  $data = $this->db->queryF(
695  'SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s',
696  ['integer', 'integer', 'integer', 'integer'],
697  [$active_id, $pass, $this->getId(), $maxStep]
698  );
699  } else {
700  $data = $this->db->queryF(
701  'SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step IS NULL',
702  ['integer', 'integer', 'integer'],
703  [$active_id, $pass, $this->getId()]
704  );
705  }
706 
707  while ($row = $this->db->fetchAssoc($data)) {
708  $result->addKeyValue($row['value1'], $row['value1']);
709  }
710 
711  $points = $this->calculateReachedPoints($active_id, $pass);
712  $max_points = $this->getMaximumPoints();
713 
714  $result->setReachedPercentage(($points / $max_points) * 100);
715 
716  return $result;
717  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
lookupMaxStep(int $active_id, int $pass)

◆ isAddSolutionSelectionRequest()

assImagemapQuestion::isAddSolutionSelectionRequest ( )
protected

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

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

◆ isComplete()

assImagemapQuestion::isComplete ( )

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

References getMaximumPoints().

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  }
+ Here is the call graph for this function:

◆ isRemoveSolutionSelectionRequest()

assImagemapQuestion::isRemoveSolutionSelectionRequest ( )
protected

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

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

◆ isReuseSolutionSelectionRequest()

assImagemapQuestion::isReuseSolutionSelectionRequest ( )
protected

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

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

◆ loadFromDb()

assImagemapQuestion::loadFromDb ( int  $question_id)

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

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

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']);
250  } catch (ilTestQuestionPoolException $e) {
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  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setNrOfTries(int $a_nr_of_tries)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setOwner(int $owner=-1)
setComment(string $comment="")
setPoints(float $points)
setObjId(int $obj_id=0)
setIsMultipleChoice($is_multiple_choice)
Set true if the Imagemapquestion is a multiplechoice Question.
setImageFilename(string $image_filename, string $image_tempfilename='')
setId(int $id=-1)
setOriginalId(?int $original_id)
setTitle(string $title="")
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setAuthor(string $author="")
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setQuestion(string $question="")
+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assImagemapQuestion::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

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

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

Referenced by saveToDb().

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  }
getAdditionalTableName()
Returns the name of the additional question data table in the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAnswerSpecificDataToDb()

assImagemapQuestion::saveAnswerSpecificDataToDb ( )

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

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

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

References assQuestion\getId().

Referenced by saveToDb().

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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePreviewData()

assImagemapQuestion::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

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

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

◆ saveToDb()

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

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

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

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

◆ saveWorkingData()

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

Saves the learners input of the question to the database.

public

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

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

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

◆ setImageFilename()

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

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

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

Referenced by loadFromDb().

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 makeDirParents(string $a_dir)
Create a new directory and all parent directories.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setIsMultipleChoice()

assImagemapQuestion::setIsMultipleChoice (   $is_multiple_choice)

Set true if the Imagemapquestion is a multiplechoice Question.

Parameters
bool$is_multiple_choice

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

References $is_multiple_choice.

Referenced by loadFromDb().

105  : void
106  {
107  $this->is_multiple_choice = $is_multiple_choice;
108  }
+ Here is the caller graph for this function:

◆ solutionValuesToLog()

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

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

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

◆ solutionValuesToText()

assImagemapQuestion::solutionValuesToText ( array  $solution_values)

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

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

◆ toJSON()

assImagemapQuestion::toJSON ( )

Returns a JSON representation of the question.

Implements ILIAS\TestQuestionPool\Questions\QuestionLMExportable.

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

611  : string
612  {
613  $result = [];
614  $result['id'] = $this->getId();
615  $result['type'] = (string) $this->getQuestionType();
616  $result['title'] = $this->getTitleForHTMLOutput();
617  $result['question'] = $this->formatSAQuestion($this->getQuestion());
618  $result['nr_of_tries'] = $this->getNrOfTries();
619  $result['shuffle'] = $this->getShuffle();
620  $result['is_multiple'] = $this->getIsMultipleChoice();
621  $result['feedback'] = [
622  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
623  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
624  ];
625  $result['image'] = $this->getImagePathWeb() . $this->getImageFilename();
626 
627  $answers = [];
628  $order = 0;
629  foreach ($this->getAnswers() as $key => $answer_obj) {
630  array_push($answers, [
631  'answertext' => (string) $answer_obj->getAnswertext(),
632  'points' => (float) $answer_obj->getPoints(),
633  'points_unchecked' => (float) $answer_obj->getPointsUnchecked(),
634  'order' => $order,
635  'coords' => $answer_obj->getCoords(),
636  'state' => $answer_obj->getState(),
637  'area' => $answer_obj->getArea(),
638  'feedback' => $this->formatSAQuestion(
639  $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), 0, $key)
640  )
641  ]);
642  $order++;
643  }
644  $result['answers'] = $answers;
645 
646  $mobs = ilObjMediaObject::_getMobsOfObject('qpl:html', $this->getId());
647  $result['mobs'] = $mobs;
648 
649  return json_encode($result);
650  }
getImagePathWeb()
Returns the web image path for web accessable images of a question.
getIsMultipleChoice()
Returns true, if the imagemap question is a multiplechoice question.
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
getQuestionType()
Returns the question type of the question.

◆ toLog()

assImagemapQuestion::toLog ( AdditionalInformationGenerator  $additional_info)

Implements ILIAS\TestQuestionPool\Questions\Question.

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

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

◆ uploadImagemap()

assImagemapQuestion::uploadImagemap ( array  $shapes)

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

References addAnswer().

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)
+ Here is the call graph for this function:

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(), getImageFilename(), and setImageFilename().

◆ $imagemap_contents

assImagemapQuestion::$imagemap_contents

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

Referenced by get_imagemap_contents().

◆ $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

◆ 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: