24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
202 $this->original_id = null;
210 $this->author = $this->ilias->account->fullname;
213 if ($this->owner <= 0)
215 $this->owner = $this->ilias->account->id;
219 $this->suggested_solutions = array();
221 $this->external_id =
'';
222 $this->nr_of_tries =
"";
225 $this->arrData = array();
239 function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
241 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class." . $this->
getQuestionType() .
"Import.php";
243 $import =
new $classname($this);
244 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
253 function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
255 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class." . $this->
getQuestionType() .
"Export.php";
257 $export =
new $classname($this);
258 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
283 $result = $ilDB->queryF(
"SELECT * FROM qpl_questions WHERE obj_fi = %s AND title = %s",
284 array(
'integer',
'text'),
285 array($questionpool_id,
$title)
287 return ($result->numRows() == 1) ? TRUE : FALSE;
323 $this->test_id =
$id;
381 $this->est_working_time = array(
"h" => (
int)$hour,
"m" => (
int)$min,
"s" => (
int)$sec);
395 foreach ($array as $key => $value)
397 if (strcmp($key, $searchkey)==0)
417 $author = $this->ilias->account->fullname;
526 if (!$this->est_working_time)
528 $this->est_working_time = array(
"h" => 0,
"m" => 0,
"s" => 0);
592 $result = $ilDB->queryF(
"SELECT points FROM qpl_questions WHERE question_id = %s",
596 if ($result->numRows() == 1)
598 $row = $ilDB->fetchAssoc($result);
614 $result = $ilDB->queryF(
"SELECT qpl_questions.*, qpl_qst_type.type_tag FROM qpl_qst_type, qpl_questions WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
618 if ($result->numRows())
620 return $ilDB->fetchAssoc($result);
635 $result = $ilDB->queryF(
"SELECT suggested_solution_id FROM qpl_sol_sug WHERE question_fi = %s",
639 return $result->numRows();
652 return $question->getSuggestedSolutionOutput();
658 foreach ($this->suggested_solutions as $solution)
660 switch ($solution[
"type"])
676 return join($output,
"<br />");
691 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s AND subquestion_index = %s",
692 array(
'integer',
'integer'),
693 array($question_id, $subquestion_index)
695 if ($result->numRows() == 1)
697 $row = $ilDB->fetchAssoc($result);
699 "internal_link" =>
$row[
"internal_link"],
700 "import_id" =>
$row[
"import_id"]
733 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
736 $result = $ilDB->queryF(
"SELECT * FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
737 array(
'integer',
'integer',
'integer'),
738 array($active_id, $question_id,
$pass)
740 if ($result->numRows() == 1)
742 $row = $ilDB->fetchAssoc($result);
784 include_once
"./Modules/Test/classes/class.ilObjTest.php";
788 if (is_null($reached_points)) $reached_points = 0;
790 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
791 array(
"integer",
"integer",
"integer"),
799 $next_id = $ilDB->nextId(
"tst_test_result");
800 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_result (test_result_id, active_fi, question_fi, pass, points, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
801 array(
"integer",
"integer",
"integer",
"integer",
"float",
"integer"),
811 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
821 include_once
'Modules/Course/classes/class.ilCourseObjectiveResult.php';
841 include_once
"./Modules/Test/classes/class.ilObjTest.php";
844 $result = $ilDB->queryF(
"SELECT tst_pass_result.* FROM tst_pass_result WHERE active_fi = %s AND pass = %s",
845 array(
'integer',
'integer'),
846 array($active_id,
$pass)
848 $row = $ilDB->fetchAssoc($result);
849 $max =
$row[
'maxpoints'];
850 $reached =
$row[
'points'];
851 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
852 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
854 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_result_cache WHERE active_fi = %s",
858 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_result_cache (active_fi, pass, max_points, reached_points, mark_short, mark_official, passed, failed, tstamp) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)",
873 strlen($max) ? $max : 0,
874 strlen($reached) ? $reached : 0,
875 strlen($mark[
"short_name"]) ? $mark[
"short_name"] :
" ",
876 strlen($mark[
"official_name"]) ? $mark[
"official_name"] :
" ",
877 ($mark[
"passed"]) ? 1 : 0,
878 (!$mark[
"passed"]) ? 1 : 0,
887 include_once
"./Modules/Test/classes/class.ilObjTest.php";
891 $result = $ilDB->queryF(
"SELECT SUM(points) reachedpoints, COUNT(question_fi) answeredquestions FROM tst_test_result WHERE active_fi = %s AND pass = %s",
892 array(
'integer',
'integer'),
893 array($active_id,
$pass)
895 if ($result->numRows() > 0)
897 $row = $ilDB->fetchAssoc($result);
898 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE active_fi = %s AND pass = %s",
899 array(
'integer',
'integer'),
900 array($active_id,
$pass)
902 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_pass_result (active_fi, pass, points, maxpoints, questioncount, answeredquestions, workingtime, tstamp) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
916 (
$row[
"reachedpoints"]) ?
$row[
"reachedpoints"] : 0,
919 $row[
"answeredquestions"],
927 'active_fi' => $active_id,
929 'points' => (
$row[
"reachedpoints"]) ?
$row[
"reachedpoints"] : 0,
930 'maxpoints' =>
$data[
"points"],
931 'questioncount' =>
$data[
"count"],
932 'answeredquestions' => $row[
"answeredquestions"],
933 'workingtime' => $time,
945 function logAction($logtext =
"", $active_id =
"", $question_id =
"")
950 if (strcmp($question_id,
"") != 0)
952 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
955 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
956 include_once
"./Modules/Test/classes/class.ilObjTest.php";
967 function _logAction($logtext =
"", $active_id =
"", $question_id =
"")
972 if (strcmp($question_id,
"") != 0)
974 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
977 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
978 include_once
"./Modules/Test/classes/class.ilObjTest.php";
991 $mediatempdir = CLIENT_WEB_DIR .
"/assessment/temp";
993 $temp_name = tempnam($mediatempdir,
$name .
"_____");
994 $temp_name = str_replace(
"\\",
"/", $temp_name);
1012 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/solution/";
1022 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/java/";
1033 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/images/";
1044 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/flash/";
1055 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1067 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1080 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1093 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1116 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s ORDER BY solution_id",
1117 array(
'integer',
'integer',
'integer'),
1120 while (
$row = $ilDB->fetchAssoc($result))
1122 array_push($values,
$row);
1133 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s ORDER BY solution_id",
1134 array(
'integer',
'integer',
'integer'),
1135 array($active_id, $question_id,
$pass)
1137 while (
$row = $ilDB->fetchAssoc($result))
1139 array_push($values,
$row);
1155 if ($question_id < 1) $question_id = $this->
getId();
1156 $result = $ilDB->queryF(
"SELECT COUNT(qpl_questions.question_id) question_count FROM qpl_questions, tst_test_question WHERE qpl_questions.original_id = %s AND qpl_questions.question_id = tst_test_question.question_fi",
1160 $row = $ilDB->fetchAssoc($result);
1161 $count =
$row[
"question_count"];
1163 $result = $ilDB->queryF(
"SELECT DISTINCT tst_active.test_fi, qpl_questions.question_id FROM qpl_questions, tst_test_rnd_qst, tst_active WHERE qpl_questions.original_id = %s AND qpl_questions.question_id = tst_test_rnd_qst.question_fi AND tst_test_rnd_qst.active_fi = tst_active.active_id",
1167 $count += $result->numRows();
1182 if ($question_id < 1) $question_id =
$this->id;
1183 $result = $ilDB->queryF(
"SELECT original_id FROM qpl_questions WHERE question_id = %s",
1187 $row = $ilDB->fetchAssoc($result);
1188 return (
$row[
"original_id"] > 0) ? TRUE : FALSE;
1199 $keys = array_keys($array);
1202 foreach ($keys as $key)
1204 $result[$key] = $array[$key];
1218 $result = $ilDB->queryF(
"SELECT qpl_qst_type.type_tag FROM qpl_qst_type, qpl_questions WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
1222 $data = $ilDB->fetchAssoc($result);
1223 return $data[
"type_tag"];
1258 if (is_array($answer_table_name))
1260 foreach ($answer_table_name as $table)
1264 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $table WHERE question_fi = %s",
1273 if (strlen($answer_table_name))
1275 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $answer_table_name WHERE question_fi = %s",
1293 if (is_array($additional_table_name))
1295 foreach ($additional_table_name as $table)
1299 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $table WHERE question_fi = %s",
1308 if (strlen($additional_table_name))
1310 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $additional_table_name WHERE question_fi = %s",
1326 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1338 public function delete($question_id)
1342 if ($question_id < 1)
return true;
1344 $result = $ilDB->queryF(
"SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
1348 if ($result->numRows() == 1)
1350 $row = $ilDB->fetchAssoc($result);
1363 $ilLog->write(
"EXCEPTION: Could not delete page of question $question_id: $e");
1367 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_questions WHERE question_id = %s",
1371 if ($affectedRows == 0)
return false;
1380 $ilLog->write(
"EXCEPTION: Could not delete additional table data of question $question_id: $e");
1387 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE question_fi = %s",
1394 $ilLog->write(
"EXCEPTION: Could not delete delete question $question_id from a test: $e");
1401 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s",
1408 $ilLog->write(
"EXCEPTION: Could not delete suggested solutions of question $question_id: $e");
1414 $directory = CLIENT_WEB_DIR .
"/assessment/" .
$obj_id .
"/$question_id";
1415 if (preg_match(
"/\d+/",
$obj_id) and preg_match(
"/\d+/", $question_id) and is_dir($directory))
1417 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1423 $ilLog->write(
"EXCEPTION: Could not delete question file directory $directory of question $question_id: $e");
1429 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1435 foreach(
$mobs as $mob)
1447 $ilLog->write(
"EXCEPTION: Error deleting the media objects of question $question_id: $e");
1454 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1459 $ilLog->write(
"EXCEPTION: Error updating the question pool question count of question pool " . $this->
getObjId() .
" when deleting question $question_id: $e");
1484 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
1485 array(
'integer',
'integer'),
1486 array($a_q_id, $a_q_id)
1488 if ($result->numRows() == 0)
1492 $found_id = array();
1493 while (
$row = $ilDB->fetchAssoc($result))
1495 array_push($found_id,
$row[
"question_id"]);
1498 $result = $ilDB->query(
"SELECT * FROM tst_test_result WHERE " . $ilDB->in(
'question_fi', $found_id,
false,
'integer'));
1500 return $result->numRows();
1513 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
1514 array(
'integer',
'integer'),
1515 array($a_q_id, $a_q_id)
1517 if ($result->numRows() == 0)
1521 $found_id = array();
1522 while (
$row = $ilDB->fetchAssoc($result))
1524 array_push($found_id,
$row[
"question_id"]);
1526 $result = $ilDB->query(
"SELECT * FROM tst_test_result WHERE " . $ilDB->in(
'question_fi', $found_id,
false,
'integer'));
1528 while (
$row = $ilDB->fetchAssoc($result))
1530 $reached =
$row[
"points"];
1531 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1533 array_push($answers, array(
"reached" => $reached,
"max" => $max));
1537 foreach ($answers as $key => $value)
1539 $max += $value[
"max"];
1540 $reached += $value[
"reached"];
1544 return $reached / $max;
1560 $result = $ilDB->queryF(
"SELECT title FROM qpl_questions WHERE question_id = %s",
1564 if ($result->numRows() == 1)
1566 $row = $ilDB->fetchAssoc($result);
1567 return $row[
"title"];
1583 $result = $ilDB->queryF(
"SELECT question_text FROM qpl_questions WHERE question_id = %s",
1587 if ($result->numRows() == 1)
1589 $row = $ilDB->fetchAssoc($result);
1590 return $row[
"question_text"];
1601 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1603 foreach (
$mobs as $mob)
1611 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1613 foreach (
$mobs as $mob)
1626 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1628 $this->page->setId($this->
getId());
1629 $this->page->setParentId($qpl_id);
1630 $this->page->setXMLContent(
"<PageObject><PageContent>".
1631 "<Question QRef=\"il__qst_".$this->
getId().
"\"/>".
1632 "</PageContent></PageObject>");
1633 $this->page->create();
1640 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1643 $xml = str_replace(
"il__qst_".$a_q_id,
"il__qst_".$this->
id,
$page->getXMLContent());
1644 $this->page->setXMLContent($xml);
1645 $this->page->saveMobUsage($xml);
1646 $this->page->updateFromXML();
1652 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1654 return $page->getXMLContent();
1668 if ($question_id < 1)
return "";
1669 $result = $ilDB->queryF(
"SELECT type_tag FROM qpl_questions, qpl_qst_type WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
1673 if ($result->numRows() == 1)
1675 $data = $ilDB->fetchAssoc($result);
1676 return $data[
"type_tag"];
1695 if ($question_id < 1)
return "";
1697 $result = $ilDB->queryF(
"SELECT title FROM qpl_questions WHERE qpl_questions.question_id = %s",
1701 if ($result->numRows() == 1)
1703 $data = $ilDB->fetchAssoc($result);
1704 return $data[
"title"];
1732 $result = $ilDB->queryF(
"SELECT external_id FROM qpl_questions WHERE question_id = %s",
1736 if ($result->numRows() == 1)
1738 $data = $ilDB->fetchAssoc($result);
1739 $this->external_id =
$data[
'external_id'];
1742 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
1744 array($this->
getId())
1746 $this->suggested_solutions = array();
1747 if ($result->numRows())
1749 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1750 while (
$row = $ilDB->fetchAssoc($result))
1753 $this->suggested_solutions[
$row[
"subquestion_index"]] = array(
1754 "type" => $row[
"type"],
1756 "internal_link" => $row[
"internal_link"],
1757 "import_id" => $row[
"import_id"]
1771 global
$ilDB, $ilUser;
1775 $estw_time = sprintf(
"%02d:%02d:%02d", $estw_time[
'h'], $estw_time[
'm'], $estw_time[
's']);
1779 $next_id = $ilDB->nextId(
'qpl_questions');
1780 $affectedRows = $ilDB->insert(
"qpl_questions", array(
1781 "question_id" => array(
"integer", $next_id),
1783 "obj_fi" => array(
"integer",
$obj_id),
1784 "title" => array(
"text", NULL),
1785 "description" => array(
"text", NULL),
1786 "author" => array(
"text", $this->
getAuthor()),
1787 "owner" => array(
"integer", $ilUser->getId()),
1788 "question_text" => array(
"clob", NULL),
1789 "points" => array(
"float", 0),
1790 "nr_of_tries" => array(
"integer", 1),
1791 "working_time" => array(
"text", $estw_time),
1792 "complete" => array(
"text", $complete),
1793 "created" => array(
"integer", time()),
1795 "original_id" => array(
"integer", NULL),
1796 "tstamp" => array(
"integer", 0)
1798 $this->
setId($next_id);
1802 return $this->
getId();
1810 $estw_time = sprintf(
"%02d:%02d:%02d", $estw_time[
'h'], $estw_time[
'm'], $estw_time[
's']);
1813 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1814 if ($this->
getId() == -1)
1817 $next_id = $ilDB->nextId(
'qpl_questions');
1818 $affectedRows = $ilDB->insert(
"qpl_questions", array(
1819 "question_id" => array(
"integer", $next_id),
1821 "obj_fi" => array(
"integer", $this->
getObjId()),
1822 "title" => array(
"text", $this->
getTitle()),
1823 "description" => array(
"text", $this->
getComment()),
1824 "author" => array(
"text", $this->
getAuthor()),
1825 "owner" => array(
"integer", $this->
getOwner()),
1828 "working_time" => array(
"text", $estw_time),
1830 "created" => array(
"integer", time()),
1833 "tstamp" => array(
"integer", time())
1835 $this->
setId($next_id);
1842 $affectedRows = $ilDB->update(
"qpl_questions", array(
1843 "obj_fi" => array(
"integer", $this->
getObjId()),
1844 "title" => array(
"text", $this->
getTitle()),
1845 "description" => array(
"text", $this->
getComment()),
1846 "author" => array(
"text", $this->
getAuthor()),
1850 "working_time" => array(
"text", $estw_time),
1852 "tstamp" => array(
"integer", time())
1854 "question_id" => array(
"integer", $this->
getId())
1881 $affectedRows = $ilDB->manipulateF(
"UPDATE qpl_questions SET tstamp = %s, owner = %s, complete = %s WHERE question_id = %s",
1882 array(
'integer',
'integer',
'text',
'integer'),
1883 array(time(), ($this->
getOwner() <= 0) ? $this->ilias->account->id : $this->getOwner(), $complete, $this->
getId())
1887 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1902 protected function onCopy($source_questionpool_id, $source_question_id)
1914 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s",
1916 array($this->
getId())
1919 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1921 $this->suggested_solutions = array();
1934 if (array_key_exists($subquestion_index, $this->suggested_solutions))
1936 return $this->suggested_solutions[$subquestion_index];
1954 if (array_key_exists($subquestion_index, $this->suggested_solutions))
1956 $title = $this->suggested_solutions[$subquestion_index][
"internal_link"];
1977 if (strcmp($solution_id,
"") != 0)
1982 $import_id = $solution_id;
1985 $this->suggested_solutions[$subquestion_index] = array(
1986 "internal_link" => $solution_id,
1987 "import_id" => $import_id
1999 foreach ($this->suggested_solutions as $index => $solution)
2001 if (strcmp($solution[
"type"],
"file") == 0)
2004 $filepath_original = str_replace(
"/$this->id/solution",
"/$question_id/solution", $filepath);
2005 if (!file_exists($filepath))
2012 if (!copy($filepath_original .
$filename, $filepath . $filename))
2014 $ilLog->write(
"File could not be duplicated!!!!", $ilLog->ERROR);
2015 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
2030 $filepath_original = str_replace(
"/$this->id/solution",
"/$original_id/solution", $filepath);
2032 foreach ($this->suggested_solutions as $index => $solution)
2034 if (strcmp($solution[
"type"],
"file") == 0)
2036 if (!file_exists($filepath_original))
2043 if (!@copy($filepath .
$filename, $filepath_original . $filename))
2045 $ilLog->write(
"File could not be duplicated!!!!", $ilLog->ERROR);
2046 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
2057 foreach ($this->suggested_solutions as $index => $solution)
2059 if (strcmp($solution[
"type"],
"file") == 0)
2062 $filepath_original = str_replace(
"/$this->obj_id/$this->id/solution",
"/$source_questionpool_id/$source_question_id/solution", $filepath);
2063 if (!file_exists($filepath))
2070 if (!copy($filepath_original .
$filename, $filepath . $filename))
2072 $ilLog->write(
"File could not be copied!!!!", $ilLog->ERROR);
2073 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
2088 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
2089 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s",
2094 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2095 foreach ($this->suggested_solutions as $index => $solution)
2097 $next_id = $ilDB->nextId(
'qpl_sol_sug');
2098 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_sol_sug (suggested_solution_id, question_fi, type, value, internal_link, import_id, subquestion_index, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
2099 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"integer",
"integer"),
2105 $solution[
"internal_link"],
2111 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
2133 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s AND subquestion_index = %s",
2134 array(
"integer",
"integer"),
2141 $next_id = $ilDB->nextId(
'qpl_sol_sug');
2142 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2143 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_sol_sug (suggested_solution_id, question_fi, type, value, internal_link, import_id, subquestion_index, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
2144 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"integer",
"integer"),
2156 if ($affectedRows == 1)
2158 $this->suggested_solutions[
"subquestion_index"] = array(
2161 "internal_link" => $solution_id,
2170 if (preg_match(
"/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches))
2172 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
2173 include_once
"./Modules/LearningModule/classes/class.ilLMObject.php";
2174 include_once
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
2175 switch ($matches[2])
2193 if (strcmp($resolved_link,
"") == 0)
2195 $resolved_link = $internal_link;
2200 $resolved_link = $internal_link;
2202 return $resolved_link;
2209 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
2213 if ($result->numRows())
2215 while (
$row = $ilDB->fetchAssoc($result))
2217 $internal_link =
$row[
"internal_link"];
2218 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
2220 if (strcmp($internal_link, $resolved_link) != 0)
2223 $affectedRows = $ilDB->manipulateF(
"UPDATE qpl_sol_sug SET internal_link = %s WHERE suggested_solution_id = %s",
2224 array(
'text',
'integer'),
2225 array($resolved_link,
$row[
"suggested_solution_id"])
2236 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
2239 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
2243 if ($result->numRows())
2245 while (
$row = $ilDB->fetchAssoc($result))
2247 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/",
$row[
"internal_link"], $matches))
2260 "lm" =>
"LearningModule",
2261 "pg" =>
"PageObject",
2262 "st" =>
"StructureObject",
2263 "git" =>
"GlossaryItem",
2264 "mob" =>
"MediaObject"
2267 if (preg_match(
"/il__(\w+)_(\d+)/", $target, $matches))
2269 $type = $matches[1];
2271 include_once
"./Services/Utilities/classes/class.ilUtil.php";
2272 switch($linktypes[$matches[1]])
2274 case "LearningModule":
2278 case "StructureObject":
2281 case "GlossaryItem":
2285 $href =
"./ilias.php?baseClass=ilLMPresentationGUI&obj_type=" . $linktypes[
$type] .
"&cmd=media&ref_id=".$_GET[
"ref_id"].
"&mob_id=".
$target_id;
2302 $result = $ilDB->queryF(
"SELECT * FROM qpl_questions WHERE question_id = %s",
2306 if ($result->numRows() > 0)
2308 $row = $ilDB->fetchAssoc($result);
2309 if (
$row[
"original_id"] > 0)
2311 return $row[
"original_id"];
2315 return $row[
"question_id"];
2363 if ($question_id < 1)
2368 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE question_id = %s",
2372 if ($result->numRows() == 1)
2391 if (strcmp($question_id,
"") != 0)
2394 if (!strlen($question_type))
return null;
2410 if (strcmp($this->points,
"") == 0)
2429 $this->points = $a_points;
2460 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
2461 array(
'integer',
'integer'),
2462 array($active_id, $question_id)
2464 if ($result->numRows() == 1)
2466 $row = $ilDB->fetchAssoc($result);
2467 return (
$row[
"maxpass"]) ?
$row[
"maxpass"] : 0;
2487 if (($question_id < 1) || ($user_id < 1))
2492 $result = $ilDB->queryF(
"SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
2496 if ($result->numRows() == 1)
2498 $row = $ilDB->fetchAssoc($result);
2499 $qpl_object_id =
$row[
"obj_fi"];
2500 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2519 if ($question_id < 1)
return 0;
2520 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE question_fi = %s",
2524 return $result->numRows();
2538 include_once
"./Modules/Test/classes/class.ilObjTest.php";
2540 if ($count_system == 1)
2548 if ($score_cutting == 0)
2573 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
2576 $result = $ilDB->queryF(
"SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
2577 array(
'integer',
'integer',
'integer'),
2578 array($active_id, $question_id,
$pass)
2580 if ($result->numRows())
2601 $res = $ilDB->queryF(
"SELECT DISTINCT(question_fi) FROM tst_test_result JOIN tst_active ".
2602 "ON (active_id = active_fi) ".
2603 "WHERE " . $ilDB->in(
'question_fi', $a_question_ids,
false,
'integer') .
2604 " AND user_fi = %s",
2608 return (
$res->numRows() == count($a_question_ids)) ?
true :
false;
2620 if (preg_match(
"/<[^>]*?>/", $a_text))
2638 include_once
"./Services/Utilities/classes/class.ilUtil.php";
2652 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
2654 $material = $a_material->getMaterial($i);
2655 if (strcmp($material[
"type"],
"mattext") == 0)
2657 $result .= $material[
"material"]->getContent();
2659 if (strcmp($material[
"type"],
"matimage") == 0)
2661 $matimage = $material[
"material"];
2662 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
2665 if (!is_array(
$_SESSION[
"import_mob_xhtml"]))
$_SESSION[
"import_mob_xhtml"] = array();
2666 array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(),
"uri" => $matimage->getUri()));
2681 function addQTIMaterial(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE)
2683 include_once
"./Services/RTE/classes/class.ilRTE.php";
2684 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2686 $a_xml_writer->xmlStartTag(
"material");
2688 "texttype" =>
"text/plain"
2690 if ($this->
isHTML($a_material))
2692 $attrs[
"texttype"] =
"text/xhtml";
2698 foreach (
$mobs as $mob)
2700 $moblabel =
"il_" . IL_INST_ID .
"_mob_" . $mob;
2701 if (strpos($a_material,
"mm_$mob") !== FALSE)
2707 "label" => $moblabel,
2708 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
2711 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
2715 if ($close_material_tag) $a_xml_writer->xmlEndTag(
"material");
2721 if (preg_match(
"/.*\.(png|jpg|gif|jpeg)$/i", $image_filename, $matches))
2723 $extension =
"." . $matches[1];
2725 $image_filename = md5($image_filename) . $extension;
2726 return $image_filename;
2752 $result = $ilDB->queryF(
"SELECT points FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
2753 array(
'integer',
'integer',
'integer'),
2754 array($active_id, $question_id,
$pass)
2756 $manual = ($manualscoring) ? 1 : 0;
2757 if ($result->numRows())
2759 $row = $ilDB->fetchAssoc($result);
2760 $old_points =
$row[
"points"];
2761 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_result SET points = %s, manual = %s, tstamp = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
2762 array(
'float',
'integer',
'integer',
'integer',
'integer',
'integer'),
2763 array(
$points, $manual, time(), $active_id, $question_id,
$pass)
2768 $next_id = $ilDB->nextId(
'tst_test_result');
2769 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_result (test_result_id, active_fi, question_fi, points, pass, manual, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
2770 array(
'integer',
'integer',
'integer',
'float',
'integer',
'integer',
'integer'),
2771 array($next_id, $active_id, $question_id,
$points,
$pass, $manual, time())
2776 include_once
"./Modules/Test/classes/class.ilObjTest.php";
2777 include_once
'./Modules/Course/classes/class.ilCourseObjectiveResult.php';
2780 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
2783 global
$lng, $ilUser;
2784 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
2852 $result = $ilDB->queryF(
"SELECT question_type_id FROM qpl_qst_type WHERE type_tag = %s",
2856 if ($result->numRows() == 1)
2858 $row = $ilDB->fetchAssoc($result);
2859 return $row[
"question_type_id"];
2877 switch ($correctness)
2887 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_generic WHERE question_fi = %s AND correctness = %s",
2888 array(
'integer',
'text'),
2889 array($this->
getId(), $correctness)
2891 if (strlen($feedback))
2893 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2894 $next_id = $ilDB->nextId(
'qpl_fb_generic');
2895 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_fb_generic (feedback_id, question_fi, correctness, feedback, tstamp) VALUES (%s, %s, %s, %s, %s)",
2896 array(
'integer',
'integer',
'text',
'text',
'integer'),
2916 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_generic WHERE question_fi = %s AND correctness = %s",
2917 array(
'integer',
'text'),
2918 array($this->
getId(), $correctness)
2920 if ($result->numRows())
2922 $row = $ilDB->fetchAssoc($result);
2923 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2940 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_generic WHERE question_fi = %s",
2944 if ($result->numRows())
2946 while (
$row = $ilDB->fetchAssoc($result))
2948 $next_id = $ilDB->nextId(
'qpl_fb_generic');
2949 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_fb_generic (feedback_id, question_fi, correctness, feedback, tstamp) VALUES (%s, %s, %s, %s, %s)",
2950 array(
'integer',
'integer',
'text',
'text',
'integer'),
2951 array($next_id, $this->
getId(),
$row[
"correctness"],
$row[
"feedback"], time())
2964 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_generic WHERE question_fi = %s",
2966 array($this->original_id)
2970 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_generic WHERE question_fi = %s",
2972 array($this->
getId())
2976 if ($result->numRows())
2978 while (
$row = $ilDB->fetchAssoc($result))
2980 $next_id = $ilDB->nextId(
'qpl_fb_generic');
2981 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_fb_generic (feedback_id, question_fi, correctness, feedback, tstamp) VALUES (%s, %s, %s, %s, %s)",
2982 array(
'integer',
'integer',
'text',
'text',
'integer'),
2983 array($next_id, $this->original_id,
$row[
"correctness"],
$row[
"feedback"], time())
3000 foreach ($this->suggested_solutions as $solution_array)
3002 $collected .= $solution_array[
"value"];
3014 include_once(
"./Services/RTE/classes/class.ilRTE.php");
3027 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id = %s",
3029 array($this->
getId())
3031 $instances = array();
3033 while (
$row = $ilDB->fetchAssoc($result))
3035 array_push($ids,
$row[
"question_id"]);
3037 foreach ($ids as $question_id)
3040 $result = $ilDB->queryF(
"SELECT tst_tests.obj_fi FROM tst_tests, tst_test_question WHERE tst_test_question.question_fi = %s AND tst_test_question.test_fi = tst_tests.test_id",
3044 while (
$row = $ilDB->fetchAssoc($result))
3049 $result = $ilDB->queryF(
"SELECT tst_tests.obj_fi FROM tst_tests, tst_test_rnd_qst, tst_active WHERE tst_test_rnd_qst.active_fi = tst_active.active_id AND tst_test_rnd_qst.question_fi = %s AND tst_tests.test_id = tst_active.test_fi",
3053 while (
$row = $ilDB->fetchAssoc($result))
3058 include_once
"./Modules/Test/classes/class.ilObjTest.php";
3059 foreach ($instances as $key => $value)
3068 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
3071 if (in_array($questiontype, $scoring))
3091 $result = $ilDB->queryF(
"SELECT * FROM tst_active WHERE active_id = %s",
3095 if ($result->numRows())
3097 $row = $ilDB->fetchAssoc($result);
3098 return array(
"user_id" =>
$row[
"user_fi"],
"test_id" =>
$row[
"test_fi"]);
3115 $type = $question_type;
3116 if ($gui)
$type .=
"GUI";
3117 if (file_exists(
"./Modules/TestQuestionPool/classes/class.".
$type.
".php"))
3119 include_once
"./Modules/TestQuestionPool/classes/class.".$type.
".php";
3123 global $ilPluginAdmin;
3124 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
3125 foreach ($pl_names as $pl_name)
3128 if (strcmp($pl->getQuestionType(), $question_type) == 0)
3130 $pl->includeClass(
"class.".
$type.
".php");
3144 if (file_exists(
"./Modules/TestQuestionPool/classes/class.".$type_tag.
".php"))
3147 return $lng->txt($type_tag);
3151 global $ilPluginAdmin;
3152 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
3153 foreach ($pl_names as $pl_name)
3156 if (strcmp($pl->getQuestionType(), $type_tag) == 0)
3158 return $pl->getQuestionTypeTranslation();
3174 if (strcmp($question_id,
"") != 0)
3177 $question_type_gui = $question_type .
"GUI";
3179 $question_gui =
new $question_type_gui();
3180 $question_gui->object->loadFromDb($question_id);
3181 return $question_gui;
3207 return $this->
getId();
3227 case "est_working_time":
3251 case "suggested_solutions":
3258 if (array_key_exists($value, $this->arrData))
3260 return $this->arrData[$value];
3278 $this->
setId($value);
3298 case "est_working_time":
3299 if (is_array($value))
3320 $this->page =& $value;
3323 $this->arrData[$key] = $value;
3335 $this->nr_of_tries = $a_nr_of_tries;
3340 if (!strlen($this->external_id))
3342 if ($this->
getId() > 0)
3344 return "il_".IL_INST_ID.
"_qst_".$this->
getId();
3348 return uniqid(
'',
true);
3359 $this->external_id =
$id;