ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
assMatchingQuestion Class Reference

Class for matching questions. More...

+ Inheritance diagram for assMatchingQuestion:
+ Collaboration diagram for assMatchingQuestion:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="", $matching_type=MT_TERMS_DEFINITIONS)
 assMatchingQuestion constructor More...
 
 isComplete ()
 Returns true, if a matching question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a assMatchingQuestion object to a database. More...
 
 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...
 
 loadFromDb ($question_id)
 Loads a assMatchingQuestion object from a database. More...
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates an assMatchingQuestion. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assMatchingQuestion. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 duplicateImages ($question_id, $objectId=null)
 
 copyImages ($question_id, $source_questionpool)
 
 insertMatchingPair ($position, $term=null, $definition=null, $points=0.0)
 Inserts a matching pair for an matching choice question. More...
 
 addMatchingPair ($term=null, $definition=null, $points=0.0)
 Adds an matching pair for an matching choice question. More...
 
 getTermWithIdentifier ($a_identifier)
 Returns a term with a given identifier. More...
 
 getDefinitionWithIdentifier ($a_identifier)
 Returns a definition with a given identifier. More...
 
 getMatchingPair ($index=0)
 Returns a matching pair with a given index. More...
 
 deleteMatchingPair ($index=0)
 Deletes a matching pair with a given index. More...
 
 flushMatchingPairs ()
 Deletes all matching pairs. More...
 
 getMatchingPairCount ()
 Returns the number of matching pairs. More...
 
 getTerms ()
 Returns the terms of the matching question. More...
 
 getDefinitions ()
 Returns the definitions of the matching question. More...
 
 getTermCount ()
 Returns the number of terms. More...
 
 getDefinitionCount ()
 Returns the number of definitions. More...
 
 addTerm ($term)
 Adds a term. More...
 
 addDefinition ($definition)
 Adds a definition. More...
 
 insertTerm ($position, $term=null)
 Inserts a term. More...
 
 insertDefinition ($position, $definition=null)
 Inserts a definition. More...
 
 flushTerms ()
 Deletes all terms. More...
 
 flushDefinitions ()
 Deletes all definitions. More...
 
 deleteTerm ($position)
 Deletes a term. More...
 
 deleteDefinition ($position)
 Deletes a definition. More...
 
 setTerm ($term, $index)
 Sets a specific term. More...
 
 calculateReachedPoints ($active_id, $pass=NULL, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getEncryptedFilename ($filename)
 Returns the encrypted save filename of a matching picture Images are saved with an encrypted filename to prevent users from cheating by guessing the solution from the image filename. More...
 
 removeTermImage ($index)
 
 removeDefinitionImage ($index)
 
 deleteImagefile ($filename)
 Deletes an imagefile from the system if the file is deleted manually. More...
 
 setImageFile ($image_tempfilename, $image_filename, $previous_filename='')
 Sets the image file and uploads the image to the object's image directory. More...
 
 checkSaveData ()
 Checks the data to be saved for consistency. More...
 
 saveWorkingData ($active_id, $pass=NULL)
 Saves the learners input of the question to the database. More...
 
 getRandomId ()
 
 setShuffle ($shuffle)
 Sets the shuffle flag. 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...
 
getMatchingPairs ()
 Returns the matchingpairs array. More...
 
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output. More...
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 getThumbGeometry ()
 Get the thumbnail geometry. More...
 
 getThumbSize ()
 Get the thumbnail geometry. More...
 
 setThumbGeometry ($a_geometry)
 Set the thumbnail geometry. More...
 
 getElementHeight ()
 Get the minimum element height. More...
 
 setElementHeight ($a_height)
 Set the minimum element height. More...
 
 rebuildThumbnails ()
 Rebuild the thumbnail images with a new thumbnail size. More...
 
 getThumbPrefix ()
 
 getEstimatedElementHeight ()
 
 toJSON ()
 Returns a JSON representation of the question TODO. 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

 $matchingpairs
 
 $matching_type
 
 $thumb_geometry = 100
 
 $element_height
 
- 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...
 
 generateThumbForFile ($path, $file)
 
- 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

 $terms
 
 $definitions
 
- 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 matching questions.

assMatchingQuestion is a class for matching questions.

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

Constructor & Destructor Documentation

◆ __construct()

assMatchingQuestion::__construct (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $question = "",
  $matching_type = MT_TERMS_DEFINITIONS 
)

assMatchingQuestion constructor

The constructor takes possible arguments an creates an instance of the assMatchingQuestion 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 matching question
int$matching_type
Returns

Definition at line 79 of file class.assMatchingQuestion.php.

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

87  {
88  parent::__construct($title, $comment, $author, $owner, $question);
89  $this->matchingpairs = array();
90  $this->matching_type = $matching_type;
91  $this->terms = array();
92  $this->definitions = array();
93  }

Member Function Documentation

◆ addDefinition()

assMatchingQuestion::addDefinition (   $definition)

Adds a definition.

Parameters
object$definitionThe definition
See also
$definitions

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

755  {
756  array_push($this->definitions, $definition);
757  }

◆ addMatchingPair()

assMatchingQuestion::addMatchingPair (   $term = null,
  $definition = null,
  $points = 0.0 
)

Adds an matching pair for an matching choice question.

The students have to fill in an order for the matching pair. The matching pair is an ASS_AnswerMatching object that will be created and assigned to the array $this->matchingpairs.

Parameters
assAnswerMatchingTerm | null$termA matching term
assAnswerMatchingDefinition | null$definitionA matching definition
float$pointsThe points for selecting the matching pair, incl. negative.
See also
$matchingpairs

Definition at line 582 of file class.assMatchingQuestion.php.

References assQuestion\$points.

583  {
584  require_once './Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php';
585  require_once './Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php';
586  require_once './Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php';
587  if (is_null($term))
588  {
589  $term = new assAnswerMatchingTerm();
590  }
591  if (is_null($definition))
592  {
593  $definition = new assAnswerMatchingDefinition();
594  }
595  $pair = new assAnswerMatchingPair($term, $definition, $points);
596  array_push($this->matchingpairs, $pair);
597  }
Class for matching question terms.
Class for matching question pairs.
Class for matching question definitions.

◆ addTerm()

assMatchingQuestion::addTerm (   $term)

Adds a term.

Parameters
string$termThe text of the term
See also
$terms

Definition at line 743 of file class.assMatchingQuestion.php.

744  {
745  array_push($this->terms, $term);
746  }

◆ calculateReachedPoints()

assMatchingQuestion::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 873 of file class.assMatchingQuestion.php.

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

874  {
875  if( $returndetails )
876  {
877  throw new ilTestException('return details not implemented for '.__METHOD__);
878  }
879 
880  global $ilDB;
881 
882  $found_value1 = array();
883  $found_value2 = array();
884  if (is_null($pass))
885  {
886  $pass = $this->getSolutionMaxPass($active_id);
887  }
888  $result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
889  array('integer','integer','integer'),
890  array($active_id, $this->getId(), $pass)
891  );
892  while ($data = $ilDB->fetchAssoc($result))
893  {
894  if (strcmp($data["value1"], "") != 0)
895  {
896  array_push($found_value1, $data["value1"]);
897  array_push($found_value2, $data["value2"]);
898  }
899  }
900  $points = 0;
901  foreach ($found_value2 as $key => $value)
902  {
903  foreach ($this->matchingpairs as $pair)
904  {
905  if (($pair->definition->identifier == $value) && ($pair->term->identifier == $found_value1[$key]))
906  {
907  $points += $pair->points;
908  }
909  }
910  }
911 
912  return $points;
913  }
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.
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:

◆ checkSaveData()

assMatchingQuestion::checkSaveData ( )

Checks the data to be saved for consistency.

Returns
boolean True, if the check was ok, False otherwise
See also
$answers

Definition at line 1028 of file class.assMatchingQuestion.php.

References $_POST, $result, assQuestion\getId(), and ilUtil\sendFailure().

Referenced by saveWorkingData().

1029  {
1030  $result = true;
1031  $matching_values = array();
1032  foreach ($_POST['matching'][$this->getId()] as $definition => $term)
1033  {
1034  if ($term > 0)
1035  {
1036  array_push($matching_values, $term);
1037  }
1038  }
1039 
1040  $check_matching = array_flip($matching_values);
1041  if (count($check_matching) != count($matching_values))
1042  {
1043  $result = false;
1044  ilUtil::sendFailure($this->lng->txt("duplicate_matching_values_selected"), true);
1045  }
1046  return $result;
1047  }
getId()
Gets the id of the assQuestion object.
$_POST['username']
Definition: cron.php:12
$result
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyImages()

assMatchingQuestion::copyImages (   $question_id,
  $source_questionpool 
)

Definition at line 494 of file class.assMatchingQuestion.php.

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

495  {
496  global $ilLog;
497 
498  $imagepath = $this->getImagePath();
499  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
500  $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
501  foreach ($this->terms as $term)
502  {
503  if (strlen($term->picture))
504  {
505  if (!file_exists($imagepath))
506  {
507  ilUtil::makeDirParents($imagepath);
508  }
509  $filename = $term->picture;
510  if (!@copy($imagepath_original . $filename, $imagepath . $filename))
511  {
512  $ilLog->write("matching question image could not be copied: $imagepath_original$filename");
513  }
514  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename))
515  {
516  $ilLog->write("matching question image thumbnail could not be copied: $imagepath_original" . $this->getThumbPrefix() . $filename);
517  }
518  }
519  }
520  foreach ($this->definitions as $definition)
521  {
522  if (strlen($definition->picture))
523  {
524  $filename = $definition->picture;
525  if (!file_exists($imagepath))
526  {
527  ilUtil::makeDirParents($imagepath);
528  }
529  if (!copy($imagepath_original . $filename, $imagepath . $filename))
530  {
531  $ilLog->write("matching question image could not be copied: $imagepath_original$filename");
532  }
533  if (!copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename))
534  {
535  $ilLog->write("matching question image thumbnail could not be copied: $imagepath_original" . $this->getThumbPrefix() . $filename);
536  }
537  }
538  }
539  }
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()

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

Copies an assMatchingQuestion.

Definition at line 369 of file class.assMatchingQuestion.php.

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

370  {
371  if ($this->id <= 0)
372  {
373  // The question has not been saved. It cannot be duplicated
374  return;
375  }
376  // duplicate the question in database
377  $clone = $this;
378  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
380  $clone->id = -1;
381  $source_questionpool_id = $this->getObjId();
382  $clone->setObjId($target_questionpool_id);
383  if ($title)
384  {
385  $clone->setTitle($title);
386  }
387  $clone->saveToDb();
388  // copy question page content
389  $clone->copyPageOfQuestion($original_id);
390  // copy XHTML media objects
391  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
392  // duplicate the image
393  $clone->copyImages($original_id, $source_questionpool_id);
394 
395  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
396 
397  return $clone->id;
398  }
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()

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

Definition at line 400 of file class.assMatchingQuestion.php.

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

401  {
402  if ($this->id <= 0)
403  {
404  // The question has not been saved. It cannot be duplicated
405  return;
406  }
407 
408  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
409 
410  $sourceQuestionId = $this->id;
411  $sourceParentId = $this->getObjId();
412 
413  // duplicate the question in database
414  $clone = $this;
415  $clone->id = -1;
416 
417  $clone->setObjId($targetParentId);
418 
419  if ($targetQuestionTitle)
420  {
421  $clone->setTitle($targetQuestionTitle);
422  }
423 
424  $clone->saveToDb();
425  // copy question page content
426  $clone->copyPageOfQuestion($sourceQuestionId);
427  // copy XHTML media objects
428  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
429  // duplicate the image
430  $clone->copyImages($sourceQuestionId, $sourceParentId);
431 
432  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
433 
434  return $clone->id;
435  }
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ deleteDefinition()

assMatchingQuestion::deleteDefinition (   $position)

Deletes a definition.

Parameters
integer$positionThe position of the definition in the definition array
See also
$definitions

Definition at line 845 of file class.assMatchingQuestion.php.

846  {
847  unset($this->definitions[$position]);
848  $this->definitions = array_values($this->definitions);
849  }

◆ deleteImagefile()

assMatchingQuestion::deleteImagefile (   $filename)

Deletes an imagefile from the system if the file is deleted manually.

Parameters
string$filenameImage file filename
Returns
boolean Success

Definition at line 976 of file class.assMatchingQuestion.php.

References $filename, $result, assQuestion\getImagePath(), and getThumbPrefix().

Referenced by removeDefinitionImage(), removeTermImage(), and setImageFile().

977  {
978  $deletename = $filename;
979  $result = @unlink($this->getImagePath().$deletename);
980  $result = $result & @unlink($this->getImagePath().$this->getThumbPrefix() . $deletename);
981  return $result;
982  }
$result
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:
+ Here is the caller graph for this function:

◆ deleteMatchingPair()

assMatchingQuestion::deleteMatchingPair (   $index = 0)

Deletes a matching pair with a given index.

The index of the first matching pair is 0, the index of the second matching pair is 1 and so on.

Parameters
integer$indexA nonnegative index of the n-th matching pair
See also
$matchingpairs

Definition at line 655 of file class.assMatchingQuestion.php.

656  {
657  if ($index < 0)
658  {
659  return;
660  }
661  if (count($this->matchingpairs) < 1)
662  {
663  return;
664  }
665  if ($index >= count($this->matchingpairs))
666  {
667  return;
668  }
669  unset($this->matchingpairs[$index]);
670  $this->matchingpairs = array_values($this->matchingpairs);
671  }

◆ deleteTerm()

assMatchingQuestion::deleteTerm (   $position)

Deletes a term.

Parameters
string$term_idThe id of the term to delete
See also
$terms

Definition at line 833 of file class.assMatchingQuestion.php.

834  {
835  unset($this->terms[$position]);
836  $this->terms = array_values($this->terms);
837  }

◆ duplicate()

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

Duplicates an assMatchingQuestion.

Definition at line 312 of file class.assMatchingQuestion.php.

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

313  {
314  if ($this->id <= 0)
315  {
316  // The question has not been saved. It cannot be duplicated
317  return;
318  }
319  // duplicate the question in database
320  $this_id = $this->getId();
321  $thisObjId = $this->getObjId();
322 
323  $clone = $this;
324  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
326  $clone->id = -1;
327 
328  if( (int)$testObjId > 0 )
329  {
330  $clone->setObjId($testObjId);
331  }
332 
333  if ($title)
334  {
335  $clone->setTitle($title);
336  }
337  if ($author)
338  {
339  $clone->setAuthor($author);
340  }
341  if ($owner)
342  {
343  $clone->setOwner($owner);
344  }
345  if ($for_test)
346  {
347  $clone->saveToDb($original_id);
348  }
349  else
350  {
351  $clone->saveToDb();
352  }
353 
354  // copy question page content
355  $clone->copyPageOfQuestion($this_id);
356  // copy XHTML media objects
357  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
358  // duplicate the image
359  $clone->duplicateImages($this_id, $thisObjId);
360 
361  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
362 
363  return $clone->id;
364  }
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:

◆ duplicateImages()

assMatchingQuestion::duplicateImages (   $question_id,
  $objectId = null 
)

Definition at line 437 of file class.assMatchingQuestion.php.

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

438  {
439  global $ilLog;
440  $imagepath = $this->getImagePath();
441  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
442 
443  if( (int)$objectId > 0 )
444  {
445  $imagepath_original = str_replace("/$this->obj_id/", "/$objectId/", $imagepath_original);
446  }
447 
448  foreach ($this->terms as $term)
449  {
450  if (strlen($term->picture))
451  {
452  $filename = $term->picture;
453  if (!file_exists($imagepath))
454  {
455  ilUtil::makeDirParents($imagepath);
456  }
457  if (!@copy($imagepath_original . $filename, $imagepath . $filename))
458  {
459  $ilLog->write("matching question image could not be duplicated: $imagepath_original$filename");
460  }
461  if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename))
462  {
463  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename))
464  {
465  $ilLog->write("matching question image thumbnail could not be duplicated: $imagepath_original" . $this->getThumbPrefix() . $filename);
466  }
467  }
468  }
469  }
470  foreach ($this->definitions as $definition)
471  {
472  if (strlen($definition->picture))
473  {
474  $filename = $definition->picture;
475  if (!file_exists($imagepath))
476  {
477  ilUtil::makeDirParents($imagepath);
478  }
479  if (!@copy($imagepath_original . $filename, $imagepath . $filename))
480  {
481  $ilLog->write("matching question image could not be duplicated: $imagepath_original$filename");
482  }
483  if (@file_exists($imagepath_original . $this->getThumbPrefix() . $filename))
484  {
485  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename))
486  {
487  $ilLog->write("matching question image thumbnail could not be duplicated: $imagepath_original" . $this->getThumbPrefix() . $filename);
488  }
489  }
490  }
491  }
492  }
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:

◆ flushDefinitions()

assMatchingQuestion::flushDefinitions ( )

Deletes all definitions.

See also
$definitions

Definition at line 822 of file class.assMatchingQuestion.php.

823  {
824  $this->definitions = array();
825  }

◆ flushMatchingPairs()

assMatchingQuestion::flushMatchingPairs ( )

Deletes all matching pairs.

See also
$matchingpairs

Definition at line 677 of file class.assMatchingQuestion.php.

678  {
679  $this->matchingpairs = array();
680  }

◆ flushTerms()

assMatchingQuestion::flushTerms ( )

Deletes all terms.

See also
$terms

Definition at line 813 of file class.assMatchingQuestion.php.

814  {
815  $this->terms = array();
816  }

◆ generateThumbForFile()

assMatchingQuestion::generateThumbForFile (   $path,
  $file 
)
protected

Definition at line 1354 of file class.assMatchingQuestion.php.

References $file, $filename, $path, ilUtil\convertImage(), getThumbGeometry(), and getThumbPrefix().

Referenced by rebuildThumbnails().

1355  {
1356  $filename = $path . $file;
1357  if (@file_exists($filename))
1358  {
1359  $thumbpath = $path . $this->getThumbPrefix() . $file;
1360  $path_info = @pathinfo($filename);
1361  $ext = "";
1362  switch (strtoupper($path_info['extension']))
1363  {
1364  case 'PNG':
1365  $ext = 'PNG';
1366  break;
1367  case 'GIF':
1368  $ext = 'GIF';
1369  break;
1370  default:
1371  $ext = 'JPEG';
1372  break;
1373  }
1374  ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbGeometry());
1375  }
1376  }
getThumbGeometry()
Get the thumbnail geometry.
print $file
$filename
Definition: buildRTE.php:89
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
$path
Definition: index.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdditionalTableName()

assMatchingQuestion::getAdditionalTableName ( )

Returns the name of the additional question data table in the database.

Returns
string The additional table name

Definition at line 1187 of file class.assMatchingQuestion.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

