ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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
 isComplete ()
 Returns TRUE, if a cloze test is complete for use.
 cleanQuestiontext ($text)
 Cleans cloze question text to remove attributes or tags from older ILIAS versions.
 loadFromDb ($question_id)
 Loads a assClozeTest object from a database.
 saveToDb ($original_id="")
 Saves a assClozeTest object to a database.
 saveAnswerSpecificDataToDb ()
 Save all gaps to the database.
 saveAdditionalQuestionDataToDb ()
 Saves the data for the additional data table.
 getGaps ()
 Returns the array of gaps.
 flushGaps ()
 Deletes all gaps without changing the cloze text.
 setClozeText ($cloze_text="")
 Evaluates the text gap solutions from the cloze text.
 setClozeTextValue ($cloze_text="")
 getClozeText ()
 Returns the cloze text.
 getStartTag ()
 Returns the start tag of a cloze gap.
 setStartTag ($start_tag="[gap]")
 Sets the start tag of a cloze gap.
 getEndTag ()
 Returns the end tag of a cloze gap.
 setEndTag ($end_tag="[/gap]")
 Sets the end tag of a cloze gap.
 createGapsFromQuestiontext ()
 Create gap entries by parsing the question text.
 setGapType ($gap_index, $gap_type)
 Set the type of a gap with a given index.
 setGapShuffle ($gap_index=0, $shuffle=1)
 Sets the shuffle state of a gap with a given index.
 clearGapAnswers ()
 Removes all answers from the gaps.
 getGapCount ()
 Returns the number of gaps.
 addGapAnswer ($gap_index, $order, $answer)
 Sets the answer text of a gap with a given index.
 getGap ($gap_index=0)
 Returns the gap at a given index.
 setGapSize ($gap_index, $order, $size)
 setGapAnswerPoints ($gap_index, $order, $points)
 Sets the points of a gap with a given index and an answer with a given order.
 addGapText ($gap_index)
 Adds a new answer text value to a text gap with a given index.
 addGapAtIndex ($gap, $index)
 Adds a ClozeGap object at a given index.
 setGapAnswerLowerBound ($gap_index, $order, $bound)
 Sets the lower bound of a gap with a given index and an answer with a given order.
 setGapAnswerUpperBound ($gap_index, $order, $bound)
 Sets the upper bound of a gap with a given index and an answer with a given order.
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question.
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates an assClozeTest.
 copyObject ($target_questionpool_id, $title="")
 Copies an assClozeTest object.
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 copyGapCombination ($orgID, $newID)
 updateClozeTextFromGaps ()
 Updates the gap parameters in the cloze text from the form input.
 deleteAnswerText ($gap_index, $answer_index)
 Deletes the answer text of a gap with a given index and an answer with a given order.
 deleteGap ($gap_index)
 Deletes a gap with a given index.
 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.
 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.
 checkForValidFormula ($value)
 calculateReachedPoints ($active_id, $pass=NULL, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question.
 getSolutionSubmit ()
 saveWorkingData ($active_id, $pass=NULL)
 Saves the learners input of the question to the database.
 getQuestionType ()
 Returns the question type of the question.
 getTextgapRating ()
 Returns the rating option for text gaps.
 setTextgapRating ($a_textgap_rating)
 Sets the rating option for text gaps.
 getIdenticalScoring ()
 Returns the identical scoring status of the question.
 setIdenticalScoring ($a_identical_scoring)
 Sets the identical scoring option for cloze questions.
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database.
 getAnswerTableName ()
 Returns the name of the answer table in the database.
 setFixedTextLength ($a_text_len)
 Sets a fixed text length for all text fields in the cloze question.
 getFixedTextLength ()
 Gets the fixed text length for all text fields in the cloze question.
 getMaximumGapPoints ($gap_index)
 Returns the maximum points for a gap.
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor.
 getGapCombinationsExists ()
 getGapCombinations ()
 setGapCombinationsExists ($value)
 setGapCombinations ($value)
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question.
 toJSON ()
 Returns a JSON representation of the question.
 getOperators ($expression)
 Get all available operations for a specific question.
 getExpressionTypes ()
 Get all available expression types for a specific question.
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option.
 calculateCombinationResult ($user_result)
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
- Public Member Functions inherited from assQuestion
 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.
 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.
 questionTitleExists ($questionpool_id, $title)
 Returns TRUE if the question title exists in the database.
 setTitle ($title="")
 Sets the title string of the assQuestion object.
 setId ($id=-1)
 Sets the id of the assQuestion object.
 setTestId ($id=-1)
 Sets the test id of the assQuestion object.
 setComment ($comment="")
 Sets the comment string of the assQuestion object.
 setOutputType ($outputType=OUTPUT_HTML)
 Sets the output type.
 setShuffle ($shuffle=true)
 Sets the shuffle flag.
 setEstimatedWorkingTime ($hour=0, $min=0, $sec=0)
 Sets the estimated working time of a question from given hour, minute and second.
 setEstimatedWorkingTimeFromDurationString ($durationString)
 Sets the estimated working time of a question from a given datetime string.
 keyInArray ($searchkey, $array)
 returns TRUE if the key occurs in an array
 setAuthor ($author="")
 Sets the authors name of the assQuestion object.
 setOwner ($owner="")
 Sets the creator/owner ID of the assQuestion object.
 getTitle ()
 Gets the title string of the assQuestion object.
 getId ()
 Gets the id of the assQuestion object.
 getShuffle ()
 Gets the shuffle flag.
 getTestId ()
 Gets the test id of the assQuestion object.
 getComment ()
 Gets the comment string of the assQuestion object.
 getOutputType ()
 Gets the output type.
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output.
 supportsNonJsOutput ()
 requiresJsSwitch ()
 getEstimatedWorkingTime ()
 Gets the estimated working time of a question.
 getAuthor ()
 Gets the authors name of the assQuestion object.
 getOwner ()
 Gets the creator/owner ID of the assQuestion object.
 getObjId ()
 Get the object id of the container object.
 setObjId ($obj_id=0)
 Set the object id of the container object.
 setExternalId ($external_id)
 getExternalId ()
 _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question.
_getQuestionInfo ($question_id)
 Returns question information from the database.
 getSuggestedSolutionOutput ()
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index.
 getSuggestedSolutions ()
 Return the suggested solutions.
 _getReachedPoints ($active_id, $question_id, $pass=NULL)
 Returns the points, a learner has reached answering the question.
 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.
 getAdjustedReachedPoints ($active_id, $pass=NULL)
 returns the reached points ...
 calculateResultsFromSolution ($active_id, $pass=NULL, $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution.
 persistWorkingState ($active_id, $pass=NULL, $obligationsEnabled=false)
 persists the working state for current testactive and testpass
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question
 _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place.
 logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log.
 _logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log.
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it.
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution.
 getJavaPath ()
 Returns the image path for web accessable images of a question.
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question.
 buildImagePath ($questionId, $parentObjectId)
 getFlashPath ()
 Returns the image path for web accessable flash files of a question.
 getJavaPathWeb ()
 Returns the web image path for web accessable java applets of a question.
 getSuggestedSolutionPathWeb ()
 Returns the web path for a suggested solution.
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question.
 getFlashPathWeb ()
 Returns the web image path for web accessable flash applications of a question.
getSolutionValues ($active_id, $pass=NULL)
 Loads solutions of a given user from the database an returns it.
 isInUse ($question_id="")
 Checks whether the question is in use or not.
 isClone ($question_id="")
 Checks whether the question is a clone of another question or not.
 pcArrayShuffle ($array)
 Shuffles the values of a given array.
 getQuestionTypeFromDb ($question_id)
 get question type for question id
 deleteAnswers ($question_id)
 Deletes datasets from answers tables.
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database.
 delete ($question_id)
 Deletes a question and all materials from the database.
 getTotalAnswers ()
 get total number of answers
 _getTotalAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method
 _getTitle ($a_q_id)
 Returns the title of a question.
 _getQuestionText ($a_q_id)
 Returns question text.
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 syncXHTMLMediaObjectsOfQuestion ()
 createPageObject ()
 create page object of question
 copyPageOfQuestion ($a_q_id)
 getPageOfQuestion ()
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id.
 _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id.
 setOriginalId ($original_id)
 getOriginalId ()
 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.
 saveQuestionDataToDb ($original_id="")
 setNewOriginalId ($newId)
 deleteSuggestedSolutions ()
 Deletes all suggestes solutions in the database.
 getSuggestedSolution ($subquestion_index=0)
 Returns a suggested solution for a given subquestion index.
 getSuggestedSolutionTitle ($subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index.
 setSuggestedSolution ($solution_id="", $subquestion_index=0, $is_import=false)
 Sets a suggested solution for the question.
 _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.
 _questionExistsInPool ($question_id)
 Returns true if the question already exists in the database and is assigned to a question pool.
 getPoints ()
 Returns the maximum available points for the question.
 setPoints ($a_points)
 Sets the maximum available points for the question.
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution.
 _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution.
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user.
 _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not.
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=NULL)
 Adjust the given reached points by checks for all special scoring options in the test container.
 isHTML ($a_text)
 Checks if a given string contains HTML or not.
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=FALSE)
 Prepares a string for a text area output in tests.
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string.
 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.
 createNewImageFileName ($image_filename, $unique=false)
 _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.
 getQuestion ()
 Gets the question string of the question object.
 setQuestion ($question="")
 Sets the question string of the question object.
 getQuestionTypeID ()
 Returns the question type of the question.
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table
getInstances ()
 Gets all instances of the question.
 _needsManualScoring ($question_id)
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id.
 __get ($value)
 Object getter.
 __set ($key, $value)
 Object setter.
 getNrOfTries ()
 setNrOfTries ($a_nr_of_tries)
 setExportImagePath ($a_path)
 _questionExistsInTest ($question_id, $test_id)
 formatSAQuestion ($a_q)
 Format self assessment question.
 setPreventRteUsage ($a_val)
 Set prevent rte usage.
 getPreventRteUsage ()
 Get prevent rte usage.
 setSelfAssessmentEditingMode ($a_selfassessmenteditingmode)
 Set Self-Assessment Editing Mode.
 getSelfAssessmentEditingMode ()
 Get Self-Assessment Editing Mode.
 setDefaultNrOfTries ($a_defaultnroftries)
 Set Default Nr of Tries.
 getDefaultNrOfTries ()
 Get Default Nr of Tries.
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not
 setObligationsToBeConsidered ($obligationsToBeConsidered=true)
 sets the flag wether obligations are to be considered or not
 areObligationsToBeConsidered ()
 gets the flag wether obligations are to be considered or not
 isAutosaveable ()
 getAdditionalContentEditingMode ()
 getter for additional content editing mode for this question
 setAdditionalContentEditingMode ($additinalContentEditingMode)
 setter for additional content editing mode for this question
 isAdditionalContentEditingModePageObject ()
 isser for additional "pageobject" content editing mode
 isValidAdditionalContentEditingMode ($additionalContentEditingMode)
 returns the fact wether the passed additional content mode is valid or not
 getValidAdditionalContentEditingModes ()
 getter for valid additional content editing modes
 addQuestionChangeListener (ilQuestionChangeListener $listener)
 getQuestionChangeListeners ()
 getHtmlUserSolutionPurifier ()
 getHtmlQuestionContentPurifier ()
 setLastChange ($lastChange)
 getLastChange ()
 setStep ($step)
 getStep ()
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass.

Data Fields

 $gaps
 $gap_combinations
 $gap_combinations_exists
 $start_tag
 $end_tag
 $textgap_rating
 $identical_scoring
 $fixedTextLength
 $cloze_text
- Data Fields inherited from assQuestion
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT = 'default'
 constant for additional content editing mode "default"
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT = 'pageobject'
 constant for additional content editing mode "pageobject"
 $feedbackOBJ = null
 $prevent_rte_usage = false
 $selfassessmenteditingmode = false
 $defaultnroftries = 0
 $questionActionCmd = 'handleQuestionAction'
- Data Fields inherited from iQuestionCondition
const StringResultExpression = '~TEXT~'
const PercentageResultExpression = '%n%'
const NumericResultExpression = '#n#'
const MatchingResultExpression = ';n:m;'
const OrderingResultExpression = '$n,m,o,p$'
const NumberOfResultExpression = '+n+'
const ExclusiveResultExpression = '*n,m,o,p*'
const EmptyAnswerExpression = "?"

Protected Member Functions

 saveClozeGapItemsToDb ($gap, $key)
 Save all items belonging to one cloze gap to the db.
 saveClozeTextGapRecordToDb ($next_id, $key, $item, $gap)
 Saves a gap-item record.
 saveClozeSelectGapRecordToDb ($next_id, $key, $item, $gap)
 Saves a gap-item record.
 saveClozeNumericGapRecordToDb ($next_id, $key, $item, $gap)
 Saves a gap-item record.
 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary.
 calculateReachedPointsForSolution ($user_result, &$detailed=null)
- Protected Member Functions inherited from assQuestion
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID.
 onDuplicate ($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test)
 beforeSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 onCopy ($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId)
 Will be called when a question is copied (into another question pool)
 duplicateSuggestedSolutionFiles ($parent_id, $question_id)
 Duplicates the files of a suggested solution if the question is duplicated.
 syncSuggestedSolutionFiles ($original_id)
 Syncs the files of a suggested solution if the question is synced.
 copySuggestedSolutionFiles ($source_questionpool_id, $source_question_id)
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 buildQuestionDataQuery ()

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static _getSuggestedSolutionCount ($question_id)
 Returns the number of suggested solutions associated with a question.
static _getSuggestedSolutionOutput ($question_id)
 Returns the output of the suggested solution.
static _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method
static _getOriginalId ($question_id)
 Returns the original id of a question.
static originalQuestionExists ($questionId)
static _instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id.
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.
static _areAnswered ($a_user_id, $a_question_ids)
 Checks if an array of question ids is answered by an user or not.
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type.
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.
static & _instanciateQuestionGUI ($question_id)
 Creates an instance of a question gui with a given question id.
static instantiateQuestionGUI ($a_question_id)
 Creates an instance of a question gui with a given question id.
static lookupParentObjId ($questionId)
 ilDB $ilDB
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)
static isObligationPossible ($questionId)
 returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration
static setResultGateway ($resultGateway)
static getResultGateway ()
static sumTimesInISO8601FormatH_i_s_Extended ($time1, $time2)
static convertISO8601FormatH_i_s_ExtendedToSeconds ($time)
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords ($activeId, $pass, $questionId)
 returns the number of existing solution records for the given test active / pass and given question id
- Protected Attributes inherited from assQuestion
 $id
 $title
 $comment
 $owner
 $author
 $question
 $points
 $est_working_time
 $shuffle
 $test_id
 $obj_id
 $ilias
 $tpl
 $lng
 $db
 $outputType
 $suggested_solutions
 $original_id
 $page
 $external_id = ''
 $questionChangeListeners = array()
 $processLocker
 $step = null
 $lastChange

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:
class.assClozeTest.php 61468 2015-12-15 09:26:35Z gitmgr

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

Constructor & Destructor Documentation

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

Reimplemented from assQuestion.

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

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

{
$this->start_tag = "[gap]";
$this->end_tag = "[/gap]";
$this->gaps = array();
$this->setQuestion($question); // @TODO: Should this be $question?? See setter for why this is not trivial.
$this->fixedTextLength = "";
$this->identical_scoring = 1;
$this->gap_combinations_exists = false;
$this->gap_combinations = array();
}

+ Here is the call graph for this function:

Member Function Documentation

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

References CLOZE_NUMERIC.

{
if (array_key_exists($gap_index, $this->gaps))
{
if ($this->gaps[$gap_index]->getType() == CLOZE_NUMERIC)
{
// only allow notation with "." for real numbers
$answer = str_replace(",", ".", $answer);
}
$this->gaps[$gap_index]->addItem(new assAnswerCloze($answer, 0, $order));
}
}
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 790 of file class.assClozeTest.php.

{
$this->gaps[$index] = $gap;
}
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 768 of file class.assClozeTest.php.

{
if (array_key_exists($gap_index, $this->gaps))
{
include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
$answer = new assAnswerCloze(
"",
0,
$this->gaps[$gap_index]->getItemCount()
);
$this->gaps[$gap_index]->addItem($answer);
}
}
assClozeTest::calculateCombinationResult (   $user_result)

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

References assQuestion\$points, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, assQuestion\getId(), getNumericgapPoints(), and getTextgapPoints().

Referenced by calculateReachedPointsForSolution().

{
$points = 0;
$assClozeGapCombinationObj = new assClozeGapCombination();
if($assClozeGapCombinationObj->combinationExistsForQid($this->getId()))
{
$combinations_for_question = $assClozeGapCombinationObj->getCleanCombinationArray($this->getId());
$gap_answers = array();
$gap_used_in_combination = array();
foreach($user_result as $user_result_build_list)
{
if(is_array($user_result_build_list))
{
$gap_answers[$user_result_build_list['gap_id']] = $user_result_build_list['value'];
}
}
foreach($combinations_for_question as $combination)
{
foreach($combination as $row_key => $row_answers)
{
$combination_fulfilled = true;
$points_for_combination = $row_answers['points'];
foreach($row_answers as $gap_key => $combination_gap_answer)
{
if($gap_key !== 'points')
{
$gap_used_in_combination[$gap_key]= $gap_key;
}
if($combination_fulfilled && array_key_exists($gap_key, $gap_answers))
{
switch($combination_gap_answer['type'])
{
case CLOZE_TEXT:
$is_text_gap_correct = $this->getTextgapPoints($gap_answers[$gap_key], $combination_gap_answer['answer'], 1);
if($is_text_gap_correct != 1)
{
$combination_fulfilled = false;
}
break;
$answer = $this->gaps[$gap_key]->getItem($gap_answers[$gap_key]);
$answertext = $answer->getAnswertext();
if($answertext != $combination_gap_answer['answer'])
{
$combination_fulfilled = false;
}
break;
$answer = $this->gaps[$gap_key]->getItem(0);
if($combination_gap_answer['answer'] != 'out_of_bound')
{
$is_numeric_gap_correct = $this->getNumericgapPoints($answer->getAnswertext(), $gap_answers[$gap_key], 1, $answer->getLowerBound(), $answer->getUpperBound());
if($is_numeric_gap_correct != 1)
{
$combination_fulfilled = false;
}
}
else
{
$wrong_is_the_new_right = $this->getNumericgapPoints($answer->getAnswertext(), $gap_answers[$gap_key], 1, $answer->getLowerBound(), $answer->getUpperBound());
if($wrong_is_the_new_right == 1)
{
$combination_fulfilled = false;
}
}
break;
}
}
else
{
if($gap_key !== 'points')
{
$combination_fulfilled = false;
}
}
}
if($combination_fulfilled)
{
$points += $points_for_combination;
}
}
}
}
return array($points, $gap_used_in_combination);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 !!)

Reimplemented from assQuestion.

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

References $ilDB, $pass, $result, calculateReachedPointsForSolution(), and assQuestion\getSolutionMaxPass().

{
global $ilDB;
if (is_null($pass))
{
$pass = $this->getSolutionMaxPass($active_id);
}
$result = $this->getCurrentSolutionResultSet($active_id, $pass);
$user_result = array();
while ($data = $ilDB->fetchAssoc($result))
{
if (strcmp($data["value2"], "") != 0)
{
$user_result[$data["value1"]] = array(
"gap_id" => $data["value1"],
"value" => $data["value2"]
);
}
}
ksort($user_result); // this is required when identical scoring for same solutions is disabled
if ($returndetails)
{
$detailed = array();
$this->calculateReachedPointsForSolution($user_result, $detailed);
return $detailed;
}
return $this->calculateReachedPointsForSolution($user_result);
}

+ Here is the call graph for this function:

assClozeTest::calculateReachedPointsForSolution (   $user_result,
$detailed = null 
)
protected
Parameters
$user_result
$detailed
Returns
array

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

References assQuestion\$points, calculateCombinationResult(), CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, getIdenticalScoring(), getMaximumGapPoints(), getNumericgapPoints(), and getTextgapPoints().

Referenced by calculateReachedPoints(), and calculateReachedPointsFromPreviewSession().

{
if($detailed === null)
{
$detailed = array();
}
$assClozeGapCombinationObj = new assClozeGapCombination();
$combinations[1] = array();
if($assClozeGapCombinationObj->combinationExistsForQid($this->getId()))
{
$combinations = $this->calculateCombinationResult($user_result);
$points = $combinations[0];
}
$counter = 0;
$solution_values_text = array(); // for identical scoring checks
$solution_values_select = array(); // for identical scoring checks
$solution_values_numeric = array(); // for identical scoring checks
foreach($user_result as $gap_id => $value)
{
if(is_string($value))
{
$value = array("value" => $value);
}
if(array_key_exists($gap_id, $this->gaps) && !array_key_exists ($gap_id, $combinations[1]))
{
switch($this->gaps[$gap_id]->getType())
{
case CLOZE_TEXT:
$gappoints = 0;
for($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++)
{
$answer = $this->gaps[$gap_id]->getItem($order);
$gotpoints = $this->getTextgapPoints($answer->getAnswertext(), $value["value"], $answer->getPoints());
if($gotpoints > $gappoints) $gappoints = $gotpoints;
}
if(!$this->getIdenticalScoring())
{
// check if the same solution text was already entered
if((in_array($value["value"], $solution_values_text)) && ($gappoints > 0))
{
$gappoints = 0;
}
}
$points += $gappoints;
$detailed[$gap_id] = array("points" => $gappoints, "best" => ($this->getMaximumGapPoints($gap_id) == $gappoints) ? TRUE : FALSE, "positive" => ($gappoints > 0) ? TRUE : FALSE);
array_push($solution_values_text, $value["value"]);
break;
$gappoints = 0;
for($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++)
{
$answer = $this->gaps[$gap_id]->getItem($order);
$gotpoints = $this->getNumericgapPoints($answer->getAnswertext(), $value["value"], $answer->getPoints(), $answer->getLowerBound(), $answer->getUpperBound());
if($gotpoints > $gappoints) $gappoints = $gotpoints;
}
if(!$this->getIdenticalScoring())
{
// check if the same solution value was already entered
include_once "./Services/Math/classes/class.EvalMath.php";
$eval = new EvalMath();
$eval->suppress_errors = TRUE;
$found_value = FALSE;
foreach($solution_values_numeric as $solval)
{
if($eval->e($solval) == $eval->e($value["value"]))
{
$found_value = TRUE;
}
}
if($found_value && ($gappoints > 0))
{
$gappoints = 0;
}
}
$points += $gappoints;
$detailed[$gap_id] = array("points" => $gappoints, "best" => ($this->getMaximumGapPoints($gap_id) == $gappoints) ? TRUE : FALSE, "positive" => ($gappoints > 0) ? TRUE : FALSE);
array_push($solution_values_numeric, $value["value"]);
break;
if($value["value"] >= 0)
{
for($order = 0; $order < $this->gaps[$gap_id]->getItemCount(); $order++)
{
$answer = $this->gaps[$gap_id]->getItem($order);
if($value["value"] == $answer->getOrder())
{
$answerpoints = $answer->getPoints();
if(!$this->getIdenticalScoring())
{
// check if the same solution value was already entered
if((in_array($answer->getAnswertext(), $solution_values_select)) && ($answerpoints > 0))
{
$answerpoints = 0;
}
}
$points += $answerpoints;
$detailed[$gap_id] = array("points" => $answerpoints, "best" => ($this->getMaximumGapPoints($gap_id) == $answerpoints) ? TRUE : FALSE, "positive" => ($answerpoints > 0) ? TRUE : FALSE);
array_push($solution_values_select, $answer->getAnswertext());
}
}
}
break;
}
}
}
return $points;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assClozeTest::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

Reimplemented from assQuestion.

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

References calculateReachedPointsForSolution(), and ilAssQuestionPreviewSession\getParticipantsSolution().

{
$userSolution = array();
foreach($previewSession->getParticipantsSolution() as $key => $val)
{
$userSolution[] = array('gap_id' => $key, 'value' => $val);
}
return $this->calculateReachedPointsForSolution($userSolution);
}

+ Here is the call graph for this function:

assClozeTest::checkForValidFormula (   $value)
Parameters
$value
Returns
int

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

{
return preg_match("/^-?(\\d*)(,|\\.|\\/){0,1}(\\d*)$/", $value, $matches);
}
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 153 of file class.assClozeTest.php.

Referenced by loadFromDb(), and setClozeText().

{
$text = preg_replace("/\[gap[^\]]*?\]/", "[gap]", $text);
$text = preg_replace("/<gap([^>]*?)>/", "[gap]", $text);
$text = str_replace("</gap>", "[/gap]", $text);
return $text;
}

+ Here is the caller graph for this function:

assClozeTest::clearGapAnswers ( )

Removes all answers from the gaps.

public

See Also
$gaps

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

{
foreach ($this->gaps as $gap_index => $gap)
{
$this->gaps[$gap_index]->clearItems();
}
}
assClozeTest::copyGapCombination (   $orgID,
  $newID 
)

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

Referenced by copyObject(), createNewOriginalFromThisDuplicate(), and duplicate().

{
$assClozeGapCombinationObj = new assClozeGapCombination();
$array = $assClozeGapCombinationObj->loadFromDb($orgID);
$assClozeGapCombinationObj->importGapCombinationToDb($newID , $array);
}

+ Here is the caller graph for this function:

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

Copies an assClozeTest object.

public

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

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

{
if ($this->getId() <= 0)
{
// The question has not been saved. It cannot be duplicated
return;
}
$thisId = $this->getId();
$thisObjId = $this->getObjId();
$clone = $this;
include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
$clone->id = -1;
$clone->setObjId($target_questionpool_id);
if ($title)
{
$clone->setTitle($title);
}
if($this->gap_combinations_exists)
{
$this->copyGapCombination($original_id, $clone->getId());
}
$clone->saveToDb();
// copy question page content
$clone->copyPageOfQuestion($original_id);
// copy XHTML media objects
$clone->copyXHTMLMediaObjectsOfQuestion($original_id);
$clone->onCopy($thisObjId, $thisId, $clone->getObjId(), $clone->getId());
return $clone->getId();
}

+ Here is the call graph for this function:

assClozeTest::createGapsFromQuestiontext ( )

Create gap entries by parsing the question text.

public

See Also
$gaps

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

References CLOZE_TEXT, and getClozeText().

Referenced by setClozeText().

{
include_once "./Modules/TestQuestionPool/classes/class.assClozeGap.php";
include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
$search_pattern = "|\[gap\](.*?)\[/gap\]|i";
preg_match_all($search_pattern, $this->getClozeText(), $found);
$this->gaps = array();
if (count($found[0]))
{
foreach ($found[1] as $gap_index => $answers)
{
// create text gaps by default
$gap = new assClozeGap(CLOZE_TEXT);
$textparams = preg_split("/(?<!\\\\),/", $answers);
foreach ($textparams as $key => $value)
{
$answer = new assAnswerCloze($value, 0, $key);
$gap->addItem($answer);
}
$this->gaps[$gap_index] = $gap;
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

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

{
if ($this->id <= 0)
{
// The question has not been saved. It cannot be duplicated
return;
}
include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
$sourceQuestionId = $this->id;
$sourceParentId = $this->getObjId();
// duplicate the question in database
$clone = $this;
$clone->id = -1;
$clone->setObjId($targetParentId);
if ($targetQuestionTitle)
{
$clone->setTitle($targetQuestionTitle);
}
$clone->saveToDb();
if($this->gap_combinations_exists)
{
$this->copyGapCombination($sourceQuestionId, $clone->getId());
}
// copy question page content
$clone->copyPageOfQuestion($sourceQuestionId);
// copy XHTML media objects
$clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
$clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
return $clone->id;
}

+ Here is the call graph for this function:

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

References deleteGap(), and updateClozeTextFromGaps().

{
if (array_key_exists($gap_index, $this->gaps))
{
if ($this->gaps[$gap_index]->getItemCount() == 1)
{
// this is the last answer text => remove the gap
$this->deleteGap($gap_index);
}
else
{
// remove the answer text
$this->gaps[$gap_index]->deleteItem($answer_index);
}
}
}

+ Here is the call graph for this function:

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

References getClozeText(), and getGaps().

Referenced by deleteAnswerText().

{
if (array_key_exists($gap_index, $this->gaps))
{
$output = $this->getClozeText();
foreach ($this->getGaps() as $replace_gap_index => $gap)
{
$answers = array();
foreach ($gap->getItemsRaw() as $item)
{
array_push($answers, str_replace(",", "\\,", $item->getAnswerText()));
}
if ($replace_gap_index == $gap_index)
{
$output = preg_replace("/\[gap\].*?\[\/gap\]/", "", $output, 1);
}
else
{
$output = preg_replace("/\[gap\].*?\[\/gap\]/", "[_gap]" . join(",", $answers) . "[/_gap]", $output, 1);
}
}
$output = str_replace("_gap]", "gap]", $output);
$this->cloze_text = $output;
unset($this->gaps[$gap_index]);
$this->gaps = array_values($this->gaps);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Duplicates an assClozeTest.

public

Reimplemented from assQuestion.

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

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

{
if ($this->id <= 0)
{
// The question has not been saved. It cannot be duplicated
return;
}
// duplicate the question in database
$this_id = $this->getId();
$thisObjId = $this->getObjId();
$clone = $this;
include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
$clone->id = -1;
if( (int)$testObjId > 0 )
{
$clone->setObjId($testObjId);
}
if ($title)
{
$clone->setTitle($title);
}
if ($author)
{
$clone->setAuthor($author);
}
if ($owner)
{
$clone->setOwner($owner);
}
if ($for_test)
{
$clone->saveToDb($original_id);
}
else
{
$clone->saveToDb();
}
if($this->gap_combinations_exists)
{
$this->copyGapCombination($this_id, $clone->getId());
}
if ($for_test)
{
$clone->saveToDb($original_id);
}
else
{
$clone->saveToDb();
}
// copy question page content
$clone->copyPageOfQuestion($this_id);
// copy XHTML media objects
$clone->copyXHTMLMediaObjectsOfQuestion($this_id);
$clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
return $clone->getId();
}

+ Here is the call graph for this function:

assClozeTest::flushGaps ( )

Deletes all gaps without changing the cloze text.

public

See Also
$gaps

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

{
$this->gaps = array();
}
assClozeTest::getAdditionalTableName ( )

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

Returns
string The additional table name public

Reimplemented from assQuestion.

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

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

{
return "qpl_qst_cloze";
}

+ Here is the caller graph for this function:

assClozeTest::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name public

Reimplemented from assQuestion.

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

{
return array("qpl_a_cloze",'qpl_a_cloze_combi_res');
}
assClozeTest::getAvailableAnswerOptions (   $index = null)

If index is null, the function returns an array with all anwser options Else it returns the specific answer option.

Parameters
null | int$index
Returns
array|ASS_AnswerSimple

Implements iQuestionCondition.

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

References getGap(), and getGaps().

{
if($index !== null)
{
return $this->getGap($index);
}
else
{
return $this->getGaps();
}
}

+ Here is the call graph for this function:

assClozeTest::getClozeText ( )

Returns the cloze text.

Returns
string The cloze text string public
See Also
$cloze_text

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

References $cloze_text.

Referenced by createGapsFromQuestiontext(), deleteGap(), getRTETextWithMediaObjects(), isComplete(), saveAdditionalQuestionDataToDb(), toJSON(), and updateClozeTextFromGaps().

{
}

+ Here is the caller graph for this function:

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

References $end_tag.

{
}
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 1490 of file class.assClozeTest.php.

References $fixedTextLength.

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

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

Referenced by getAvailableAnswerOptions(), getSolutionSubmit(), and saveWorkingData().

{
if (array_key_exists($gap_index, $this->gaps))
{
return $this->gaps[$gap_index];
}
else
{
return NULL;
}
}

+ Here is the caller graph for this function:

assClozeTest::getGapCombinations ( )

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

References $gap_combinations.

assClozeTest::getGapCombinationsExists ( )

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

References $gap_combinations_exists.

assClozeTest::getGapCount ( )

Returns the number of gaps.

Returns
integer The number of gaps public
See Also
$gaps

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

{
if (is_array($this->gaps))
{
return count($this->gaps);
}
else
{
return 0;
}
}
assClozeTest::getGaps ( )

Returns the array of gaps.

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

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

References $gaps.

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

{
return $this->gaps;
}

+ Here is the caller graph for this function:

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

Referenced by calculateReachedPointsForSolution(), and saveAdditionalQuestionDataToDb().

{
return ($this->identical_scoring) ? 1 : 0;
}

+ Here is the caller graph for this function:

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

References assQuestion\$points.

Referenced by calculateReachedPointsForSolution().

{
$points = 0;
$gap_max_points = 0;
if (array_key_exists($gap_index, $this->gaps))
{
$gap =& $this->gaps[$gap_index];
foreach ($gap->getItems() as $answer)
{
if ($answer->getPoints() > $gap_max_points)
{
$gap_max_points = $answer->getPoints();
}
}
$points += $gap_max_points;
}
return $points;
}

+ Here is the caller graph for this function:

assClozeTest::getMaximumPoints ( )

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

public

See Also
$points

Reimplemented from assQuestion.

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

References assQuestion\$points, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, and assQuestion\getId().

Referenced by isComplete().

{
$assClozeGapCombinationObj = new assClozeGapCombination();
$points = 0;
$gaps_used_in_combination = array();
if($assClozeGapCombinationObj->combinationExistsForQid($this->getId()))
{
$points = $assClozeGapCombinationObj->getMaxPointsForCombination($this->getId());
$gaps_used_in_combination = $assClozeGapCombinationObj->getGapsWhichAreUsedInCombination($this->getId());
}
foreach ($this->gaps as $gap_index => $gap)
{
if(! array_key_exists($gap_index, $gaps_used_in_combination))
{
if ($gap->getType() == CLOZE_TEXT)
{
$gap_max_points = 0;
foreach ($gap->getItems() as $item)
{
if ($item->getPoints() > $gap_max_points)
{
$gap_max_points = $item->getPoints();
}
}
$points += $gap_max_points;
}
else if ($gap->getType() == CLOZE_SELECT)
{
$srpoints = 0;
foreach ($gap->getItems() as $item)
{
if ($item->getPoints() > $srpoints)
{
$srpoints = $item->getPoints();
}
}
$points += $srpoints;
}
else if ($gap->getType() == CLOZE_NUMERIC)
{
$numpoints = 0;
foreach ($gap->getItems() as $item)
{
if ($item->getPoints() > $numpoints)
{
$numpoints = $item->getPoints();
}
}
$points += $numpoints;
}
}
}
return $points;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $result.

Referenced by calculateCombinationResult(), and calculateReachedPointsForSolution().

{
// fau: fixGapFormula - check entered value by evalMath
// if( ! $this->checkForValidFormula($a_entered) )
// {
// return 0;
// }
include_once "./Services/Math/classes/class.EvalMath.php";
$eval = new EvalMath();
$eval->suppress_errors = TRUE;
$result = 0;
if ($eval->e($a_entered) === FALSE)
{
return 0;
}
elseif (($eval->e($lowerBound) !== FALSE) && ($eval->e($upperBound) !== FALSE))
// fau.
{
if (($eval->e($a_entered) >= $eval->e($lowerBound)) && ($eval->e($a_entered) <= $eval->e($upperBound))) $result = $max_points;
}
else if ($eval->e($lowerBound) !== FALSE)
{
if (($eval->e($a_entered) >= $eval->e($lowerBound)) && ($eval->e($a_entered) <= $eval->e($a_original))) $result = $max_points;
}
else if ($eval->e($upperBound) !== FALSE)
{
if (($eval->e($a_entered) >= $eval->e($a_original)) && ($eval->e($a_entered) <= $eval->e($upperBound))) $result = $max_points;
}
else
{
if ($eval->e($a_entered) == $eval->e($a_original)) $result = $max_points;
}
return $result;
}

+ Here is the caller graph for this function:

assClozeTest::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
string$expression

Implements iQuestionCondition.

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

References ilOperatorsExpressionMapping\getOperatorsByExpression().

{
require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
}

+ Here is the call graph for this function:

assClozeTest::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

Reimplemented from assQuestion.

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

Referenced by toJSON().

{
return "assClozeTest";
}

+ Here is the caller graph for this function:

assClozeTest::getRTETextWithMediaObjects ( )

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

Reimplemented from assQuestion.

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

References getClozeText().

+ Here is the call graph for this function:

assClozeTest::getSolutionSubmit ( )

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

References $_POST, CLOZE_NUMERIC, CLOZE_SELECT, getGap(), and ilUtil\stripSlashes().

Referenced by saveWorkingData().

{
$solutionSubmit = array();
foreach ($_POST as $key => $value)
{
if (preg_match("/^gap_(\d+)/", $key, $matches))
{
$value = ilUtil::stripSlashes($value, FALSE);
if (strlen($value))
{
$gap = $this->getGap($matches[1]);
if (is_object($gap))
{
if (!(($gap->getType() == CLOZE_SELECT) && ($value == -1)))
{
if ($gap->getType() == CLOZE_NUMERIC)
{
$value = str_replace(",", ".", $value);
}
$solutionSubmit[trim($matches[1])] = $value;
}
}
}
}
}
return $solutionSubmit;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $start_tag.

{
}
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 1142 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 calculateCombinationResult(), and calculateReachedPointsForSolution().

{
include_once "./Services/Utilities/classes/class.ilStr.php";
$result = 0;
$gaprating = $this->getTextgapRating();
switch ($gaprating)
{
if (strcmp(ilStr::strToLower($a_original), ilStr::strToLower($a_entered)) == 0) $result = $max_points;
break;
if (strcmp($a_original, $a_entered) == 0) $result = $max_points;
break;
if (levenshtein($a_original, $a_entered) <= 1) $result = $max_points;
break;
if (levenshtein($a_original, $a_entered) <= 2) $result = $max_points;
break;
if (levenshtein($a_original, $a_entered) <= 3) $result = $max_points;
break;
if (levenshtein($a_original, $a_entered) <= 4) $result = $max_points;
break;
if (levenshtein($a_original, $a_entered) <= 5) $result = $max_points;
break;
}
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $textgap_rating.

Referenced by getTextgapPoints(), and saveAdditionalQuestionDataToDb().

{
}

+ Here is the caller graph for this function:

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

Reimplemented from assQuestion.

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

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

{
if (strlen($this->getTitle())
&& $this->getAuthor()
&& $this->getClozeText()
&& count($this->getGaps())
&& $this->getMaximumPoints() > 0)
{
return true;
}
return false;
}

+ Here is the call graph for this function:

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

Reimplemented from assQuestion.

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

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

{
global $ilDB;
$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",
array("integer"),
array($question_id)
);
if ($result->numRows() == 1)
{
$data = $ilDB->fetchAssoc($result);
$this->setId($question_id);
$this->setNrOfTries($data['nr_of_tries']);
$this->setObjId($data["obj_fi"]);
$this->setTitle($data["title"]);
$this->setComment($data["description"]);
$this->setOriginalId($data["original_id"]);
$this->setAuthor($data["author"]);
$this->setPoints($data["points"]);
$this->setOwner($data["owner"]);
$this->setQuestion($this->cleanQuestiontext($data["question_text"]));
$this->setClozeText($data['cloze_text']);
$this->setFixedTextLength($data["fixed_textlen"]);
$this->setIdenticalScoring(($data['tstamp'] == 0) ? true : $data["identical_scoring"]);
// replacement of old syntax with new syntax
include_once("./Services/RTE/classes/class.ilRTE.php");
$this->question = ilRTE::_replaceMediaObjectImageSrc($this->question, 1);
$this->cloze_text = ilRTE::_replaceMediaObjectImageSrc($this->cloze_text, 1);
$this->setTextgapRating($data["textgap_rating"]);
$this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
try
{
$this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
}
{
}
// open the cloze gaps with all answers
include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
include_once "./Modules/TestQuestionPool/classes/class.assClozeGap.php";
$result = $ilDB->queryF("SELECT * FROM qpl_a_cloze WHERE question_fi = %s ORDER BY gap_id, aorder ASC",
array("integer"),
array($question_id)
);
if ($result->numRows() > 0)
{
$this->gaps = array();
while ($data = $ilDB->fetchAssoc($result))
{
switch ($data["cloze_type"])
{
case CLOZE_TEXT:
if (!array_key_exists($data["gap_id"], $this->gaps))
{
$this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_TEXT);
}
$answer = new assAnswerCloze(
$data["answertext"],
$data["points"],
$data["aorder"]
);
$this->gaps[$data["gap_id"]]->setGapSize($data['gap_size']);
$this->gaps[$data["gap_id"]]->addItem($answer);
break;
if (!array_key_exists($data["gap_id"], $this->gaps))
{
$this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_SELECT);
$this->gaps[$data["gap_id"]]->setShuffle($data["shuffle"]);
}
$answer = new assAnswerCloze(
$data["answertext"],
$data["points"],
$data["aorder"]
);
$this->gaps[$data["gap_id"]]->addItem($answer);
break;
if (!array_key_exists($data["gap_id"], $this->gaps))
{
$this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_NUMERIC);
}
$answer = new assAnswerCloze(
$data["answertext"],
$data["points"],
$data["aorder"]
);
$this->gaps[$data["gap_id"]]->setGapSize($data['gap_size']);
$answer->setLowerBound($data["lowerlimit"]);
$answer->setUpperBound($data["upperlimit"]);
$this->gaps[$data["gap_id"]]->addItem($answer);
break;
}
}
}
}
$assClozeGapCombinationObj = new assClozeGapCombination();
$check_for_gap_combinations = $assClozeGapCombinationObj->loadFromDb($question_id);
if(count($check_for_gap_combinations) != 0)
{
$this->setGapCombinations($check_for_gap_combinations);
}
parent::loadFromDb($question_id);
}

+ Here is the call graph for this function:

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

Reworks the allready saved working data if neccessary.

protected

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered

Reimplemented from assQuestion.

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

{
// nothing to rework!
}
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 318 of file class.assClozeTest.php.

References $ilDB, ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), getClozeText(), getFixedTextLength(), assQuestion\getId(), getIdenticalScoring(), and getTextgapRating().

Referenced by saveToDb().

{
global $ilDB;
$ilDB->manipulateF( "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
array( "integer" ),
array( $this->getId() )
);
$ilDB->manipulateF( "INSERT INTO " . $this->getAdditionalTableName()
. " (question_fi, textgap_rating, identical_scoring, fixed_textlen, cloze_text) VALUES (%s, %s, %s, %s, %s)",
array(
"integer",
"text",
"text",
"integer",
"text"
),
array(
$this->getId(),
$this->getTextgapRating(),
$this->getFixedTextLength() ? $this->getFixedTextLength() : NULL,
)
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assClozeTest::saveAnswerSpecificDataToDb ( )

Save all gaps to the database.

Implements ilObjAnswerScoringAdjustable.

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

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

Referenced by saveToDb().

{
global $ilDB;
$ilDB->manipulateF( "DELETE FROM qpl_a_cloze WHERE question_fi = %s",
array( "integer" ),
array( $this->getId() )
);
foreach ($this->gaps as $key => $gap)
{
$this->saveClozeGapItemsToDb( $gap, $key );
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

Parameters
$gap
$key

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

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

Referenced by saveAnswerSpecificDataToDb().

{
global $ilDB;
foreach ($gap->getItems() as $item)
{
$query = "";
$next_id = $ilDB->nextId( 'qpl_a_cloze' );
switch ($gap->getType())
{
case CLOZE_TEXT:
$this->saveClozeTextGapRecordToDb($next_id, $key, $item, $gap );
break;
$this->saveClozeSelectGapRecordToDb($next_id, $key, $item, $gap );
break;
$this->saveClozeNumericGapRecordToDb($next_id, $key, $item, $gap );
break;
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $ilDB, and assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

{
global $ilDB;
include_once "./Services/Math/classes/class.EvalMath.php";
$eval = new EvalMath();
$eval->suppress_errors = TRUE;
$ilDB->manipulateF( "INSERT INTO qpl_a_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type, lowerlimit, upperlimit, gap_size) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
array(
"integer",
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text",
"text",
"integer"
),
array(
$next_id,
$this->getId(),
$key,
strlen( $item->getAnswertext() ) ? $item->getAnswertext() : "",
$item->getPoints(),
$item->getOrder(),
$gap->getType(),
($eval->e( $item->getLowerBound() !== FALSE ) && strlen( $item->getLowerBound()
) > 0) ? $item->getLowerBound() : $item->getAnswertext(),
($eval->e( $item->getUpperBound() !== FALSE ) && strlen( $item->getUpperBound()
) > 0) ? $item->getUpperBound() : $item->getAnswertext(),
$gap->getGapSize()
)
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $ilDB, and assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

{
global $ilDB;
$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)",
array(
"integer",
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text"
),
array(
$next_id,
$this->getId(),
$key,
strlen( $item->getAnswertext() ) ? $item->getAnswertext() : "",
$item->getPoints(),
$item->getOrder(),
$gap->getType(),
($gap->getShuffle()) ? "1" : "0"
)
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $ilDB, and assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

{
global $ilDB;
$ilDB->manipulateF( "INSERT INTO qpl_a_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type, gap_size) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
array(
"integer",
"integer",
"integer",
"text",
"float",
"integer",
"text",
"integer"
),
array(
$next_id,
$this->getId(),
$key,
strlen( $item->getAnswertext() ) ? $item->getAnswertext() : "",
$item->getPoints(),
$item->getOrder(),
$gap->getType(),
$gap->getGapSize()
)
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assClozeTest::saveToDb (   $original_id = "")

Saves a assClozeTest object to a database.

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

public

Reimplemented from assQuestion.

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

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

+ Here is the call graph for this function:

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

Reimplemented from assQuestion.

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

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

{
global $ilDB;
global $ilUser;
if (is_null($pass))
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$pass = ilObjTest::_getPass($active_id);
}
$this->getProcessLocker()->requestUserSolutionUpdateLock();
$affectedRows = $this->removeCurrentSolution($active_id, $pass);
$entered_values = 0;
foreach($this->getSolutionSubmit() as $val1 => $val2)
{
$value = trim(ilUtil::stripSlashes($val2, FALSE));
if (strlen($value))
{
$gap = $this->getGap(trim(ilUtil::stripSlashes($val1)));
if (is_object($gap))
{
if (!(($gap->getType() == CLOZE_SELECT) && ($value == -1)))
{
$affectedRows = $this->saveCurrentSolution($active_id,$pass, $val1, $value);
$entered_values++;
}
}
}
}
$this->getProcessLocker()->releaseUserSolutionUpdateLock();
if ($entered_values)
{
include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
{
$this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
}
}
else
{
include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
{
$this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
}
}
return TRUE;
}

+ Here is the call graph for this function:

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

References $cloze_text, cleanQuestiontext(), and createGapsFromQuestiontext().

Referenced by loadFromDb().

{
$this->gaps = array();
$this->cloze_text = $cloze_text;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assClozeTest::setClozeTextValue (   $cloze_text = "")

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

References $cloze_text.

{
$this->cloze_text = $cloze_text;
}
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 593 of file class.assClozeTest.php.

References $end_tag.

{
$this->end_tag = $end_tag;
}
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

Reimplemented from assQuestion.

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

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

{
include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
$solution = $this->getSolutionValues($active_id, $pass);
$worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
$worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
$i = 1;
foreach ($this->getGaps() as $gap_index => $gap)
{
$worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($this->lng->txt("gap") . " $i"), $format_bold);
$checked = FALSE;
foreach ($solution as $solutionvalue)
{
if ($gap_index == $solutionvalue["value1"])
{
switch ($gap->getType())
{
$worksheet->writeString($startrow + $i, 1, $gap->getItem($solutionvalue["value2"])->getAnswertext());
break;
case CLOZE_TEXT:
$worksheet->writeString($startrow + $i, 1, $solutionvalue["value2"]);
break;
}
}
}
$i++;
}
return $startrow + $i + 1;
}

+ Here is the call graph for this function:

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

Referenced by loadFromDb().

{
$this->fixedTextLength = $a_text_len;
}

+ Here is the caller graph for this function:

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

{
if (array_key_exists($gap_index, $this->gaps))
{
$this->gaps[$gap_index]->setItemLowerBound($order, $bound);
}
}
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 752 of file class.assClozeTest.php.

References assQuestion\$points.

{
if (array_key_exists($gap_index, $this->gaps))
{
$this->gaps[$gap_index]->setItemPoints($order, $points);
}
}
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 823 of file class.assClozeTest.php.

{
if (array_key_exists($gap_index, $this->gaps))
{
$this->gaps[$gap_index]->setItemUpperBound($order, $bound);
}
}
assClozeTest::setGapCombinations (   $value)

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

Referenced by loadFromDb().

{
$this->gap_combinations = $value;
}

+ Here is the caller graph for this function:

assClozeTest::setGapCombinationsExists (   $value)

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

Referenced by loadFromDb().

{
$this->gap_combinations_exists = $value;
}

+ Here is the caller graph for this function:

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

References assQuestion\$shuffle.

{
if (array_key_exists($gap_index, $this->gaps))
{
$this->gaps[$gap_index]->setShuffle($shuffle);
}
}
assClozeTest::setGapSize (   $gap_index,
  $order,
  $size 
)

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

References $size.

{
if (array_key_exists($gap_index, $this->gaps))
{
$this->gaps[$gap_index]->setGapSize( $size);
}
}
assClozeTest::setGapType (   $gap_index,
  $gap_type 
)

Set the type of a gap with a given index.

private

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

{
if (array_key_exists($gap_index, $this->gaps))
{
$this->gaps[$gap_index]->setType($gap_type);
}
}
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 1446 of file class.assClozeTest.php.

Referenced by loadFromDb().

{
$this->identical_scoring = ($a_identical_scoring) ? 1 : 0;
}

+ Here is the caller graph for this function:

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

References $start_tag.

{
$this->start_tag = $start_tag;
}
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 1408 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().

{
switch ($a_textgap_rating)
{
$this->textgap_rating = $a_textgap_rating;
break;
default:
$this->textgap_rating = TEXTGAP_RATING_CASEINSENSITIVE;
break;
}
}

+ Here is the caller graph for this function:

assClozeTest::toJSON ( )

Returns a JSON representation of the question.

Reimplemented from assQuestion.

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

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

{
include_once("./Services/RTE/classes/class.ilRTE.php");
$result = array();
$result['id'] = (int) $this->getId();
$result['type'] = (string) $this->getQuestionType();
$result['title'] = (string) $this->getTitle();
$result['question'] = $this->formatSAQuestion(
$this->getQuestion() . '<br/>' . $this->getClozeText()
);
$result['nr_of_tries'] = (int) $this->getNrOfTries();
$result['shuffle'] = (bool) $this->getShuffle();
$result['feedback'] = array(
'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
);
$gaps = array();
foreach ($this->getGaps() as $key => $gap)
{
$items = array();
foreach ($gap->getItems() as $item)
{
$jitem = array();
$jitem['points'] = $item->getPoints();
$jitem['value'] = $this->formatSAQuestion($item->getAnswertext());
$jitem['order'] = $item->getOrder();
if ($gap->getType() == CLOZE_NUMERIC)
{
$jitem['lowerbound'] = $item->getLowerBound();
$jitem['upperbound'] = $item->getUpperBound();
}
else
{
$jitem['value'] = trim($jitem['value']);
}
array_push($items, $jitem);
}
if( $gap->getGapSize() && ($gap->getType() == CLOZE_TEXT || $gap->getType() == CLOZE_NUMERIC) )
{
$jgap['size'] = $gap->getGapSize();
}
$jgap['shuffle'] = $gap->getShuffle();
$jgap['type'] = $gap->getType();
$jgap['item'] = $items;
array_push($gaps, $jgap);
}
$result['gaps'] = $gaps;
$result['mobs'] = $mobs;
return json_encode($result);
}

+ Here is the call graph for this function:

assClozeTest::updateClozeTextFromGaps ( )

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

private

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

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

Referenced by deleteAnswerText().

{
$output = $this->getClozeText();
foreach ($this->getGaps() as $gap_index => $gap)
{
$answers = array();
foreach ($gap->getItemsRaw() as $item)
{
array_push($answers, str_replace(",", "\\,", $item->getAnswerText()));
}
$output = preg_replace("/\[gap\].*?\[\/gap\]/", "[_gap]" . $this->prepareTextareaOutput(join(",", $answers), true) . "[/_gap]", $output, 1);
}
$output = str_replace("_gap]", "gap]", $output);
$this->cloze_text = $output;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

assClozeTest::$cloze_text

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

Referenced by getClozeText(), setClozeText(), and setClozeTextValue().

assClozeTest::$end_tag

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

Referenced by getEndTag(), and setEndTag().

assClozeTest::$fixedTextLength

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

Referenced by getFixedTextLength().

assClozeTest::$gap_combinations

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

Referenced by getGapCombinations().

assClozeTest::$gap_combinations_exists

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

Referenced by getGapCombinationsExists().

assClozeTest::$gaps

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

Referenced by getGaps(), and toJSON().

assClozeTest::$identical_scoring

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

assClozeTest::$start_tag

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

Referenced by getStartTag(), and setStartTag().

assClozeTest::$textgap_rating

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

Referenced by getTextgapRating().


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