Class for matching questions. More...
Inheritance diagram for ASS_MatchingQuestion:
Collaboration diagram for ASS_MatchingQuestion:Public Member Functions | |
| ASS_MatchingQuestion ($title="", $comment="", $author="", $owner=-1, $question="", $matching_type=MT_TERMS_DEFINITIONS) | |
| ASS_MatchingQuestion constructor. | |
| isComplete () | |
| Returns true, if a matching question is complete for use. | |
| from_xml ($xml_text) | |
| Imports a question from XML. | |
| to_xml ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false) | |
| Returns a QTI xml representation of the question. | |
| saveToDb ($original_id="") | |
| Saves a ASS_MatchingQuestion object to a database. | |
| loadFromDb ($question_id) | |
| Loads a ASS_MatchingQuestion object from a database. | |
| addMatchingPair ($answertext, $points, $answerorder, $matchingtext, $matchingorder) | |
| Adds an answer to the question. | |
| duplicate ($for_test=true, $title="", $author="", $owner="") | |
| Duplicates an ASS_MatchingQuestion. | |
| duplicateImages ($question_id) | |
| set_question ($question="") | |
| Sets the matching question text. | |
| set_matching_type ($matching_type=MT_TERMS_DEFINITIONS) | |
| Sets the matching question type. | |
| get_question () | |
| Returns the question text. | |
| get_matching_type () | |
| Returns the matching question type. | |
| add_matchingpair ($term="", $picture_or_definition="", $points=0.0, $term_id=0, $picture_or_definition_id=0) | |
| Adds an matching pair for an matching question. | |
| get_matchingpair ($index=0) | |
| Returns a matching pair. | |
| delete_matchingpair ($index=0) | |
| Deletes a matching pair. | |
| flush_matchingpairs () | |
| Deletes all matching pairs. | |
| get_matchingpair_count () | |
| Returns the number of matching pairs. | |
| calculateReachedPoints ($user_id, $test_id) | |
| Returns the points, a learner has reached answering the question. | |
| getReachedInformation ($user_id, $test_id) | |
| Returns the evaluation data, a learner has entered to answer the question. | |
| getMaximumPoints () | |
| Returns the maximum points, a learner can reach answering the question. | |
| set_image_file ($image_filename, $image_tempfilename="") | |
| Sets the image file. | |
| checkSaveData () | |
| Checks the data to be saved for consistency. | |
| saveWorkingData ($test_id, $limit_to=LIMIT_NO_LIMIT) | |
| Saves the learners input of the question to the database. | |
| get_random_id () | |
| syncWithOriginal () | |
| pc_array_shuffle ($array) | |
| createRandomSolution ($test_id, $user_id) | |
| getQuestionType () | |
| Returns the question type of the question. | |
Data Fields | |
| $question | |
| $matchingpairs | |
| $matching_type | |
Class for matching questions.
ASS_MatchingQuestion is a class for matching questions.
class.assMatchingQuestion.php Assessment
Definition at line 40 of file class.assMatchingQuestion.php.
| ASS_MatchingQuestion::add_matchingpair | ( | $ | term = "", |
|
| $ | picture_or_definition = "", |
|||
| $ | points = 0.0, |
|||
| $ | term_id = 0, |
|||
| $ | picture_or_definition_id = 0 | |||
| ) |
Adds an matching pair for an matching question.
Adds an matching pair for an matching choice question. The students have to fill in an order for the matching pair. The matching pair is an ASS_AnswerMatching object that will be created and assigned to the array $this->matchingpairs.
| string | $answertext The answer text | |
| string | $matchingtext The matching text of the answer text | |
| double | $points The points for selecting the matching pair (even negative points can be used) | |
| integer | $order A possible display order of the matching pair public |
Definition at line 987 of file class.assMatchingQuestion.php.
References ASS_Question::$points, and get_random_id().
Referenced by from_xml().
{
// append answer
if ($term_id == 0)
{
$term_id = $this->get_random_id();
}
if ($picture_or_definition_id == 0)
{
$picture_or_definition_id = $this->get_random_id();
}
$matchingpair = new ASS_AnswerMatching($term, $points, $term_id, $picture_or_definition, $picture_or_definition_id);
array_push($this->matchingpairs, $matchingpair);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ASS_MatchingQuestion::addMatchingPair | ( | $ | answertext, | |
| $ | points, | |||
| $ | answerorder, | |||
| $ | matchingtext, | |||
| $ | matchingorder | |||
| ) |
Adds an answer to the question.
Adds an answer to the question
public
Definition at line 838 of file class.assMatchingQuestion.php.
References ASS_Question::$points.
{
array_push($this->matchingpairs, new ASS_AnswerMatching($answertext, $points, $answerorder, $matchingtext, $matchingorder));
}
| ASS_MatchingQuestion::ASS_MatchingQuestion | ( | $ | title = "", |
|
| $ | comment = "", |
|||
| $ | author = "", |
|||
| $ | owner = -1, |
|||
| $ | question = "", |
|||
| $ | matching_type = MT_TERMS_DEFINITIONS | |||
| ) |
ASS_MatchingQuestion constructor.
The constructor takes possible arguments an creates an instance of the ASS_MatchingQuestion object.
| string | $title A title string to describe the question | |
| string | $comment A comment string to describe the question | |
| string | $author A string containing the name of the questions author | |
| integer | $owner A numerical ID to identify the owner/creator | |
| string | $question The question string of the matching question public |
Definition at line 82 of file class.assMatchingQuestion.php.
References ASS_Question::$author, ASS_Question::$comment, $matching_type, ASS_Question::$owner, $question, ASS_Question::$title, and ASS_Question::ASS_Question().
{
$this->ASS_Question($title, $comment, $author, $owner);
$this->matchingpairs = array();
$this->question = $question;
$this->matching_type = $matching_type;
}
Here is the call graph for this function:| ASS_MatchingQuestion::calculateReachedPoints | ( | $ | user_id, | |
| $ | test_id | |||
| ) |
Returns the points, a learner has reached answering the question.
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.
| integer | $user_id The database ID of the learner | |
| integer | $test_id The database Id of the test containing the question public |
Definition at line 1103 of file class.assMatchingQuestion.php.
References $data, ASS_Question::$points, $query, $result, $row, ASS_Question::$test_id, $user_id, ASS_Question::getId(), and getMaximumPoints().
{
global $ilDB;
$found_value1 = array();
$found_value2 = array();
$query = sprintf("SELECT * FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s",
$ilDB->quote($user_id),
$ilDB->quote($test_id),
$ilDB->quote($this->getId())
);
$result = $ilDB->query($query);
while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT))
{
if (strcmp($data->value1, "") != 0)
{
array_push($found_value1, $data->value1);
array_push($found_value2, $data->value2);
}
}
$points = 0;
foreach ($found_value2 as $key => $value)
{
foreach ($this->matchingpairs as $answer_key => $answer_value)
{
if (($answer_value->getDefinitionId() == $value) and ($answer_value->getTermId() == $found_value1[$key]))
{
$points += $answer_value->getPoints();
}
}
}
// check for special scoring options in test
$query = sprintf("SELECT * FROM tst_tests WHERE test_id = %s",
$ilDB->quote($test_id)
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
if ($row["count_system"] == 1)
{
if ($points != $this->getMaximumPoints())
{
$points = 0;
}
}
}
else
{
$points = 0;
}
return $points;
}
Here is the call graph for this function:| ASS_MatchingQuestion::checkSaveData | ( | ) |
Checks the data to be saved for consistency.
Checks the data to be saved for consistency
Definition at line 1291 of file class.assMatchingQuestion.php.
References $_POST, $result, and sendInfo().
Referenced by saveWorkingData().
{
$result = true;
$matching_values = array();
foreach ($_POST as $key => $value)
{
if (preg_match("/^sel_matching_(\d+)/", $key, $matches))
{
if ((strcmp($value, "") != 0) && ($value != -1))
{
array_push($matching_values, $value);
}
}
}
$check_matching = array_flip($matching_values);
if (count($check_matching) != count($matching_values))
{
// duplicate matching values!!!
$result = false;
sendInfo($this->lng->txt("duplicate_matching_values_selected"));
}
return $result;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ASS_MatchingQuestion::createRandomSolution | ( | $ | test_id, | |
| $ | user_id | |||
| ) |
Reimplemented from ASS_Question.
Definition at line 1457 of file class.assMatchingQuestion.php.
References $ilUser, $query, $result, ASS_Question::$test_id, $user_id, ASS_Question::getId(), and pc_array_shuffle().
{
global $ilDB;
global $ilUser;
$db =& $ilDB->db;
$query = sprintf("DELETE FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s",
$db->quote($user_id),
$db->quote($test_id),
$db->quote($this->getId())
);
$result = $db->query($query);
$terms = array();
$definitions = array();
foreach ($this->matchingpairs as $key => $pair)
{
array_push($terms, $pair->getTermId());
array_push($definitions, $pair->getDefinitionId());
}
$definitions = $this->pc_array_shuffle($definitions);
foreach ($terms as $key => $value)
{
$query = sprintf("INSERT INTO tst_solutions (solution_id, user_fi, test_fi, question_fi, value1, value2, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, NULL)",
$db->quote($user_id),
$db->quote($test_id),
$db->quote($this->getId()),
$db->quote($value),
$db->quote($definitions[$key])
);
$result = $db->query($query);
}
}
Here is the call graph for this function:| ASS_MatchingQuestion::delete_matchingpair | ( | $ | index = 0 |
) |
Deletes a matching pair.
Deletes a matching pair with a given index. The index of the first matching pair is 0, the index of the second matching pair is 1 and so on.
| integer | $index A nonnegative index of the n-th matching pair public |
Definition at line 1047 of file class.assMatchingQuestion.php.
{
if ($index < 0)
{
return;
}
if (count($this->matchingpairs) < 1)
{
return;
}
if ($index >= count($this->matchingpairs))
{
return;
}
unset($this->matchingpairs[$index]);
$this->matchingpairs = array_values($this->matchingpairs);
}
| ASS_MatchingQuestion::duplicate | ( | $ | for_test = true, |
|
| $ | title = "", |
|||
| $ | author = "", |
|||
| $ | owner = "" | |||
| ) |
Duplicates an ASS_MatchingQuestion.
Duplicates an ASS_MatchingQuestion
public
Definition at line 851 of file class.assMatchingQuestion.php.
References ASS_Question::$author, ASS_Question::$owner, ASS_Question::$title, and ASS_Question::_getOriginalId().
{
if ($this->id <= 0)
{
// The question has not been saved. It cannot be duplicated
return;
}
// duplicate the question in database
$clone = $this;
include_once ("./assessment/classes/class.assQuestion.php");
$original_id = ASS_Question::_getOriginalId($this->id);
$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($original_id);
// duplicate the image
$clone->duplicateImages($original_id);
return $clone->id;
}
Here is the call graph for this function:| ASS_MatchingQuestion::duplicateImages | ( | $ | question_id | ) |
Definition at line 892 of file class.assMatchingQuestion.php.
References get_matching_type(), ASS_Question::getImagePath(), and ilUtil::makeDirParents().
{
if ($this->get_matching_type() == MT_TERMS_PICTURES)
{
$imagepath = $this->getImagePath();
$imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
if (!file_exists($imagepath))
{
ilUtil::makeDirParents($imagepath);
}
foreach ($this->matchingpairs as $answer)
{
$filename = $answer->getPicture();
if (!copy($imagepath_original . $filename, $imagepath . $filename))
{
print "image could not be duplicated!!!! ";
}
if (!copy($imagepath_original . $filename . ".thumb.jpg", $imagepath . $filename . ".thumb.jpg"))
{
print "image thumbnail could not be duplicated!!!! ";
}
}
}
}
Here is the call graph for this function:| ASS_MatchingQuestion::flush_matchingpairs | ( | ) |
Deletes all matching pairs.
Deletes all matching pairs
public
Definition at line 1073 of file class.assMatchingQuestion.php.
{
$this->matchingpairs = array();
}
| ASS_MatchingQuestion::from_xml | ( | $ | xml_text | ) |
Imports a question from XML.
Sets the attributes of the question from the XML text passed as argument
Definition at line 126 of file class.assMatchingQuestion.php.
References ASS_Question::$comment, $idx, $ilErr, $image, $result, ASS_Question::$shuffle, ilQTIUtils::_getRespcondition(), add_matchingpair(), ilUtil::convertImage(), domxml_open_mem(), get_matching_type(), ASS_Question::getId(), ASS_Question::getImagePath(), ilUtil::makeDirParents(), saveToDb(), set_matching_type(), set_question(), ASS_Question::setAuthor(), ASS_Question::setComment(), ASS_Question::setEstimatedWorkingTime(), ASS_Question::setShuffle(), ASS_Question::setSuggestedSolution(), and ASS_Question::setTitle().
{
$result = false;
if (!empty($this->domxml))
{
$this->domxml->free();
}
$xml_text = preg_replace("/>\s*?</", "><", $xml_text);
$this->domxml = domxml_open_mem($xml_text);
if (!empty($this->domxml))
{
$root = $this->domxml->document_element();
$item = $root->first_child();
$this->setTitle($item->get_attribute("title"));
$this->gaps = array();
$itemnodes = $item->child_nodes();
$materials = array();
$images = array();
$shuffle = "";
foreach ($itemnodes as $index => $node)
{
switch ($node->node_name())
{
case "qticomment":
$comment = $node->get_content();
if (strpos($comment, "ILIAS Version=") !== false)
{
}
elseif (strpos($comment, "Questiontype=") !== false)
{
}
elseif (strpos($comment, "Author=") !== false)
{
$comment = str_replace("Author=", "", $comment);
$this->setAuthor($comment);
}
else
{
$this->setComment($comment);
}
break;
case "itemmetadata":
$md_array = array();
$metanodes = $node->child_nodes();
foreach ($metanodes as $metanode)
{
switch ($metanode->node_name())
{
case "qtimetadata":
$metafields = $metanode->child_nodes();
foreach ($metafields as $metafield)
{
switch ($metafield->node_name())
{
case "qtimetadatafield":
$metafieldlist = $metafield->child_nodes();
$md = array("label" => "", "entry" => "");
foreach ($metafieldlist as $attr)
{
switch ($attr->node_name())
{
case "fieldlabel":
$md["label"] = $attr->get_content();
break;
case "fieldentry":
$md["entry"] = $attr->get_content();
break;
}
}
array_push($md_array, $md);
break;
}
}
break;
}
}
foreach ($md_array as $md)
{
switch ($md["label"])
{
case "ILIAS_VERSION":
break;
case "QUESTIONTYPE":
break;
case "AUTHOR":
$this->setAuthor($md["entry"]);
break;
}
}
break;
case "duration":
$iso8601period = $node->get_content();
if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
{
$this->setEstimatedWorkingTime($matches[4], $matches[5], $matches[6]);
}
break;
case "presentation":
$flow = $node->first_child();
$flownodes = $flow->child_nodes();
foreach ($flownodes as $idx => $flownode)
{
if (strcmp($flownode->node_name(), "material") == 0)
{
$mattext = $flownode->first_child();
$this->set_question($mattext->get_content());
}
elseif (strcmp($flownode->node_name(), "response_grp") == 0)
{
$ident = $flownode->get_attribute("ident");
if (strcmp($ident, "MQT") == 0)
{
$this->set_matching_type(MT_TERMS_DEFINITIONS);
}
elseif (strcmp($ident, "MQP") == 0)
{
$this->set_matching_type(MT_TERMS_PICTURES);
}
$subnodes = $flownode->child_nodes();
foreach ($subnodes as $node_type)
{
switch ($node_type->node_name())
{
case "material":
$matlabel = $node_type->get_attribute("label");
if (strcmp($matlabel, "suggested_solution") == 0)
{
$mattype = $node_type->first_child();
if (strcmp($mattype->node_name(), "mattext") == 0)
{
$suggested_solution = $mattype->get_content();
if ($suggested_solution)
{
if ($this->getId() < 1)
{
$this->saveToDb();
}
$this->setSuggestedSolution($suggested_solution, 0, true);
}
}
}
break;
case "render_choice":
$render_choice = $node_type;
$shuffle = $render_choice->get_attribute("shuffle");
$shuf = 0;
if (strcmp(strtolower($shuffle), "yes") == 0)
{
$shuf = 1;
}
$this->setShuffle($shuf);
$labels = $render_choice->child_nodes();
foreach ($labels as $lidx => $response_label)
{
$material = $response_label->first_child();
if ($this->get_matching_type() == MT_TERMS_PICTURES)
{
$mattype = $material->first_child();
if (strcmp($mattype->node_name(), "matimage") == 0)
{
$filename = $mattype->get_attribute("label");
$image = base64_decode($mattype->get_content());
$images["$filename"] = $image;
$materials[$response_label->get_attribute("ident")] = $filename;
}
else
{
$materials[$response_label->get_attribute("ident")] = $mattype->get_content();
}
}
else
{
$mattext = $material->first_child();
$materials[$response_label->get_attribute("ident")] = $mattext->get_content();
}
}
break;
}
}
}
}
break;
case "resprocessing":
$resproc_nodes = $node->child_nodes();
foreach ($resproc_nodes as $index => $respcondition)
{
if (strcmp($respcondition->node_name(), "respcondition") == 0)
{
$respcondition_array =& ilQTIUtils::_getRespcondition($respcondition);
$pair = split(",", $respcondition_array["conditionvar"]["value"]);
$this->add_matchingpair($materials[$pair[0]], $materials[$pair[1]], $respcondition_array["setvar"]["points"], $pair[0], $pair[1]);
}
}
break;
}
}
if (count($images))
{
$this->saveToDb();
foreach ($images as $filename => $image)
{
if ($filename)
{
$imagepath = $this->getImagePath();
if (!file_exists($imagepath))
{
ilUtil::makeDirParents($imagepath);
}
$imagepath .= $filename;
$fh = fopen($imagepath, "wb");
if ($fh == false)
{
global $ilErr;
$ilErr->raiseError($this->lng->txt("error_save_image_file") . ": $php_errormsg", $ilErr->MESSAGE);
return;
}
$imagefile = fwrite($fh, $image);
fclose($fh);
// create thumbnail file
$thumbpath = $imagepath . "." . "thumb.jpg";
ilUtil::convertImage($imagepath, $thumbpath, "JPEG", 100);
}
}
}
$result = true;
}
return $result;
}
Here is the call graph for this function:| ASS_MatchingQuestion::get_matching_type | ( | ) |
Returns the matching question type.
Returns the matching question type
Definition at line 968 of file class.assMatchingQuestion.php.
Referenced by duplicateImages(), from_xml(), and to_xml().
{
return $this->matching_type;
}
Here is the caller graph for this function:| ASS_MatchingQuestion::get_matchingpair | ( | $ | index = 0 |
) |
Returns a matching pair.
Returns a matching pair with a given index. The index of the first matching pair is 0, the index of the second matching pair is 1 and so on.
| integer | $index A nonnegative index of the n-th matching pair |
Definition at line 1020 of file class.assMatchingQuestion.php.
{
if ($index < 0)
{
return NULL;
}
if (count($this->matchingpairs) < 1)
{
return NULL;
}
if ($index >= count($this->matchingpairs))
{
return NULL;
}
return $this->matchingpairs[$index];
}
| ASS_MatchingQuestion::get_matchingpair_count | ( | ) |
Returns the number of matching pairs.
Returns the number of matching pairs
Definition at line 1087 of file class.assMatchingQuestion.php.
{
return count($this->matchingpairs);
}
| ASS_MatchingQuestion::get_question | ( | ) |
Returns the question text.
Returns the question text
Definition at line 954 of file class.assMatchingQuestion.php.
Referenced by to_xml().
{
return $this->question;
}
Here is the caller graph for this function:| ASS_MatchingQuestion::get_random_id | ( | ) |
Definition at line 1364 of file class.assMatchingQuestion.php.
Referenced by add_matchingpair().
{
mt_srand((double)microtime()*1000000);
$random_number = mt_rand(1, 100000);
$found = FALSE;
while ($found)
{
$found = FALSE;
foreach ($this->matchingpairs as $key => $value)
{
if (($value->getTermId() == $random_number) || ($value->getDefinitionId() == $random_number))
{
$found = TRUE;
$random_number++;
}
}
}
return $random_number;
}
Here is the caller graph for this function:| ASS_MatchingQuestion::getMaximumPoints | ( | ) |
Returns the maximum points, a learner can reach answering the question.
Returns the maximum points, a learner can reach answering the question
public
Reimplemented from ASS_Question.
Definition at line 1223 of file class.assMatchingQuestion.php.
References ASS_Question::$points.
Referenced by calculateReachedPoints(), saveToDb(), and syncWithOriginal().
{
$points = 0;
foreach ($this->matchingpairs as $key => $value)
{
if ($value->getPoints() > 0)
{
$points += $value->getPoints();
}
}
return $points;
}
Here is the caller graph for this function:| ASS_MatchingQuestion::getQuestionType | ( | ) |
Returns the question type of the question.
Returns the question type of the question
Definition at line 1500 of file class.assMatchingQuestion.php.
Referenced by saveToDb().
{
return 4;
}
Here is the caller graph for this function:| ASS_MatchingQuestion::getReachedInformation | ( | $ | user_id, | |
| $ | test_id | |||
| ) |
Returns the evaluation data, a learner has entered to answer the question.
Returns the evaluation data, a learner has entered to answer the question
| integer | $user_id The database ID of the learner | |
| integer | $test_id The database Id of the test containing the question public |
Definition at line 1167 of file class.assMatchingQuestion.php.
References $counter, $data, ASS_Question::$points, $query, $result, ASS_Question::$test_id, $user_id, and ASS_Question::getId().
{
$found_value1 = array();
$found_value2 = array();
$query = sprintf("SELECT * FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s",
$this->ilias->db->quote($user_id),
$this->ilias->db->quote($test_id),
$this->ilias->db->quote($this->getId())
);
$result = $this->ilias->db->query($query);
while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT))
{
array_push($found_value1, $data->value1);
array_push($found_value2, $data->value2);
}
$counter = 1;
$user_result = array();
foreach ($found_value1 as $key => $value)
{
$solution = array(
"order" => "$counter",
"points" => 0,
"true" => 0,
"term" => "",
"definition" => ""
);
foreach ($this->matchingpairs as $answer_key => $answer_value)
{
if (($answer_value->getDefinitionId() == $found_value2[$key]) and ($answer_value->getTermId() == $value))
{
$points += $answer_value->getPoints();
$solution["points"] = $answer_value->getPoints();
$solution["term"] = $value;
$solution["definition"] = $found_value2[$key];
$solution["true"] = 1;
}
else
{
$solution["term"] = $value;
$solution["definition"] = $found_value2[$key];
}
}
$counter++;
array_push($user_result, $solution);
}
return $user_result;
}
Here is the call graph for this function:| ASS_MatchingQuestion::isComplete | ( | ) |
Returns true, if a matching question is complete for use.
Returns true, if a matching question is complete for use
Reimplemented from ASS_Question.
Definition at line 105 of file class.assMatchingQuestion.php.
Referenced by saveToDb(), and syncWithOriginal().
{
if (($this->title) and ($this->author) and ($this->question) and (count($this->matchingpairs)))
{
return true;
}
else
{
return false;
}
}
Here is the caller graph for this function:| ASS_MatchingQuestion::loadFromDb | ( | $ | question_id | ) |
Loads a ASS_MatchingQuestion object from a database.
Loads a ASS_MatchingQuestion object from a database (experimental)
| object | $db A pear DB object | |
| integer | $question_id A unique key which defines the multiple choice test in the database public |
Reimplemented from ASS_Question.
Definition at line 787 of file class.assMatchingQuestion.php.
References $data, ASS_Question::$ilias, $query, $result, and ASS_Question::setEstimatedWorkingTime().
{
global $ilias;
$db =& $ilias->db;
$query = sprintf("SELECT * FROM qpl_questions WHERE question_id = %s",
$db->quote($question_id)
);
$result = $db->query($query);
if (strcmp(strtolower(get_class($result)), db_result) == 0)
{
if ($result->numRows() == 1)
{
$data = $result->fetchRow(DB_FETCHMODE_OBJECT);
$this->id = $question_id;
$this->title = $data->title;
$this->comment = $data->comment;
$this->author = $data->author;
$this->solution_hint = $data->solution_hint;
$this->obj_id = $data->obj_fi;
$this->original_id = $data->original_id;
$this->owner = $data->owner;
$this->matching_type = $data->matching_type;
$this->question = $data->question_text;
$this->points = $data->points;
$this->shuffle = $data->shuffle;
$this->setEstimatedWorkingTime(substr($data->working_time, 0, 2), substr($data->working_time, 3, 2), substr($data->working_time, 6, 2));
}
$query = sprintf("SELECT * FROM qpl_answers WHERE question_fi = %s ORDER BY answer_id ASC",
$db->quote($question_id)
);
$result = $db->query($query);
if (strcmp(strtolower(get_class($result)), db_result) == 0)
{
while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT))
{
array_push($this->matchingpairs, new ASS_AnswerMatching($data->answertext, $data->points, $data->aorder, $data->matchingtext, $data->matching_order));
}
}
}
parent::loadFromDb($question_id);
}
Here is the call graph for this function:| ASS_MatchingQuestion::pc_array_shuffle | ( | $ | array | ) |
Definition at line 1440 of file class.assMatchingQuestion.php.
Referenced by createRandomSolution().
{
$i = count($array);
mt_srand((double)microtime()*1000000);
while(--$i)
{
$j = mt_rand(0, $i);
if ($i != $j)
{
// swap elements
$tmp = $array[$j];
$array[$j] = $array[$i];
$array[$i] = $tmp;
}
}
return $array;
}
Here is the caller graph for this function:| ASS_MatchingQuestion::saveToDb | ( | $ | original_id = "" |
) |
Saves a ASS_MatchingQuestion object to a database.
Saves a ASS_MatchingQuestion object to a database (experimental)
| object | $db A pear DB object public |
Reimplemented from ASS_Question.
Definition at line 672 of file class.assMatchingQuestion.php.
References ASS_Question::$ilias, $query, $result, ASS_Question::createPageObject(), ASS_Question::getEstimatedWorkingTime(), getMaximumPoints(), getQuestionType(), ASS_Question::getTestId(), ASS_Question::insertIntoTest(), and isComplete().
Referenced by from_xml().
{
global $ilias;
$db =& $ilias->db;
$complete = 0;
if ($this->isComplete())
{
$complete = 1;
}
$estw_time = $this->getEstimatedWorkingTime();
$estw_time = sprintf("%02d:%02d:%02d", $estw_time['h'], $estw_time['m'], $estw_time['s']);
if ($original_id)
{
$original_id = $db->quote($original_id);
}
else
{
$original_id = "NULL";
}
if ($this->id == -1)
{
// Neuen Datensatz schreiben
$now = getdate();
$question_type = $this->getQuestionType();
$created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
$query = sprintf("INSERT INTO qpl_questions (question_id, question_type_fi, obj_fi, title, comment, author, owner, question_text, working_time, shuffle, matching_type, points, complete, created, original_id, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)",
$db->quote($question_type. ""),
$db->quote($this->obj_id. ""),
$db->quote($this->title. ""),
$db->quote($this->comment. ""),
$db->quote($this->author. ""),
$db->quote($this->owner. ""),
$db->quote($this->question. ""),
$db->quote($estw_time. ""),
$db->quote($this->shuffle . ""),
$db->quote($this->matching_type. ""),
$db->quote($this->getMaximumPoints() . ""),
$db->quote($complete. ""),
$db->quote($created. ""),
$original_id
);
$result = $db->query($query);
if ($result == DB_OK)
{
$this->id = $this->ilias->db->getLastInsertId();
// create page object of question
$this->createPageObject();
// Falls die Frage in einen Test eingef�gt werden soll, auch diese Verbindung erstellen
if ($this->getTestId() > 0)
{
$this->insertIntoTest($this->getTestId());
}
}
}
else
{
// Vorhandenen Datensatz aktualisieren
$query = sprintf("UPDATE qpl_questions SET obj_fi = %s, title = %s, comment = %s, author = %s, question_text = %s, working_time=%s, shuffle = %s, matching_type = %s, points = %s, complete = %s WHERE question_id = %s",
$db->quote($this->obj_id. ""),
$db->quote($this->title. ""),
$db->quote($this->comment. ""),
$db->quote($this->author. ""),
$db->quote($this->question. ""),
$db->quote($estw_time. ""),
$db->quote($this->shuffle . ""),
$db->quote($this->matching_type. ""),
$db->quote($this->getMaximumPoints() . ""),
$db->quote($complete. ""),
$db->quote($this->id. "")
);
$result = $db->query($query);
}
if ($result == DB_OK)
{
// Antworten schreiben
// alte Antworten löschen
$query = sprintf("DELETE FROM qpl_answers WHERE question_fi = %s",
$db->quote($this->id)
);
$result = $db->query($query);
// Anworten wegschreiben
foreach ($this->matchingpairs as $key => $value)
{
$matching_obj = $this->matchingpairs[$key];
$query = sprintf("INSERT INTO qpl_answers (answer_id, question_fi, answertext, points, aorder, matchingtext, matching_order, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, NULL)",
$db->quote($this->id),
$db->quote($matching_obj->getTerm() . ""),
$db->quote($matching_obj->getPoints() . ""),
$db->quote($matching_obj->getTermId() . ""),
$db->quote($matching_obj->getDefinition() . ""),
$db->quote($matching_obj->getDefinitionId() . "")
);
$matching_result = $db->query($query);
}
}
parent::saveToDb($original_id);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ASS_MatchingQuestion::saveWorkingData | ( | $ | test_id, | |
| $ | limit_to = LIMIT_NO_LIMIT | |||
| ) |
Saves the learners input of the question to the database.
Saves the learners input of the question to the database
| integer | $test_id The database id of the test containing this question |
Reimplemented from ASS_Question.
Definition at line 1325 of file class.assMatchingQuestion.php.
References $_POST, $ilUser, $query, $result, ASS_Question::$test_id, checkSaveData(), and ASS_Question::getId().
{
global $ilDB;
global $ilUser;
$saveWorkingDataResult = $this->checkSaveData();
if ($saveWorkingDataResult)
{
$db =& $ilDB->db;
$query = sprintf("DELETE FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s",
$db->quote($ilUser->id),
$db->quote($test_id),
$db->quote($this->getId())
);
$result = $db->query($query);
foreach ($_POST as $key => $value)
{
if (preg_match("/^sel_matching_(\d+)/", $key, $matches))
{
if (!(preg_match("/initial_value_\d+/", $value)))
{
$query = sprintf("INSERT INTO tst_solutions (solution_id, user_fi, test_fi, question_fi, value1, value2, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, NULL)",
$db->quote($ilUser->id),
$db->quote($test_id),
$db->quote($this->getId()),
$db->quote($value),
$db->quote($matches[1])
);
$result = $db->query($query);
}
}
}
$saveWorkingDataResult = true;
}
parent::saveWorkingData($test_id);
return $saveWorkingDataResult;
}
Here is the call graph for this function:| ASS_MatchingQuestion::set_image_file | ( | $ | image_filename, | |
| $ | image_tempfilename = "" | |||
| ) |
Sets the image file.
Sets the image file and uploads the image to the object's image directory.
| string | $image_filename Name of the original image file | |
| string | $image_tempfilename Name of the temporary uploaded image file |
Definition at line 1246 of file class.assMatchingQuestion.php.
References $result, ilUtil::convertImage(), ASS_Question::getImagePath(), ilObjMediaObject::getMimeType(), ilUtil::makeDirParents(), and ilUtil::moveUploadedFile().
{
$result = 0;
if (!empty($image_tempfilename))
{
$image_filename = str_replace(" ", "_", $image_filename);
$imagepath = $this->getImagePath();
if (!file_exists($imagepath))
{
ilUtil::makeDirParents($imagepath);
}
//if (!move_uploaded_file($image_tempfilename, $imagepath . $image_filename))
if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $imagepath.$image_filename))
{
$result = 2;
}
else
{
require_once "./content/classes/Media/class.ilObjMediaObject.php";
$mimetype = ilObjMediaObject::getMimeType($imagepath . $image_filename);
if (!preg_match("/^image/", $mimetype))
{
unlink($imagepath . $image_filename);
$result = 1;
}
else
{
// create thumbnail file
$thumbpath = $imagepath . $image_filename . "." . "thumb.jpg";
ilUtil::convertImage($imagepath.$image_filename, $thumbpath, "JPEG", 100);
}
}
}
return $result;
}
Here is the call graph for this function:| ASS_MatchingQuestion::set_matching_type | ( | $ | matching_type = MT_TERMS_DEFINITIONS |
) |
Sets the matching question type.
Sets the matching question type
| integer | $matching_type The question matching type public |
Definition at line 940 of file class.assMatchingQuestion.php.
References $matching_type.
Referenced by from_xml().
{
$this->matching_type = $matching_type;
}
Here is the caller graph for this function:| ASS_MatchingQuestion::set_question | ( | $ | question = "" |
) |
Sets the matching question text.
Sets the matching question text
| string | $question The question text public |
Definition at line 926 of file class.assMatchingQuestion.php.
References $question.
Referenced by from_xml().
{
$this->question = $question;
}
Here is the caller graph for this function:| ASS_MatchingQuestion::syncWithOriginal | ( | ) |
Reimplemented from ASS_Question.
Definition at line 1384 of file class.assMatchingQuestion.php.
References ASS_Question::$ilias, $query, $result, ASS_Question::getEstimatedWorkingTime(), getMaximumPoints(), and isComplete().
{
global $ilias;
if ($this->original_id)
{
$complete = 0;
if ($this->isComplete())
{
$complete = 1;
}
$db = & $ilias->db;
$estw_time = $this->getEstimatedWorkingTime();
$estw_time = sprintf("%02d:%02d:%02d", $estw_time['h'], $estw_time['m'], $estw_time['s']);
$query = sprintf("UPDATE qpl_questions SET obj_fi = %s, title = %s, comment = %s, author = %s, question_text = %s, working_time=%s, matching_type = %s, points = %s, complete = %s WHERE question_id = %s",
$db->quote($this->obj_id. ""),
$db->quote($this->title. ""),
$db->quote($this->comment. ""),
$db->quote($this->author. ""),
$db->quote($this->question. ""),
$db->quote($estw_time. ""),
$db->quote($this->matching_type. ""),
$db->quote($this->getMaximumPoints() . ""),
$db->quote($complete. ""),
$db->quote($this->original_id. "")
);
$result = $db->query($query);
if ($result == DB_OK)
{
// write answers
// delete old answers
$query = sprintf("DELETE FROM qpl_answers WHERE question_fi = %s",
$db->quote($this->original_id)
);
$result = $db->query($query);
foreach ($this->matchingpairs as $key => $value)
{
$matching_obj = $this->matchingpairs[$key];
$query = sprintf("INSERT INTO qpl_answers (answer_id, question_fi, answertext, points, aorder, matchingtext, matching_order, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, NULL)",
$db->quote($this->original_id . ""),
$db->quote($matching_obj->getTerm() . ""),
$db->quote($matching_obj->getPoints() . ""),
$db->quote($matching_obj->getTermId() . ""),
$db->quote($matching_obj->getDefinition() . ""),
$db->quote($matching_obj->getDefinitionId() . "")
);
$matching_result = $db->query($query);
}
}
parent::syncWithOriginal();
}
}
Here is the call graph for this function:| ASS_MatchingQuestion::to_xml | ( | $ | a_include_header = true, |
|
| $ | a_include_binary = true, |
|||
| $ | a_shuffle = false, |
|||
| $ | test_output = false | |||
| ) |
Returns a QTI xml representation of the question.
Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation
Definition at line 364 of file class.assMatchingQuestion.php.
References $pos, $xml, domxml_open_mem(), get_matching_type(), get_question(), ASS_Question::getAuthor(), ASS_Question::getComment(), ASS_Question::getEstimatedWorkingTime(), ASS_Question::getImagePath(), ASS_Question::getImagePathWeb(), ASS_Question::getOutputType(), ASS_Question::getShuffle(), ASS_Question::getSuggestedSolution(), ASS_Question::getTitle(), and ASS_Question::pcArrayShuffle().
{
if (!empty($this->domxml))
{
$this->domxml->free();
}
$xml_header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<questestinterop></questestinterop>\n";
$this->domxml = domxml_open_mem($xml_header);
$root = $this->domxml->document_element();
// qti comment with version information
$qtiComment = $this->domxml->create_element("qticomment");
// qti ident
$qtiIdent = $this->domxml->create_element("item");
$qtiIdent->set_attribute("ident", "il_".IL_INST_ID."_qst_".$this->getId());
$qtiIdent->set_attribute("title", $this->getTitle());
$root->append_child($qtiIdent);
// add question description
$qtiComment = $this->domxml->create_element("qticomment");
$qtiCommentText = $this->domxml->create_text_node($this->getComment());
$qtiComment->append_child($qtiCommentText);
$qtiIdent->append_child($qtiComment);
// add estimated working time
$qtiDuration = $this->domxml->create_element("duration");
$workingtime = $this->getEstimatedWorkingTime();
$qtiDurationText = $this->domxml->create_text_node(sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]));
$qtiDuration->append_child($qtiDurationText);
$qtiIdent->append_child($qtiDuration);
// add ILIAS specific metadata
$qtiItemmetadata = $this->domxml->create_element("itemmetadata");
$qtiMetadata = $this->domxml->create_element("qtimetadata");
$qtiMetadatafield = $this->domxml->create_element("qtimetadatafield");
$qtiFieldlabel = $this->domxml->create_element("fieldlabel");
$qtiFieldlabelText = $this->domxml->create_text_node("ILIAS_VERSION");
$qtiFieldlabel->append_child($qtiFieldlabelText);
$qtiFieldentry = $this->domxml->create_element("fieldentry");
$qtiFieldentryText = $this->domxml->create_text_node($this->ilias->getSetting("ilias_version"));
$qtiFieldentry->append_child($qtiFieldentryText);
$qtiMetadatafield->append_child($qtiFieldlabel);
$qtiMetadatafield->append_child($qtiFieldentry);
$qtiMetadata->append_child($qtiMetadatafield);
$qtiMetadatafield = $this->domxml->create_element("qtimetadatafield");
$qtiFieldlabel = $this->domxml->create_element("fieldlabel");
$qtiFieldlabelText = $this->domxml->create_text_node("QUESTIONTYPE");
$qtiFieldlabel->append_child($qtiFieldlabelText);
$qtiFieldentry = $this->domxml->create_element("fieldentry");
$qtiFieldentryText = $this->domxml->create_text_node(MATCHING_QUESTION_IDENTIFIER);
$qtiFieldentry->append_child($qtiFieldentryText);
$qtiMetadatafield->append_child($qtiFieldlabel);
$qtiMetadatafield->append_child($qtiFieldentry);
$qtiMetadata->append_child($qtiMetadatafield);
$qtiMetadatafield = $this->domxml->create_element("qtimetadatafield");
$qtiFieldlabel = $this->domxml->create_element("fieldlabel");
$qtiFieldlabelText = $this->domxml->create_text_node("AUTHOR");
$qtiFieldlabel->append_child($qtiFieldlabelText);
$qtiFieldentry = $this->domxml->create_element("fieldentry");
$qtiFieldentryText = $this->domxml->create_text_node($this->getAuthor());
$qtiFieldentry->append_child($qtiFieldentryText);
$qtiMetadatafield->append_child($qtiFieldlabel);
$qtiMetadatafield->append_child($qtiFieldentry);
$qtiMetadata->append_child($qtiMetadatafield);
$qtiItemmetadata->append_child($qtiMetadata);
$qtiIdent->append_child($qtiItemmetadata);
// PART I: qti presentation
$qtiPresentation = $this->domxml->create_element("presentation");
$qtiPresentation->set_attribute("label", $this->getTitle());
// add flow to presentation
$qtiFlow = $this->domxml->create_element("flow");
// add material with question text to presentation
$qtiMaterial = $this->domxml->create_element("material");
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatTextText = $this->domxml->create_text_node($this->get_question());
$qtiMatText->append_child($qtiMatTextText);
$qtiMaterial->append_child($qtiMatText);
$qtiFlow->append_child($qtiMaterial);
// add answers to presentation
$qtiResponseGrp = $this->domxml->create_element("response_grp");
if ($this->get_matching_type() == MT_TERMS_PICTURES)
{
$qtiResponseGrp->set_attribute("ident", "MQP");
$qtiResponseGrp->set_attribute("rcardinality", "Multiple");
if ($this->getOutputType() == OUTPUT_JAVASCRIPT)
{
$qtiResponseGrp->set_attribute("output", "javascript");
}
}
else
{
$qtiResponseGrp->set_attribute("ident", "MQT");
$qtiResponseGrp->set_attribute("rcardinality", "Multiple");
if ($this->getOutputType() == OUTPUT_JAVASCRIPT)
{
$qtiResponseGrp->set_attribute("output", "javascript");
}
}
$solution = $this->getSuggestedSolution(0);
if (count($solution))
{
if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches))
{
$qtiMaterial = $this->domxml->create_element("material");
$qtiMaterial->set_attribute("label", "suggested_solution");
$qtiMatText = $this->domxml->create_element("mattext");
$intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
if (strcmp($matches[1], "") != 0)
{
$intlink = $solution["internal_link"];
}
$qtiMatTextText = $this->domxml->create_text_node($intlink);
$qtiMatText->append_child($qtiMatTextText);
$qtiMaterial->append_child($qtiMatText);
$qtiResponseGrp->append_child($qtiMaterial);
}
}
$qtiRenderChoice = $this->domxml->create_element("render_choice");
// shuffle output
if ($this->getShuffle())
{
$qtiRenderChoice->set_attribute("shuffle", "Yes");
}
else
{
$qtiRenderChoice->set_attribute("shuffle", "No");
}
// add answertext
$matchingtext_orders = array();
foreach ($this->matchingpairs as $index => $matchingpair)
{
array_push($matchingtext_orders, $matchingpair->getTermId());
}
// shuffle it
$pkeys = array_keys($this->matchingpairs);
if ($this->getshuffle() && $a_shuffle)
{
$pkeys = $this->pcArrayShuffle($pkeys);
}
// add answers
foreach ($pkeys as $index)
{
$matchingpair = $this->matchingpairs[$index];
$qtiResponseLabel = $this->domxml->create_element("response_label");
$qtiResponseLabel->set_attribute("ident", $matchingpair->getDefinitionId());
$qtiResponseLabel->set_attribute("match_max", "1");
$qtiResponseLabel->set_attribute("match_group", join($matchingtext_orders, ","));
$qtiMaterial = $this->domxml->create_element("material");
if ($this->get_matching_type() == MT_TERMS_PICTURES)
{
$qtiMatImage = $this->domxml->create_element("matimage");
$qtiMatImage->set_attribute("imagtype", "image/jpeg");
$qtiMatImage->set_attribute("label", $matchingpair->getPicture());
if ($test_output)
{
$qtiMatImage->set_attribute("uri", $this->getImagePathWeb() . $matchingpair->getPicture());
}
else
{
$qtiMatImage->set_attribute("embedded", "base64");
$imagepath = $this->getImagePath() . $matchingpair->getPicture();
$fh = @fopen($imagepath, "rb");
if ($fh == false)
{
//global $ilErr;
//$ilErr->raiseError($this->lng->txt("error_open_image_file"), $ilErr->MESSAGE);
//return;
}
else
{
$imagefile = fread($fh, filesize($imagepath));
fclose($fh);
$base64 = base64_encode($imagefile);
$qtiBase64Data = $this->domxml->create_text_node($base64);
$qtiMatImage->append_child($qtiBase64Data);
}
}
$qtiMaterial->append_child($qtiMatImage);
}
else
{
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatTextText = $this->domxml->create_text_node($matchingpair->getDefinition());
$qtiMatText->append_child($qtiMatTextText);
$qtiMaterial->append_child($qtiMatText);
}
$qtiResponseLabel->append_child($qtiMaterial);
$qtiRenderChoice->append_child($qtiResponseLabel);
}
// shuffle again to get another order for the terms or pictures
if ($this->getshuffle() && $a_shuffle)
{
$pkeys = $this->pcArrayShuffle($pkeys);
}
// add matchingtext
foreach ($pkeys as $index)
{
$matchingpair = $this->matchingpairs[$index];
$qtiResponseLabel = $this->domxml->create_element("response_label");
$qtiResponseLabel->set_attribute("ident", $matchingpair->getTermId());
$qtiMaterial = $this->domxml->create_element("material");
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatTextText = $this->domxml->create_text_node($matchingpair->getTerm());
$qtiMatText->append_child($qtiMatTextText);
$qtiMaterial->append_child($qtiMatText);
$qtiResponseLabel->append_child($qtiMaterial);
$qtiRenderChoice->append_child($qtiResponseLabel);
}
$qtiResponseGrp->append_child($qtiRenderChoice);
$qtiFlow->append_child($qtiResponseGrp);
$qtiPresentation->append_child($qtiFlow);
$qtiIdent->append_child($qtiPresentation);
// PART II: qti resprocessing
$qtiResprocessing = $this->domxml->create_element("resprocessing");
$qtiOutcomes = $this->domxml->create_element("outcomes");
$qtiDecvar = $this->domxml->create_element("decvar");
$qtiOutcomes->append_child($qtiDecvar);
$qtiResprocessing->append_child($qtiOutcomes);
// add response conditions
foreach ($this->matchingpairs as $index => $matchingpair)
{
$qtiRespcondition = $this->domxml->create_element("respcondition");
$qtiRespcondition->set_attribute("continue", "Yes");
// qti conditionvar
$qtiConditionvar = $this->domxml->create_element("conditionvar");
$qtiVarsubset = $this->domxml->create_element("varsubset");
if ($this->get_matching_type() == MT_TERMS_PICTURES)
{
$qtiVarsubset->set_attribute("respident", "MQP");
}
else
{
$qtiVarsubset->set_attribute("respident", "MQT");
}
$qtiVarsubsetText = $this->domxml->create_text_node($matchingpair->getTermId() . "," . $matchingpair->getDefinitionId());
$qtiVarsubset->append_child($qtiVarsubsetText);
$qtiConditionvar->append_child($qtiVarsubset);
// qti setvar
$qtiSetvar = $this->domxml->create_element("setvar");
$qtiSetvar->set_attribute("action", "Add");
$qtiSetvarText = $this->domxml->create_text_node($matchingpair->getPoints());
$qtiSetvar->append_child($qtiSetvarText);
// qti displayfeedback
$qtiDisplayfeedback = $this->domxml->create_element("displayfeedback");
$qtiDisplayfeedback->set_attribute("feedbacktype", "Response");
$qtiDisplayfeedback->set_attribute("linkrefid", "correct_" . $matchingpair->getTermId() . "_" . $matchingpair->getDefinitionId());
$qtiRespcondition->append_child($qtiConditionvar);
$qtiRespcondition->append_child($qtiSetvar);
$qtiRespcondition->append_child($qtiDisplayfeedback);
$qtiResprocessing->append_child($qtiRespcondition);
}
$qtiIdent->append_child($qtiResprocessing);
// PART III: qti itemfeedback
foreach ($this->matchingpairs as $index => $matchingpair)
{
$qtiItemfeedback = $this->domxml->create_element("itemfeedback");
$qtiItemfeedback->set_attribute("ident", "correct_" . $matchingpair->getTermId() . "_" . $matchingpair->getDefinitionId());
$qtiItemfeedback->set_attribute("view", "All");
// qti flow_mat
$qtiFlowmat = $this->domxml->create_element("flow_mat");
$qtiMaterial = $this->domxml->create_element("material");
$qtiMattext = $this->domxml->create_element("mattext");
// Insert response text for right/wrong answers here!!!
$qtiMattextText = $this->domxml->create_text_node("");
$qtiMattext->append_child($qtiMattextText);
$qtiMaterial->append_child($qtiMattext);
$qtiFlowmat->append_child($qtiMaterial);
$qtiItemfeedback->append_child($qtiFlowmat);
$qtiIdent->append_child($qtiItemfeedback);
}
$xml = $this->domxml->dump_mem(true);
if (!$a_include_header)
{
$pos = strpos($xml, "?>");
$xml = substr($xml, $pos + 2);
}
//echo htmlentities($xml);
return $xml;
}
Here is the call graph for this function:| ASS_MatchingQuestion::$matching_type |
Definition at line 68 of file class.assMatchingQuestion.php.
Referenced by ASS_MatchingQuestion(), and set_matching_type().
| ASS_MatchingQuestion::$matchingpairs |
Definition at line 58 of file class.assMatchingQuestion.php.
| ASS_MatchingQuestion::$question |
Definition at line 49 of file class.assMatchingQuestion.php.
Referenced by ASS_MatchingQuestion(), and set_question().
1.7.1