ILIAS  Release_3_10_x_branch Revision 61812
 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

 assClozeTest ($title="", $comment="", $author="", $owner=-1, $cloze_text="")
 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.
 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="")
 Duplicates an assClozeTest.
 copyObject ($target_questionpool, $title="")
 Copies an assClozeTest object.
 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 The points are calculated from the given answers including checks for all special scoring options in the test container.
 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.
- Public Member Functions inherited from assQuestion
 assQuestion ($title="", $comment="", $author="", $owner=-1, $question="")
 assQuestion constructor
 _assQuestion ()
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Creates a question from a QTI file.
 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.
 setId ($id=-1)
 Sets the id.
 setTestId ($id=-1)
 Sets the test id.
 setComment ($comment="")
 Sets the comment.
 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.
 setOwner ($owner="")
 Sets the creator/owner.
 getTitle ()
 Gets the title string.
 getId ()
 Gets the id.
 getShuffle ()
 Gets the shuffle flag.
 getTestId ()
 Gets the test id.
 getComment ()
 Gets the comment.
 getOutputType ()
 Gets the output type.
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output.
 getEstimatedWorkingTime ()
 Gets the estimated working time of a question.
 getAuthor ()
 Gets the authors name.
 getOwner ()
 Gets the creator/owner.
 getObjId ()
 Get the object id of the container object.
 setObjId ($obj_id=0)
 Set the object id of the container object.
 createPageObject ()
 create page object of question
 insertIntoTest ($test_id)
 Insert the question into a test.
 _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question.
_getQuestionInfo ($question_id)
 Returns question information from the database.
 _getSuggestedSolutionCount ($question_id)
 Returns the number of suggested solutions associated with a question.
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index.
 _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.
 _updateTestPassResults ($active_id, $pass)
 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.
 getJavaPath ()
 Returns the image path for web accessable images of a question.
 getImagePath ()
 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.
 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.
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 syncXHTMLMediaObjectsOfQuestion ()
 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 ()
 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.
 saveSuggestedSolution ($solution_id="", $subquestion_index=0)
 Saves a suggested solution for the question.
 _resolveInternalLink ($internal_link)
 _resolveIntLinks ($question_id)
 _getInternalLinkHref ($target="")
 _getOriginalId ($question_id)
 Returns the original id of a question.
 syncWithOriginal ()
 createRandomSolution ($test_id, $user_id)
 _questionExists ($question_id)
 Returns true if the question already exists in the database.
_instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id.
 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.
 _isWorkedThrough ($active_id, $question_id, $pass=NULL)
 Returns true if the question was worked through in the given pass.
 getMultilineAnswerSetting ()
 setMultilineAnswerSetting ($a_setting=0)
 _areAnswered ($a_user_id, $a_question_ids)
 Checks if an array of question ids is answered by an user or not.
 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=NULL)
 Sets the points, a learner has reached answering the question Additionally objective results are updated.
 getQuestion ()
 Gets the question text.
 setQuestion ($question="")
 Sets the question text.
 getQuestionTypeID ()
 Returns the question type of the question.
 saveFeedbackGeneric ($correctness, $feedback)
 Saves generic feedback to the database.
 getFeedbackGeneric ($correctness)
 Returns the generic feedback for a given question state.
 duplicateFeedbackGeneric ($original_id)
 Duplicates the generic feedback of a question.
 syncFeedbackGeneric ()
 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.
_instanciateQuestionGUI ($question_id)
 Creates an instance of a question gui with a given question id.

Data Fields

 $gaps
 $start_tag
 $end_tag
 $textgap_rating
 $identical_scoring
 $fixedTextLength
- Data Fields inherited from assQuestion
 $id
 $title
 $comment
 $owner
 $author
 $question
 $points
 $est_working_time
 $shuffle
 $test_id
 $obj_id
 $ilias
 $tpl
 $lng
 $domxml
 $outputType
 $suggested_solutions
 $original_id

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type.
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag.
- Protected Member Functions inherited from assQuestion
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID.

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
Version
Id:
class.assClozeTest.php 23089 2010-03-01 09:00:53Z hschottm

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

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 684 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 765 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 743 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::assClozeTest (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $cloze_text = "" 
)

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$cloze_textThe question string of the cloze test public

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

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

{
$this->start_tag = "[gap]";
$this->end_tag = "[/gap]";
$this->gaps = array();
$this->setClozeText($cloze_text);
$this->fixedTextLength = "";
$this->identical_scoring = 1;
}

+ Here is the call 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 including checks for all special scoring options in the test container.

Parameters
integer$user_idThe database ID of the learner
integer$test_idThe database Id of the test containing the question public

Reimplemented from assQuestion.

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

References $data, $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);
}
$statement = $ilDB->prepare("SELECT * FROM tst_solutions WHERE active_fi = ? AND question_fi = ? AND pass = ?",
array(
"integer",
"integer",
"integer"
)
);
$result = $ilDB->execute($statement,
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"]
);
}
}
$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 public

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

{
foreach ($this->gaps as $gap_index => $gap)
{
$this->gaps[$gap_index]->clearItems();
}
}
assClozeTest::copyObject (   $target_questionpool,
  $title = "" 
)

Copies an assClozeTest object.

public

Definition at line 911 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;
}
$clone = $this;
include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
$clone->id = -1;
$source_questionpool = $this->getObjId();
$clone->setObjId($target_questionpool);
if ($title)
{
$clone->setTitle($title);
}
$clone->saveToDb();
// copy question page content
$clone->copyPageOfQuestion($original_id);
// copy XHTML media objects
$clone->copyXHTMLMediaObjectsOfQuestion($original_id);
// duplicate the generic feedback
$clone->duplicateFeedbackGeneric($original_id);
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 587 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::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 970 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 996 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 = "" 
)

Duplicates an assClozeTest.

public

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

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

{
if ($this->id <= 0)
{
// The question has not been saved. It cannot be duplicated
return;
}
// duplicate the question in database
$this_id = $this->getId();
$clone = $this;
include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
$clone->id = -1;
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);
// duplicate the generic feedback
$clone->duplicateFeedbackGeneric($this_id);
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 499 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 1415 of file class.assClozeTest.php.

Referenced by loadFromDb(), and saveToDb().

{
return "qpl_question_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 1426 of file class.assClozeTest.php.

{
return "qpl_answer_cloze";
}
assClozeTest::getClozeText ( )

Returns the cloze text.

Returns
string The cloze text string public
See Also
$cloze_text

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

References assQuestion\$question.

Referenced by createGapsFromQuestiontext(), deleteGap(), isComplete(), saveToDb(), 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 564 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 1448 of file class.assClozeTest.php.

References $fixedTextLength.

Referenced by saveToDb().

+ 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 705 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 662 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 487 of file class.assClozeTest.php.

References $gaps.

Referenced by deleteGap(), isComplete(), setExportDetailsXLS(), 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 Public

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

Referenced by calculateReachedPoints(), and saveToDb().

{
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 1461 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];
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 812 of file class.assClozeTest.php.

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

Referenced by isComplete(), and saveToDb().

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

References $result.

Referenced by calculateReachedPoints().

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

{
return "assClozeTest";
}
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 1483 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 540 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 1033 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 Public

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

References $textgap_rating.

Referenced by getTextgapPoints(), and saveToDb().

{
}

+ 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 public

Reimplemented from assQuestion.

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

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

Referenced by saveToDb().

{
if (($this->getTitle()) and ($this->getAuthor()) and ($this->getClozeText()) and (count($this->getGaps())) and ($this->getMaximumPoints() > 0))
{
return TRUE;
}
else
{
return FALSE;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assClozeTest::loadFromDb (   $question_id)

Loads a assClozeTest object from a database.

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

Reimplemented from assQuestion.

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

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

{
global $ilDB;
if ($question_id < 1) return;
$statement = $ilDB->prepare("SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions, " . $this->getAdditionalTableName() . " WHERE question_id = ? AND qpl_questions.question_id = " . $this->getAdditionalTableName() . ".question_fi",
array(
"integer"
)
);
$result = $ilDB->execute($statement,
array(
$question_id
)
);
if ($result->numRows() == 1)
{
$data = $ilDB->fetchAssoc($result);
$this->setId($question_id);
$this->setObjId($data["obj_fi"]);
$this->setTitle($data["title"]);
$this->setComment($data["comment"]);
$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["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));
// open the cloze gaps with all answers
include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
include_once "./Modules/TestQuestionPool/classes/class.assClozeGap.php";
$statement = $ilDB->prepare("SELECT * FROM qpl_answer_cloze WHERE question_fi = ? ORDER BY gap_id, aorder ASC",
array(
"integer"
)
);
$result = $ilDB->execute($statement,
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::saveToDb (   $original_id = "")

Saves a assClozeTest object to a database.

Saves a assClozeTest object to a database (experimental)

Parameters
object$dbA pear DB object public

Reimplemented from assQuestion.

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

References $data, assQuestion\$original_id, ilRTE\_replaceMediaObjectImageSrc(), CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, assQuestion\createPageObject(), getAdditionalTableName(), assQuestion\getAuthor(), getClozeText(), assQuestion\getComment(), assQuestion\getEstimatedWorkingTime(), getFixedTextLength(), assQuestion\getId(), getIdenticalScoring(), getMaximumPoints(), assQuestion\getObjId(), assQuestion\getOwner(), assQuestion\getQuestionTypeID(), assQuestion\getTestId(), getTextgapRating(), assQuestion\getTitle(), assQuestion\insertIntoTest(), isComplete(), and assQuestion\setId().

{
global $ilDB;
include_once "./Services/Math/classes/class.EvalMath.php";
$eval = new EvalMath();
$eval->suppress_errors = TRUE;
$estw_time = $this->getEstimatedWorkingTime();
$estw_time = sprintf("%02d:%02d:%02d", $estw_time['h'], $estw_time['m'], $estw_time['s']);
// cleanup RTE images which are not inserted into the question text
include_once("./Services/RTE/classes/class.ilRTE.php");
if ($this->id == -1)
{
$now = getdate();
$created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
$statement = $ilDB->prepareManip("INSERT INTO qpl_questions (question_id, question_type_fi, obj_fi, title, comment, points, author, " .
"owner, question_text, working_time, complete, created, original_id, TIMESTAMP) " .
"VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)",
array(
"integer",
"integer",
"text",
"text",
"float",
"text",
"integer",
"text",
"time",
"text",
"text",
"integer"
)
);
$data = array(
$this->getObjId(),
$this->getTitle(),
$this->getComment(),
$this->getMaximumPoints(),
$this->getAuthor(),
$this->getOwner(),
$estw_time,
($this->isComplete()) ? "1" : "0",
$created,
($original_id > 0) ? $original_id : NULL
);
$affectedRows = $ilDB->execute($statement, $data);
$this->setId($ilDB->getLastInsertId());
$statement = $ilDB->prepareManip("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, textgap_rating, identical_scoring, fixed_textlen) VALUES (?, ?, ?, ?)",
array(
"integer",
"text",
"text",
"integer"
)
);
$data = array(
$this->getId(),
$this->getTextgapRating(),
$this->getFixedTextLength() ? $this->getFixedTextLength() : NULL
);
$affectedRows = $ilDB->execute($statement, $data);
$this->createPageObject();
if ($this->getTestId() > 0)
{
$this->insertIntoTest($this->getTestId());
}
}
else
{
$statement = $ilDB->prepareManip("UPDATE qpl_questions SET obj_fi = ?, title = ?, comment = ?, points = ?, author = ?, " .
"question_text = ?, working_time = ?, complete = ? WHERE question_id = ?",
array(
"integer",
"text",
"text",
"float",
"text",
"text",
"time",
"text",
"integer"
)
);
$data = array(
$this->getObjId(),
$this->getTitle(),
$this->getComment(),
$this->getMaximumPoints(),
$this->getAuthor(),
$estw_time,
($this->isComplete()) ? "1" : "0",
$this->getId()
);
$affectedRows = $ilDB->execute($statement, $data);
$statement = $ilDB->prepareManip("UPDATE " . $this->getAdditionalTableName() . " SET textgap_rating = ?, fixed_textlen = ?, identical_scoring = ? WHERE question_fi = ?",
array(
"text",
"integer",
"text",
"integer"
)
);
$data = array(
$this->getTextgapRating(),
$this->getFixedTextLength() ? $this->getFixedTextLength() : NULL,
$this->getId()
);
$affectedRows = $ilDB->execute($statement, $data);
}
$statement = $ilDB->prepareManip("DELETE FROM qpl_answer_cloze WHERE question_fi = ?",
array(
"integer"
)
);
$data = array(
$this->getId()
);
$affectedRows = $ilDB->execute($statement, $data);
foreach ($this->gaps as $key => $gap)
{
foreach ($gap->getItems() as $item)
{
$query = "";
switch ($gap->getType())
{
case CLOZE_TEXT:
$statement = $ilDB->prepareManip("INSERT INTO qpl_answer_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type) VALUES (NULL, ?, ?, ?, ?, ?, ?)",
array(
"integer",
"integer",
"text",
"float",
"integer",
"text"
)
);
$data = array(
$this->getId(),
$key,
strlen($item->getAnswertext()) ? $item->getAnswertext() : "",
$item->getPoints(),
$item->getOrder(),
$gap->getType()
);
break;
$statement = $ilDB->prepareManip("INSERT INTO qpl_answer_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type, shuffle) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)",
array(
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text"
)
);
$data = array(
$this->getId(),
$key,
strlen($item->getAnswertext()) ? $item->getAnswertext() : "",
$item->getPoints(),
$item->getOrder(),
$gap->getType(),
($gap->getShuffle()) ? "1" : "0"
);
break;
$statement = $ilDB->prepareManip("INSERT INTO qpl_answer_cloze (answer_id, question_fi, gap_id, answertext, points, aorder, cloze_type, lowerlimit, upperlimit) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)",
array(
"integer",
"integer",
"text",
"float",
"integer",
"text",
"text",
"text"
)
);
$data = array(
$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() : "0",
($eval->e($item->getUpperBound() !== FALSE) && strlen($item->getUpperBound()) > 0) ? $item->getUpperBound() : "0"
);
break;
}
$affectedRows = $ilDB->execute($statement, $data);
}
}
}

+ Here is the call graph for this function:

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

Saves the learners input of the question to the database.

Parameters
integer$test_idThe database id of the test containing this question
Returns
boolean Indicates the save status (true if saved successful, false otherwise) public
See Also
$answers

Reimplemented from assQuestion.

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

References $data, $pass, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), CLOZE_NUMERIC, CLOZE_SELECT, getGap(), assQuestion\getId(), 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);
}
$statement = $ilDB->prepareManip("DELETE FROM tst_solutions WHERE active_fi = ? AND question_fi = ? AND pass = ?",
array(
"integer",
"integer",
"integer"
)
);
$data = array(
$active_id,
$this->getId(),
);
$affectedRows = $ilDB->execute($statement, $data);
$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);
}
$statement = $ilDB->prepareManip("INSERT INTO tst_solutions (solution_id, active_fi, question_fi, value1, value2, pass, TIMESTAMP) VALUES (NULL, ?, ?, ?, ?, ?, NULL)",
array(
"integer",
"integer",
"text",
"text",
"integer"
)
);
$data = array(
$active_id,
$this->getId(),
trim($matches[1]),
trim($value),
);
$affectedRows = $ilDB->execute($statement, $data);
$entered_values++;
}
}
}
}
}
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 513 of file class.assClozeTest.php.

References cleanQuestiontext(), and createGapsFromQuestiontext().

Referenced by assClozeTest().

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

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

{
include_once ("./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 1437 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 780 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 727 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 798 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 633 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 616 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 Public

Definition at line 1404 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 552 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 Public

Definition at line 1366 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::updateClozeTextFromGaps ( )

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

private

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

References getClozeText(), getGaps(), and ilUtil\prepareFormOutput().

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]" . ilUtil::prepareFormOutput(join(",", $answers)) . "[/_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 61 of file class.assClozeTest.php.

Referenced by getEndTag(), and setEndTag().

assClozeTest::$fixedTextLength

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

Referenced by getFixedTextLength().

assClozeTest::$gaps

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

Referenced by getGaps().

assClozeTest::$identical_scoring

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

assClozeTest::$start_tag

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

Referenced by getStartTag(), and setStartTag().

assClozeTest::$textgap_rating

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

Referenced by getTextgapRating().


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