24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
205 $this->original_id = null;
213 $this->author = $this->ilias->account->fullname;
216 if ($this->owner <= 0)
218 $this->owner = $this->ilias->account->id;
222 $this->suggested_solutions = array();
224 $this->nr_of_tries =
"";
227 $this->arrData = array();
241 function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
243 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class." . $this->
getQuestionType() .
"Import.php";
245 $import =
new $classname($this);
246 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
255 function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
257 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class." . $this->
getQuestionType() .
"Export.php";
259 $export =
new $classname($this);
260 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
285 $result = $ilDB->queryF(
"SELECT * FROM qpl_questions WHERE obj_fi = %s AND title = %s",
286 array(
'integer',
'text'),
287 array($questionpool_id,
$title)
289 return (
$result->numRows() == 1) ? TRUE : FALSE;
325 $this->test_id =
$id;
383 $this->est_working_time = array(
"h" => (
int)$hour,
"m" => (
int)$min,
"s" => (
int)$sec);
397 foreach ($array as $key => $value)
399 if (strcmp($key, $searchkey)==0)
419 $author = $this->ilias->account->fullname;
528 if (!$this->est_working_time)
530 $this->est_working_time = array(
"h" => 0,
"m" => 0,
"s" => 0);
594 $result = $ilDB->queryF(
"SELECT points FROM qpl_questions WHERE question_id = %s",
616 $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",
622 return $ilDB->fetchAssoc(
$result);
637 $result = $ilDB->queryF(
"SELECT suggested_solution_id FROM qpl_sol_sug WHERE question_fi = %s",
654 return $question->getSuggestedSolutionOutput();
660 foreach ($this->suggested_solutions as $solution)
662 switch ($solution[
"type"])
678 return join($output,
"<br />");
693 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s AND subquestion_index = %s",
694 array(
'integer',
'integer'),
695 array($question_id, $subquestion_index)
701 "internal_link" =>
$row[
"internal_link"],
702 "import_id" =>
$row[
"import_id"]
735 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
738 $result = $ilDB->queryF(
"SELECT * FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
739 array(
'integer',
'integer',
'integer'),
740 array($active_id, $question_id,
$pass)
786 include_once
"./Modules/Test/classes/class.ilObjTest.php";
790 if (is_null($reached_points)) $reached_points = 0;
792 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
793 array(
"integer",
"integer",
"integer"),
801 $next_id = $ilDB->nextId(
"tst_test_result");
802 $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)",
803 array(
"integer",
"integer",
"integer",
"integer",
"float",
"integer"),
813 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
823 include_once
'Modules/Course/classes/class.ilCourseObjectiveResult.php';
843 include_once
"./Modules/Test/classes/class.ilObjTest.php";
846 $result = $ilDB->queryF(
"SELECT tst_pass_result.* FROM tst_pass_result WHERE active_fi = %s AND pass = %s",
847 array(
'integer',
'integer'),
848 array($active_id,
$pass)
851 $max =
$row[
'maxpoints'];
852 $reached =
$row[
'points'];
853 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
854 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
856 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_result_cache WHERE active_fi = %s",
860 $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)",
875 strlen($max) ? $max : 0,
876 strlen($reached) ? $reached : 0,
877 strlen($mark[
"short_name"]) ? $mark[
"short_name"] :
" ",
878 strlen($mark[
"official_name"]) ? $mark[
"official_name"] :
" ",
879 ($mark[
"passed"]) ? 1 : 0,
880 (!$mark[
"passed"]) ? 1 : 0,
889 include_once
"./Modules/Test/classes/class.ilObjTest.php";
893 $result = $ilDB->queryF(
"SELECT SUM(points) reachedpoints, COUNT(question_fi) answeredquestions FROM tst_test_result WHERE active_fi = %s AND pass = %s",
894 array(
'integer',
'integer'),
895 array($active_id,
$pass)
900 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE active_fi = %s AND pass = %s",
901 array(
'integer',
'integer'),
902 array($active_id,
$pass)
904 $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)",
918 (
$row[
"reachedpoints"]) ?
$row[
"reachedpoints"] : 0,
921 $row[
"answeredquestions"],
929 'active_fi' => $active_id,
931 'points' => (
$row[
"reachedpoints"]) ?
$row[
"reachedpoints"] : 0,
932 'maxpoints' =>
$data[
"points"],
933 'questioncount' =>
$data[
"count"],
934 'answeredquestions' => $row[
"answeredquestions"],
935 'workingtime' => $time,
947 function logAction($logtext =
"", $active_id =
"", $question_id =
"")
952 if (strcmp($question_id,
"") != 0)
954 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
957 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
958 include_once
"./Modules/Test/classes/class.ilObjTest.php";
969 function _logAction($logtext =
"", $active_id =
"", $question_id =
"")
974 if (strcmp($question_id,
"") != 0)
976 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
979 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
980 include_once
"./Modules/Test/classes/class.ilObjTest.php";
993 $mediatempdir = CLIENT_WEB_DIR .
"/assessment/temp";
995 $temp_name = tempnam($mediatempdir, $name .
"_____");
996 $temp_name = str_replace(
"\\",
"/", $temp_name);
1014 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/solution/";
1024 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/java/";
1035 if( $question_id === null)
1040 if( $object_id === null)
1045 return CLIENT_WEB_DIR .
"/assessment/$object_id/$question_id/images/";
1056 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/flash/";
1067 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1079 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1092 if(!$this->export_image_path)
1094 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1112 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1135 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s ORDER BY solution_id",
1136 array(
'integer',
'integer',
'integer'),
1141 array_push($values,
$row);
1157 if ($question_id < 1) $question_id = $this->
getId();
1158 $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",
1163 $count =
$row[
"question_count"];
1165 $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",
1184 if ($question_id < 1) $question_id =
$this->id;
1185 $result = $ilDB->queryF(
"SELECT original_id FROM qpl_questions WHERE question_id = %s",
1190 return (
$row[
"original_id"] > 0) ? TRUE : FALSE;
1201 $keys = array_keys($array);
1204 foreach ($keys as $key)
1220 $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",
1225 return $data[
"type_tag"];
1260 if (is_array($answer_table_name))
1262 foreach ($answer_table_name as $table)
1266 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $table WHERE question_fi = %s",
1275 if (strlen($answer_table_name))
1277 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $answer_table_name WHERE question_fi = %s",
1295 if (is_array($additional_table_name))
1297 foreach ($additional_table_name as $table)
1301 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $table WHERE question_fi = %s",
1310 if (strlen($additional_table_name))
1312 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $additional_table_name WHERE question_fi = %s",
1328 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1340 public function delete($question_id)
1344 if ($question_id < 1)
return true;
1346 $result = $ilDB->queryF(
"SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
1365 $ilLog->write(
"EXCEPTION: Could not delete page of question $question_id: $e");
1369 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_questions WHERE question_id = %s",
1373 if ($affectedRows == 0)
return false;
1382 $ilLog->write(
"EXCEPTION: Could not delete additional table data of question $question_id: $e");
1389 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE question_fi = %s",
1396 $ilLog->write(
"EXCEPTION: Could not delete delete question $question_id from a test: $e");
1403 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s",
1410 $ilLog->write(
"EXCEPTION: Could not delete suggested solutions of question $question_id: $e");
1416 $directory = CLIENT_WEB_DIR .
"/assessment/" .
$obj_id .
"/$question_id";
1417 if (preg_match(
"/\d+/",
$obj_id) and preg_match(
"/\d+/", $question_id) and is_dir($directory))
1419 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1425 $ilLog->write(
"EXCEPTION: Could not delete question file directory $directory of question $question_id: $e");
1431 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1437 foreach(
$mobs as $mob)
1449 $ilLog->write(
"EXCEPTION: Error deleting the media objects of question $question_id: $e");
1456 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1461 $ilLog->write(
"EXCEPTION: Error updating the question pool question count of question pool " . $this->
getObjId() .
" when deleting question $question_id: $e");
1486 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
1487 array(
'integer',
'integer'),
1488 array($a_q_id, $a_q_id)
1494 $found_id = array();
1497 array_push($found_id,
$row[
"question_id"]);
1500 $result = $ilDB->query(
"SELECT * FROM tst_test_result WHERE " . $ilDB->in(
'question_fi', $found_id,
false,
'integer'));
1515 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
1516 array(
'integer',
'integer'),
1517 array($a_q_id, $a_q_id)
1523 $found_id = array();
1526 array_push($found_id,
$row[
"question_id"]);
1528 $result = $ilDB->query(
"SELECT * FROM tst_test_result WHERE " . $ilDB->in(
'question_fi', $found_id,
false,
'integer'));
1532 $reached =
$row[
"points"];
1533 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1535 array_push($answers, array(
"reached" => $reached,
"max" => $max));
1539 foreach ($answers as $key => $value)
1541 $max += $value[
"max"];
1542 $reached += $value[
"reached"];
1546 return $reached / $max;
1562 $result = $ilDB->queryF(
"SELECT title FROM qpl_questions WHERE question_id = %s",
1569 return $row[
"title"];
1585 $result = $ilDB->queryF(
"SELECT question_text FROM qpl_questions WHERE question_id = %s",
1592 return $row[
"question_text"];
1603 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1605 foreach (
$mobs as $mob)
1613 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1615 foreach (
$mobs as $mob)
1628 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1630 $this->page->setId($this->
getId());
1631 $this->page->setParentId($qpl_id);
1632 $this->page->setXMLContent(
"<PageObject><PageContent>".
1633 "<Question QRef=\"il__qst_".$this->
getId().
"\"/>".
1634 "</PageContent></PageObject>");
1635 $this->page->create();
1642 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1645 $xml = str_replace(
"il__qst_".$a_q_id,
"il__qst_".$this->
id,
$page->getXMLContent());
1646 $this->page->setXMLContent($xml);
1647 $this->page->saveMobUsage($xml);
1648 $this->page->updateFromXML();
1654 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1656 return $page->getXMLContent();
1670 if ($question_id < 1)
return "";
1671 $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",
1678 return $data[
"type_tag"];
1697 if ($question_id < 1)
return "";
1699 $result = $ilDB->queryF(
"SELECT title FROM qpl_questions WHERE qpl_questions.question_id = %s",
1706 return $data[
"title"];
1734 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
1736 array($this->
getId())
1738 $this->suggested_solutions = array();
1741 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1745 $this->suggested_solutions[
$row[
"subquestion_index"]] = array(
1746 "type" => $row[
"type"],
1748 "internal_link" => $row[
"internal_link"],
1749 "import_id" => $row[
"import_id"]
1763 global
$ilDB, $ilUser;
1767 $estw_time = sprintf(
"%02d:%02d:%02d", $estw_time[
'h'], $estw_time[
'm'], $estw_time[
's']);
1781 $next_id = $ilDB->nextId(
'qpl_questions');
1782 $affectedRows = $ilDB->insert(
"qpl_questions", array(
1783 "question_id" => array(
"integer", $next_id),
1785 "obj_fi" => array(
"integer",
$obj_id),
1786 "title" => array(
"text", NULL),
1787 "description" => array(
"text", NULL),
1788 "author" => array(
"text", $this->
getAuthor()),
1789 "owner" => array(
"integer", $ilUser->getId()),
1790 "question_text" => array(
"clob", NULL),
1791 "points" => array(
"float", 0),
1792 "nr_of_tries" => array(
"integer", 1),
1793 "working_time" => array(
"text", $estw_time),
1794 "complete" => array(
"text", $complete),
1795 "created" => array(
"integer", time()),
1796 "original_id" => array(
"integer", NULL),
1797 "tstamp" => array(
"integer", $tstamp)
1799 $this->
setId($next_id);
1807 return $this->
getId();
1815 $estw_time = sprintf(
"%02d:%02d:%02d", $estw_time[
'h'], $estw_time[
'm'], $estw_time[
's']);
1818 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1819 if ($this->
getId() == -1)
1822 $next_id = $ilDB->nextId(
'qpl_questions');
1823 $affectedRows = $ilDB->insert(
"qpl_questions", array(
1824 "question_id" => array(
"integer", $next_id),
1826 "obj_fi" => array(
"integer", $this->
getObjId()),
1827 "title" => array(
"text", $this->
getTitle()),
1828 "description" => array(
"text", $this->
getComment()),
1829 "author" => array(
"text", $this->
getAuthor()),
1830 "owner" => array(
"integer", $this->
getOwner()),
1833 "working_time" => array(
"text", $estw_time),
1835 "created" => array(
"integer", time()),
1837 "tstamp" => array(
"integer", time())
1839 $this->
setId($next_id);
1846 $affectedRows = $ilDB->update(
"qpl_questions", array(
1847 "obj_fi" => array(
"integer", $this->
getObjId()),
1848 "title" => array(
"text", $this->
getTitle()),
1849 "description" => array(
"text", $this->
getComment()),
1850 "author" => array(
"text", $this->
getAuthor()),
1854 "working_time" => array(
"text", $estw_time),
1855 "tstamp" => array(
"integer", time())
1857 "question_id" => array(
"integer", $this->
getId())
1872 $this->updateSuggestedSolutions();
1884 $affectedRows = $ilDB->manipulateF(
"UPDATE qpl_questions SET tstamp = %s, owner = %s, complete = %s WHERE question_id = %s",
1885 array(
'integer',
'integer',
'integer',
'text'),
1886 array(time(), ($this->
getOwner() <= 0) ? $this->ilias->account->id : $this->getOwner(), $complete, $this->
getId())
1890 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1896 $ilDB->manipulateF(
"UPDATE qpl_questions SET tstamp = %s, original_id = %s WHERE question_id = %s",
1897 array(
'integer',
'integer',
'text'),
1898 array(time(), $newId, $this->
getId())
1905 protected function onDuplicate($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
1913 protected function onCopy($source_questionpool_id, $source_question_id)
1925 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s",
1927 array($this->
getId())
1930 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1932 $this->suggested_solutions = array();
1945 if (array_key_exists($subquestion_index, $this->suggested_solutions))
1947 return $this->suggested_solutions[$subquestion_index];
1965 if (array_key_exists($subquestion_index, $this->suggested_solutions))
1967 $title = $this->suggested_solutions[$subquestion_index][
"internal_link"];
1988 if (strcmp($solution_id,
"") != 0)
1993 $import_id = $solution_id;
1996 $this->suggested_solutions[$subquestion_index] = array(
1997 "internal_link" => $solution_id,
1998 "import_id" => $import_id
2010 foreach ($this->suggested_solutions as $index => $solution)
2012 if (strcmp($solution[
"type"],
"file") == 0)
2015 $filepath_original = str_replace(
2016 "/{$this->obj_id}/{$this->id}/solution",
2017 "/$parent_id/$question_id/solution",
2020 if (!file_exists($filepath))
2027 if (!copy($filepath_original .
$filename, $filepath . $filename))
2029 $ilLog->write(
"File could not be duplicated!!!!", $ilLog->ERROR);
2030 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
2045 $filepath_original = str_replace(
"/$this->id/solution",
"/$original_id/solution", $filepath);
2047 foreach ($this->suggested_solutions as $index => $solution)
2049 if (strcmp($solution[
"type"],
"file") == 0)
2051 if (!file_exists($filepath_original))
2058 if (!@copy($filepath .
$filename, $filepath_original . $filename))
2060 $ilLog->write(
"File could not be duplicated!!!!", $ilLog->ERROR);
2061 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
2072 foreach ($this->suggested_solutions as $index => $solution)
2074 if (strcmp($solution[
"type"],
"file") == 0)
2077 $filepath_original = str_replace(
"/$this->obj_id/$this->id/solution",
"/$source_questionpool_id/$source_question_id/solution", $filepath);
2078 if (!file_exists($filepath))
2085 if (!copy($filepath_original .
$filename, $filepath . $filename))
2087 $ilLog->write(
"File could not be copied!!!!", $ilLog->ERROR);
2088 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
2098 public function updateSuggestedSolutions(
$original_id =
"")
2103 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
2104 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s",
2109 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2110 foreach ($this->suggested_solutions as $index => $solution)
2112 $next_id = $ilDB->nextId(
'qpl_sol_sug');
2115 $ilDB->insert(
'qpl_sol_sug', array(
2116 'suggested_solution_id' => array(
'integer', $next_id ),
2117 'question_fi' => array(
'integer',
$id ),
2118 'type' => array(
'text', $solution[
'type'] ),
2120 'internal_link' => array(
'text', $solution[
'internal_link'] ),
2121 'import_id' => array(
'text', null ),
2122 'subquestion_index' => array(
'integer', $index ),
2123 'tstamp' => array(
'integer', time() ),
2127 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
2145 function saveSuggestedSolution($type, $solution_id =
"", $subquestion_index = 0, $value =
"")
2149 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s AND subquestion_index = %s",
2150 array(
"integer",
"integer"),
2157 $next_id = $ilDB->nextId(
'qpl_sol_sug');
2158 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2160 $affectedRows = $ilDB->insert(
'qpl_sol_sug', array(
2161 'suggested_solution_id' => array(
'integer', $next_id ),
2162 'question_fi' => array(
'integer', $this->
getId() ),
2163 'type' => array(
'text', $type ),
2165 'internal_link' => array(
'text', $solution_id ),
2166 'import_id' => array(
'text', null ),
2167 'subquestion_index' => array(
'integer', $subquestion_index ),
2168 'tstamp' => array(
'integer', time() ),
2172 if ($affectedRows == 1)
2174 $this->suggested_solutions[
"subquestion_index"] = array(
2177 "internal_link" => $solution_id,
2186 if (preg_match(
"/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches))
2188 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
2189 include_once
"./Modules/LearningModule/classes/class.ilLMObject.php";
2190 include_once
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
2191 switch ($matches[2])
2209 if (strcmp($resolved_link,
"") == 0)
2211 $resolved_link = $internal_link;
2216 $resolved_link = $internal_link;
2218 return $resolved_link;
2225 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
2233 $internal_link =
$row[
"internal_link"];
2234 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
2236 if (strcmp($internal_link, $resolved_link) != 0)
2239 $affectedRows = $ilDB->manipulateF(
"UPDATE qpl_sol_sug SET internal_link = %s WHERE suggested_solution_id = %s",
2240 array(
'text',
'integer'),
2241 array($resolved_link,
$row[
"suggested_solution_id"])
2252 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
2255 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
2263 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/",
$row[
"internal_link"], $matches))
2276 "lm" =>
"LearningModule",
2277 "pg" =>
"PageObject",
2278 "st" =>
"StructureObject",
2279 "git" =>
"GlossaryItem",
2280 "mob" =>
"MediaObject"
2283 if (preg_match(
"/il__(\w+)_(\d+)/", $target, $matches))
2285 $type = $matches[1];
2287 include_once
"./Services/Utilities/classes/class.ilUtil.php";
2288 switch($linktypes[$matches[1]])
2290 case "LearningModule":
2291 $href =
"./goto.php?target=" . $type .
"_" .
$target_id;
2294 case "StructureObject":
2295 $href =
"./goto.php?target=" . $type .
"_" .
$target_id;
2297 case "GlossaryItem":
2298 $href =
"./goto.php?target=" . $type .
"_" .
$target_id;
2301 $href =
"./ilias.php?baseClass=ilLMPresentationGUI&obj_type=" . $linktypes[$type] .
"&cmd=media&ref_id=".$_GET[
"ref_id"].
"&mob_id=".
$target_id;
2318 $result = $ilDB->queryF(
"SELECT * FROM qpl_questions WHERE question_id = %s",
2325 if (
$row[
"original_id"] > 0)
2327 return $row[
"original_id"];
2331 return $row[
"question_id"];
2351 if ( !$originalObjId )
2369 $this->updateSuggestedSolutions($original);
2370 $this->syncFeedbackGeneric();
2386 $query =
"SELECT obj_fi FROM qpl_questions WHERE question_id = %s";
2388 $res = $ilDB->queryF(
$query, array(
'integer'), array((
int)$originalQuestionId));
2391 return $row[
'obj_fi'];
2409 if ($question_id < 1)
2414 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE question_id = %s",
2439 if ($question_id < 1)
2444 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions INNER JOIN object_data ON obj_fi = obj_id WHERE question_id = %s AND type = 'qpl'",
2467 if (strcmp($question_id,
"") != 0)
2470 if (!strlen($question_type))
return null;
2486 if (strcmp($this->points,
"") == 0)
2505 $this->points = $a_points;
2536 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
2537 array(
'integer',
'integer'),
2538 array($active_id, $question_id)
2543 return $row[
"maxpass"];
2563 if (($question_id < 1) || ($user_id < 1))
2568 $result = $ilDB->queryF(
"SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
2575 $qpl_object_id =
$row[
"obj_fi"];
2576 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2595 if ($question_id < 1)
return 0;
2596 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE question_fi = %s",
2614 include_once
"./Modules/Test/classes/class.ilObjTest.php";
2616 if ($count_system == 1)
2624 if ($score_cutting == 0)
2649 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
2652 $result = $ilDB->queryF(
"SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
2653 array(
'integer',
'integer',
'integer'),
2654 array($active_id, $question_id,
$pass)
2677 $res = $ilDB->queryF(
"SELECT DISTINCT(question_fi) FROM tst_test_result JOIN tst_active ".
2678 "ON (active_id = active_fi) ".
2679 "WHERE " . $ilDB->in(
'question_fi', $a_question_ids,
false,
'integer') .
2680 " AND user_fi = %s",
2684 return (
$res->numRows() == count($a_question_ids)) ?
true :
false;
2696 if (preg_match(
"/<[^>]*?>/", $a_text))
2714 include_once
"./Services/Utilities/classes/class.ilUtil.php";
2728 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
2730 $material = $a_material->getMaterial($i);
2731 if (strcmp($material[
"type"],
"mattext") == 0)
2733 $result .= $material[
"material"]->getContent();
2735 if (strcmp($material[
"type"],
"matimage") == 0)
2737 $matimage = $material[
"material"];
2738 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
2741 if (!is_array(
$_SESSION[
"import_mob_xhtml"]))
$_SESSION[
"import_mob_xhtml"] = array();
2742 array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(),
"uri" => $matimage->getUri()));
2757 function addQTIMaterial(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE)
2759 include_once
"./Services/RTE/classes/class.ilRTE.php";
2760 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2762 $a_xml_writer->xmlStartTag(
"material");
2764 "texttype" =>
"text/plain"
2766 if ($this->
isHTML($a_material))
2768 $attrs[
"texttype"] =
"text/xhtml";
2774 foreach (
$mobs as $mob)
2776 $moblabel =
"il_" . IL_INST_ID .
"_mob_" . $mob;
2777 if (strpos($a_material,
"mm_$mob") !== FALSE)
2783 "label" => $moblabel,
2784 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
2787 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
2791 if ($close_material_tag) $a_xml_writer->xmlEndTag(
"material");
2797 if (preg_match(
"/.*\.(png|jpg|gif|jpeg)$/i", $image_filename, $matches))
2799 $extension =
"." . $matches[1];
2801 $image_filename = md5($image_filename) . $extension;
2802 return $image_filename;
2828 $result = $ilDB->queryF(
"SELECT points FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
2829 array(
'integer',
'integer',
'integer'),
2830 array($active_id, $question_id,
$pass)
2832 $manual = ($manualscoring) ? 1 : 0;
2836 $old_points =
$row[
"points"];
2837 $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",
2838 array(
'float',
'integer',
'integer',
'integer',
'integer',
'integer'),
2839 array(
$points, $manual, time(), $active_id, $question_id,
$pass)
2844 $next_id = $ilDB->nextId(
'tst_test_result');
2845 $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)",
2846 array(
'integer',
'integer',
'integer',
'float',
'integer',
'integer',
'integer'),
2847 array($next_id, $active_id, $question_id,
$points,
$pass, $manual, time())
2852 include_once
"./Modules/Test/classes/class.ilObjTest.php";
2853 include_once
'./Modules/Course/classes/class.ilCourseObjectiveResult.php';
2856 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
2859 global
$lng, $ilUser;
2860 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
2921 $result = $ilDB->queryF(
"SELECT question_type_id FROM qpl_qst_type WHERE type_tag = %s",
2928 return $row[
"question_type_id"];
2942 function saveFeedbackGeneric($correctness, $feedback)
2946 switch ($correctness)
2956 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_generic WHERE question_fi = %s AND correctness = %s",
2957 array(
'integer',
'text'),
2958 array($this->
getId(), $correctness)
2960 if (strlen($feedback))
2962 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2963 $next_id = $ilDB->nextId(
'qpl_fb_generic');
2966 $ilDB->insert(
'qpl_fb_generic', array(
2967 'feedback_id' => array(
'integer', $next_id ),
2968 'question_fi' => array(
'integer', $this->
getId() ),
2969 'correctness' => array(
'text', $correctness ),
2971 'tstamp' => array(
'integer', time() ),
2991 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_generic WHERE question_fi = %s AND correctness = %s",
2992 array(
'integer',
'text'),
2993 array($this->
getId(), $correctness)
2998 include_once(
"./Services/RTE/classes/class.ilRTE.php");
3015 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_generic WHERE question_fi = %s",
3023 $next_id = $ilDB->nextId(
'qpl_fb_generic');
3026 $ilDB->insert(
'qpl_fb_generic', array(
3027 'feedback_id' => array(
'integer', $next_id ),
3028 'question_fi' => array(
'integer', $this->
getId() ),
3029 'correctness' => array(
'text',
$row[
"correctness"] ),
3030 'feedback' => array(
'clob',
$row[
"feedback"] ),
3031 'tstamp' => array(
'integer', time() ),
3038 function syncFeedbackGeneric()
3045 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_generic WHERE question_fi = %s",
3047 array($this->original_id)
3051 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_generic WHERE question_fi = %s",
3053 array($this->
getId())
3061 $next_id = $ilDB->nextId(
'qpl_fb_generic');
3064 $ilDB->insert(
'qpl_fb_generic', array(
3065 'feedback_id' => array(
'integer', $next_id ),
3066 'question_fi' => array(
'integer', $this->original_id ),
3067 'correctness' => array(
'text',
$row[
"correctness"] ),
3068 'feedback' => array(
'clob',
$row[
"feedback"] ),
3069 'tstamp' => array(
'integer', time() ),
3088 foreach ($this->suggested_solutions as $solution_array)
3090 $collected .= $solution_array[
"value"];
3102 include_once(
"./Services/RTE/classes/class.ilRTE.php");
3115 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id = %s",
3117 array($this->
getId())
3119 $instances = array();
3123 array_push($ids,
$row[
"question_id"]);
3125 foreach ($ids as $question_id)
3128 $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",
3137 $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",
3146 include_once
"./Modules/Test/classes/class.ilObjTest.php";
3147 foreach ($instances as $key => $value)
3156 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
3159 if (in_array($questiontype, $scoring))
3179 $result = $ilDB->queryF(
"SELECT * FROM tst_active WHERE active_id = %s",
3186 return array(
"user_id" =>
$row[
"user_fi"],
"test_id" =>
$row[
"test_fi"]);
3203 $type = $question_type;
3204 if ($gui) $type .=
"GUI";
3205 if (file_exists(
"./Modules/TestQuestionPool/classes/class.".$type.
".php"))
3207 include_once
"./Modules/TestQuestionPool/classes/class.".$type.
".php";
3211 global $ilPluginAdmin;
3212 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
3213 foreach ($pl_names as $pl_name)
3216 if (strcmp($pl->getQuestionType(), $question_type) == 0)
3218 $pl->includeClass(
"class.".$type.
".php");
3232 if (file_exists(
"./Modules/TestQuestionPool/classes/class.".$type_tag.
".php"))
3235 return $lng->txt($type_tag);
3239 global $ilPluginAdmin;
3240 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
3241 foreach ($pl_names as $pl_name)
3244 if (strcmp($pl->getQuestionType(), $type_tag) == 0)
3246 return $pl->getQuestionTypeTranslation();
3262 if (strcmp($question_id,
"") != 0)
3265 $question_type_gui = $question_type .
"GUI";
3267 $question_gui =
new $question_type_gui();
3268 $question_gui->object->loadFromDb($question_id);
3269 return $question_gui;
3298 return $this->
getId();
3318 case "est_working_time":
3342 case "suggested_solutions":
3349 if (array_key_exists($value, $this->arrData))
3351 return $this->arrData[$value];
3369 $this->
setId($value);
3389 case "est_working_time":
3390 if (is_array($value))
3411 $this->page =& $value;
3414 $this->arrData[$key] = $value;
3426 $this->nr_of_tries = $a_nr_of_tries;
3431 $this->export_image_path = (string)$a_path;
3438 if ($question_id < 1)
3443 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE question_fi = %s AND test_fi = %s",
3444 array(
'integer',
'integer'),
3465 include_once(
"./Services/RTE/classes/class.ilRTE.php");
3467 $a_q = str_replace(
"</li><br />",
"</li>", $a_q);
3468 $a_q = str_replace(
"</li><br>",
"</li>", $a_q);