1188  {
1189  return "qpl_qst_matching";
1190  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assMatchingQuestion::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name

Definition at line 1197 of file class.assMatchingQuestion.php.

1198  {
1199  return array("qpl_a_matching", "qpl_a_mterm");
1200  }

◆ getDefinitionCount()

assMatchingQuestion::getDefinitionCount ( )

Returns the number of definitions.

Returns
integer The number of definitions
See also
$definitions

Definition at line 732 of file class.assMatchingQuestion.php.

733  {
734  return count($this->definitions);
735  }

◆ getDefinitions()

assMatchingQuestion::getDefinitions ( )

Returns the definitions of the matching question.

Returns
array An array containing the definitions
See also
$terms

Definition at line 710 of file class.assMatchingQuestion.php.

References $definitions.

Referenced by toJSON().

711  {
712  return $this->definitions;
713  }
+ Here is the caller graph for this function:

◆ getDefinitionWithIdentifier()

assMatchingQuestion::getDefinitionWithIdentifier (   $a_identifier)

Returns a definition with a given identifier.

Definition at line 614 of file class.assMatchingQuestion.php.

615  {
616  foreach ($this->definitions as $definition)
617  {
618  if ($definition->identifier == $a_identifier) return $definition;
619  }
620  return null;
621  }

◆ getElementHeight()

assMatchingQuestion::getElementHeight ( )

Get the minimum element height.

Returns
integer Height

Definition at line 1319 of file class.assMatchingQuestion.php.

References $element_height.

Referenced by getEstimatedElementHeight(), and saveAdditionalQuestionDataToDb().

1320  {
1321  return $this->element_height;
1322  }
+ Here is the caller graph for this function:

◆ getEncryptedFilename()

assMatchingQuestion::getEncryptedFilename (   $filename)

Returns the encrypted save filename of a matching picture Images are saved with an encrypted filename to prevent users from cheating by guessing the solution from the image filename.

Parameters
string$filenameOriginal filename
Returns
string Encrypted filename

Definition at line 939 of file class.assMatchingQuestion.php.

References $filename.

940  {
941  $extension = "";
942  if (preg_match("/.*\\.(\\w+)$/", $filename, $matches))
943  {
944  $extension = $matches[1];
945  }
946  return md5($filename) . "." . $extension;
947  }
$filename
Definition: buildRTE.php:89

◆ getEstimatedElementHeight()

assMatchingQuestion::getEstimatedElementHeight ( )

Definition at line 1378 of file class.assMatchingQuestion.php.

References getElementHeight(), and getThumbSize().

1379  {
1380  $hasImages = false;
1381  foreach ($this->terms as $term)
1382  {
1383  if (strlen($term->picture))
1384  {
1385  $hasImages = true;
1386  }
1387  }
1388  foreach ($this->definitions as $definition)
1389  {
1390  if (strlen($definition->picture))
1391  {
1392  $hasImages = true;
1393  }
1394  }
1395  if ($hasImages)
1396  { // 40 is approx. the height of the preview image
1397  return max($this->getElementHeight(), $this->getThumbSize() + 40);
1398  }
1399  else
1400  {
1401  return ($this->getElementHeight()) ? $this->getElementHeight() : 0;
1402  }
1403  }
getElementHeight()
Get the minimum element height.
getThumbSize()
Get the thumbnail geometry.
+ Here is the call graph for this function:

◆ getMatchingPair()

assMatchingQuestion::getMatchingPair (   $index = 0)

Returns a matching pair with a given index.

The index of the first matching pair is 0, the index of the second matching pair is 1 and so on.

Parameters
integer$indexA nonnegative index of the n-th matching pair
Returns
object ASS_AnswerMatching-Object
See also
$matchingpairs

Definition at line 631 of file class.assMatchingQuestion.php.

632  {
633  if ($index < 0)
634  {
635  return NULL;
636  }
637  if (count($this->matchingpairs) < 1)
638  {
639  return NULL;
640  }
641  if ($index >= count($this->matchingpairs))
642  {
643  return NULL;
644  }
645  return $this->matchingpairs[$index];
646  }

◆ getMatchingPairCount()

assMatchingQuestion::getMatchingPairCount ( )

Returns the number of matching pairs.

Returns
integer The number of matching pairs of the matching question
See also
$matchingpairs

Definition at line 688 of file class.assMatchingQuestion.php.

689  {
690  return count($this->matchingpairs);
691  }

◆ getMatchingPairs()

& assMatchingQuestion::getMatchingPairs ( )

Returns the matchingpairs array.

Definition at line 1214 of file class.assMatchingQuestion.php.

References $matchingpairs.

Referenced by saveAnswerSpecificDataToDb(), setExportDetailsXLS(), and toJSON().

1215  {
1216  return $this->matchingpairs;
1217  }
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assMatchingQuestion::getMaximumPoints ( )

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

Definition at line 918 of file class.assMatchingQuestion.php.

References assQuestion\$points.

Referenced by isComplete().

919  {
920  $points = 0;
921  foreach ($this->matchingpairs as $key => $pair)
922  {
923  if ($pair->points > 0)
924  {
925  $points += $pair->points;
926  }
927  }
928  return $points;
929  }
+ Here is the caller graph for this function:

◆ getQuestionType()

assMatchingQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

Definition at line 1177 of file class.assMatchingQuestion.php.

Referenced by toJSON().

1178  {
1179  return "assMatchingQuestion";
1180  }
+ Here is the caller graph for this function:

◆ getRandomId()

assMatchingQuestion::getRandomId ( )

Definition at line 1130 of file class.assMatchingQuestion.php.

1131  {
1132  mt_srand((double)microtime()*1000000);
1133  $random_number = mt_rand(1, 100000);
1134  $found = FALSE;
1135  while ($found)
1136  {
1137  $found = FALSE;
1138  foreach ($this->matchingpairs as $key => $pair)
1139  {
1140  if (($pair->term->identifier == $random_number) || ($pair->definition->identifier == $random_number))
1141  {
1142  $found = TRUE;
1143  $random_number++;
1144  }
1145  }
1146  }
1147  return $random_number;
1148  }

◆ getRTETextWithMediaObjects()

assMatchingQuestion::getRTETextWithMediaObjects ( )

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

Definition at line 1206 of file class.assMatchingQuestion.php.

1207  {
1208  return parent::getRTETextWithMediaObjects();
1209  }

◆ getTermCount()

assMatchingQuestion::getTermCount ( )

Returns the number of terms.

Returns
integer The number of terms
See also
$terms

Definition at line 721 of file class.assMatchingQuestion.php.

722  {
723  return count($this->terms);
724  }

◆ getTerms()

assMatchingQuestion::getTerms ( )

Returns the terms of the matching question.

Returns
array An array containing the terms
See also
$terms

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

References $terms.

Referenced by toJSON().

700  {
701  return $this->terms;
702  }
+ Here is the caller graph for this function:

◆ getTermWithIdentifier()

assMatchingQuestion::getTermWithIdentifier (   $a_identifier)

Returns a term with a given identifier.

Definition at line 602 of file class.assMatchingQuestion.php.

603  {
604  foreach ($this->terms as $term)
605  {
606  if ($term->identifier == $a_identifier) return $term;
607  }
608  return null;
609  }

◆ getThumbGeometry()

assMatchingQuestion::getThumbGeometry ( )

Get the thumbnail geometry.

Returns
integer Geometry

Definition at line 1289 of file class.assMatchingQuestion.php.

References $thumb_geometry.

Referenced by generateThumbForFile(), getThumbSize(), and saveAdditionalQuestionDataToDb().

1290  {
1291  return $this->thumb_geometry;
1292  }
+ Here is the caller graph for this function:

◆ getThumbPrefix()

assMatchingQuestion::getThumbPrefix ( )

Definition at line 1349 of file class.assMatchingQuestion.php.

Referenced by copyImages(), deleteImagefile(), duplicateImages(), generateThumbForFile(), and setImageFile().

1350  {
1351  return "thumb.";
1352  }
+ Here is the caller graph for this function:

◆ getThumbSize()

assMatchingQuestion::getThumbSize ( )

Get the thumbnail geometry.

Returns
integer Geometry

Definition at line 1299 of file class.assMatchingQuestion.php.

References getThumbGeometry().

Referenced by getEstimatedElementHeight().

1300  {
1301  return $this->getThumbGeometry();
1302  }
getThumbGeometry()
Get the thumbnail geometry.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertDefinition()

assMatchingQuestion::insertDefinition (   $position,
  $definition = null 
)

Inserts a definition.

Parameters
object$definitionThe definition
See also
$definitions

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

791  {
792  if (is_null($definition))
793  {
794  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
795  $definition = new assAnswerMatchingDefinition();
796  }
797  if ($position < count($this->definitions))
798  {
799  $part1 = array_slice($this->definitions, 0, $position);
800  $part2 = array_slice($this->definitions, $position);
801  $this->definitions = array_merge($part1, array($definition), $part2);
802  }
803  else
804  {
805  array_push($this->definitions, $definition);
806  }
807  }
Class for matching question definitions.

◆ insertMatchingPair()

assMatchingQuestion::insertMatchingPair (   $position,
  $term = null,
  $definition = null,
  $points = 0.0 
)

Inserts a matching pair for an matching choice question.

The students have to fill in an order for the matching pair. The matching pair is an ASS_AnswerMatching object that will be created and assigned to the array $this->matchingpairs.

Parameters
integer$positionThe insert position in the matching pairs array
object$termA matching term
object$definitionA matching definition
double$pointsThe points for selecting the matching pair (even negative points can be used)
See also
$matchingpairs

Definition at line 551 of file class.assMatchingQuestion.php.

References assQuestion\$points.

552  {
553  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
554  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
555  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
556  if (is_null($term)) $term = new assAnswerMatchingTerm();
557  if (is_null($definition)) $definition = new assAnswerMatchingDefinition();
558  $pair = new assAnswerMatchingPair($term, $definition, $points);
559  if ($position < count($this->matchingpairs))
560  {
561  $part1 = array_slice($this->matchingpairs, 0, $position);
562  $part2 = array_slice($this->matchingpairs, $position);
563  $this->matchingpairs = array_merge($part1, array($pair), $part2);
564  }
565  else
566  {
567  array_push($this->matchingpairs, $pair);
568  }
569  }
Class for matching question terms.
Class for matching question pairs.
Class for matching question definitions.

◆ insertTerm()

assMatchingQuestion::insertTerm (   $position,
  $term = null 
)

Inserts a term.

Parameters
string$termThe text of the term
See also
$terms

Definition at line 765 of file class.assMatchingQuestion.php.

766  {
767  if (is_null($term))
768  {
769  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
770  $term = new assAnswerMatchingTerm();
771  }
772  if ($position < count($this->terms))
773  {
774  $part1 = array_slice($this->terms, 0, $position);
775  $part2 = array_slice($this->terms, $position);
776  $this->terms = array_merge($part1, array($term), $part2);
777  }
778  else
779  {
780  array_push($this->terms, $term);
781  }
782  }
Class for matching question terms.

◆ isComplete()

assMatchingQuestion::isComplete ( )

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

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

Definition at line 100 of file class.assMatchingQuestion.php.

References getMaximumPoints().

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

◆ loadFromDb()

assMatchingQuestion::loadFromDb (   $question_id)

Loads a assMatchingQuestion object from a database.

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

Definition at line 222 of file class.assMatchingQuestion.php.

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

223  {
224  global $ilDB;
225 
226  $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",
227  array("integer"),
228  array($question_id)
229  );
230  if ($result->numRows() == 1)
231  {
232  $data = $ilDB->fetchAssoc($result);
233  $this->setId($question_id);
234  $this->setObjId($data["obj_fi"]);
235  $this->setTitle($data["title"]);
236  $this->setComment($data["description"]);
237  $this->setOriginalId($data["original_id"]);
238  $this->setNrOfTries($data['nr_of_tries']);
239  $this->setAuthor($data["author"]);
240  $this->setPoints($data["points"]);
241  $this->setOwner($data["owner"]);
242  include_once("./Services/RTE/classes/class.ilRTE.php");
243  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
244  $this->setThumbGeometry($data["thumb_geometry"]);
245  $this->setElementHeight($data["element_height"]);
246  $this->setShuffle($data["shuffle"]);
247  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
248 
249  try
250  {
251  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
252  }
254  {
255  }
256  }
257 
258  $termids = array();
259  $result = $ilDB->queryF("SELECT * FROM qpl_a_mterm WHERE question_fi = %s ORDER BY term_id ASC",
260  array('integer'),
261  array($question_id)
262  );
263  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
264  $this->terms = array();
265  if ($result->numRows() > 0)
266  {
267  while ($data = $ilDB->fetchAssoc($result))
268  {
269  $term = new assAnswerMatchingTerm($data['term'], $data['picture'], $data['term_id']);
270  array_push($this->terms, $term);
271  $termids[$data['term_id']] = $term;
272  }
273  }
274 
275  $definitionids = array();
276  $result = $ilDB->queryF("SELECT * FROM qpl_a_mdef WHERE question_fi = %s ORDER BY def_id ASC",
277  array('integer'),
278  array($question_id)
279  );
280  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
281  $this->definitions = array();
282  if ($result->numRows() > 0)
283  {
284  while ($data = $ilDB->fetchAssoc($result))
285  {
286  $definition = new assAnswerMatchingDefinition($data['definition'], $data['picture'], $data['morder']);
287  array_push($this->definitions, $definition);
288  $definitionids[$data['def_id']] = $definition;
289  }
290  }
291 
292  $this->matchingpairs = array();
293  $result = $ilDB->queryF("SELECT * FROM qpl_a_matching WHERE question_fi = %s ORDER BY answer_id",
294  array('integer'),
295  array($question_id)
296  );
297  include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
298  if ($result->numRows() > 0)
299  {
300  while ($data = $ilDB->fetchAssoc($result))
301  {
302  array_push($this->matchingpairs, new assAnswerMatchingPair($termids[$data['term_fi']], $definitionids[$data['definition_fi']], $data['points']));
303  }
304  }
305  parent::loadFromDb($question_id);
306  }
Class for matching question terms.
Class for matching question pairs.
$result
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.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
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.
setElementHeight($a_height)
Set the minimum element height.
setShuffle($shuffle)
Sets the shuffle flag.
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.
setThumbGeometry($a_geometry)
Set the thumbnail geometry.
setOriginalId($original_id)
Class for matching question definitions.
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.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
+ Here is the call graph for this function:

◆ rebuildThumbnails()

assMatchingQuestion::rebuildThumbnails ( )

Rebuild the thumbnail images with a new thumbnail size.

Definition at line 1337 of file class.assMatchingQuestion.php.

References generateThumbForFile(), and assQuestion\getImagePath().

Referenced by saveAnswerSpecificDataToDb().

1338  {
1339  foreach ($this->terms as $term)
1340  {
1341  if (strlen($term->picture)) $this->generateThumbForFile($this->getImagePath(), $term->picture);
1342  }
1343  foreach ($this->definitions as $definition)
1344  {
1345  if (strlen($definition->picture)) $this->generateThumbForFile($this->getImagePath(), $definition->picture);
1346  }
1347  }
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:

◆ removeDefinitionImage()

assMatchingQuestion::removeDefinitionImage (   $index)

Definition at line 959 of file class.assMatchingQuestion.php.

References deleteImagefile().

960  {
961  $definition = $this->definitions[$index];
962  if (is_object($definition))
963  {
964  $this->deleteImagefile($definition->picture);
965  $definition->picture = null;
966  }
967  }
deleteImagefile($filename)
Deletes an imagefile from the system if the file is deleted manually.
+ Here is the call graph for this function:

◆ removeTermImage()

assMatchingQuestion::removeTermImage (   $index)

Definition at line 949 of file class.assMatchingQuestion.php.

References deleteImagefile().

950  {
951  $term = $this->terms[$index];
952  if (is_object($term))
953  {
954  $this->deleteImagefile($term->picture);
955  $term->picture = null;
956  }
957  }
deleteImagefile($filename)
Deletes an imagefile from the system if the file is deleted manually.
+ Here is the call graph for this function:

◆ reworkWorkingData()

assMatchingQuestion::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 1125 of file class.assMatchingQuestion.php.

1126  {
1127  // nothing to rework!
1128  }

◆ saveAdditionalQuestionDataToDb()

assMatchingQuestion::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

Definition at line 195 of file class.assMatchingQuestion.php.

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

Referenced by saveToDb().

196  {
197  global $ilDB;
198  // save additional data
199  $ilDB->manipulateF( "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
200  array( "integer" ),
201  array( $this->getId() )
202  );
203  $ilDB->manipulateF( "INSERT INTO " . $this->getAdditionalTableName(
204  ) . " (question_fi, shuffle, matching_type, thumb_geometry, element_height) VALUES (%s, %s, %s, %s, %s)",
205  array( "integer", "text", "text", "integer", "integer" ),
206  array(
207  $this->getId(),
208  $this->shuffle,
209  $this->matching_type,
210  $this->getThumbGeometry(),
211  ($this->getElementHeight() >= 20) ? $this->getElementHeight() : NULL
212  )
213  );
214  }
getThumbGeometry()
Get the thumbnail geometry.
getId()
Gets the id of the assQuestion object.
getElementHeight()
Get the minimum element height.
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()

assMatchingQuestion::saveAnswerSpecificDataToDb ( )

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

Returns
mixed

Implements ilObjAnswerScoringAdjustable.

Definition at line 132 of file class.assMatchingQuestion.php.

References assQuestion\getId(), getMatchingPairs(), and rebuildThumbnails().

Referenced by saveToDb().

133  {
134  global $ilDB;
135  // delete old terms
136  $ilDB->manipulateF( "DELETE FROM qpl_a_mterm WHERE question_fi = %s",
137  array( 'integer' ),
138  array( $this->getId() )
139  );
140 
141  // delete old definitions
142  $ilDB->manipulateF( "DELETE FROM qpl_a_mdef WHERE question_fi = %s",
143  array( 'integer' ),
144  array( $this->getId() )
145  );
146 
147  $termids = array();
148  // write terms
149  foreach ($this->terms as $key => $term)
150  {
151  $next_id = $ilDB->nextId( 'qpl_a_mterm' );
152  $ilDB->manipulateF( "INSERT INTO qpl_a_mterm (term_id, question_fi, picture, term) VALUES (%s, %s, %s, %s)",
153  array( 'integer', 'integer', 'text', 'text' ),
154  array( $next_id, $this->getId(), $term->picture, $term->text )
155  );
156  $termids[$term->identifier] = $next_id;
157  }
158 
159  $definitionids = array();
160  // write definitions
161  foreach ($this->definitions as $key => $definition)
162  {
163  $next_id = $ilDB->nextId( 'qpl_a_mdef' );
164  $ilDB->manipulateF( "INSERT INTO qpl_a_mdef (def_id, question_fi, picture, definition, morder) VALUES (%s, %s, %s, %s, %s)",
165  array( 'integer', 'integer', 'text', 'text', 'integer' ),
166  array( $next_id, $this->getId(
167  ), $definition->picture, $definition->text, $definition->identifier )
168  );
169  $definitionids[$definition->identifier] = $next_id;
170  }
171 
172  $ilDB->manipulateF( "DELETE FROM qpl_a_matching WHERE question_fi = %s",
173  array( 'integer' ),
174  array( $this->getId() )
175  );
176  $matchingpairs = $this->getMatchingPairs();
177  foreach ($matchingpairs as $key => $pair)
178  {
179  $next_id = $ilDB->nextId( 'qpl_a_matching' );
180  $ilDB->manipulateF( "INSERT INTO qpl_a_matching (answer_id, question_fi, points, term_fi, definition_fi) VALUES (%s, %s, %s, %s, %s)",
181  array( 'integer', 'integer', 'float', 'integer', 'integer' ),
182  array(
183  $next_id,
184  $this->getId(),
185  $pair->points,
186  $termids[$pair->term->identifier],
187  $definitionids[$pair->definition->identifier]
188  )
189  );
190  }
191 
192  $this->rebuildThumbnails();
193  }
getId()
Gets the id of the assQuestion object.
rebuildThumbnails()
Rebuild the thumbnail images with a new thumbnail size.
& getMatchingPairs()
Returns the matchingpairs array.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

assMatchingQuestion::saveToDb (   $original_id = "")

Saves a assMatchingQuestion object to a database.

Parameters
string$original_id

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

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

121  {
122  global $ilDB;
123 
126  $this->saveAnswerSpecificDataToDb( $ilDB );
127 
128 
129  parent::saveToDb($original_id);
130  }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb($original_id="")
+ Here is the call graph for this function:

◆ saveWorkingData()

assMatchingQuestion::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 1057 of file class.assMatchingQuestion.php.

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

1058  {
1059  global $ilDB;
1060  global $ilUser;
1061  $saveWorkingDataResult = $this->checkSaveData();
1062  $entered_values = 0;
1063  if ($saveWorkingDataResult)
1064  {
1065  if (is_null($pass))
1066  {
1067  include_once "./Modules/Test/classes/class.ilObjTest.php";
1068  $pass = ilObjTest::_getPass($active_id);
1069  }
1070 
1071  $this->getProcessLocker()->requestUserSolutionUpdateLock();
1072 
1073  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
1074  array('integer','integer','integer'),
1075  array($active_id, $this->getId(), $pass)
1076  );
1077 
1078  foreach ($_POST['matching'][$this->getId()] as $definition => $term)
1079  {
1080  $entered_values++;
1081  $next_id = $ilDB->nextId('tst_solutions');
1082  $affectedRows = $ilDB->insert("tst_solutions", array(
1083  "solution_id" => array("integer", $next_id),
1084  "active_fi" => array("integer", $active_id),
1085  "question_fi" => array("integer", $this->getId()),
1086  "value1" => array("clob", $term),
1087  "value2" => array("clob", $definition),
1088  "pass" => array("integer", $pass),
1089  "tstamp" => array("integer", time())
1090  ));
1091  }
1092 
1093  $this->getProcessLocker()->releaseUserSolutionUpdateLock();
1094 
1095  $saveWorkingDataResult = true;
1096  }
1097  if ($entered_values)
1098  {
1099  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1101  {
1102  $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1103  }
1104  }
1105  else
1106  {
1107  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1109  {
1110  $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1111  }
1112  }
1113 
1114  return $saveWorkingDataResult;
1115  }
getId()
Gets the id of the assQuestion object.
$_POST['username']
Definition: cron.php:12
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
checkSaveData()
Checks the data to be saved for consistency.
_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:

◆ setElementHeight()

assMatchingQuestion::setElementHeight (   $a_height)

Set the minimum element height.

Parameters
integer$a_heightHeight

Definition at line 1329 of file class.assMatchingQuestion.php.

Referenced by loadFromDb().

1330  {
1331  $this->element_height = ($a_height < 20) ? "" : $a_height;
1332  }
+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

assMatchingQuestion::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 1241 of file class.assMatchingQuestion.php.

References $pass, ilExcelUtils\_convert_text(), assQuestion\getImagePath(), getMatchingPairs(), assQuestion\getSolutionValues(), and assQuestion\getTitle().

1242  {
1243  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
1244  $solutions = $this->getSolutionValues($active_id, $pass);
1245  $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
1246  $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
1247  $imagepath = $this->getImagePath();
1248  $i = 1;
1249  foreach ($solutions as $solution)
1250  {
1251  $matches_written = FALSE;
1252  foreach ($this->getMatchingPairs() as $idx => $pair)
1253  {
1254  if (!$matches_written) $worksheet->writeString($startrow + $i, 1, ilExcelUtils::_convert_text($this->lng->txt("matches")));
1255  $matches_written = TRUE;
1256  if ($pair->definition->identifier == $solution["value2"])
1257  {
1258  if (strlen($pair->definition->text))
1259  {
1260  $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($pair->definition->text));
1261  }
1262  else
1263  {
1264  $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($pair->definition->picture));
1265  }
1266  }
1267  if ($pair->term->identifier == $solution["value1"])
1268  {
1269  if (strlen($pair->term->text))
1270  {
1271  $worksheet->writeString($startrow + $i, 2, ilExcelUtils::_convert_text($pair->term->text));
1272  }
1273  else
1274  {
1275  $worksheet->writeString($startrow + $i, 2, ilExcelUtils::_convert_text($pair->term->picture));
1276  }
1277  }
1278  }
1279  $i++;
1280  }
1281  return $startrow + $i + 1;
1282  }
& 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")
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
getTitle()
Gets the title string of the assQuestion object.
& getMatchingPairs()
Returns the matchingpairs array.
+ Here is the call graph for this function:

◆ setImageFile()

assMatchingQuestion::setImageFile (   $image_tempfilename,
  $image_filename,
  $previous_filename = '' 
)

Sets the image file and uploads the image to the object's image directory.

Parameters
string$image_filenameName of the original image file
string$image_tempfilenameName of the temporary uploaded image file
Returns
integer An errorcode if the image upload fails, 0 otherwise public

Definition at line 992 of file class.assMatchingQuestion.php.

References $result, ilUtil\convertImage(), deleteImagefile(), assQuestion\getImagePath(), getThumbPrefix(), ilUtil\makeDirParents(), and ilUtil\moveUploadedFile().

