ILIAS  Release_4_1_x_branch Revision 61804
 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.
 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.
 toJSON ()
 Returns a JSON representation of the question.
- Public Member Functions inherited from assQuestion
 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.
 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.
 _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.
 calculateResultsFromSolution ($active_id, $pass=NULL)
 Calculates the question results from a previously saved question solution.
 _updateTestResultCache ($active_id)
 _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.
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution.
 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.
 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 ()
 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="")
 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.
 updateSuggestedSolutions ($original_id="")
 Update the suggested solutions of a question based on the suggested solution array attribute.
 saveSuggestedSolution ($type, $solution_id="", $subquestion_index=0, $value="")
 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.
 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, $manualscoring=FALSE)
 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.
 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.
 __get ($value)
 Object getter.
 __set ($key, $value)
 Object setter.
 getNrOfTries ()
 setNrOfTries ($a_nr_of_tries)

Data Fields

 $gaps
 $start_tag
 $end_tag
 $textgap_rating
 $identical_scoring
 $fixedTextLength

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 _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 _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.
 onDuplicate ($source_question_id)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test)
 onCopy ($source_questionpool_id, $source_question_id)
 Will be called when a question is copied (into another question pool)
 duplicateSuggestedSolutionFiles ($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)
- 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

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 26807 2010-12-02 11:11:36Z akill

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

Reimplemented from assQuestion.

Definition at line 105 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($cloze_text);
$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 584 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 665 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 643 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 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 1011 of file class.assClozeTest.php.

References $data, $ilDB, $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"]
);
}
}
$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 547 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 813 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);
$clone->onCopy($this->getObjId(), $this->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 487 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 873 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 899 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 762 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);
$clone->onDuplicate($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 399 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 1308 of file class.assClozeTest.php.

Referenced by loadFromDb(), and saveToDb().

{
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 1319 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 428 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 464 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 1341 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 605 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 562 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 387 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 1285 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 1354 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 712 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 977 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 1235 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 1376 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 440 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 936 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 1247 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().

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

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, $ilDB, $result, ilRTE\_replaceMediaObjectImageSrc(), cleanQuestiontext(), CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, getAdditionalTableName(), 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));
// 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::saveToDb (   $original_id = "")

Saves a assClozeTest object to a database.

Parameters
integer$original_idID of the original question public

Reimplemented from assQuestion.

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

References $ilDB, assQuestion\$original_id, $query, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, getAdditionalTableName(), getFixedTextLength(), assQuestion\getId(), getIdenticalScoring(), getTextgapRating(), and assQuestion\saveQuestionDataToDb().

{
global $ilDB;
include_once "./Services/Math/classes/class.EvalMath.php";
$eval = new EvalMath();
$eval->suppress_errors = TRUE;
// save additional data
$affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
array("integer"),
array($this->getId())
);
$affectedRows = $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
)
);
$affectedRows = $ilDB->manipulateF("DELETE FROM qpl_a_cloze WHERE question_fi = %s",
array("integer"),
array($this->getId())
);
foreach ($this->gaps as $key => $gap)
{
foreach ($gap->getItems() as $item)
{
$query = "";
switch ($gap->getType())
{
case CLOZE_TEXT:
$next_id = $ilDB->nextId('qpl_a_cloze');
$affectedRows = $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()
)
);
break;
$next_id = $ilDB->nextId('qpl_a_cloze');
$affectedRows = $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"
)
);
break;
$next_id = $ilDB->nextId('qpl_a_cloze');
$affectedRows = $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,
strlen($item->getAnswertext()) ? $item->getAnswertext() : "",
$item->getPoints(),
$item->getOrder(),
$gap->getType(),
($eval->e($item->getLowerBound() !== FALSE) && strlen($item->getLowerBound()) > 0) ? $item->getLowerBound() : $item->getAnswertext(),
($eval->e($item->getUpperBound() !== FALSE) && strlen($item->getUpperBound()) > 0) ? $item->getUpperBound() : $item->getAnswertext()
)
);
break;
}
}
}
}

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

References $_POST, $ilDB, $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);
}
$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++;
}
}
}
}
}
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 413 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 476 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 1393 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 1330 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 680 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 627 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 698 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 533 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 516 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 1297 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 452 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 1259 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 1428 of file class.assClozeTest.php.

References $gaps, $mobs, $result, ilObjMediaObject\_getMobsOfObject(), ilRTE\_replaceMediaObjectImageSrc(), CLOZE_NUMERIC, assQuestion\getFeedbackGeneric(), 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'] = (string) nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getQuestion(), 0));
$result['nr_of_tries'] = (int) $this->getNrOfTries();
$result['shuffle'] = (bool) $this->getShuffle();
$result['feedback'] = array(
"onenotcorrect" => nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackGeneric(0), 0)),
"allcorrect" => nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackGeneric(1), 0))
);
$gaps = array();
foreach ($this->getGaps() as $key => $gap)
{
$items = array();
foreach ($gap->getItems() as $item)
{
$jitem = array();
$jitem['points'] = $item->getPoints();
$jitem['value'] = $item->getAnswertext();
$jitem['order'] = $item->getOrder();
if ($gap->getType() == CLOZE_NUMERIC)
{
$jitem['lowerbound'] = $item->getLowerBound();
$jitem['upperbound'] = $item->getUpperBound();
}
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 848 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 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(), and toJSON().

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: