ILIAS  release_4-4 Revision
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 ()
 Returns true, if a imagemap question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves an assImagemapQuestion object to a database. More...
 
 saveAnswerSpecificDataToDb ()
 
 saveAdditionalQuestionDataToDb ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates an assImagemapQuestion. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assImagemapQuestion object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 duplicateImage ($question_id, $objectId=null)
 
 copyImage ($question_id, $source_questionpool)
 
 loadFromDb ($question_id)
 Loads a assImagemapQuestion object from a database. More...
 
 uploadImagemap ($imagemap_filename="")
 Uploads an image map and takes over the areas. More...
 
 getImageFilename ()
 
 setImageFilename ($image_filename, $image_tempfilename="")
 Sets the image file name. More...
 
 get_imagemap_contents ($href="#")
 Gets the imagemap file contents. More...
 
 addAnswer ( $answertext="", $points=0.0, $order=0, $coords="", $area="", $points_unchecked=0.0)
 Adds a possible answer for a imagemap question. More...
 
 getAnswerCount ()
 Returns the number of answers. More...
 
 getAnswer ($index=0)
 Returns an answer. More...
 
getAnswers ()
 Returns the answer array. More...
 
 deleteArea ($index=0)
 Deletes an answer. More...
 
 flushAnswers ()
 Deletes all answers. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 calculateReachedPoints ($active_id, $pass=NULL, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question. More...
 
 saveWorkingData ($active_id, $pass=NULL)
 Saves the learners input of the question to the database. More...
 
 syncWithOriginal ()
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 deleteImage ()
 Deletes the image file. More...
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
- Public Member Functions inherited from assQuestion
 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assQuestion constructor More...
 
 setProcessLocker ($processLocker)
 
 getProcessLocker ()
 
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 isComplete ()
 Returns true, if a question is complete for use. More...
 
 questionTitleExists ($questionpool_id, $title)
 Returns TRUE if the question title exists in the database. More...
 
 setTitle ($title="")
 Sets the title string of the assQuestion object. More...
 
 setId ($id=-1)
 Sets the id of the assQuestion object. More...
 
 setTestId ($id=-1)
 Sets the test id of the assQuestion object. More...
 
 setComment ($comment="")
 Sets the comment string of the assQuestion object. More...
 
 setOutputType ($outputType=OUTPUT_HTML)
 Sets the output type. More...
 
 setShuffle ($shuffle=true)
 Sets the shuffle flag. More...
 
 setEstimatedWorkingTime ($hour=0, $min=0, $sec=0)
 Sets the estimated working time of a question. More...
 
 keyInArray ($searchkey, $array)
 returns TRUE if the key occurs in an array More...
 
 setAuthor ($author="")
 Sets the authors name of the assQuestion object. More...
 
 setOwner ($owner="")
 Sets the creator/owner ID of the assQuestion object. More...
 
 getTitle ()
 Gets the title string of the assQuestion object. More...
 
 getId ()
 Gets the id of the assQuestion object. More...
 
 getShuffle ()
 Gets the shuffle flag. More...
 
 getTestId ()
 Gets the test id of the assQuestion object. More...
 
 getComment ()
 Gets the comment string of the assQuestion object. More...
 
 getOutputType ()
 Gets the output type. More...
 
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output. More...
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getEstimatedWorkingTime ()
 Gets the estimated working time of a question. More...
 
 getAuthor ()
 Gets the authors name of the assQuestion object. More...
 
 getOwner ()
 Gets the creator/owner ID of the assQuestion object. More...
 
 getObjId ()
 Get the object id of the container object. More...
 
 setObjId ($obj_id=0)
 Set the object id of the container object. More...
 
 setExternalId ($external_id)
 
 getExternalId ()
 
 _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
_getQuestionInfo ($question_id)
 Returns question information from the database. More...
 
 getSuggestedSolutionOutput ()
 
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 Return the suggested solutions. More...
 
 _getReachedPoints ($active_id, $question_id, $pass=NULL)
 Returns the points, a learner has reached answering the question. More...
 
 getReachedPoints ($active_id, $pass=NULL)
 Returns the points, a learner has reached answering the question This is the fast way to get the points directly from the database. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getAdjustedReachedPoints ($active_id, $pass=NULL)
 returns the reached points ... More...
 
 calculateResultsFromSolution ($active_id, $pass=NULL, $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState ($active_id, $pass=NULL, $obligationsEnabled=false)
 persists the working state for current testactive and testpass More...
 
 saveWorkingData ($active_id, $pass=NULL)
 Saves the learners input of the question to the database. More...
 
 _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place. More...
 
 logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
 _logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution. More...
 
 getJavaPath ()
 Returns the image path for web accessable images of a question. More...
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 getFlashPath ()
 Returns the image path for web accessable flash files of a question. More...
 
 getJavaPathWeb ()
 Returns the web image path for web accessable java applets of a question. More...
 
 getSuggestedSolutionPathWeb ()
 Returns the web path for a suggested solution. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getFlashPathWeb ()
 Returns the web image path for web accessable flash applications of a question. More...
 
getSolutionValues ($active_id, $pass=NULL)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse ($question_id="")
 Checks whether the question is in use or not. More...
 
 isClone ($question_id="")
 Checks whether the question is a clone of another question or not. More...
 
 pcArrayShuffle ($array)
 Shuffles the values of a given array. More...
 
 getQuestionTypeFromDb ($question_id)
 get question type for question id 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...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 getTotalAnswers ()
 get total number of answers More...
 
 _getTotalAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
 _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
 _getTitle ($a_q_id)
 Returns the title of a question. More...
 
 _getQuestionText ($a_q_id)
 Returns question text. More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 create page object of question More...
 
 copyPageOfQuestion ($a_q_id)
 
 getPageOfQuestion ()
 
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
 _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 loadFromDb ($question_id)
 Loads the question from the database. More...
 
 createNewQuestion ($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 ($original_id="")
 
 saveToDb ($original_id="")
 Saves the question to the database. More...
 
 setNewOriginalId ($newId)
 
 deleteSuggestedSolutions ()
 Deletes all suggestes solutions in the database. More...
 
 getSuggestedSolution ($subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle ($subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution ($solution_id="", $subquestion_index=0, $is_import=false)
 Sets a suggested solution for the question. More...
 
 _resolveInternalLink ($internal_link)
 
 _resolveIntLinks ($question_id)
 
 _getInternalLinkHref ($target="")
 
 syncWithOriginal ()
 
 createRandomSolution ($test_id, $user_id)
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool ($question_id)
 Returns true if the question already exists in the database and is assigned to a question pool. More...
 
 getPoints ()
 Returns the maximum available points for the question. More...
 
 setPoints ($a_points)
 Sets the maximum available points for the question. More...
 
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution. More...
 
 _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution. More...
 
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
 _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not. More...
 
 calculateReachedPoints ($active_id, $pass=NULL, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question. More...
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=NULL)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=FALSE)
 Prepares a string for a text area output in tests. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addQTIMaterial (&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE)
 Creates a QTI material tag from a plain text or xhtml text. More...
 
 createNewImageFileName ($image_filename)
 
 _setReachedPoints ($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
 getQuestion ()
 Gets the question string of the question object. More...
 
 setQuestion ($question="")
 Sets the question string of the question object. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 Returns the question type of the question. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table More...
 
getInstances ()
 Gets all instances of the question. More...
 
 _needsManualScoring ($question_id)
 
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id. More...
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getNrOfTries ()
 
 setNrOfTries ($a_nr_of_tries)
 
 setExportImagePath ($a_path)
 
 _questionExistsInTest ($question_id, $test_id)
 
 formatSAQuestion ($a_q)
 Format self assessment question. More...
 
 setPreventRteUsage ($a_val)
 Set prevent rte usage. More...
 
 getPreventRteUsage ()
 Get prevent rte usage. More...
 
 setSelfAssessmentEditingMode ($a_selfassessmenteditingmode)
 Set Self-Assessment Editing Mode. More...
 
 getSelfAssessmentEditingMode ()
 Get Self-Assessment Editing Mode. More...
 
 setDefaultNrOfTries ($a_defaultnroftries)
 Set Default Nr of Tries. More...
 
 getDefaultNrOfTries ()
 Get Default Nr of Tries. More...
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not More...
 
 setObligationsToBeConsidered ($obligationsToBeConsidered=true)
 sets the flag wether obligations are to be considered or not More...
 
 areObligationsToBeConsidered ()
 gets the flag wether obligations are to be considered or not More...
 
 isAutosaveable ()
 
 getAdditionalContentEditingMode ()
 getter for additional content editing mode for this question More...
 
 setAdditionalContentEditingMode ($additinalContentEditingMode)
 setter for additional content editing mode for this question More...
 
 isAdditionalContentEditingModePageObject ()
 isser for additional "pageobject" content editing mode More...
 
 isValidAdditionalContentEditingMode ($additionalContentEditingMode)
 returns the fact wether the passed additional content mode is valid or not More...
 
 getValidAdditionalContentEditingModes ()
 getter for valid additional content editing modes More...
 
 addQuestionChangeListener (ilQuestionChangeListener $listener)
 
 getQuestionChangeListeners ()
 
 getHtmlUserSolutionPurifier ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 

Data Fields

const MODE_SINGLE_CHOICE = 0
 
const MODE_MULTIPLE_CHOICE = 1
 
 $answers
 
 $image_filename
 
 $imagemap_contents
 
 $coords
 
- Data Fields inherited from assQuestion
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT = 'default'
 constant for additional content editing mode "default" More...
 
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT = 'pageobject'
 constant for additional content editing mode "pageobject" More...
 
 $feedbackOBJ = null
 
 $prevent_rte_usage = false
 
 $selfassessmenteditingmode = false
 
 $defaultnroftries = false
 

Protected Member Functions

 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. More...
 
- Protected Member Functions inherited from assQuestion
 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. More...
 
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID. More...
 
 onDuplicate ($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test) More...
 
 onSyncWithOriginal ($originalQuestionId, $duplicateQuestionId)
 
 onCopy ($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId)
 Will be called when a question is copied (into another question pool) More...
 
 duplicateSuggestedSolutionFiles ($parent_id, $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles ($original_id)
 Syncs the files of a suggested solution if the question is synced. More...
 
 copySuggestedSolutionFiles ($source_questionpool_id, $source_question_id)
 
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 

Protected Attributes

 $is_multiple_choice = false
 
- Protected Attributes inherited from assQuestion
 $id
 
 $title
 
 $comment
 
 $owner
 
 $author
 
 $question
 
 $points
 
 $est_working_time
 
 $shuffle
 
 $test_id
 
 $obj_id
 
 $ilias
 
 $tpl
 
 $lng
 
 $outputType
 
 $suggested_solutions
 
 $original_id
 
 $page
 
 $external_id = ''
 
 $questionChangeListeners = array()
 
 $processLocker
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static _getSuggestedSolutionCount ($question_id)
 Returns the number of suggested solutions associated with a question. More...
 
static _getSuggestedSolutionOutput ($question_id)
 Returns the output of the suggested solution. More...
 
static _getOriginalId ($question_id)
 Returns the original id of a question. More...
 
static originalQuestionExists ($questionId)
 
static _instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id. More...
 
static _instantiateQuestion ($question_id)
 
static _isWorkedThrough ($active_id, $question_id, $pass=NULL)
 Returns true if the question was worked through in the given pass Worked through means that the user entered at least one value. More...
 
static _areAnswered ($a_user_id, $a_question_ids)
 Checks if an array of question ids is answered by an user or not. More...
 
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type. More...
 
static getGuiClassNameByQuestionType ($questionType)
 
static getObjectClassNameByQuestionType ($questionType)
 
static getFeedbackClassNameByQuestionType ($questionType)
 
static isCoreQuestionType ($questionType)
 
static includeCoreClass ($questionType, $withGuiClass)
 
static includePluginClass ($questionType, $withGuiClass)
 
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag. More...
 
static & _instanciateQuestionGUI ($question_id)
 Creates an instance of a question gui with a given question id. More...
 
static instantiateQuestionGUI ($a_question_id)
 Creates an instance of a question gui with a given question id. More...
 
static lookupParentObjId ($questionId)
 ilDB $ilDB More...
 
static lookupOriginalParentObjId ($originalQuestionId)
 returns the parent object id for given original question id (should be a qpl id, but theoretically it can be a tst id, too) More...
 
static isObligationPossible ($questionId)
 returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration More...
 
- Static Protected Member Functions inherited from assQuestion
static doesSolutionRecordsExist ($activeId, $pass, $questionId)
 checks wether there are existing solution records for the given test active / pass and given question id More...
 

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 22 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
Returns

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

References assQuestion\$author, assQuestion\$comment, $image_filename, assQuestion\$owner, assQuestion\$question, and assQuestion\$title.

64  {
65  parent::__construct($title, $comment, $author, $owner, $question);
66  $this->image_filename = $image_filename;
67  $this->answers = array();
68  $this->coords = array();
69  }

Member Function Documentation

◆ addAnswer()

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

Adds a possible answer for a imagemap question.

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

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

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

References assQuestion\$points.

Referenced by uploadImagemap().

507  {
508  include_once "./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
509  if (array_key_exists($order, $this->answers))
510  {
511  // Insert answer
512  $answer = new ASS_AnswerImagemap($answertext, $points, $order, $coords, $area, -1, $points_unchecked);
513  for ($i = count($this->answers) - 1; $i >= $order; $i--)
514  {
515  $this->answers[$i+1] = $this->answers[$i];
516  $this->answers[$i+1]->setOrder($i+1);
517  }
518  $this->answers[$order] = $answer;
519  }
520  else
521  {
522  // Append answer
523  $answer = new ASS_AnswerImagemap($answertext, $points, count($this->answers), $coords, $area, -1, $points_unchecked);
524  array_push($this->answers, $answer);
525  }
526  }
Class for true/false or yes/no answers.
+ Here is the caller graph for this function:

◆ calculateReachedPoints()

assImagemapQuestion::calculateReachedPoints (   $active_id,
  $pass = NULL,
  $returndetails = FALSE 
)

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

The points are calculated from the given answers.

public

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

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

References $data, $pass, assQuestion\$points, $result, ilDB\fetchAssoc(), assQuestion\getId(), getIsMultipleChoice(), and assQuestion\getSolutionMaxPass().

653  {
654  if( $returndetails )
655  {
656  throw new ilTestException('return details not implemented for '.__METHOD__);
657  }
658 
659  global $ilDB;
660 
661  $found_values = array();
662  if (is_null($pass))
663  {
664  $pass = $this->getSolutionMaxPass($active_id);
665  }
666  $result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
667  array("integer","integer","integer"),
668  array($active_id, $this->getId(), $pass)
669  );
670  while ($data = $ilDB->fetchAssoc($result))
671  {
672  if (strcmp($data["value1"], "") != 0)
673  {
674  array_push($found_values, $data["value1"]);
675  }
676  }
677  $points = 0;
678  if (count($found_values) > 0)
679  {
680  foreach ($this->answers as $key => $answer)
681  {
682  if (in_array($key, $found_values))
683  {
684  $points += $answer->getPoints();
685  }
686  elseif( $this->getIsMultipleChoice() )
687  {
688  $points += $answer->getPointsUnchecked();
689  }
690  }
691  }
692 
693  return $points;
694  }
getId()
Gets the id of the assQuestion object.
$result
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
getIsMultipleChoice()
Returns true, if the imagemap question is a multiplechoice question.
fetchAssoc($a_set)
Fetch row as associative array from result set.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:

◆ copyImage()

assImagemapQuestion::copyImage (   $question_id,
  $source_questionpool 
)

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

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

327  {
328  $imagepath = $this->getImagePath();
329  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
330  $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
331  if (!file_exists($imagepath))
332  {
333  ilUtil::makeDirParents($imagepath);
334  }
335  $filename = $this->getImageFilename();
336  if (!copy($imagepath_original . $filename, $imagepath . $filename))
337  {
338  print "image could not be copied!!!! ";
339  }
340  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

◆ copyObject()

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

Copies an assImagemapQuestion object.

Copies an assImagemapQuestion object

public

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

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

239  {
240  if ($this->id <= 0)
241  {
242  // The question has not been saved. It cannot be duplicated
243  return;
244  }
245  // duplicate the question in database
246  $clone = $this;
247  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
249  $clone->id = -1;
250  $source_questionpool_id = $this->getObjId();
251  $clone->setObjId($target_questionpool_id);
252  if ($title)
253  {
254  $clone->setTitle($title);
255  }
256  $clone->saveToDb();
257 
258  // copy question page content
259  $clone->copyPageOfQuestion($original_id);
260  // copy XHTML media objects
261  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
262  // duplicate the image
263  $clone->copyImage($original_id, $source_questionpool_id);
264 
265  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
266 
267  return $clone->id;
268  }
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

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

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

271  {
272  if ($this->id <= 0)
273  {
274  // The question has not been saved. It cannot be duplicated
275  return;
276  }
277 
278  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
279 
280  $sourceQuestionId = $this->id;
281  $sourceParentId = $this->getObjId();
282 
283  // duplicate the question in database
284  $clone = $this;
285  $clone->id = -1;
286 
287  $clone->setObjId($targetParentId);
288 
289  if ($targetQuestionTitle)
290  {
291  $clone->setTitle($targetQuestionTitle);
292  }
293 
294  $clone->saveToDb();
295  // copy question page content
296  $clone->copyPageOfQuestion($sourceQuestionId);
297  // copy XHTML media objects
298  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
299  // duplicate the image
300  $clone->copyImage($sourceQuestionId, $sourceParentId);
301 
302  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
303 
304  return $clone->id;
305  }
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ deleteArea()

assImagemapQuestion::deleteArea (   $index = 0)

Deletes an answer.

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

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

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

584  {
585  if ($index < 0) return;
586  if (count($this->answers) < 1) return;
587  if ($index >= count($this->answers)) return;
588  unset($this->answers[$index]);
589  $this->answers = array_values($this->answers);
590  for ($i = 0; $i < count($this->answers); $i++) {
591  if ($this->answers[$i]->getOrder() > $index) {
592  $this->answers[$i]->setOrder($i);
593  }
594  }
595  }

◆ deleteImage()

assImagemapQuestion::deleteImage ( )

Deletes the image file.

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

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

889  {
890  $file = $this->getImagePath() . $this->getImageFilename();
891  @unlink($file);
892  $this->flushAnswers();
893  $this->image_filename = "";
894  }
print $file
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
flushAnswers()
Deletes all answers.
+ Here is the call graph for this function:

◆ duplicate()

assImagemapQuestion::duplicate (   $for_test = true,
  $title = "",
  $author = "",
  $owner = "",
  $testObjId = null 
)

Duplicates an assImagemapQuestion.

public

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

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

178  {
179  if ($this->id <= 0)
180  {
181  // The question has not been saved. It cannot be duplicated
182  return;
183  }
184  // duplicate the question in database
185  $this_id = $this->getId();
186  $thisObjId = $this->getObjId();
187 
188  $clone = $this;
189  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
191  $clone->id = -1;
192 
193  if( (int)$testObjId > 0 )
194  {
195  $clone->setObjId($testObjId);
196  }
197 
198  if ($title)
199  {
200  $clone->setTitle($title);
201  }
202  if ($author)
203  {
204  $clone->setAuthor($author);
205  }
206  if ($owner)
207  {
208  $clone->setOwner($owner);
209  }
210  if ($for_test)
211  {
212  $clone->saveToDb($original_id);
213  }
214  else
215  {
216  $clone->saveToDb();
217  }
218 
219  // copy question page content
220  $clone->copyPageOfQuestion($this_id);
221  // copy XHTML media objects
222  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
223  // duplicate the image
224  $clone->duplicateImage($this_id, $thisObjId);
225 
226  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
227 
228  return $clone->id;
229  }
getId()
Gets the id of the assQuestion object.
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ duplicateImage()

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

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

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

308  {
309  $imagepath = $this->getImagePath();
310  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
311 
312  if( (int)$objectId > 0 )
313  {
314  $imagepath_original = str_replace("/$this->obj_id/", "/$objectId/", $imagepath_original);
315  }
316 
317  if (!file_exists($imagepath)) {
318  ilUtil::makeDirParents($imagepath);
319  }
320  $filename = $this->getImageFilename();
321  if (!copy($imagepath_original . $filename, $imagepath . $filename)) {
322  print "image could not be duplicated!!!! ";
323  }
324  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

◆ flushAnswers()

assImagemapQuestion::flushAnswers ( )

Deletes all answers.

Deletes all answers

public

See also
$answers

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

Referenced by deleteImage().

605  {
606  $this->answers = array();
607  }
+ Here is the caller graph for this function:

◆ get_imagemap_contents()

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

Gets the imagemap file contents.

Gets the imagemap file contents

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

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

References $imagemap_contents.

473  {
474  $imagemap_contents = "<map name=\"".$this->title."\"> ";
475  for ($i = 0; $i < count($this->answers); $i++) {
476  $imagemap_contents .= "<area alt=\"".$this->answers[$i]->getAnswertext()."\" ";
477  $imagemap_contents .= "shape=\"".$this->answers[$i]->getArea()."\" ";
478  $imagemap_contents .= "coords=\"".$this->answers[$i]->getCoords()."\" ";
479  $imagemap_contents .= "href=\"$href&selimage=" . $this->answers[$i]->getOrder() . "\" /> ";
480  }
481  $imagemap_contents .= "</map>";
482  return $imagemap_contents;
483  }

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

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

819  {
820  return "qpl_qst_imagemap";
821  }
+ Here is the caller graph for this function:

◆ getAnswer()

assImagemapQuestion::getAnswer (   $index = 0)

Returns an answer.

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

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

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

552  {
553  if ($index < 0) return NULL;
554  if (count($this->answers) < 1) return NULL;
555  if ($index >= count($this->answers)) return NULL;
556  return $this->answers[$index];
557  }

◆ getAnswerCount()

assImagemapQuestion::getAnswerCount ( )

Returns the number of answers.

Returns the number of answers

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

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

537  {
538  return count($this->answers);
539  }

◆ getAnswers()

& assImagemapQuestion::getAnswers ( )

Returns the answer array.

Returns the answer array

Returns
array The answer array public
See also
$answers

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

References $answers.

Referenced by setExportDetailsXLS(), and toJSON().

569  {
570  return $this->answers;
571  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assImagemapQuestion::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns the name of the answer table in the database

Returns
string The answer table name public

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

832  {
833  return "qpl_a_imagemap";
834  }

◆ getImageFilename()

assImagemapQuestion::getImageFilename ( )

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

References $image_filename.

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

431  {
432  return $this->image_filename;
433  }
+ Here is the caller graph for this function:

◆ getIsMultipleChoice()

assImagemapQuestion::getIsMultipleChoice ( )

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

Returns
bool

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

References $is_multiple_choice.

Referenced by calculateReachedPoints(), and toJSON().

+ Here is the caller graph for this function:

◆ getMaximumPoints()

assImagemapQuestion::getMaximumPoints ( )

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

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

public

See also
$points

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

References assQuestion\$points.

Referenced by isComplete().

617  {
618  $points = 0;
619  foreach ($this->answers as $key => $value) {
620  if($this->is_multiple_choice)
621  {
622  if($value->getPoints() > $value->getPointsUnchecked())
623  {
624  $points += $value->getPoints();
625  }
626  else
627  {
628  $points += $value->getPointsUnchecked();
629  }
630  }
631  else
632  {
633  if($value->getPoints() > $points)
634  {
635  $points = $value->getPoints();
636  }
637  }
638  }
639  return $points;
640  }
+ Here is the caller graph for this function:

◆ getQuestionType()

assImagemapQuestion::getQuestionType ( )

Returns the question type of the question.

Returns the question type of the question

Returns
integer The question type of the question public

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

Referenced by toJSON().

806  {
807  return "assImagemapQuestion";
808  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assImagemapQuestion::getRTETextWithMediaObjects ( )

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

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

References assQuestion\getId().

841  {
842  $text = parent::getRTETextWithMediaObjects();
843  foreach ($this->answers as $index => $answer)
844  {
845  $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->getId(), $index);
846  }
847  return $text;
848  }
getId()
Gets the id of the assQuestion object.
+ Here is the call graph for this function:

◆ isComplete()

assImagemapQuestion::isComplete ( )

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

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

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

References getMaximumPoints().

98  {
99  if (strlen($this->title)
100  && ($this->author)
101  && ($this->question)
102  && ($this->image_filename)
103  && (count($this->answers))
104  && ($this->getMaximumPoints() > 0)
105  )
106  {
107  return true;
108  }
109  return false;
110  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ loadFromDb()

assImagemapQuestion::loadFromDb (   $question_id)

Loads a assImagemapQuestion object from a database.

Loads a assImagemapQuestion object from a database (experimental)

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

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

References $data, $result, ilRTE\_replaceMediaObjectImageSrc(), ilDB\fetchAssoc(), getAdditionalTableName(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setEstimatedWorkingTime(), assQuestion\setId(), setImageFilename(), setIsMultipleChoice(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), and assQuestion\setTitle().

352  {
353  global $ilDB;
354 
355  $result = $ilDB->queryF("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",
356  array("integer"),
357  array($question_id)
358  );
359  if ($result->numRows() == 1)
360  {
361  $data = $ilDB->fetchAssoc($result);
362  $this->setId($question_id);
363  $this->setObjId($data["obj_fi"]);
364  $this->setTitle($data["title"]);
365  $this->setComment($data["description"]);
366  $this->setOriginalId($data["original_id"]);
367  $this->setNrOfTries($data['nr_of_tries']);
368  $this->setAuthor($data["author"]);
369  $this->setPoints($data["points"]);
370  $this->setOwner($data["owner"]);
371  $this->setIsMultipleChoice($data["is_multiple_choice"] == self::MODE_MULTIPLE_CHOICE);
372  include_once("./Services/RTE/classes/class.ilRTE.php");
373  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
374  $this->setImageFilename($data["image_file"]);
375  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
376 
377  try
378  {
379  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
380  }
382  {
383  }
384 
385  $result = $ilDB->queryF("SELECT * FROM qpl_a_imagemap WHERE question_fi = %s ORDER BY aorder ASC",
386  array("integer"),
387  array($question_id)
388  );
389  include_once "./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
390  if ($result->numRows() > 0)
391  {
392  while ($data = $ilDB->fetchAssoc($result))
393  {
394  array_push($this->answers, new ASS_AnswerImagemap($data["answertext"], $data["points"], $data["aorder"], $data["coords"], $data["area"], $data['question_fi'], $data['points_unchecked']));
395  }
396  }
397  }
398  parent::loadFromDb($question_id);
399  }
$result
Class for true/false or yes/no answers.
setId($id=-1)
Sets the id of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
fetchAssoc($a_set)
Fetch row as associative array from result set.
setAuthor($author="")
Sets the authors name of the assQuestion object.
setIsMultipleChoice($is_multiple_choice)
Set true if the Imagemapquestion is a multiplechoice Question.
setPoints($a_points)
Sets the maximum available points for the question.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
setQuestion($question="")
Sets the question string of the question object.
setImageFilename($image_filename, $image_tempfilename="")
Sets the image file name.
setOriginalId($original_id)
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setComment($comment="")
Sets the comment string of the assQuestion object.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
+ Here is the call graph for this function:

◆ reworkWorkingData()

assImagemapQuestion::reworkWorkingData (   $active_id,
  $pass,
  $obligationsAnswered 
)
protected

Reworks the allready saved working data if neccessary.

protected

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered

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

785  {
786  // nothing to rework!
787  }

◆ saveAdditionalQuestionDataToDb()

assImagemapQuestion::saveAdditionalQuestionDataToDb ( )

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

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

Referenced by saveToDb().

153  {
154  global $ilDB;
155 
156  $ilDB->manipulateF( "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
157  array( "integer" ),
158  array( $this->getId() )
159  );
160 
161  $ilDB->manipulateF( "INSERT INTO " . $this->getAdditionalTableName(
162  ) . " (question_fi, image_file, is_multiple_choice) VALUES (%s, %s, %s)",
163  array( "integer", "text", 'integer' ),
164  array(
165  $this->getId(),
166  $this->image_filename,
167  (int)$this->is_multiple_choice
168  )
169  );
170  }
getId()
Gets the id of the assQuestion object.
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 ( )

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

References assQuestion\getId().

Referenced by saveToDb().

130  {
131  global $ilDB;
132  $ilDB->manipulateF( "DELETE FROM qpl_a_imagemap WHERE question_fi = %s",
133  array( "integer" ),
134  array( $this->getId() )
135  );
136 
137  // Anworten wegschreiben
138  foreach ($this->answers as $key => $value)
139  {
140  $answer_obj = $this->answers[$key];
141  $next_id = $ilDB->nextId( 'qpl_a_imagemap' );
142  $ilDB->manipulateF( "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)",
143  array( "integer", "integer", "text", "float", "integer", "text", "text", "float" ),
144  array( $next_id, $this->id, $answer_obj->getAnswertext(
145  ), $answer_obj->getPoints(), $answer_obj->getOrder(
146  ), $answer_obj->getCoords(), $answer_obj->getArea(
147  ), $answer_obj->getPointsUnchecked() )
148  );
149  }
150  }
getId()
Gets the id of the assQuestion object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

assImagemapQuestion::saveToDb (   $original_id = "")

Saves an assImagemapQuestion object to a database.

Saves an assImagemapQuestion object to a database

Parameters
string$original_id
Returns
mixed|void

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

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

122  {
126  parent::saveToDb($original_id);
127  }
saveQuestionDataToDb($original_id="")
+ Here is the call graph for this function:

◆ saveWorkingData()

assImagemapQuestion::saveWorkingData (   $active_id,
  $pass = NULL 
)

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

References $_GET, $ilUser, $pass, $query, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), assQuestion\getId(), assQuestion\getProcessLocker(), and assQuestion\logAction().

705  {
706  global $ilDB;
707  global $ilUser;
708 
709  if (is_null($pass))
710  {
711  include_once "./Modules/Test/classes/class.ilObjTest.php";
712  $pass = ilObjTest::_getPass($active_id);
713  }
714 
715  $this->getProcessLocker()->requestUserSolutionUpdateLock();
716 
717  if($this->is_multiple_choice && strlen($_GET['remImage']))
718  {
719  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND value1 = %s",
720  array("integer", "integer", "integer", "integer"),
721  array($active_id, $this->getId(), $pass, $_GET['remImage'])
722  );
723  }
724  elseif(!$this->is_multiple_choice)
725  {
726  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
727  array("integer", "integer", "integer"),
728  array($active_id, $this->getId(), $pass)
729  );
730  }
731 
732  if (strlen($_GET["selImage"]))
733  {
734  $imageWasSelected = true;
735 
736  $types = array('integer', 'integer', 'integer', 'integer');
737  $values = array($active_id, $this->getId(), $pass, (int)$_GET['selImage']);
738  $query = 'DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND value1 = %s';
739 
740  $ilDB->manipulateF($query, $types, $values);
741 
742  $next_id = $ilDB->nextId('tst_solutions');
743  $affectedRows = $ilDB->insert("tst_solutions", array(
744  "solution_id" => array("integer", $next_id),
745  "active_fi" => array("integer", $active_id),
746  "question_fi" => array("integer", $this->getId()),
747  "value1" => array("clob", $_GET['selImage']),
748  "value2" => array("clob", null),
749  "pass" => array("integer", $pass),
750  "tstamp" => array("integer", time())
751  ));
752  }
753  else
754  {
755  $imageWasSelected = false;
756  }
757 
758  $this->getProcessLocker()->releaseUserSolutionUpdateLock();
759 
760  require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
762  {
763  if( $imageWasSelected )
764  {
765  $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
766  }
767  else
768  {
769  $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
770  }
771  }
772 
773  return true;
774  }
getId()
Gets the id of the assQuestion object.
$_GET["client_id"]
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
_getLogLanguage()
retrieve the log language for assessment logging
global $ilUser
Definition: imgupload.php:15
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
+ Here is the call graph for this function:

◆ setExportDetailsXLS()

assImagemapQuestion::setExportDetailsXLS ( $worksheet,
  $startrow,
  $active_id,
  $pass,
$format_title,
$format_bold 
)

Creates an Excel worksheet for the detailed cumulated results of this question.

Parameters
object$worksheetReference to the parent excel worksheet
object$startrowStartrow of the output in the excel worksheet
object$active_idActive id of the participant
object$passTest pass
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data public

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

References assQuestion\$id, $pass, ilExcelUtils\_convert_text(), getAnswers(), assQuestion\getSolutionValues(), and assQuestion\getTitle().

863  {
864  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
865  $solution = $this->getSolutionValues($active_id, $pass);
866  $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
867  $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
868  $i = 1;
869  foreach ($this->getAnswers() as $id => $answer)
870  {
871  $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($answer->getArea() . ": " . $answer->getCoords()), $format_bold);
872  if ($id == $solution[0]["value1"])
873  {
874  $worksheet->write($startrow + $i, 1, 1);
875  }
876  else
877  {
878  $worksheet->write($startrow + $i, 1, 0);
879  }
880  $i++;
881  }
882  return $startrow + $i + 1;
883  }
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
_convert_text($a_text, $a_target="has been removed")
& getAnswers()
Returns the answer array.
getTitle()
Gets the title string of the assQuestion object.
+ Here is the call graph for this function:

◆ setImageFilename()

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

Sets the image file name.

Parameters
string$image_filename. public
See also
$image_filename

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

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

Referenced by loadFromDb().

443  {
444  if (!empty($image_filename))
445  {
446  $image_filename = str_replace(" ", "_", $image_filename);
447  $this->image_filename = $image_filename;
448  }
449  if (!empty($image_tempfilename))
450  {
451  $imagepath = $this->getImagePath();
452  if (!file_exists($imagepath))
453  {
454  ilUtil::makeDirParents($imagepath);
455  }
456  if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $imagepath.$image_filename))
457  {
458  $this->ilias->raiseError("The image could not be uploaded!", $this->ilias->error_obj->MESSAGE);
459  }
460  global $ilLog; $ilLog->write("gespeichert: " . $imagepath.$image_filename);
461  }
462  }
static makeDirParents($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($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
redirection script todo: (a better solution should control the processing via a xml 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 76 of file class.assImagemapQuestion.php.

References $is_multiple_choice.

Referenced by loadFromDb().

77  {
78  $this->is_multiple_choice = $is_multiple_choice;
79  }
+ Here is the caller graph for this function:

◆ syncWithOriginal()

assImagemapQuestion::syncWithOriginal ( )

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

References assQuestion\getOriginalId().

790  {
791  if ($this->getOriginalId())
792  {
793  parent::syncWithOriginal();
794  }
795  }
+ Here is the call graph for this function:

◆ toJSON()

assImagemapQuestion::toJSON ( )

Returns a JSON representation of the question.

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

References $answers, $mobs, $result, ilObjMediaObject\_getMobsOfObject(), ilRTE\_replaceMediaObjectImageSrc(), assQuestion\formatSAQuestion(), getAnswers(), assQuestion\getId(), getImageFilename(), assQuestion\getImagePathWeb(), getIsMultipleChoice(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), and assQuestion\getTitle().

900  {
901  include_once("./Services/RTE/classes/class.ilRTE.php");
902  $result = array();
903  $result['id'] = (int) $this->getId();
904  $result['type'] = (string) $this->getQuestionType();
905  $result['title'] = (string) $this->getTitle();
906  $result['question'] = $this->formatSAQuestion($this->getQuestion());
907  $result['nr_of_tries'] = (int) $this->getNrOfTries();
908  $result['shuffle'] = (bool) $this->getShuffle();
909  $result['is_multiple'] = (bool) $this->getIsMultipleChoice();
910  $result['feedback'] = array(
911  "onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false),
912  "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)
913  );
914  $result['image'] = (string) $this->getImagePathWeb() . $this->getImageFilename();
915 
916  $answers = array();
917  $order = 0;
918  foreach ($this->getAnswers() as $key => $answer_obj)
919  {
920  array_push($answers, array(
921  "answertext" => (string)$answer_obj->getAnswertext(),
922  "points" => (float)$answer_obj->getPoints(),
923  "points_unchecked" => (float)$answer_obj->getPointsUnchecked(),
924  "order" => (int)$order,
925  "coords" => $answer_obj->getCoords(),
926  "state" => $answer_obj->getState(),
927  "area" => $answer_obj->getArea(),
929  $this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key), 0
930  )
931  ));
932  $order++;
933  }
934  $result['answers'] = $answers;
935 
936  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
937  $result['mobs'] = $mobs;
938 
939  return json_encode($result);
940  }
getId()
Gets the id of the assQuestion object.
formatSAQuestion($a_q)
Format self assessment question.
$result
getImagePathWeb()
Returns the web image path for web accessable images of a question.
getShuffle()
Gets the shuffle flag.
$mobs
getIsMultipleChoice()
Returns true, if the imagemap question is a multiplechoice question.
getQuestion()
Gets the question string of the question object.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
& getAnswers()
Returns the answer array.
getTitle()
Gets the title string of the assQuestion object.
getQuestionType()
Returns the question type of the question.
+ Here is the call graph for this function:

◆ uploadImagemap()

assImagemapQuestion::uploadImagemap (   $imagemap_filename = "")

Uploads an image map and takes over the areas.

Parameters
string$imagemap_filenameImagemap filename
Returns
integer number of areas added

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

References addAnswer().

408  {
409  $added = 0;
410  if (!empty($imagemap_filename))
411  {
412  $fp = fopen($imagemap_filename, "r");
413  $contents = fread($fp, filesize($imagemap_filename));
414  fclose($fp);
415  if (preg_match_all("/<area(.+)>/siU", $contents, $matches))
416  {
417  for ($i=0; $i< count($matches[1]); $i++)
418  {
419  preg_match("/alt\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $alt);
420  preg_match("/coords\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $coords);
421  preg_match("/shape\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $shape);
422  $this->addAnswer($alt[1], 0.0, count($this->answers), $coords[1], $shape[1]);
423  $added++;
424  }
425  }
426  }
427  return $added;
428  }
addAnswer( $answertext="", $points=0.0, $order=0, $coords="", $area="", $points_unchecked=0.0)
Adds a possible answer for a imagemap question.
+ Here is the call graph for this function:

Field Documentation

◆ $answers

assImagemapQuestion::$answers

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

Referenced by getAnswers(), and toJSON().

◆ $coords

assImagemapQuestion::$coords

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

◆ $image_filename

assImagemapQuestion::$image_filename

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

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

◆ $imagemap_contents

assImagemapQuestion::$imagemap_contents

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

Referenced by get_imagemap_contents().

◆ $is_multiple_choice

assImagemapQuestion::$is_multiple_choice = false
protected

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

Referenced by getIsMultipleChoice(), and setIsMultipleChoice().

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