993  {
994  $result = TRUE;
995  if (strlen($image_tempfilename))
996  {
997  $image_filename = str_replace(" ", "_", $image_filename);
998  $imagepath = $this->getImagePath();
999  if (!file_exists($imagepath))
1000  {
1001  ilUtil::makeDirParents($imagepath);
1002  }
1003  $savename = $image_filename;
1004  if (!ilUtil::moveUploadedFile($image_tempfilename, $savename, $imagepath.$savename))
1005  {
1006  $result = FALSE;
1007  }
1008  else
1009  {
1010  // create thumbnail file
1011  $thumbpath = $imagepath . $this->getThumbPrefix() . $savename;
1012  ilUtil::convertImage($imagepath.$savename, $thumbpath, "JPEG", $this->getThumbGeometry());
1013  }
1014  if ($result && (strcmp($image_filename, $previous_filename) != 0) && (strlen($previous_filename)))
1015  {
1016  $this->deleteImagefile($previous_filename);
1017  }
1018  }
1019  return $result;
1020  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$result
deleteImagefile($filename)
Deletes an imagefile from the system if the file is deleted manually.
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
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
+ Here is the call graph for this function:

◆ setShuffle()

assMatchingQuestion::setShuffle (   $shuffle)

Sets the shuffle flag.

Parameters
integer$shuffleA flag indicating whether the answers are shuffled or not
See also
$shuffle

Definition at line 1156 of file class.assMatchingQuestion.php.

References assQuestion\$shuffle.

Referenced by loadFromDb().

1157  {
1158  switch ($shuffle)
1159  {
1160  case 0:
1161  case 1:
1162  case 2:
1163  case 3:
1164  $this->shuffle = $shuffle;
1165  break;
1166  default:
1167  $this->shuffle = 1;
1168  break;
1169  }
1170  }
+ Here is the caller graph for this function:

◆ setTerm()

assMatchingQuestion::setTerm (   $term,
  $index 
)

Sets a specific term.

Parameters
string$termThe text of the term
string$indexThe index of the term
See also
$terms

Definition at line 858 of file class.assMatchingQuestion.php.

859  {
860  $this->terms[$index] = $term;
861  }

◆ setThumbGeometry()

assMatchingQuestion::setThumbGeometry (   $a_geometry)

Set the thumbnail geometry.

Parameters
integer$a_geometryGeometry

Definition at line 1309 of file class.assMatchingQuestion.php.

Referenced by loadFromDb().

1310  {
1311  $this->thumb_geometry = ($a_geometry < 1) ? 100 : $a_geometry;
1312  }
+ Here is the caller graph for this function:

◆ supportsJavascriptOutput()

assMatchingQuestion::supportsJavascriptOutput ( )

Returns true if the question type supports JavaScript output.

Returns
boolean TRUE if the question type supports JavaScript output, FALSE otherwise

Definition at line 1224 of file class.assMatchingQuestion.php.

1225  {
1226  return TRUE;
1227  }

◆ toJSON()

assMatchingQuestion::toJSON ( )

Returns a JSON representation of the question TODO.

Definition at line 1409 of file class.assMatchingQuestion.php.

References $mobs, assQuestion\$points, $result, $terms, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getDefinitions(), assQuestion\getId(), getMatchingPairs(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), getTerms(), and assQuestion\getTitle().

1410  {
1411  include_once("./Services/RTE/classes/class.ilRTE.php");
1412  $result = array();
1413  $result['id'] = (int) $this->getId();
1414  $result['type'] = (string) $this->getQuestionType();
1415  $result['title'] = (string) $this->getTitle();
1416  $result['question'] = $this->formatSAQuestion($this->getQuestion());
1417  $result['nr_of_tries'] = (int) $this->getNrOfTries();
1418  $result['shuffle'] = true;
1419  $result['feedback'] = array(
1420  "onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false),
1421  "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)
1422  );
1423 
1424  $terms = array("" => array("id"=>"-1",
1425  "term"=>$this->lng->txt("please_select")));
1426  foreach ($this->getTerms() as $term)
1427  {
1428  $terms[(int)$term->identifier] = array(
1429  "term" => $term->text,
1430  "id" =>(int)$term->identifier
1431  );
1432  }
1433  // $terms = $this->pcArrayShuffle($terms);
1434 
1435  // alex 9.9.2010 as a fix for bug 6513 I added the question id
1436  // to the "def_id" in the array. The $pair->definition->identifier is not
1437  // unique, since it gets it value from the morder table field
1438  // this value is not changed, when a question is copied.
1439  // thus copying the same question on a page results in problems
1440  // when the second one (the copy) is answered.
1441 
1442  $pairs = array();
1443  foreach ($this->getDefinitions() as $def)
1444  {
1445  array_push($pairs, array(
1446  "definition" => (string) $def->text,
1447  "def_id" => (int) $this->getId().$def->identifier,
1448  "terms" => $terms
1449  ));
1450  }
1451  $result['pairs'] = $pairs;
1452 
1453  // #10353
1454  $match = $points = array();
1455  foreach ($this->getMatchingPairs() as $pair)
1456  {
1457  $pid = $pair->definition->identifier;
1458 
1459  // we only need pairs with max. points for def-id
1460  if(!isset($match[$pid]) || $match[$pid]["points"] < $pair->points)
1461  {
1462  $match[$pid] = array(
1463  "term_id" => (int) $pair->term->identifier,
1464  "def_id" => (int) $this->getId().$pair->definition->identifier,
1465  "points" => (int) $pair->points
1466  );
1467  }
1468  }
1469  $result['match'] = array_values($match);
1470 
1471  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1472  $result['mobs'] = $mobs;
1473 
1474  return json_encode($result);
1475  }
getId()
Gets the id of the assQuestion object.
formatSAQuestion($a_q)
Format self assessment question.
$result
getQuestionType()
Returns the question type of the question.
getDefinitions()
Returns the definitions of the matching question.
$mobs
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
getTerms()
Returns the terms of the matching question.
getTitle()
Gets the title string of the assQuestion object.
& getMatchingPairs()
Returns the matchingpairs array.
+ Here is the call graph for this function:

Field Documentation

◆ $definitions

assMatchingQuestion::$definitions
protected

Definition at line 49 of file class.assMatchingQuestion.php.

Referenced by getDefinitions().

◆ $element_height

assMatchingQuestion::$element_height

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

Referenced by getElementHeight().

◆ $matching_type

assMatchingQuestion::$matching_type

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

Referenced by __construct().

◆ $matchingpairs

assMatchingQuestion::$matchingpairs

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

Referenced by getMatchingPairs().

◆ $terms

assMatchingQuestion::$terms
protected

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

Referenced by getTerms(), and toJSON().

◆ $thumb_geometry

assMatchingQuestion::$thumb_geometry = 100

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

Referenced by getThumbGeometry().


The documentation for this class was generated from the following file: