ILIAS  Release_4_4_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.
 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.
 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="")
 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.
 calculateReachedPoints ($active_id, $pass=NULL, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question.
 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.
 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.
- 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.
 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
 _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.
 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
 _getTotalRightAnswers ($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.
 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)
 _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 ()

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"
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT = 'pageobject'
 constant for additional content editing mode "pageobject"
 $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.
 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.
- Protected Member Functions inherited from assQuestion
 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)
 onSyncWithOriginal ($originalQuestionId, $duplicateQuestionId)
 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)

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 _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 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
- 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:
class.assClozeTest.php 61096 2015-10-16 08:50:08Z gitmgr

Definition at line 20 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 92 of file class.assClozeTest.php.

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

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

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

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

{
global $ilDB;
$found_value1 = array();
$found_value2 = array();
$detailed = array();
if (is_null($pass))
{
$pass = $this->getSolutionMaxPass($active_id);
}
$result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
array(
"integer",
"integer",
"integer"
),
array(
$active_id,
$this->getId(),
)
);
$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
$points = 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 (array_key_exists($gap_id, $this->gaps))
{
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;
}
}
}
if ($returndetails)
{
return $detailed;
}
else
{
return $points;
}
}

+ Here is the call graph for this function:

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

{
$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 637 of file class.assClozeTest.php.

{
foreach ($this->gaps as $gap_index => $gap)
{
$this->gaps[$gap_index]->clearItems();
}
}
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().

{
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);
}
$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 577 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 941 of file class.assClozeTest.php.

References assQuestion\$id, 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();
// 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 1006 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 1032 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->question = $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 852 of file class.assClozeTest.php.

References assQuestion\$author, assQuestion\$original_id, assQuestion\$owner, assQuestion\$title, assQuestion\_getOriginalId(), 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();
}
// 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 489 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 1467 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 1478 of file class.assClozeTest.php.

{
return "qpl_a_cloze";
}
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().

{
}

+ 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 554 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 1500 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 695 of file class.assClozeTest.php.

Referenced by 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::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.

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

References $gaps.

Referenced by deleteGap(), 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 1444 of file class.assClozeTest.php.

Referenced by calculateReachedPoints(), 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 1513 of file class.assClozeTest.php.

References assQuestion\$points.

Referenced by calculateReachedPoints().

{
$points = 0;
if (array_key_exists($gap_index, $this->gaps))
{
$gap =& $this->gaps[$gap_index];
$gap_max_points = 0;
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 802 of file class.assClozeTest.php.

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

Referenced by isComplete().

{
$points = 0;
foreach ($this->gaps as $gap_index => $gap)
{
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 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 1110 of file class.assClozeTest.php.

References $result.

Referenced by calculateReachedPoints().

{
if( !is_numeric($a_entered) )
{
return 0;
}
include_once "./Services/Math/classes/class.EvalMath.php";
$eval = new EvalMath();
$eval->suppress_errors = TRUE;
$result = 0;
if (($eval->e($lowerBound) !== FALSE) && ($eval->e($upperBound) !== FALSE))
{
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::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

Reimplemented from assQuestion.

Definition at line 1394 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 1537 of file class.assClozeTest.php.

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.

{
}
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().

{
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 1406 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 114 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 148 of file class.assClozeTest.php.

References $result, ilRTE\_replaceMediaObjectImageSrc(), cleanQuestiontext(), CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, 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().

{
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->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->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"]]->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"]
);
$answer->setLowerBound($data["lowerlimit"]);
$answer->setUpperBound($data["upperlimit"]);
$this->gaps[$data["gap_id"]]->addItem($answer);
break;
}
}
}
}
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 1383 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 287 of file class.assClozeTest.php.

References getAdditionalTableName(), 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) VALUES (%s, %s, %s, %s)",
array(
"integer",
"text",
"text",
"integer"
),
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 267 of file class.assClozeTest.php.

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

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

References assQuestion\getId().

Referenced by saveClozeGapItemsToDb().

{
global $ilDB;
include_once "./Services/Math/classes/class.EvalMath.php";
$eval = new EvalMath();
$eval->suppress_errors = TRUE;
// Bugfix for mantis: 14034
// It is a numeric gap, so cast to integer! // BH we should cast to float ;)
$answerText = strlen($item->getAnswertext()) ? (float)$item->getAnswertext() : 0;
$lowerBound = (
$eval->e( $item->getLowerBound() !== FALSE ) && strlen( $item->getLowerBound() ) ?
$item->getLowerBound() : $item->getAnswertext()
);
$upperBound = (
$eval->e( $item->getUpperBound() !== FALSE ) && strlen( $item->getUpperBound() ) ?
$item->getUpperBound() : $item->getAnswertext()
);
//vd($answerText, $lowerBound, $upperBound);
$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)",
array(
"integer",
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text",
"text"
),
array(
$next_id,
$this->getId(),
$key,
$answerText,
$item->getPoints(),
$item->getOrder(),
$gap->getType(),
$lowerBound,
$upperBound
)
);
}

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

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

References 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) VALUES (%s, %s, %s, %s, %s, %s, %s)",
array(
"integer",
"integer",
"integer",
"text",
"float",
"integer",
"text"
),
array(
$next_id,
$this->getId(),
$key,
strlen( $item->getAnswertext() ) ? $item->getAnswertext() : "",
$item->getPoints(),
$item->getOrder(),
$gap->getType()
)
);
}

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

{
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 = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
array(
"integer",
"integer",
"integer"
),
array(
$active_id,
$this->getId(),
)
);
$entered_values = 0;
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);
}
$next_id = $ilDB->nextId("tst_solutions");
$affectedRows = $ilDB->insert("tst_solutions", array(
"solution_id" => array("integer", $next_id),
"active_fi" => array("integer", $active_id),
"question_fi" => array("integer", $this->getId()),
"value1" => array("clob", trim($matches[1])),
"value2" => array("clob", trim($value)),
"pass" => array("integer", $pass),
"tstamp" => array("integer", time())
));
$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 503 of file class.assClozeTest.php.

References cleanQuestiontext(), and createGapsFromQuestiontext().

Referenced by __construct().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

{
$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 1554 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 1489 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 770 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 717 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 788 of file class.assClozeTest.php.

{
if (array_key_exists($gap_index, $this->gaps))
{
$this->gaps[$gap_index]->setItemUpperBound($order, $bound);
}
}
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.

{
if (array_key_exists($gap_index, $this->gaps))
{
$this->gaps[$gap_index]->setShuffle($shuffle);
}
}
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.

{
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 1456 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 542 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 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().

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

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

{
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());
$result['nr_of_tries'] = (int) $this->getNrOfTries();
$result['shuffle'] = (bool) $this->getShuffle();
$result['feedback'] = array(
"onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false),
"allcorrect" => $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);
}
$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 981 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->question = $output;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

assClozeTest::$end_tag

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

Referenced by getEndTag(), and setEndTag().

assClozeTest::$fixedTextLength

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

Referenced by getFixedTextLength().

assClozeTest::$gaps

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

Referenced by getGaps(), and toJSON().

assClozeTest::$identical_scoring

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

assClozeTest::$start_tag

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

Referenced by getStartTag(), and setStartTag().

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: