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

Class for cloze tests. More...

+ Inheritance diagram for assClozeTest:
+ Collaboration diagram for assClozeTest:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assClozeTest constructor More...
 
 isComplete ()
 Returns TRUE, if a cloze test is complete for use. More...
 
 cleanQuestiontext ($text)
 Cleans cloze question text to remove attributes or tags from older ILIAS versions. More...
 
 loadFromDb ($question_id)
 Loads a assClozeTest object from a database. More...
 
 saveToDb ($original_id="")
 Saves a assClozeTest object to a database. More...
 
 saveAnswerSpecificDataToDb ()
 Save all gaps to the database. More...
 
 saveAdditionalQuestionDataToDb ()
 Saves the data for the additional data table. More...
 
 getGaps ()
 Returns the array of gaps. More...
 
 flushGaps ()
 Deletes all gaps without changing the cloze text. More...
 
 setClozeText ($cloze_text="")
 Evaluates the text gap solutions from the cloze text. More...
 
 getClozeText ()
 Returns the cloze text. More...
 
 getStartTag ()
 Returns the start tag of a cloze gap. More...
 
 setStartTag ($start_tag="[gap]")
 Sets the start tag of a cloze gap. More...
 
 getEndTag ()
 Returns the end tag of a cloze gap. More...
 
 setEndTag ($end_tag="[/gap]")
 Sets the end tag of a cloze gap. More...
 
 createGapsFromQuestiontext ()
 Create gap entries by parsing the question text. More...
 
 setGapType ($gap_index, $gap_type)
 Set the type of a gap with a given index. More...
 
 setGapShuffle ($gap_index=0, $shuffle=1)
 Sets the shuffle state of a gap with a given index. More...
 
 clearGapAnswers ()
 Removes all answers from the gaps. More...
 
 getGapCount ()
 Returns the number of gaps. More...
 
 addGapAnswer ($gap_index, $order, $answer)
 Sets the answer text of a gap with a given index. More...
 
 getGap ($gap_index=0)
 Returns the gap at a given index. More...
 
 setGapAnswerPoints ($gap_index, $order, $points)
 Sets the points of a gap with a given index and an answer with a given order. More...
 
 addGapText ($gap_index)
 Adds a new answer text value to a text gap with a given index. More...
 
 addGapAtIndex ($gap, $index)
 Adds a ClozeGap object at a given index. More...
 
 setGapAnswerLowerBound ($gap_index, $order, $bound)
 Sets the lower bound of a gap with a given index and an answer with a given order. More...
 
 setGapAnswerUpperBound ($gap_index, $order, $bound)
 Sets the upper bound of a gap with a given index and an answer with a given order. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates an assClozeTest. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assClozeTest object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 updateClozeTextFromGaps ()
 Updates the gap parameters in the cloze text from the form input. More...
 
 deleteAnswerText ($gap_index, $answer_index)
 Deletes the answer text of a gap with a given index and an answer with a given order. More...
 
 deleteGap ($gap_index)
 Deletes a gap with a given index. More...
 
 getTextgapPoints ($a_original, $a_entered, $max_points)
 Returns the points for a text gap and compares the given solution with the entered solution using the text gap rating options. More...
 
 getNumericgapPoints ($a_original, $a_entered, $max_points, $lowerBound, $upperBound)
 Returns the points for a text gap and compares the given solution with the entered solution using the text gap rating options. 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...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getTextgapRating ()
 Returns the rating option for text gaps. More...
 
 setTextgapRating ($a_textgap_rating)
 Sets the rating option for text gaps. More...
 
 getIdenticalScoring ()
 Returns the identical scoring status of the question. More...
 
 setIdenticalScoring ($a_identical_scoring)
 Sets the identical scoring option for cloze questions. 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...
 
 setFixedTextLength ($a_text_len)
 Sets a fixed text length for all text fields in the cloze question. More...
 
 getFixedTextLength ()
 Gets the fixed text length for all text fields in the cloze question. More...
 
 getMaximumGapPoints ($gap_index)
 Returns the maximum points for a gap. 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...
 
 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

 $gaps
 
 $start_tag
 
 $end_tag
 
 $textgap_rating
 
 $identical_scoring
 
 $fixedTextLength
 
- 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

 saveClozeGapItemsToDb ($gap, $key)
 Save all items belonging to one cloze gap to the db. More...
 
 saveClozeTextGapRecordToDb ($next_id, $key, $item, $gap)
 Saves a gap-item record. More...
 
 saveClozeSelectGapRecordToDb ($next_id, $key, $item, $gap)
 Saves a gap-item record. More...
 
 saveClozeNumericGapRecordToDb ($next_id, $key, $item, $gap)
 Saves a gap-item record. More...
 
 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)
 

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

Detailed Description

Class for cloze tests.

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 20 of file class.assClozeTest.php.

Constructor & Destructor Documentation

◆ __construct()

assClozeTest::__construct (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $question = "" 
)

assClozeTest constructor

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

Definition at line 92 of file class.assClozeTest.php.

References assQuestion\$author, assQuestion\$comment, assQuestion\$owner, assQuestion\$question, assQuestion\$title, and setClozeText().

99  {
100  parent::__construct($title, $comment, $author, $owner, $question);
101  $this->start_tag = "[gap]";
102  $this->end_tag = "[/gap]";
103  $this->gaps = array();
104  $this->setClozeText($question); // @TODO: Should this be $question?? See setter for why this is not trivial.
105  $this->fixedTextLength = "";
106  $this->identical_scoring = 1;
107  }
setClozeText($cloze_text="")
Evaluates the text gap solutions from the cloze text.
+ Here is the call graph for this function:

Member Function Documentation

◆ addGapAnswer()

assClozeTest::addGapAnswer (   $gap_index,
  $order,
  $answer 
)

Sets the answer text of a gap with a given index.

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

Parameters
integer$gap_indexA nonnegative index of the n-th gap
integer$orderThe order of the answer text
string$answerThe answer text public
See also
$gaps

Definition at line 674 of file class.assClozeTest.php.

References CLOZE_NUMERIC.

675  {
676  if (array_key_exists($gap_index, $this->gaps))
677  {
678  if ($this->gaps[$gap_index]->getType() == CLOZE_NUMERIC)
679  {
680  // only allow notation with "." for real numbers
681  $answer = str_replace(",", ".", $answer);
682  }
683  $this->gaps[$gap_index]->addItem(new assAnswerCloze($answer, 0, $order));
684  }
685  }
Class for cloze question numeric answers.
const CLOZE_NUMERIC

◆ addGapAtIndex()

assClozeTest::addGapAtIndex (   $gap,
  $index 
)

Adds a ClozeGap object at a given index.

Parameters
object$gapThe gap object
integer$indexA nonnegative index of the n-th gap public
See also
$gaps

Definition at line 755 of file class.assClozeTest.php.

756  {
757  $this->gaps[$index] = $gap;
758  }

◆ addGapText()

assClozeTest::addGapText (   $gap_index)

Adds a new answer text value to a text gap with a given index.

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

Parameters
integer$gap_indexA nonnegative index of the n-th gap public
See also
$gaps

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

734  {
735  if (array_key_exists($gap_index, $this->gaps))
736  {
737  include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
738  $answer = new assAnswerCloze(
739  "",
740  0,
741  $this->gaps[$gap_index]->getItemCount()
742  );
743  $this->gaps[$gap_index]->addItem($answer);
744  }
745  }
Class for cloze question numeric answers.

◆ calculateReachedPoints()

assClozeTest::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 1150 of file class.assClozeTest.php.

