24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
215 $this->original_id = null;
222 $this->author = $this->ilias->account->fullname;
225 if ($this->owner == -1)
227 $this->owner = $this->ilias->account->id;
231 $this->suggested_solutions = array();
235 register_shutdown_function(array(&$this,
'_assQuestion'));
240 if (!empty($this->domxml))
242 $this->domxml->free();
259 function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
261 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class." . $this->
getQuestionType() .
"Import.php";
263 $import =
new $classname($this);
264 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
276 function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
278 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class." . $this->
getQuestionType() .
"Export.php";
280 $export =
new $classname($this);
281 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
310 $query = sprintf(
"SELECT * FROM qpl_questions WHERE obj_fi = %s AND title = %s",
311 $ilDB->quote($questionpool_id .
""),
314 $result = $ilDB->query($query);
315 if ($result->numRows() == 1)
361 $this->test_id =
$id;
427 $this->est_working_time = array(
"h" => (
int)$hour,
"m" => (
int)$min,
"s" => (
int)$sec);
443 foreach ($array as $key => $value)
445 if (strcmp($key, $searchkey)==0)
467 $author = $this->ilias->account->fullname;
594 if (!$this->est_working_time)
596 $this->est_working_time = array(
"h" => 0,
"m" => 0,
"s" => 0);
664 include_once
"./Services/COPage/classes/class.ilPageObject.php";
666 $this->page->setId($this->
getId());
667 $this->page->setParentId($qpl_id);
668 $this->page->setXMLContent(
"<PageObject><PageContent>".
669 "<Question QRef=\"il__qst_".$this->
getId().
"\"/>".
670 "</PageContent></PageObject>");
671 $this->page->create();
687 $query = sprintf(
"SELECT MAX(sequence) AS seq FROM dum_test_question WHERE test_fi=%s",
690 $result = $ilDB->query($query);
692 if ($result->numRows() == 1)
694 $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
695 $sequence =
$data->seq + 1;
697 $query = sprintf(
"INSERT INTO dum_test_question (test_question_id, test_fi, question_fi, sequence, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
699 $ilDB->quote($this->
getId()),
700 $ilDB->quote($sequence)
702 $result = $ilDB->query($query);
703 if (PEAR::isError($result))
706 $ilias->raiseError($result->getMessage());
724 $query = sprintf(
"SELECT points FROM qpl_questions WHERE question_id = %s",
725 $ilDB->quote($question_id .
"")
727 $result = $ilDB->query($query);
728 if ($result->numRows() == 1)
730 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
749 $query = sprintf(
"SELECT qpl_questions.*, qpl_question_type.type_tag FROM qpl_question_type, qpl_questions WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_question_type.question_type_id",
750 $ilDB->quote($question_id .
"")
752 $result = $ilDB->query($query);
753 if ($result->numRows())
755 return $result->fetchRow(MDB2_FETCHMODE_ASSOC);
773 $query = sprintf(
"SELECT suggested_solution_id FROM qpl_suggested_solutions WHERE question_fi = %s",
774 $ilDB->quote($question_id .
"")
776 $result = $ilDB->query($query);
777 return $result->numRows();
794 $query = sprintf(
"SELECT * FROM qpl_suggested_solutions WHERE question_fi = %s AND subquestion_index = %s",
795 $ilDB->quote($question_id .
""),
796 $ilDB->quote($subquestion_index .
"")
798 $result = $ilDB->query($query);
799 if ($result->numRows() == 1)
801 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
803 "internal_link" => $row[
"internal_link"],
804 "import_id" => $row[
"import_id"]
830 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
833 $query = sprintf(
"SELECT * FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
834 $ilDB->quote($active_id .
""),
835 $ilDB->quote($question_id .
""),
836 $ilDB->quote(
$pass .
"")
838 $result = $ilDB->query($query);
839 if ($result->numRows() == 1)
841 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
890 include_once
"./Modules/Test/classes/class.ilObjTest.php";
894 $query = sprintf(
"REPLACE INTO tst_test_result (active_fi, question_fi, pass, points) VALUES (%s, %s, %s, %s)",
895 $ilDB->quote($active_id .
""),
896 $ilDB->quote($this->
getId() .
""),
897 $ilDB->quote(
$pass .
""),
898 $ilDB->quote($reached_points .
"")
900 $result = $ilDB->query($query);
901 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
911 include_once
'Modules/Course/classes/class.ilCourseObjectiveResult.php';
919 include_once
"./Modules/Test/classes/class.ilObjTest.php";
923 $query = sprintf(
"SELECT SUM(points) AS reachedpoints, COUNT(question_fi) AS answeredquestions FROM tst_test_result WHERE active_fi = %s AND pass = %s",
924 $ilDB->quote($active_id .
""),
925 $ilDB->quote(
$pass .
"")
927 $result = $ilDB->query($query);
928 if ($result->numRows() > 0)
930 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
931 $newresultquery = sprintf(
"REPLACE INTO tst_test_pass_result SET active_fi = %s, pass = %s, points = %s, maxpoints = %s, questioncount = %s, answeredquestions = %s, workingtime = %s",
932 $ilDB->quote($active_id .
""),
933 $ilDB->quote(
$pass .
""),
934 $ilDB->quote((($row[
"reachedpoints"]) ? $row[
"reachedpoints"] : 0) .
""),
935 $ilDB->quote(
$data[
"points"]),
936 $ilDB->quote(
$data[
"count"]),
937 $ilDB->quote($row[
"answeredquestions"]),
940 $ilDB->query($newresultquery);
952 function logAction($logtext =
"", $active_id =
"", $question_id =
"")
957 if (strcmp($question_id,
"") != 0)
959 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
962 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
963 include_once
"./Modules/Test/classes/class.ilObjTest.php";
976 function _logAction($logtext =
"", $active_id =
"", $question_id =
"")
981 if (strcmp($question_id,
"") != 0)
983 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
986 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
987 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1000 $mediatempdir = CLIENT_WEB_DIR .
"/assessment/temp";
1002 $temp_name = tempnam($mediatempdir, $name .
"_____");
1003 $temp_name = str_replace(
"\\",
"/", $temp_name);
1004 @unlink($temp_name);
1024 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/java/";
1037 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/images/";
1050 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/flash/";
1063 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1078 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1093 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1134 $query = sprintf(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
1135 $ilDB->quote($active_id .
""),
1136 $ilDB->quote($this->
getId() .
""),
1137 $ilDB->quote(
$pass .
"")
1139 $result = $ilDB->query($query);
1140 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
1142 array_push($values, $row);
1160 if ($question_id < 1) $question_id =
$this->id;
1161 $query = sprintf(
"SELECT COUNT(qpl_questions.question_id) AS question_count FROM qpl_questions, tst_test_question WHERE qpl_questions.original_id = %s AND qpl_questions.question_id = tst_test_question.question_fi",
1162 $ilDB->quote($question_id .
"")
1164 $result = $ilDB->query($query);
1165 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
1166 $count = $row[
"question_count"];
1168 $query = sprintf(
"SELECT DISTINCT tst_active.test_fi, qpl_questions.question_id FROM qpl_questions, tst_test_random_question, tst_active WHERE qpl_questions.original_id = %s AND qpl_questions.question_id = tst_test_random_question.question_fi AND tst_test_random_question.active_fi = tst_active.active_id",
1169 $ilDB->quote($question_id .
"")
1171 $result = $ilDB->query($query);
1172 $count += $result->numRows();
1189 if ($question_id < 1) $question_id =
$this->id;
1190 $query = sprintf(
"SELECT original_id FROM qpl_questions WHERE question_id = %s",
1191 $ilDB->quote($question_id .
"")
1193 $result = $ilDB->query($query);
1194 $row = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
1195 if ($row->original_id > 0)
1215 mt_srand((
double)microtime()*1000000);
1221 $j = mt_rand(0, $i);
1226 $array[$j] = $array[$i];
1243 $query = sprintf(
"SELECT qpl_question_type.type_tag FROM qpl_question_type, qpl_questions WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_question_type.question_type_id",
1244 $ilDB->quote($question_id));
1246 $result = $ilDB->query($query);
1247 $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
1249 return $data->type_tag;
1290 if (is_array($answer_table_name))
1292 foreach ($answer_table_name as $table)
1296 $query = sprintf(
"DELETE FROM $table WHERE question_fi = %s",
1297 $ilDB->quote($question_id .
"")
1299 $result = $ilDB->query($query);
1305 if (strlen($answer_table_name))
1307 $query = sprintf(
"DELETE FROM $answer_table_name WHERE question_fi = %s",
1308 $ilDB->quote($question_id .
"")
1310 $result = $ilDB->query($query);
1327 if (is_array($additional_table_name))
1329 foreach ($additional_table_name as $table)
1333 $query = sprintf(
"DELETE FROM $table WHERE question_fi = %s",
1334 $ilDB->quote($question_id .
"")
1336 $result = $ilDB->query($query);
1342 if (strlen($additional_table_name))
1344 $query = sprintf(
"DELETE FROM $additional_table_name WHERE question_fi = %s",
1345 $ilDB->quote($question_id .
"")
1347 $result = $ilDB->query($query);
1360 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1371 function delete($question_id)
1375 if ($question_id < 1)
1378 $query = sprintf(
"SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
1379 $ilDB->quote($question_id)
1381 $result = $ilDB->query($query);
1382 if ($result->numRows() == 1)
1384 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
1392 $query = sprintf(
"DELETE FROM qpl_questions WHERE question_id = %s",
1393 $ilDB->quote($question_id)
1395 $result = $ilDB->query($query);
1401 $querydelete = sprintf(
"DELETE FROM tst_test_question WHERE question_fi = %s", $ilDB->quote($question_id));
1402 $deleteresult = $ilDB->query($querydelete);
1405 $querydelete = sprintf(
"DELETE FROM qpl_suggested_solutions WHERE question_fi = %s", $ilDB->quote($question_id));
1406 $deleteresult = $ilDB->query($querydelete);
1408 $directory = CLIENT_WEB_DIR .
"/assessment/" .
$obj_id .
"/$question_id";
1409 if (preg_match(
"/\d+/",
$obj_id) and preg_match(
"/\d+/", $question_id) and is_dir($directory))
1411 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1415 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1421 foreach(
$mobs as $mob)
1432 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1455 $query = sprintf(
"SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
1456 $ilDB->quote($a_q_id),
1457 $ilDB->quote($a_q_id)
1460 $result = $ilDB->query($query);
1462 if ($result->numRows() == 0)
1466 $found_id = array();
1467 while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
1469 array_push($found_id, $row->question_id);
1472 $query = sprintf(
"SELECT * FROM tst_test_result WHERE question_fi IN ('%s')",
1473 join($found_id,
"','"));
1474 $result = $ilDB->query($query);
1476 return $result->numRows();
1489 $query = sprintf(
"SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
1490 $ilDB->quote($a_q_id),
1491 $ilDB->quote($a_q_id)
1493 $result = $ilDB->query($query);
1494 if ($result->numRows() == 0)
1498 $found_id = array();
1499 while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
1501 array_push($found_id, $row->question_id);
1503 $query = sprintf(
"SELECT * FROM tst_test_result WHERE question_fi IN ('%s')",
1504 join($found_id,
"','"));
1505 $result = $ilDB->query($query);
1507 while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
1509 $reached = $row->points;
1510 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1512 array_push($answers, array(
"reached" => $reached,
"max" => $max));
1516 foreach ($answers as $key => $value)
1518 $max += $value[
"max"];
1519 $reached += $value[
"reached"];
1523 return $reached / $max;
1539 $query = sprintf(
"SELECT title FROM qpl_questions WHERE question_id = %s",
1540 $ilDB->quote($a_q_id)
1542 $result = $ilDB->query($query);
1543 if ($result->numRows() == 1)
1545 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
1546 return $row[
"title"];
1556 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1558 foreach (
$mobs as $mob)
1566 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1568 foreach (
$mobs as $mob)
1578 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1581 $xml = str_replace(
"il__qst_".$a_q_id,
"il__qst_".$this->
id,
1582 $page->getXMLContent());
1583 $this->page->setXMLContent($xml);
1584 $this->page->saveMobUsage($xml);
1585 $this->page->updateFromXML();
1591 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1593 return $page->getXMLContent();
1608 if ($question_id < 1)
1611 $query = sprintf(
"SELECT type_tag FROM qpl_questions, qpl_question_type WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_question_type.question_type_id",
1612 $ilDB->quote($question_id)
1614 $result = $ilDB->query($query);
1615 if ($result->numRows() == 1) {
1616 $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
1617 return $data->type_tag;
1635 if ($question_id < 1)
1638 $query = sprintf(
"SELECT title FROM qpl_questions WHERE qpl_questions.question_id = %s",
1639 $ilDB->quote($question_id)
1641 $result = $ilDB->query($query);
1642 if ($result->numRows() == 1) {
1643 $data = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
1644 return $data[
"title"];
1672 $query = sprintf(
"SELECT * FROM qpl_suggested_solutions WHERE question_fi = %s",
1673 $ilDB->quote($this->getId() .
"")
1675 $result = $ilDB->query($query);
1676 $this->suggested_solutions = array();
1679 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
1681 $this->suggested_solutions[$row[
"subquestion_index"]] = array(
1682 "internal_link" => $row[
"internal_link"],
1683 "import_id" => $row[
"import_id"]
1701 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1702 $query = sprintf(
"DELETE FROM qpl_suggested_solutions WHERE question_fi = %s",
1703 $ilDB->quote($this->getId() .
"")
1705 $result = $ilDB->query($query);
1707 foreach ($this->suggested_solutions as $index => $solution)
1709 $query = sprintf(
"INSERT INTO qpl_suggested_solutions (suggested_solution_id, question_fi, internal_link, import_id, subquestion_index, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
1710 $ilDB->quote($this->getId() .
""),
1711 $ilDB->quote($solution[
"internal_link"] .
""),
1712 $ilDB->quote($solution[
"import_id"] .
""),
1713 $ilDB->quote($index .
"")
1715 $ilDB->query($query);
1716 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
1724 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1728 $query = sprintf(
"UPDATE qpl_questions SET TIMESTAMP = NULL WHERE question_id = %s",
1731 $ilDB->query($query);
1745 $query = sprintf(
"DELETE FROM qpl_suggested_solutions WHERE question_fi = %s",
1746 $ilDB->quote($this->getId() .
"")
1748 $result = $ilDB->query($query);
1750 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1752 $this->suggested_solutions = array();
1766 if (array_key_exists($subquestion_index, $this->suggested_solutions))
1768 return $this->suggested_solutions[$subquestion_index];
1788 if (array_key_exists($subquestion_index, $this->suggested_solutions))
1790 $title = $this->suggested_solutions[$subquestion_index][
"internal_link"];
1813 if (strcmp($solution_id,
"") != 0)
1818 $import_id = $solution_id;
1821 $this->suggested_solutions[$subquestion_index] = array(
1822 "internal_link" => $solution_id,
1823 "import_id" => $import_id
1841 $statement = $ilDB->prepareManip(
"DELETE FROM qpl_suggested_solutions WHERE question_fi = ? AND subquestion_index = ?",
1842 array(
"integer",
"integer")
1848 $affectedRows = $ilDB->execute($statement,
$data);
1850 $statement = $ilDB->prepareManip(
"INSERT INTO qpl_suggested_solutions (question_fi, internal_link, import_id, subquestion_index) VALUES (?, ?, ?, ?)",
1851 array(
"integer",
"text",
"text",
"integer")
1859 $affectedRows = $ilDB->execute($statement,
$data);
1864 if (preg_match(
"/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches))
1866 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1867 include_once
"./Modules/LearningModule/classes/class.ilLMObject.php";
1868 include_once
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1869 switch ($matches[2])
1887 if (strcmp($resolved_link,
"") == 0)
1889 $resolved_link = $internal_link;
1894 $resolved_link = $internal_link;
1896 return $resolved_link;
1903 $query = sprintf(
"SELECT * FROM qpl_suggested_solutions WHERE question_fi = %s",
1904 $ilDB->quote($question_id .
"")
1906 $result = $ilDB->query($query);
1907 if ($result->numRows())
1909 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
1911 $internal_link = $row[
"internal_link"];
1912 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1914 if (strcmp($internal_link, $resolved_link) != 0)
1917 $queryupdate = sprintf(
"UPDATE qpl_suggested_solutions SET internal_link = %s WHERE suggested_solution_id = %s",
1918 $ilDB->quote($resolved_link),
1919 $ilDB->quote($row[
"suggested_solution_id"] .
"")
1921 $updateresult = $ilDB->query($queryupdate);
1931 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1934 $query = sprintf(
"SELECT * FROM qpl_suggested_solutions WHERE question_fi = %s",
1935 $ilDB->quote($question_id .
"")
1937 $result = $ilDB->query($query);
1938 if ($result->numRows())
1940 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
1942 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $row[
"internal_link"], $matches))
1955 "lm" =>
"LearningModule",
1956 "pg" =>
"PageObject",
1957 "st" =>
"StructureObject",
1958 "git" =>
"GlossaryItem",
1959 "mob" =>
"MediaObject"
1962 if (preg_match(
"/il__(\w+)_(\d+)/", $target, $matches))
1964 $type = $matches[1];
1966 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1967 switch($linktypes[$matches[1]])
1969 case "LearningModule":
1970 $href =
"./goto.php?target=" . $type .
"_" .
$target_id;
1973 case "StructureObject":
1974 $href =
"./goto.php?target=" . $type .
"_" .
$target_id;
1976 case "GlossaryItem":
1977 $href =
"./goto.php?target=" . $type .
"_" .
$target_id;
1980 $href =
"./ilias.php?baseClass=ilLMPresentationGUI&obj_type=" . $linktypes[$type] .
"&cmd=media&ref_id=".$_GET[
"ref_id"].
"&mob_id=".
$target_id;
1999 $query = sprintf(
"SELECT * FROM qpl_questions WHERE question_id = %s",
2000 $ilDB->quote($question_id .
"")
2002 $result = $ilDB->query($query);
2003 if ($result->numRows() > 0)
2005 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
2006 if ($row[
"original_id"] > 0)
2008 return $row[
"original_id"];
2012 return $row[
"question_id"];
2040 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
2041 $query = sprintf(
"DELETE FROM qpl_suggested_solutions WHERE question_fi = %s",
2042 $ilDB->quote($this->getOriginalId() .
"")
2044 $result = $ilDB->query($query);
2046 foreach ($this->suggested_solutions as $index => $solution)
2048 $query = sprintf(
"INSERT INTO qpl_suggested_solutions (suggested_solution_id, question_fi, internal_link, import_id, subquestion_index, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
2049 $ilDB->quote($this->getOriginalId() .
""),
2050 $ilDB->quote($solution[
"internal_link"] .
""),
2051 $ilDB->quote($solution[
"import_id"] .
""),
2052 $ilDB->quote($index .
"")
2054 $ilDB->query($query);
2055 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
2082 if ($question_id < 1)
2087 $query = sprintf(
"SELECT question_id FROM qpl_questions WHERE question_id = %s",
2088 $ilDB->quote($question_id)
2090 $result = $ilDB->query($query);
2091 if ($result->numRows() == 1)
2112 if (strcmp($question_id,
"") != 0)
2132 if (strcmp($this->points,
"") == 0)
2153 $this->points = $a_points;
2188 $query = sprintf(
"SELECT MAX(pass) as maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
2189 $ilDB->quote($active_id .
""),
2190 $ilDB->quote($question_id .
"")
2192 $result = $ilDB->query($query);
2193 if ($result->numRows() == 1)
2195 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
2196 return $row[
"maxpass"];
2218 if (($question_id < 1) || ($user_id < 1))
2223 $query = sprintf(
"SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
2224 $ilDB->quote($question_id .
"")
2226 $result = $ilDB->query($query);
2227 if ($result->numRows() == 1)
2229 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
2230 $qpl_object_id = $row[
"obj_fi"];
2231 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2252 if ($question_id < 1)
return 0;
2253 $query = sprintf(
"SELECT test_random_question_id FROM tst_test_random_question WHERE question_fi = %s",
2254 $ilDB->quote($question_id .
"")
2256 $result = $ilDB->query($query);
2257 return $result->numRows();
2273 include_once
"./Modules/Test/classes/class.ilObjTest.php";
2275 if ($count_system == 1)
2283 if ($score_cutting == 0)
2311 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
2314 $query = sprintf(
"SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
2315 $ilDB->quote($active_id .
""),
2316 $ilDB->quote($question_id .
""),
2317 $ilDB->quote(
$pass .
"")
2319 $result = $ilDB->query($query);
2320 if ($result->numRows())
2334 $multilineAnswerSetting = $ilUser->getPref(
"tst_multiline_answers");
2335 if ($multilineAnswerSetting != 1)
2337 $multilineAnswerSetting = 0;
2339 return $multilineAnswerSetting;
2345 $ilUser->writePref(
"tst_multiline_answers", $a_setting);
2360 $query =
"SELECT DISTINCT(question_fi) FROM tst_test_result JOIN tst_active ".
2361 "ON (active_id = active_fi) ".
2362 "WHERE question_fi IN ('".implode(
"','",$a_question_ids).
"') ".
2363 "AND user_fi = '".$a_user_id.
"'";
2364 $res = $ilDB->query($query);
2365 return (
$res->numRows() == count($a_question_ids)) ?
true :
false;
2377 if (preg_match(
"/<[^>]*?>/", $a_text))
2395 include_once
"./Services/Utilities/classes/class.ilUtil.php";
2409 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
2411 $material = $a_material->getMaterial($i);
2412 if (strcmp($material[
"type"],
"mattext") == 0)
2414 $result .= $material[
"material"]->getContent();
2416 if (strcmp($material[
"type"],
"matimage") == 0)
2418 $matimage = $material[
"material"];
2419 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
2422 if (!is_array(
$_SESSION[
"import_mob_xhtml"]))
$_SESSION[
"import_mob_xhtml"] = array();
2423 array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(),
"uri" => $matimage->getUri()));
2438 function addQTIMaterial(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE)
2440 include_once
"./Services/RTE/classes/class.ilRTE.php";
2441 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2443 $a_xml_writer->xmlStartTag(
"material");
2445 "texttype" =>
"text/plain"
2447 if ($this->
isHTML($a_material))
2449 $attrs[
"texttype"] =
"text/xhtml";
2455 foreach (
$mobs as $mob)
2457 $moblabel =
"il_" . IL_INST_ID .
"_mob_" . $mob;
2458 if (strpos($a_material,
"mm_$mob") !== FALSE)
2464 "label" => $moblabel,
2465 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
2468 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
2472 if ($close_material_tag) $a_xml_writer->xmlEndTag(
"material");
2478 if (preg_match(
"/.*\.(png|jpg|gif|jpeg)$/i", $image_filename, $matches))
2480 $extension =
"." . $matches[1];
2482 $image_filename = md5($image_filename) . $extension;
2483 return $image_filename;
2511 $query = sprintf(
"SELECT points FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
2512 $ilDB->quote($active_id .
""),
2513 $ilDB->quote($question_id .
""),
2514 $ilDB->quote(
$pass .
"")
2516 $result = $ilDB->query($query);
2517 if ($result->numRows())
2519 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
2520 $old_points = $row[
"points"];
2521 $query = sprintf(
"UPDATE tst_test_result SET points = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
2523 $ilDB->quote($active_id .
""),
2524 $ilDB->quote($question_id .
""),
2525 $ilDB->quote(
$pass .
"")
2530 $query = sprintf(
"INSERT INTO tst_test_result (active_fi, question_fi, points, pass) VALUES (%s, %s, %s, %s)",
2531 $ilDB->quote($active_id .
""),
2532 $ilDB->quote($question_id .
""),
2534 $ilDB->quote(
$pass .
"")
2537 $result = $ilDB->query($query);
2538 if (PEAR::isError($result))
2541 $ilias->raiseError($result->getMessage());
2545 include_once
"./Modules/Test/classes/class.ilObjTest.php";
2546 include_once
'./Modules/Course/classes/class.ilCourseObjectiveResult.php';
2549 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
2552 global
$lng, $ilUser;
2553 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
2620 $query = sprintf(
"SELECT question_type_id FROM qpl_question_type WHERE type_tag = %s",
2621 $ilDB->quote($this->getQuestionType() .
"")
2623 $result = $ilDB->query($query);
2626 $row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC);
2627 return $row[
"question_type_id"];
2647 switch ($correctness)
2657 $query = sprintf(
"DELETE FROM qpl_feedback_generic WHERE question_fi = %s AND correctness = %s",
2658 $ilDB->quote($this->getId() .
""),
2659 $ilDB->quote($correctness .
"")
2661 $result = $ilDB->query($query);
2662 if (strlen($feedback))
2664 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2665 $query = sprintf(
"INSERT INTO qpl_feedback_generic VALUES (NULL, %s, %s, %s, NULL)",
2666 $ilDB->quote($this->getId() .
""),
2667 $ilDB->quote($correctness .
""),
2670 $result = $ilDB->query($query);
2690 $query = sprintf(
"SELECT * FROM qpl_feedback_generic WHERE question_fi = %s AND correctness = %s",
2691 $ilDB->quote($this->getId() .
""),
2692 $ilDB->quote($correctness .
"")
2694 $result = $ilDB->query($query);
2695 if ($result->numRows())
2697 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
2698 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2717 $query = sprintf(
"SELECT * FROM qpl_feedback_generic WHERE question_fi = %s",
2720 $result = $ilDB->query($query);
2721 if ($result->numRows())
2723 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
2725 $duplicatequery = sprintf(
"INSERT INTO qpl_feedback_generic VALUES (NULL, %s, %s, %s, NULL)",
2726 $ilDB->quote($this->getId() .
""),
2727 $ilDB->quote($row[
"correctness"] .
""),
2728 $ilDB->quote($row[
"feedback"] .
"")
2730 $duplicateresult = $ilDB->query($duplicatequery);
2742 $deletequery = sprintf(
"DELETE FROM qpl_feedback_generic WHERE question_fi = %s",
2743 $ilDB->quote($this->original_id .
"")
2745 $result = $ilDB->query($deletequery);
2748 $query = sprintf(
"SELECT * FROM qpl_feedback_generic WHERE question_fi = %s",
2749 $ilDB->quote($this->getId() .
"")
2751 $result = $ilDB->query($query);
2754 if ($result->numRows())
2756 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
2758 $duplicatequery = sprintf(
"INSERT INTO qpl_feedback_generic VALUES (NULL, %s, %s, %s, NULL)",
2759 $ilDB->quote($this->original_id .
""),
2760 $ilDB->quote($row[
"correctness"] .
""),
2761 $ilDB->quote($row[
"feedback"] .
"")
2763 $duplicateresult = $ilDB->query($duplicatequery);
2789 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2801 $query = sprintf(
"SELECT question_id FROM qpl_questions WHERE original_id = %s",
2802 $ilDB->quote($this->getId())
2804 $result = $ilDB->query($query);
2805 $instances = array();
2807 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
2809 array_push($ids, $row[
"question_id"]);
2811 foreach ($ids as $question_id)
2813 $query = sprintf(
"SELECT DISTINCT object_data.obj_id, object_data.title FROM tst_test_question, object_data, tst_tests WHERE question_fi = %s AND tst_tests.test_id = tst_test_question.test_fi AND object_data.obj_id = tst_tests.obj_fi",
2814 $ilDB->quote($question_id .
"")
2816 $result = $ilDB->query($query);
2817 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
2819 $instances[$row[
"obj_id"]] = $row[
"title"];
2821 $query = sprintf(
"SELECT DISTINCT object_data.obj_id, object_data.title FROM tst_test_random_question, tst_active, object_data, tst_tests WHERE tst_test_random_question.active_fi = tst_active.active_id AND tst_test_random_question.question_fi = %s AND tst_tests.test_id = tst_active.test_fi AND object_data.obj_id = tst_tests.obj_fi",
2822 $ilDB->quote($question_id .
"")
2824 $result = $ilDB->query($query);
2825 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
2827 $instances[$row[
"obj_id"]] = $row[
"title"];
2830 include_once
"./Modules/Test/classes/class.ilObjTest.php";
2831 foreach ($instances as $key => $value)
2833 $query = sprintf(
"SELECT object_reference.ref_id FROM object_reference WHERE obj_id = %s",
2834 $ilDB->quote($key .
"")
2836 $result = $ilDB->query($query);
2838 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
2840 array_push($refs, $row[
"ref_id"]);
2842 $instances[$key] = array(
"obj_id" => $key,
"title" => $value,
"author" =>
ilObjTest::_lookupAuthor($key),
"refs" => $refs);
2849 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
2852 if (in_array($questiontype, $scoring))
2872 $query = sprintf(
"SELECT * FROM tst_active WHERE active_id = %s",
2873 $ilDB->quote($active_id .
"")
2875 $result = $ilDB->query($query);
2876 if ($result->numRows())
2878 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
2879 return array(
"user_id" => $row[
"user_fi"],
"test_id" => $row[
"test_fi"]);
2896 $type = $question_type;
2897 if ($gui) $type .=
"GUI";
2898 if (file_exists(
"./Modules/TestQuestionPool/classes/class.".$type.
".php"))
2900 include_once
"./Modules/TestQuestionPool/classes/class.".$type.
".php";
2904 global $ilPluginAdmin;
2905 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
2906 foreach ($pl_names as $pl_name)
2909 if (strcmp($pl->getQuestionType(), $question_type) == 0)
2911 $pl->includeClass(
"class.".$type.
".php");
2925 if (file_exists(
"./Modules/TestQuestionPool/classes/class.".$type_tag.
".php"))
2928 return $lng->txt($type_tag);
2932 global $ilPluginAdmin;
2933 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
2934 foreach ($pl_names as $pl_name)
2937 if (strcmp($pl->getQuestionType(), $type_tag) == 0)
2939 return $pl->getQuestionTypeTranslation();
2957 if (strcmp($question_id,
"") != 0)
2960 $question_type_gui = $question_type .
"GUI";
2962 $question_gui =
new $question_type_gui();
2963 $question_gui->object->loadFromDb($question_id);
2964 return $question_gui;