References $data, $pass, assQuestion\$points, $result, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, ilDB\fetchAssoc(), assQuestion\getId(), getIdenticalScoring(), getMaximumGapPoints(), getNumericgapPoints(), assQuestion\getSolutionMaxPass(), and getTextgapPoints().

1151  {
1152  global $ilDB;
1153 
1154  $found_value1 = array();
1155  $found_value2 = array();
1156  $detailed = array();
1157  if (is_null($pass))
1158  {
1159  $pass = $this->getSolutionMaxPass($active_id);
1160  }
1161  $result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
1162  array(
1163  "integer",
1164  "integer",
1165  "integer"
1166  ),
1167  array(
1168  $active_id,
1169  $this->getId(),
1170  $pass
1171  )
1172  );
1173  $user_result = array();
1174  while ($data = $ilDB->fetchAssoc($result))
1175  {
1176  if (strcmp($data["value2"], "") != 0)
1177  {
1178  $user_result[$data["value1"]] = array(
1179  "gap_id" => $data["value1"],
1180  "value" => $data["value2"]
1181  );
1182  }
1183  }
1184 
1185  ksort($user_result); // this is required when identical scoring for same solutions is disabled
1186 
1187  $points = 0;
1188  $counter = 0;
1189  $solution_values_text = array(); // for identical scoring checks
1190  $solution_values_select = array(); // for identical scoring checks
1191  $solution_values_numeric = array(); // for identical scoring checks
1192  foreach ($user_result as $gap_id => $value)
1193  {
1194  if (array_key_exists($gap_id, $this->gaps))
1195  {
1196  switch ($this->gaps[$gap_id]->getType())
1197  {
1198  case CLOZE_TEXT:
1199  $gappoints = 0;
1200  for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++)
1201  {
1202  $answer = $this->gaps[$gap_id]->getItem($order);
1203  $gotpoints = $this->getTextgapPoints($answer->getAnswertext(), $value["value"], $answer->getPoints());
1204  if ($gotpoints > $gappoints) $gappoints = $gotpoints;
1205  }
1206  if (!$this->getIdenticalScoring())
1207  {
1208  // check if the same solution text was already entered
1209  if ((in_array($value["value"], $solution_values_text)) && ($gappoints > 0))
1210  {
1211  $gappoints = 0;
1212  }
1213  }
1214  $points += $gappoints;
1215  $detailed[$gap_id] = array("points" =>$gappoints, "best" => ($this->getMaximumGapPoints($gap_id) == $gappoints) ? TRUE : FALSE, "positive" => ($gappoints > 0) ? TRUE : FALSE);
1216  array_push($solution_values_text, $value["value"]);
1217  break;
1218  case CLOZE_NUMERIC:
1219  $gappoints = 0;
1220  for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++)
1221  {
1222  $answer = $this->gaps[$gap_id]->getItem($order);
1223  $gotpoints = $this->getNumericgapPoints($answer->getAnswertext(), $value["value"], $answer->getPoints(), $answer->getLowerBound(), $answer->getUpperBound());
1224  if ($gotpoints > $gappoints) $gappoints = $gotpoints;
1225  }
1226  if (!$this->getIdenticalScoring())
1227  {
1228  // check if the same solution value was already entered
1229  include_once "./Services/Math/classes/class.EvalMath.php";
1230  $eval = new EvalMath();
1231  $eval->suppress_errors = TRUE;
1232  $found_value = FALSE;
1233  foreach ($solution_values_numeric as $solval)
1234  {
1235  if ($eval->e($solval) == $eval->e($value["value"]))
1236  {
1237  $found_value = TRUE;
1238  }
1239  }
1240  if ($found_value && ($gappoints > 0))
1241  {
1242  $gappoints = 0;
1243  }
1244  }
1245  $points += $gappoints;
1246  $detailed[$gap_id] = array("points" =>$gappoints, "best" => ($this->getMaximumGapPoints($gap_id) == $gappoints) ? TRUE : FALSE, "positive" => ($gappoints > 0) ? TRUE : FALSE);
1247  array_push($solution_values_numeric, $value["value"]);
1248  break;
1249  case CLOZE_SELECT:
1250  if ($value["value"] >= 0)
1251  {
1252  for ($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++)
1253  {
1254  $answer = $this->gaps[$gap_id]->getItem($order);
1255  if ($value["value"] == $answer->getOrder())
1256  {
1257  $answerpoints = $answer->getPoints();
1258  if (!$this->getIdenticalScoring())
1259  {
1260  // check if the same solution value was already entered
1261  if ((in_array($answer->getAnswertext(), $solution_values_select)) && ($answerpoints > 0))
1262  {
1263  $answerpoints = 0;
1264  }
1265  }
1266  $points += $answerpoints;
1267  $detailed[$gap_id] = array("points" =>$answerpoints, "best" => ($this->getMaximumGapPoints($gap_id) == $answerpoints) ? TRUE : FALSE, "positive" => ($answerpoints > 0) ? TRUE : FALSE);
1268  array_push($solution_values_select, $answer->getAnswertext());
1269  }
1270  }
1271  }
1272  break;
1273  }
1274  }
1275  }
1276  if ($returndetails)
1277  {
1278  return $detailed;
1279  }
1280  else
1281  {
1282  return $points;
1283  }
1284  }
getId()
Gets the id of the assQuestion object.
getMaximumGapPoints($gap_index)
Returns the maximum points for a gap.
$result
const CLOZE_TEXT
Cloze question constants.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
getNumericgapPoints($a_original, $a_entered, $max_points, $lowerBound, $upperBound)
Returns the points for a text gap and compares the given solution with the entered solution using the...
getTextgapPoints($a_original, $a_entered, $max_points)
Returns the points for a text gap and compares the given solution with the entered solution using the...
fetchAssoc($a_set)
Fetch row as associative array from result set.
const CLOZE_SELECT
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
const CLOZE_NUMERIC
getIdenticalScoring()
Returns the identical scoring status of the question.
+ Here is the call graph for this function:

◆ cleanQuestiontext()

assClozeTest::cleanQuestiontext (   $text)

Cleans cloze question text to remove attributes or tags from older ILIAS versions.

Parameters
string$textThe cloze question text
Returns
string The cleaned cloze question text

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

Referenced by loadFromDb(), and setClozeText().

135  {
136  $text = preg_replace("/\[gap[^\]]*?\]/", "[gap]", $text);
137  $text = preg_replace("/<gap([^>]*?)>/", "[gap]", $text);
138  $text = str_replace("</gap>", "[/gap]", $text);
139  return $text;
140  }
+ Here is the caller graph for this function:

◆ clearGapAnswers()

assClozeTest::clearGapAnswers ( )

Removes all answers from the gaps.

public

See also
$gaps

Definition at line 637 of file class.assClozeTest.php.

638  {
639  foreach ($this->gaps as $gap_index => $gap)
640  {
641  $this->gaps[$gap_index]->clearItems();
642  }
643  }

◆ copyObject()

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

Copies an assClozeTest object.

public

Definition at line 909 of file class.assClozeTest.php.

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

910  {
911  if ($this->getId() <= 0)
912  {
913  // The question has not been saved. It cannot be duplicated
914  return;
915  }
916 
917  $thisId = $this->getId();
918  $thisObjId = $this->getObjId();
919 
920  $clone = $this;
921  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
923  $clone->id = -1;
924  $clone->setObjId($target_questionpool_id);
925  if ($title)
926  {
927  $clone->setTitle($title);
928  }
929  $clone->saveToDb();
930 
931  // copy question page content
932  $clone->copyPageOfQuestion($original_id);
933  // copy XHTML media objects
934  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
935 
936  $clone->onCopy($thisObjId, $thisId, $clone->getObjId(), $clone->getId());
937 
938  return $clone->getId();
939  }
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:

◆ createGapsFromQuestiontext()

assClozeTest::createGapsFromQuestiontext ( )

Create gap entries by parsing the question text.

public

See also
$gaps

Definition at line 577 of file class.assClozeTest.php.

References CLOZE_TEXT, and getClozeText().

Referenced by setClozeText().

578  {
579  include_once "./Modules/TestQuestionPool/classes/class.assClozeGap.php";
580  include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
581  $search_pattern = "|\[gap\](.*?)\[/gap\]|i";
582  preg_match_all($search_pattern, $this->getClozeText(), $found);
583  $this->gaps = array();
584  if (count($found[0]))
585  {
586  foreach ($found[1] as $gap_index => $answers)
587  {
588  // create text gaps by default
589  $gap = new assClozeGap(CLOZE_TEXT);
590  $textparams = preg_split("/(?<!\\\\),/", $answers);
591  foreach ($textparams as $key => $value)
592  {
593  $answer = new assAnswerCloze($value, 0, $key);
594  $gap->addItem($answer);
595  }
596  $this->gaps[$gap_index] = $gap;
597  }
598  }
599  }
Class for cloze question numeric answers.
const CLOZE_TEXT
Cloze question constants.
Class for cloze question gaps.
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

Definition at line 941 of file class.assClozeTest.php.

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

942  {
943  if ($this->id <= 0)
944  {
945  // The question has not been saved. It cannot be duplicated
946  return;
947  }
948 
949  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
950 
951  $sourceQuestionId = $this->id;
952  $sourceParentId = $this->getObjId();
953 
954  // duplicate the question in database
955  $clone = $this;
956  $clone->id = -1;
957 
958  $clone->setObjId($targetParentId);
959 
960  if ($targetQuestionTitle)
961  {
962  $clone->setTitle($targetQuestionTitle);
963  }
964 
965  $clone->saveToDb();
966  // copy question page content
967  $clone->copyPageOfQuestion($sourceQuestionId);
968  // copy XHTML media objects
969  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
970 
971  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
972 
973  return $clone->id;
974  }
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ deleteAnswerText()

assClozeTest::deleteAnswerText (   $gap_index,
  $answer_index 
)

Deletes the answer text of a gap with a given index and an answer with a given order.

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

Parameters
integer$gap_indexA nonnegative index of the n-th gap
integer$answer_indexThe order of the answer text public
See also
$gaps

Definition at line 1006 of file class.assClozeTest.php.

References deleteGap(), and updateClozeTextFromGaps().

1007  {
1008  if (array_key_exists($gap_index, $this->gaps))
1009  {
1010  if ($this->gaps[$gap_index]->getItemCount() == 1)
1011  {
1012  // this is the last answer text => remove the gap
1013  $this->deleteGap($gap_index);
1014  }
1015  else
1016  {
1017  // remove the answer text
1018  $this->gaps[$gap_index]->deleteItem($answer_index);
1019  $this->updateClozeTextFromGaps();
1020  }
1021  }
1022  }
deleteGap($gap_index)
Deletes a gap with a given index.
updateClozeTextFromGaps()
Updates the gap parameters in the cloze text from the form input.
+ Here is the call graph for this function:

◆ deleteGap()

assClozeTest::deleteGap (   $gap_index)

Deletes a gap with a given index.

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

Parameters
integer$gap_indexA nonnegative index of the n-th gap public
See also
$gaps

Definition at line 1032 of file class.assClozeTest.php.

References getClozeText(), and getGaps().

Referenced by deleteAnswerText().

1033  {
1034  if (array_key_exists($gap_index, $this->gaps))
1035  {
1036  $output = $this->getClozeText();
1037  foreach ($this->getGaps() as $replace_gap_index => $gap)
1038  {
1039  $answers = array();
1040  foreach ($gap->getItemsRaw() as $item)
1041  {
1042  array_push($answers, str_replace(",", "\\,", $item->getAnswerText()));
1043  }
1044  if ($replace_gap_index == $gap_index)
1045  {
1046  $output = preg_replace("/\[gap\].*?\[\/gap\]/", "", $output, 1);
1047  }
1048  else
1049  {
1050  $output = preg_replace("/\[gap\].*?\[\/gap\]/", "[_gap]" . join(",", $answers) . "[/_gap]", $output, 1);
1051  }
1052  }
1053  $output = str_replace("_gap]", "gap]", $output);
1054  $this->question = $output;
1055  unset($this->gaps[$gap_index]);
1056  $this->gaps = array_values($this->gaps);
1057  }
1058  }
getGaps()
Returns the array of gaps.
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duplicate()

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

Duplicates an assClozeTest.

public

Definition at line 852 of file class.assClozeTest.php.

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

853  {
854  if ($this->id <= 0)
855  {
856  // The question has not been saved. It cannot be duplicated
857  return;
858  }
859  // duplicate the question in database
860  $this_id = $this->getId();
861  $thisObjId = $this->getObjId();
862 
863  $clone = $this;
864  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
866  $clone->id = -1;
867 
868  if( (int)$testObjId > 0 )
869  {
870  $clone->setObjId($testObjId);
871  }
872 
873  if ($title)
874  {
875  $clone->setTitle($title);
876  }
877  if ($author)
878  {
879  $clone->setAuthor($author);
880  }
881  if ($owner)
882  {
883  $clone->setOwner($owner);
884  }
885  if ($for_test)
886  {
887  $clone->saveToDb($original_id);
888  }
889  else
890  {
891  $clone->saveToDb();
892  }
893 
894  // copy question page content
895  $clone->copyPageOfQuestion($this_id);
896  // copy XHTML media objects
897  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
898 
899  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
900 
901  return $clone->getId();
902  }
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:

◆ flushGaps()

assClozeTest::flushGaps ( )

Deletes all gaps without changing the cloze text.

public

See also
$gaps

Definition at line 489 of file class.assClozeTest.php.

490  {
491  $this->gaps = array();
492  }

◆ getAdditionalTableName()

assClozeTest::getAdditionalTableName ( )

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

Returns
string The additional table name public

Definition at line 1467 of file class.assClozeTest.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

1468  {
1469  return "qpl_qst_cloze";
1470  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assClozeTest::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name public

Definition at line 1478 of file class.assClozeTest.php.

1479  {
1480  return "qpl_a_cloze";
1481  }

◆ getClozeText()

assClozeTest::getClozeText ( )

Returns the cloze text.

Returns
string The cloze text string public
See also
$cloze_text

Definition at line 518 of file class.assClozeTest.php.

References assQuestion\$question.

Referenced by createGapsFromQuestiontext(), deleteGap(), isComplete(), and updateClozeTextFromGaps().

519  {
520  return $this->question;
521  }
+ Here is the caller graph for this function:

◆ getEndTag()

assClozeTest::getEndTag ( )

Returns the end tag of a cloze gap.

Returns
string The end tag of a cloze gap public
See also
$end_tag

Definition at line 554 of file class.assClozeTest.php.

References $end_tag.

555  {
556  return $this->end_tag;
557  }

◆ getFixedTextLength()

assClozeTest::getFixedTextLength ( )

Gets the fixed text length for all text fields in the cloze question.

Returns
integer The text field length public

Definition at line 1500 of file class.assClozeTest.php.

References $fixedTextLength.

Referenced by saveAdditionalQuestionDataToDb().

1501  {
1502  return $this->fixedTextLength;
1503  }
+ Here is the caller graph for this function:

◆ getGap()

assClozeTest::getGap (   $gap_index = 0)

Returns the gap at a given index.

Parameters
integer$gap_indexA nonnegative index of the n-th gap
Returns
object The gap of the given index public
See also
$gaps

Definition at line 695 of file class.assClozeTest.php.

Referenced by saveWorkingData().

696  {
697  if (array_key_exists($gap_index, $this->gaps))
698  {
699  return $this->gaps[$gap_index];
700  }
701  else
702  {
703  return NULL;
704  }
705  }
+ Here is the caller graph for this function:

◆ getGapCount()

assClozeTest::getGapCount ( )

Returns the number of gaps.

Returns
integer The number of gaps public
See also
$gaps

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

653  {
654  if (is_array($this->gaps))
655  {
656  return count($this->gaps);
657  }
658  else
659  {
660  return 0;
661  }
662  }

◆ getGaps()

assClozeTest::getGaps ( )

Returns the array of gaps.

Returns
array Array containing the gap objects of the cloze question gaps public

Definition at line 477 of file class.assClozeTest.php.

References $gaps.

Referenced by deleteGap(), isComplete(), setExportDetailsXLS(), toJSON(), and updateClozeTextFromGaps().

478  {
479  return $this->gaps;
480  }
+ Here is the caller graph for this function:

◆ getIdenticalScoring()

assClozeTest::getIdenticalScoring ( )

Returns the identical scoring status of the question.

Returns
boolean The identical scoring status
See also
$identical_scoring User interface

Definition at line 1444 of file class.assClozeTest.php.

Referenced by calculateReachedPoints(), and saveAdditionalQuestionDataToDb().

1445  {
1446  return ($this->identical_scoring) ? 1 : 0;
1447  }
+ Here is the caller graph for this function:

◆ getMaximumGapPoints()

assClozeTest::getMaximumGapPoints (   $gap_index)

Returns the maximum points for a gap.

Parameters
integer$gap_indexThe index of the gap
Returns
double The maximum points for the gap public
See also
$points

Definition at line 1513 of file class.assClozeTest.php.

References assQuestion\$points.

Referenced by calculateReachedPoints().

1514  {
1515  $points = 0;
1516  if (array_key_exists($gap_index, $this->gaps))
1517  {
1518  $gap =& $this->gaps[$gap_index];
1519 
1520  $gap_max_points = 0;
1521  foreach ($gap->getItems() as $answer)
1522  {
1523  if ($answer->getPoints() > $gap_max_points)
1524  {
1525  $gap_max_points = $answer->getPoints();
1526  }
1527  }
1528  $points += $gap_max_points;
1529  }
1530  return $points;
1531  }
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assClozeTest::getMaximumPoints ( )

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

public

See also
$points

Definition at line 802 of file class.assClozeTest.php.

References assQuestion\$points, CLOZE_NUMERIC, CLOZE_SELECT, and CLOZE_TEXT.

Referenced by isComplete().

803  {
804  $points = 0;
805  foreach ($this->gaps as $gap_index => $gap)
806  {
807  if ($gap->getType() == CLOZE_TEXT)
808  {
809  $gap_max_points = 0;
810  foreach ($gap->getItems() as $item)
811  {
812  if ($item->getPoints() > $gap_max_points)
813  {
814  $gap_max_points = $item->getPoints();
815  }
816  }
817  $points += $gap_max_points;
818  }
819  else if ($gap->getType() == CLOZE_SELECT)
820  {
821  $srpoints = 0;
822  foreach ($gap->getItems() as $item)
823  {
824  if ($item->getPoints() > $srpoints)
825  {
826  $srpoints = $item->getPoints();
827  }
828  }
829  $points += $srpoints;
830  }
831  else if ($gap->getType() == CLOZE_NUMERIC)
832  {
833  $numpoints = 0;
834  foreach ($gap->getItems() as $item)
835  {
836  if ($item->getPoints() > $numpoints)
837  {
838  $numpoints = $item->getPoints();
839  }
840  }
841  $points += $numpoints;
842  }
843  }
844  return $points;
845  }
const CLOZE_TEXT
Cloze question constants.
const CLOZE_SELECT
const CLOZE_NUMERIC
+ Here is the caller graph for this function:

◆ getNumericgapPoints()

assClozeTest::getNumericgapPoints (   $a_original,
  $a_entered,
  $max_points,
  $lowerBound,
  $upperBound 
)

Returns the points for a text gap and compares the given solution with the entered solution using the text gap rating options.

Parameters
string$a_originalThe original (correct) text
string$a_enteredThe text entered by the user
integer$max_pointsThe maximum number of points for the solution public

Definition at line 1110 of file class.assClozeTest.php.

References $result.

Referenced by calculateReachedPoints().

1111  {
1112  if( !is_numeric($a_entered) )
1113  {
1114  return 0;
1115  }
1116 
1117  include_once "./Services/Math/classes/class.EvalMath.php";
1118  $eval = new EvalMath();
1119  $eval->suppress_errors = TRUE;
1120  $result = 0;
1121  if (($eval->e($lowerBound) !== FALSE) && ($eval->e($upperBound) !== FALSE))
1122  {
1123  if (($eval->e($a_entered) >= $eval->e($lowerBound)) && ($eval->e($a_entered) <= $eval->e($upperBound))) $result = $max_points;
1124  }
1125  else if ($eval->e($lowerBound) !== FALSE)
1126  {
1127  if (($eval->e($a_entered) >= $eval->e($lowerBound)) && ($eval->e($a_entered) <= $eval->e($a_original))) $result = $max_points;
1128  }
1129  else if ($eval->e($upperBound) !== FALSE)
1130  {
1131  if (($eval->e($a_entered) >= $eval->e($a_original)) && ($eval->e($a_entered) <= $eval->e($upperBound))) $result = $max_points;
1132  }
1133  else
1134  {
1135  if ($eval->e($a_entered) == $eval->e($a_original)) $result = $max_points;
1136  }
1137  return $result;
1138  }
$result
+ Here is the caller graph for this function:

◆ getQuestionType()

assClozeTest::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

Definition at line 1394 of file class.assClozeTest.php.

Referenced by toJSON().

1395  {
1396  return "assClozeTest";
1397  }
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assClozeTest::getRTETextWithMediaObjects ( )

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

Definition at line 1537 of file class.assClozeTest.php.

1538  {
1539  return parent::getRTETextWithMediaObjects();
1540  }

◆ getStartTag()

assClozeTest::getStartTag ( )

Returns the start tag of a cloze gap.

Returns
string The start tag of a cloze gap public
See also
$start_tag

Definition at line 530 of file class.assClozeTest.php.

References $start_tag.

531  {
532  return $this->start_tag;
533  }

◆ getTextgapPoints()

assClozeTest::getTextgapPoints (   $a_original,
  $a_entered,
  $max_points 
)

Returns the points for a text gap and compares the given solution with the entered solution using the text gap rating options.

Parameters
string$a_originalThe original (correct) text
string$a_enteredThe text entered by the user
integer$max_pointsThe maximum number of points for the solution public

Definition at line 1069 of file class.assClozeTest.php.

References $result, getTextgapRating(), ilStr\strToLower(), TEXTGAP_RATING_CASEINSENSITIVE, TEXTGAP_RATING_CASESENSITIVE, TEXTGAP_RATING_LEVENSHTEIN1, TEXTGAP_RATING_LEVENSHTEIN2, TEXTGAP_RATING_LEVENSHTEIN3, TEXTGAP_RATING_LEVENSHTEIN4, and TEXTGAP_RATING_LEVENSHTEIN5.

Referenced by calculateReachedPoints().

1070  {
1071  include_once "./Services/Utilities/classes/class.ilStr.php";
1072  $result = 0;
1073  $gaprating = $this->getTextgapRating();
1074  switch ($gaprating)
1075  {
1077  if (strcmp(ilStr::strToLower($a_original), ilStr::strToLower($a_entered)) == 0) $result = $max_points;
1078  break;
1080  if (strcmp($a_original, $a_entered) == 0) $result = $max_points;
1081  break;
1083  if (levenshtein($a_original, $a_entered) <= 1) $result = $max_points;
1084  break;
1086  if (levenshtein($a_original, $a_entered) <= 2) $result = $max_points;
1087  break;
1089  if (levenshtein($a_original, $a_entered) <= 3) $result = $max_points;
1090  break;
1092  if (levenshtein($a_original, $a_entered) <= 4) $result = $max_points;
1093  break;
1095  if (levenshtein($a_original, $a_entered) <= 5) $result = $max_points;
1096  break;
1097  }
1098  return $result;
1099  }
const TEXTGAP_RATING_LEVENSHTEIN5
$result
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
getTextgapRating()
Returns the rating option for text gaps.
static strToLower($a_string)
Definition: class.ilStr.php:91
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_CASEINSENSITIVE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextgapRating()

assClozeTest::getTextgapRating ( )

Returns the rating option for text gaps.

Returns
string The rating option for text gaps
See also
$textgap_rating User interface

Definition at line 1406 of file class.assClozeTest.php.

References $textgap_rating.

Referenced by getTextgapPoints(), and saveAdditionalQuestionDataToDb().

1407  {
1408  return $this->textgap_rating;
1409  }
+ Here is the caller graph for this function:

◆ isComplete()

assClozeTest::isComplete ( )

Returns TRUE, if a cloze test is complete for use.

Returns
boolean TRUE, if the cloze test is complete for use, otherwise FALSE

Definition at line 114 of file class.assClozeTest.php.

References assQuestion\getAuthor(), getClozeText(), getGaps(), getMaximumPoints(), and assQuestion\getTitle().

115  {
116  if (strlen($this->getTitle())
117  && $this->getAuthor()
118  && $this->getClozeText()
119  && count($this->getGaps())
120  && $this->getMaximumPoints() > 0)
121  {
122  return true;
123  }
124  return false;
125  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
getGaps()
Returns the array of gaps.
getAuthor()
Gets the authors name of the assQuestion object.
getClozeText()
Returns the cloze text.
getTitle()
Gets the title string of the assQuestion object.
+ Here is the call graph for this function:

◆ loadFromDb()

assClozeTest::loadFromDb (   $question_id)

Loads a assClozeTest object from a database.

Parameters
integer$question_idA unique key which defines the cloze test in the database

Definition at line 148 of file class.assClozeTest.php.

References $data, $result, ilRTE\_replaceMediaObjectImageSrc(), cleanQuestiontext(), CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, ilDB\fetchAssoc(), getAdditionalTableName(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setEstimatedWorkingTime(), setFixedTextLength(), assQuestion\setId(), setIdenticalScoring(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), setTextgapRating(), and assQuestion\setTitle().

149  {
150  global $ilDB;
151  $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",
152  array("integer"),
153  array($question_id)
154  );
155  if ($result->numRows() == 1)
156  {
157  $data = $ilDB->fetchAssoc($result);
158  $this->setId($question_id);
159  $this->setNrOfTries($data['nr_of_tries']);
160  $this->setObjId($data["obj_fi"]);
161  $this->setTitle($data["title"]);
162  $this->setComment($data["description"]);
163  $this->setOriginalId($data["original_id"]);
164  $this->setAuthor($data["author"]);
165  $this->setPoints($data["points"]);
166  $this->setOwner($data["owner"]);
167  $this->setQuestion($this->cleanQuestiontext($data["question_text"]));
168  $this->setFixedTextLength($data["fixed_textlen"]);
169  $this->setIdenticalScoring(($data['tstamp'] == 0) ? true : $data["identical_scoring"]);
170  // replacement of old syntax with new syntax
171  include_once("./Services/RTE/classes/class.ilRTE.php");
172  $this->question = ilRTE::_replaceMediaObjectImageSrc($this->question, 1);
173  $this->setTextgapRating($data["textgap_rating"]);
174  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
175 
176  try
177  {
178  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
179  }
181  {
182  }
183 
184  // open the cloze gaps with all answers
185  include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
186  include_once "./Modules/TestQuestionPool/classes/class.assClozeGap.php";
187  $result = $ilDB->queryF("SELECT * FROM qpl_a_cloze WHERE question_fi = %s ORDER BY gap_id, aorder ASC",
188  array("integer"),
189  array($question_id)
190  );
191  if ($result->numRows() > 0)
192  {
193  $this->gaps = array();
194  while ($data = $ilDB->fetchAssoc($result))
195  {
196  switch ($data["cloze_type"])
197  {
198  case CLOZE_TEXT:
199  if (!array_key_exists($data["gap_id"], $this->gaps))
200  {
201  $this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_TEXT);
202  }
203  $answer = new assAnswerCloze(
204  $data["answertext"],
205  $data["points"],
206  $data["aorder"]
207  );
208  $this->gaps[$data["gap_id"]]->addItem($answer);
209  break;
210  case CLOZE_SELECT:
211  if (!array_key_exists($data["gap_id"], $this->gaps))
212  {
213  $this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_SELECT);
214  $this->gaps[$data["gap_id"]]->setShuffle($data["shuffle"]);
215  }
216  $answer = new assAnswerCloze(
217  $data["answertext"],
218  $data["points"],
219  $data["aorder"]
220  );
221  $this->gaps[$data["gap_id"]]->addItem($answer);
222  break;
223  case CLOZE_NUMERIC:
224  if (!array_key_exists($data["gap_id"], $this->gaps))
225  {
226  $this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_NUMERIC);
227  }
228  $answer = new assAnswerCloze(
229  $data["answertext"],
230  $data["points"],
231  $data["aorder"]
232  );
233  $answer->setLowerBound($data["lowerlimit"]);
234  $answer->setUpperBound($data["upperlimit"]);
235  $this->gaps[$data["gap_id"]]->addItem($answer);
236  break;
237  }
238  }
239  }
240  }
241  parent::loadFromDb($question_id);
242  }
Class for cloze question numeric answers.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
$result
const CLOZE_TEXT
Cloze question constants.
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.
Class for cloze question gaps.
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.
const CLOZE_SELECT
setFixedTextLength($a_text_len)
Sets a fixed text length for all text fields in the cloze question.
cleanQuestiontext($text)
Cleans cloze question text to remove attributes or tags from older ILIAS versions.
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
setTextgapRating($a_textgap_rating)
Sets the rating option for text gaps.
setQuestion($question="")
Sets the question string of the question object.
setOriginalId($original_id)
const CLOZE_NUMERIC
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setIdenticalScoring($a_identical_scoring)
Sets the identical scoring option for cloze questions.
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:

◆ reworkWorkingData()

assClozeTest::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 1383 of file class.assClozeTest.php.

1384  {
1385  // nothing to rework!
1386  }

◆ saveAdditionalQuestionDataToDb()

assClozeTest::saveAdditionalQuestionDataToDb ( )

Saves the data for the additional data table.

This method uses the ugly DELETE-INSERT. Here, this does no harm.

Implements ilObjQuestionScoringAdjustable.

Definition at line 287 of file class.assClozeTest.php.

References getAdditionalTableName(), getFixedTextLength(), assQuestion\getId(), getIdenticalScoring(), and getTextgapRating().

Referenced by saveToDb().

288  {
289  global $ilDB;
290 
291  $ilDB->manipulateF( "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
292  array( "integer" ),
293  array( $this->getId() )
294  );
295 
296  $ilDB->manipulateF( "INSERT INTO " . $this->getAdditionalTableName()
297  . " (question_fi, textgap_rating, identical_scoring, fixed_textlen) VALUES (%s, %s, %s, %s)",
298  array(
299  "integer",
300  "text",
301  "text",
302  "integer"
303  ),
304  array(
305  $this->getId(),
306  $this->getTextgapRating(),
307  $this->getIdenticalScoring(),
308  $this->getFixedTextLength() ? $this->getFixedTextLength() : NULL
309  )
310  );
311  }
getId()
Gets the id of the assQuestion object.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getTextgapRating()
Returns the rating option for text gaps.
getFixedTextLength()
Gets the fixed text length for all text fields in the cloze question.
getIdenticalScoring()
Returns the identical scoring status of the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAnswerSpecificDataToDb()

assClozeTest::saveAnswerSpecificDataToDb ( )

Save all gaps to the database.

Implements ilObjAnswerScoringAdjustable.

Definition at line 267 of file class.assClozeTest.php.

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

Referenced by saveToDb().

268  {
269  global $ilDB;
270 
271  $ilDB->manipulateF( "DELETE FROM qpl_a_cloze WHERE question_fi = %s",
272  array( "integer" ),
273  array( $this->getId() )
274  );
275 
276  foreach ($this->gaps as $key => $gap)
277  {
278  $this->saveClozeGapItemsToDb( $gap, $key );
279  }
280  }
getId()
Gets the id of the assQuestion object.
saveClozeGapItemsToDb($gap, $key)
Save all items belonging to one cloze gap to the db.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeGapItemsToDb()

assClozeTest::saveClozeGapItemsToDb (   $gap,
  $key 
)
protected

Save all items belonging to one cloze gap to the db.

Parameters
$gap
$key

Definition at line 319 of file class.assClozeTest.php.

References $query, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, saveClozeNumericGapRecordToDb(), saveClozeSelectGapRecordToDb(), and saveClozeTextGapRecordToDb().

Referenced by saveAnswerSpecificDataToDb().

320  {
321  global $ilDB;
322  foreach ($gap->getItems() as $item)
323  {
324  $query = "";
325  $next_id = $ilDB->nextId( 'qpl_a_cloze' );
326  switch ($gap->getType())
327  {
328  case CLOZE_TEXT:
329  $this->saveClozeTextGapRecordToDb($next_id, $key, $item, $gap );
330  break;
331  case CLOZE_SELECT:
332  $this->saveClozeSelectGapRecordToDb($next_id, $key, $item, $gap );
333  break;
334  case CLOZE_NUMERIC:
335  $this->saveClozeNumericGapRecordToDb($next_id, $key, $item, $gap );
336  break;
337  }
338  }
339  }
const CLOZE_TEXT
Cloze question constants.
const CLOZE_SELECT
saveClozeTextGapRecordToDb($next_id, $key, $item, $gap)
Saves a gap-item record.
saveClozeNumericGapRecordToDb($next_id, $key, $item, $gap)
Saves a gap-item record.
saveClozeSelectGapRecordToDb($next_id, $key, $item, $gap)
Saves a gap-item record.
const CLOZE_NUMERIC
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeNumericGapRecordToDb()

assClozeTest::saveClozeNumericGapRecordToDb (   $next_id,
  $key,
  $item,
  $gap 
)
protected

Saves a gap-item record.

Parameters
$next_idint Next Id for the record.
$keyint Gap Id
$itemgap Gap item data object.
$gapgap Gap data object.

Definition at line 417 of file class.assClozeTest.php.

References assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

418  {
419  global $ilDB;
420 
421  include_once "./Services/Math/classes/class.EvalMath.php";
422  $eval = new EvalMath();
423  $eval->suppress_errors = TRUE;
424 
425  // Bugfix for mantis: 14034
426  // It is a numeric gap, so cast to integer! // BH we should cast to float ;)
427  $answerText = strlen($item->getAnswertext()) ? (float)$item->getAnswertext() : 0;
428 
429  $lowerBound = (
430  $eval->e( $item->getLowerBound() !== FALSE ) && strlen( $item->getLowerBound() ) ?
431  $item->getLowerBound() : $item->getAnswertext()
432  );
433 
434  $upperBound = (
435  $eval->e( $item->getUpperBound() !== FALSE ) && strlen( $item->getUpperBound() ) ?
436  $item->getUpperBound() : $item->getAnswertext()
437  );
438 
439  //vd($answerText, $lowerBound, $upperBound);
440 
441  $ilDB->manipulateF( "INSERT INTO qpl_a_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type, lowerlimit, upperlimit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
442  array(
443  "integer",
444  "integer",
445  "integer",
446  "text",
447  "float",
448  "integer",
449  "text",
450  "text",
451  "text"
452  ),
453  array(
454  $next_id,
455  $this->getId(),
456  $key,
457  $answerText,
458  $item->getPoints(),
459  $item->getOrder(),
460  $gap->getType(),
461  $lowerBound,
462  $upperBound
463  )
464  );
465  }
getId()
Gets the id of the assQuestion object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeSelectGapRecordToDb()

assClozeTest::saveClozeSelectGapRecordToDb (   $next_id,
  $key,
  $item,
  $gap 
)
protected

Saves a gap-item record.

Parameters
$next_idint Next Id for the record.
$keyint Gap Id
$itemgap Gap item data object.
$gapgap Gap data object.

Definition at line 382 of file class.assClozeTest.php.

References assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

383  {
384  global $ilDB;
385  $ilDB->manipulateF( "INSERT INTO qpl_a_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type, shuffle) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
386  array(
387  "integer",
388  "integer",
389  "integer",
390  "text",
391  "float",
392  "integer",
393  "text",
394  "text"
395  ),
396  array(
397  $next_id,
398  $this->getId(),
399  $key,
400  strlen( $item->getAnswertext() ) ? $item->getAnswertext() : "",
401  $item->getPoints(),
402  $item->getOrder(),
403  $gap->getType(),
404  ($gap->getShuffle()) ? "1" : "0"
405  )
406  );
407  }
getId()
Gets the id of the assQuestion object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClozeTextGapRecordToDb()

assClozeTest::saveClozeTextGapRecordToDb (   $next_id,
  $key,
  $item,
  $gap 
)
protected

Saves a gap-item record.

Parameters
$next_idint Next Id for the record.
$keyint Gap Id
$itemgap Gap item data object.
$gapgap Gap data object.

Definition at line 349 of file class.assClozeTest.php.

References assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

350  {
351  global $ilDB;
352  $ilDB->manipulateF( "INSERT INTO qpl_a_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type) VALUES (%s, %s, %s, %s, %s, %s, %s)",
353  array(
354  "integer",
355  "integer",
356  "integer",
357  "text",
358  "float",
359  "integer",
360  "text"
361  ),
362  array(
363  $next_id,
364  $this->getId(),
365  $key,
366  strlen( $item->getAnswertext() ) ? $item->getAnswertext() : "",
367  $item->getPoints(),
368  $item->getOrder(),
369  $gap->getType()
370  )
371  );
372  }
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()

assClozeTest::saveToDb (   $original_id = "")

Saves a assClozeTest object to a database.

Parameters
int | string$original_idID of the original question
Returns
mixed|void

public

Definition at line 255 of file class.assClozeTest.php.

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

256  {
260 
261  parent::saveToDb($original_id);
262  }
saveAnswerSpecificDataToDb()
Save all gaps to the database.
saveAdditionalQuestionDataToDb()
Saves the data for the additional data table.
saveQuestionDataToDb($original_id="")
+ Here is the call graph for this function:

◆ saveWorkingData()

assClozeTest::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 1294 of file class.assClozeTest.php.

References $_POST, $ilUser, $pass, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), CLOZE_NUMERIC, CLOZE_SELECT, getGap(), assQuestion\getId(), assQuestion\getProcessLocker(), assQuestion\logAction(), and ilUtil\stripSlashes().

1295  {
1296  global $ilDB;
1297  global $ilUser;
1298  if (is_null($pass))
1299  {
1300  include_once "./Modules/Test/classes/class.ilObjTest.php";
1301  $pass = ilObjTest::_getPass($active_id);
1302  }
1303 
1304  $this->getProcessLocker()->requestUserSolutionUpdateLock();
1305 
1306  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
1307  array(
1308  "integer",
1309  "integer",
1310  "integer"
1311  ),
1312  array(
1313  $active_id,
1314  $this->getId(),
1315  $pass
1316  )
1317  );
1318 
1319  $entered_values = 0;
1320  foreach ($_POST as $key => $value)
1321  {
1322  if (preg_match("/^gap_(\d+)/", $key, $matches))
1323  {
1324  $value = ilUtil::stripSlashes($value, FALSE);
1325  if (strlen($value))
1326  {
1327  $gap = $this->getGap($matches[1]);
1328  if (is_object($gap))
1329  {
1330  if (!(($gap->getType() == CLOZE_SELECT) && ($value == -1)))
1331  {
1332  if ($gap->getType() == CLOZE_NUMERIC)
1333  {
1334  $value = str_replace(",", ".", $value);
1335  }
1336  $next_id = $ilDB->nextId("tst_solutions");
1337  $affectedRows = $ilDB->insert("tst_solutions", array(
1338  "solution_id" => array("integer", $next_id),
1339  "active_fi" => array("integer", $active_id),
1340  "question_fi" => array("integer", $this->getId()),
1341  "value1" => array("clob", trim($matches[1])),
1342  "value2" => array("clob", trim($value)),
1343  "pass" => array("integer", $pass),
1344  "tstamp" => array("integer", time())
1345  ));
1346  $entered_values++;
1347  }
1348  }
1349  }
1350  }
1351  }
1352 
1353  $this->getProcessLocker()->releaseUserSolutionUpdateLock();
1354 
1355  if ($entered_values)
1356  {
1357  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1359  {
1360  $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1361  }
1362  }
1363  else
1364  {
1365  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1367  {
1368  $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1369  }
1370  }
1371 
1372  return TRUE;
1373  }
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.
getGap($gap_index=0)
Returns the gap at a given index.
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
const CLOZE_SELECT
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
_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.
const CLOZE_NUMERIC
+ Here is the call graph for this function:

◆ setClozeText()

assClozeTest::setClozeText (   $cloze_text = "")

Evaluates the text gap solutions from the cloze text.

A single or multiple text gap solutions could be entered using the following syntax in the cloze text: solution1 [, solution2, ..., solutionN] enclosed in the text gap selector gap[]

Parameters
string$cloze_textThe cloze text with all gaps and gap gaps public
See also
$cloze_text

Definition at line 503 of file class.assClozeTest.php.

References cleanQuestiontext(), and createGapsFromQuestiontext().

Referenced by __construct().

504  {
505  $this->gaps = array();
506  $cloze_text = $this->cleanQuestiontext($cloze_text);
507  $this->question = $cloze_text;
509  }
createGapsFromQuestiontext()
Create gap entries by parsing the question text.
cleanQuestiontext($text)
Cleans cloze question text to remove attributes or tags from older ILIAS versions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setEndTag()

assClozeTest::setEndTag (   $end_tag = "[/gap]")

Sets the end tag of a cloze gap.

Parameters
string$end_tagThe end tag for a cloze gap public
See also
$end_tag

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

References $end_tag.

567  {
568  $this->end_tag = $end_tag;
569  }

◆ setExportDetailsXLS()

assClozeTest::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 1554 of file class.assClozeTest.php.

References $pass, ilExcelUtils\_convert_text(), CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, getGaps(), assQuestion\getSolutionValues(), and assQuestion\getTitle().

1555  {
1556  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
1557  $solution = $this->getSolutionValues($active_id, $pass);
1558  $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
1559  $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
1560  $i = 1;
1561  foreach ($this->getGaps() as $gap_index => $gap)
1562  {
1563  $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($this->lng->txt("gap") . " $i"), $format_bold);
1564  $checked = FALSE;
1565  foreach ($solution as $solutionvalue)
1566  {
1567  if ($gap_index == $solutionvalue["value1"])
1568  {
1569  switch ($gap->getType())
1570  {
1571  case CLOZE_SELECT:
1572  $worksheet->writeString($startrow + $i, 1, $gap->getItem($solutionvalue["value2"])->getAnswertext());
1573  break;
1574  case CLOZE_NUMERIC:
1575  case CLOZE_TEXT:
1576  $worksheet->writeString($startrow + $i, 1, $solutionvalue["value2"]);
1577  break;
1578  }
1579  }
1580  }
1581  $i++;
1582  }
1583  return $startrow + $i + 1;
1584  }
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
const CLOZE_TEXT
Cloze question constants.
_convert_text($a_text, $a_target="has been removed")
getGaps()
Returns the array of gaps.
const CLOZE_SELECT
getTitle()
Gets the title string of the assQuestion object.
const CLOZE_NUMERIC
+ Here is the call graph for this function:

◆ setFixedTextLength()

assClozeTest::setFixedTextLength (   $a_text_len)

Sets a fixed text length for all text fields in the cloze question.

Parameters
integer$a_text_lenThe text field length public

Definition at line 1489 of file class.assClozeTest.php.

Referenced by loadFromDb().

1490  {
1491  $this->fixedTextLength = $a_text_len;
1492  }
+ Here is the caller graph for this function:

◆ setGapAnswerLowerBound()

assClozeTest::setGapAnswerLowerBound (   $gap_index,
  $order,
  $bound 
)

Sets the lower bound of a gap with a given index and an answer with a given order.

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

Parameters
integer$gap_indexA nonnegative index of the n-th gap
integer$orderThe order of the answer text
string$answerThe lower bound of the answer public
See also
$gaps

Definition at line 770 of file class.assClozeTest.php.

771  {
772  if (array_key_exists($gap_index, $this->gaps))
773  {
774  $this->gaps[$gap_index]->setItemLowerBound($order, $bound);
775  }
776  }

◆ setGapAnswerPoints()

assClozeTest::setGapAnswerPoints (   $gap_index,
  $order,
  $points 
)

Sets the points of a gap with a given index and an answer with a given order.

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

Parameters
integer$gap_indexA nonnegative index of the n-th gap
integer$orderThe order of the answer text
string$answerThe points of the answer public
See also
$gaps

Definition at line 717 of file class.assClozeTest.php.

References assQuestion\$points.

718  {
719  if (array_key_exists($gap_index, $this->gaps))
720  {
721  $this->gaps[$gap_index]->setItemPoints($order, $points);
722  }
723  }

◆ setGapAnswerUpperBound()

assClozeTest::setGapAnswerUpperBound (   $gap_index,
  $order,
  $bound 
)

Sets the upper bound of a gap with a given index and an answer with a given order.

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

Parameters
integer$gap_indexA nonnegative index of the n-th gap
integer$orderThe order of the answer text
string$answerThe upper bound of the answer public
See also
$gaps

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

789  {
790  if (array_key_exists($gap_index, $this->gaps))
791  {
792  $this->gaps[$gap_index]->setItemUpperBound($order, $bound);
793  }
794  }

◆ setGapShuffle()

assClozeTest::setGapShuffle (   $gap_index = 0,
  $shuffle = 1 
)

Sets the shuffle state of a gap with a given index.

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

Parameters
integer$indexA nonnegative index of the n-th gap
integer$shuffleTurn shuffle on (=1) or off (=0) public
See also
$gaps

Definition at line 623 of file class.assClozeTest.php.

References assQuestion\$shuffle.

624  {
625  if (array_key_exists($gap_index, $this->gaps))
626  {
627  $this->gaps[$gap_index]->setShuffle($shuffle);
628  }
629  }

◆ setGapType()

assClozeTest::setGapType (   $gap_index,
  $gap_type 
)

Set the type of a gap with a given index.

private

Definition at line 606 of file class.assClozeTest.php.

607  {
608  if (array_key_exists($gap_index, $this->gaps))
609  {
610  $this->gaps[$gap_index]->setType($gap_type);
611  }
612  }

◆ setIdenticalScoring()

assClozeTest::setIdenticalScoring (   $a_identical_scoring)

Sets the identical scoring option for cloze questions.

Parameters
boolean$a_identical_scoringThe identical scoring option for cloze questions
See also
$identical_scoring User interface

Definition at line 1456 of file class.assClozeTest.php.

Referenced by loadFromDb().

1457  {
1458  $this->identical_scoring = ($a_identical_scoring) ? 1 : 0;
1459  }
+ Here is the caller graph for this function:

◆ setStartTag()

assClozeTest::setStartTag (   $start_tag = "[gap]")

Sets the start tag of a cloze gap.

Parameters
string$start_tagThe start tag for a cloze gap public
See also
$start_tag

Definition at line 542 of file class.assClozeTest.php.

References $start_tag.

543  {
544  $this->start_tag = $start_tag;
545  }

◆ setTextgapRating()

assClozeTest::setTextgapRating (   $a_textgap_rating)

Sets the rating option for text gaps.

Parameters
string$a_textgap_ratingThe rating option for text gaps
See also
$textgap_rating User interface

Definition at line 1418 of file class.assClozeTest.php.

References TEXTGAP_RATING_CASEINSENSITIVE, TEXTGAP_RATING_CASESENSITIVE, TEXTGAP_RATING_LEVENSHTEIN1, TEXTGAP_RATING_LEVENSHTEIN2, TEXTGAP_RATING_LEVENSHTEIN3, TEXTGAP_RATING_LEVENSHTEIN4, and TEXTGAP_RATING_LEVENSHTEIN5.

Referenced by loadFromDb().

1419  {
1420  switch ($a_textgap_rating)
1421  {
1429  $this->textgap_rating = $a_textgap_rating;
1430  break;
1431  default:
1432  $this->textgap_rating = TEXTGAP_RATING_CASEINSENSITIVE;
1433  break;
1434  }
1435  }
const TEXTGAP_RATING_LEVENSHTEIN5
const TEXTGAP_RATING_LEVENSHTEIN2
const TEXTGAP_RATING_LEVENSHTEIN1
const TEXTGAP_RATING_LEVENSHTEIN3
const TEXTGAP_RATING_CASESENSITIVE
const TEXTGAP_RATING_LEVENSHTEIN4
const TEXTGAP_RATING_CASEINSENSITIVE
+ Here is the caller graph for this function:

◆ toJSON()

assClozeTest::toJSON ( )

Returns a JSON representation of the question.

Definition at line 1589 of file class.assClozeTest.php.

References $gaps, $mobs, $result, ilObjMediaObject\_getMobsOfObject(), CLOZE_NUMERIC, assQuestion\formatSAQuestion(), getGaps(), assQuestion\getId(), assQuestion\getNrOfTries(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getShuffle(), and assQuestion\getTitle().

1590  {
1591  include_once("./Services/RTE/classes/class.ilRTE.php");
1592  $result = array();
1593  $result['id'] = (int) $this->getId();
1594  $result['type'] = (string) $this->getQuestionType();
1595  $result['title'] = (string) $this->getTitle();
1596  $result['question'] = $this->formatSAQuestion($this->getQuestion());
1597  $result['nr_of_tries'] = (int) $this->getNrOfTries();
1598  $result['shuffle'] = (bool) $this->getShuffle();
1599  $result['feedback'] = array(
1600  "onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false),
1601  "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)
1602  );
1603  $gaps = array();
1604  foreach ($this->getGaps() as $key => $gap)
1605  {
1606  $items = array();
1607  foreach ($gap->getItems() as $item)
1608  {
1609  $jitem = array();
1610  $jitem['points'] = $item->getPoints();
1611  $jitem['value'] = $this->formatSAQuestion($item->getAnswertext());
1612  $jitem['order'] = $item->getOrder();
1613  if ($gap->getType() == CLOZE_NUMERIC)
1614  {
1615  $jitem['lowerbound'] = $item->getLowerBound();
1616  $jitem['upperbound'] = $item->getUpperBound();
1617  }
1618  else
1619  {
1620  $jitem['value'] = trim($jitem['value']);
1621  }
1622  array_push($items, $jitem);
1623  }
1624  $jgap['shuffle'] = $gap->getShuffle();
1625  $jgap['type'] = $gap->getType();
1626  $jgap['item'] = $items;
1627  array_push($gaps, $jgap);
1628 
1629  }
1630  $result['gaps'] = $gaps;
1631  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1632  $result['mobs'] = $mobs;
1633  return json_encode($result);
1634  }
getId()
Gets the id of the assQuestion object.
formatSAQuestion($a_q)
Format self assessment question.
getQuestionType()
Returns the question type of the question.
$result
getShuffle()
Gets the shuffle flag.
$mobs
getGaps()
Returns the array of gaps.
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
getTitle()
Gets the title string of the assQuestion object.
const CLOZE_NUMERIC
+ Here is the call graph for this function:

◆ updateClozeTextFromGaps()

assClozeTest::updateClozeTextFromGaps ( )

Updates the gap parameters in the cloze text from the form input.

private

Definition at line 981 of file class.assClozeTest.php.

References getClozeText(), getGaps(), and assQuestion\prepareTextareaOutput().

Referenced by deleteAnswerText().

982  {
983  $output = $this->getClozeText();
984  foreach ($this->getGaps() as $gap_index => $gap)
985  {
986  $answers = array();
987  foreach ($gap->getItemsRaw() as $item)
988  {
989  array_push($answers, str_replace(",", "\\,", $item->getAnswerText()));
990  }
991  $output = preg_replace("/\[gap\].*?\[\/gap\]/", "[_gap]" . $this->prepareTextareaOutput(join(",", $answers), true) . "[/_gap]", $output, 1);
992  }
993  $output = str_replace("_gap]", "gap]", $output);
994  $this->question = $output;
995  }
getGaps()
Returns the array of gaps.
prepareTextareaOutput($txt_output, $prepare_for_latex_output=FALSE)
Prepares a string for a text area output in tests.
getClozeText()
Returns the cloze text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $end_tag

assClozeTest::$end_tag

Definition at line 47 of file class.assClozeTest.php.

Referenced by getEndTag(), and setEndTag().

◆ $fixedTextLength

assClozeTest::$fixedTextLength

Definition at line 77 of file class.assClozeTest.php.

Referenced by getFixedTextLength().

◆ $gaps

assClozeTest::$gaps

Definition at line 29 of file class.assClozeTest.php.

Referenced by getGaps(), and toJSON().

◆ $identical_scoring

assClozeTest::$identical_scoring

Definition at line 70 of file class.assClozeTest.php.

◆ $start_tag

assClozeTest::$start_tag

Definition at line 38 of file class.assClozeTest.php.

Referenced by getStartTag(), and setStartTag().

◆ $textgap_rating

assClozeTest::$textgap_rating

Definition at line 59 of file class.assClozeTest.php.

Referenced by getTextgapRating().


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