24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
200 $this->original_id = null;
208 $this->author = $this->ilias->account->fullname;
211 if ($this->owner <= 0)
213 $this->owner = $this->ilias->account->id;
217 $this->suggested_solutions = array();
219 $this->nr_of_tries =
"";
222 $this->arrData = array();
236 function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
238 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class." . $this->
getQuestionType() .
"Import.php";
240 $import =
new $classname($this);
241 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
250 function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
252 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class." . $this->
getQuestionType() .
"Export.php";
254 $export =
new $classname($this);
255 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
280 $result = $ilDB->queryF(
"SELECT * FROM qpl_questions WHERE obj_fi = %s AND title = %s",
281 array(
'integer',
'text'),
282 array($questionpool_id,
$title)
284 return (
$result->numRows() == 1) ? TRUE : FALSE;
320 $this->test_id =
$id;
378 $this->est_working_time = array(
"h" => (
int)$hour,
"m" => (
int)$min,
"s" => (
int)$sec);
392 foreach ($array as
$key => $value)
394 if (strcmp(
$key, $searchkey)==0)
414 $author = $this->ilias->account->fullname;
523 if (!$this->est_working_time)
525 $this->est_working_time = array(
"h" => 0,
"m" => 0,
"s" => 0);
589 $result = $ilDB->queryF(
"SELECT points FROM qpl_questions WHERE question_id = %s",
611 $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",
617 return $ilDB->fetchAssoc(
$result);
632 $result = $ilDB->queryF(
"SELECT suggested_solution_id FROM qpl_sol_sug WHERE question_fi = %s",
649 return $question->getSuggestedSolutionOutput();
655 foreach ($this->suggested_solutions as $solution)
657 switch ($solution[
"type"])
673 return join($output,
"<br />");
688 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s AND subquestion_index = %s",
689 array(
'integer',
'integer'),
690 array($question_id, $subquestion_index)
696 "internal_link" =>
$row[
"internal_link"],
697 "import_id" =>
$row[
"import_id"]
730 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
733 $result = $ilDB->queryF(
"SELECT * FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
734 array(
'integer',
'integer',
'integer'),
735 array($active_id, $question_id,
$pass)
781 include_once
"./Modules/Test/classes/class.ilObjTest.php";
785 if (is_null($reached_points)) $reached_points = 0;
787 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
788 array(
"integer",
"integer",
"integer"),
796 $next_id = $ilDB->nextId(
"tst_test_result");
797 $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)",
798 array(
"integer",
"integer",
"integer",
"integer",
"float",
"integer"),
808 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
818 include_once
'Modules/Course/classes/class.ilCourseObjectiveResult.php';
838 include_once
"./Modules/Test/classes/class.ilObjTest.php";
841 $result = $ilDB->queryF(
"SELECT tst_pass_result.* FROM tst_pass_result WHERE active_fi = %s AND pass = %s",
842 array(
'integer',
'integer'),
843 array($active_id,
$pass)
846 $max =
$row[
'maxpoints'];
847 $reached =
$row[
'points'];
848 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
849 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
851 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_result_cache WHERE active_fi = %s",
855 $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)",
870 strlen($max) ? $max : 0,
871 strlen($reached) ? $reached : 0,
872 strlen($mark[
"short_name"]) ? $mark[
"short_name"] :
" ",
873 strlen($mark[
"official_name"]) ? $mark[
"official_name"] :
" ",
874 ($mark[
"passed"]) ? 1 : 0,
875 (!$mark[
"passed"]) ? 1 : 0,
884 include_once
"./Modules/Test/classes/class.ilObjTest.php";
888 $result = $ilDB->queryF(
"SELECT SUM(points) reachedpoints, COUNT(question_fi) answeredquestions FROM tst_test_result WHERE active_fi = %s AND pass = %s",
889 array(
'integer',
'integer'),
890 array($active_id,
$pass)
895 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE active_fi = %s AND pass = %s",
896 array(
'integer',
'integer'),
897 array($active_id,
$pass)
899 $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)",
913 (
$row[
"reachedpoints"]) ?
$row[
"reachedpoints"] : 0,
916 $row[
"answeredquestions"],
924 'active_fi' => $active_id,
926 'points' => (
$row[
"reachedpoints"]) ?
$row[
"reachedpoints"] : 0,
927 'maxpoints' =>
$data[
"points"],
928 'questioncount' =>
$data[
"count"],
929 'answeredquestions' => $row[
"answeredquestions"],
930 'workingtime' => $time,
942 function logAction($logtext =
"", $active_id =
"", $question_id =
"")
947 if (strcmp($question_id,
"") != 0)
949 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
952 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
953 include_once
"./Modules/Test/classes/class.ilObjTest.php";
964 function _logAction($logtext =
"", $active_id =
"", $question_id =
"")
969 if (strcmp($question_id,
"") != 0)
971 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
974 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
975 include_once
"./Modules/Test/classes/class.ilObjTest.php";
988 $mediatempdir = CLIENT_WEB_DIR .
"/assessment/temp";
990 $temp_name = tempnam($mediatempdir,
$name .
"_____");
991 $temp_name = str_replace(
"\\",
"/", $temp_name);
1009 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/solution/";
1019 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/java/";
1030 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/images/";
1041 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/flash/";
1052 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1064 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1077 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1090 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1113 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s ORDER BY solution_id",
1114 array(
'integer',
'integer',
'integer'),
1119 array_push($values,
$row);
1135 if ($question_id < 1) $question_id = $this->
getId();
1136 $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",
1141 $count =
$row[
"question_count"];
1143 $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",
1162 if ($question_id < 1) $question_id =
$this->id;
1163 $result = $ilDB->queryF(
"SELECT original_id FROM qpl_questions WHERE question_id = %s",
1168 return (
$row[
"original_id"] > 0) ? TRUE : FALSE;
1179 $keys = array_keys($array);
1182 foreach ($keys as
$key)
1198 $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",
1203 return $data[
"type_tag"];
1238 if (is_array($answer_table_name))
1240 foreach ($answer_table_name as $table)
1244 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $table WHERE question_fi = %s",
1253 if (strlen($answer_table_name))
1255 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $answer_table_name WHERE question_fi = %s",
1273 if (is_array($additional_table_name))
1275 foreach ($additional_table_name as $table)
1279 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $table WHERE question_fi = %s",
1288 if (strlen($additional_table_name))
1290 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $additional_table_name WHERE question_fi = %s",
1306 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1318 public function delete($question_id)
1322 if ($question_id < 1)
return true;
1324 $result = $ilDB->queryF(
"SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
1343 $ilLog->write(
"EXCEPTION: Could not delete page of question $question_id: $e");
1347 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_questions WHERE question_id = %s",
1351 if ($affectedRows == 0)
return false;
1360 $ilLog->write(
"EXCEPTION: Could not delete additional table data of question $question_id: $e");
1367 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE question_fi = %s",
1374 $ilLog->write(
"EXCEPTION: Could not delete delete question $question_id from a test: $e");
1381 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s",
1388 $ilLog->write(
"EXCEPTION: Could not delete suggested solutions of question $question_id: $e");
1394 $directory = CLIENT_WEB_DIR .
"/assessment/" .
$obj_id .
"/$question_id";
1395 if (preg_match(
"/\d+/",
$obj_id) and preg_match(
"/\d+/", $question_id) and is_dir($directory))
1397 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1403 $ilLog->write(
"EXCEPTION: Could not delete question file directory $directory of question $question_id: $e");
1409 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1415 foreach(
$mobs as $mob)
1427 $ilLog->write(
"EXCEPTION: Error deleting the media objects of question $question_id: $e");
1434 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1439 $ilLog->write(
"EXCEPTION: Error updating the question pool question count of question pool " . $this->
getObjId() .
" when deleting question $question_id: $e");
1464 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
1465 array(
'integer',
'integer'),
1466 array($a_q_id, $a_q_id)
1472 $found_id = array();
1475 array_push($found_id,
$row[
"question_id"]);
1478 $result = $ilDB->query(
"SELECT * FROM tst_test_result WHERE " . $ilDB->in(
'question_fi', $found_id,
false,
'integer'));
1493 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
1494 array(
'integer',
'integer'),
1495 array($a_q_id, $a_q_id)
1501 $found_id = array();
1504 array_push($found_id,
$row[
"question_id"]);
1506 $result = $ilDB->query(
"SELECT * FROM tst_test_result WHERE " . $ilDB->in(
'question_fi', $found_id,
false,
'integer'));
1510 $reached =
$row[
"points"];
1511 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1513 array_push($answers, array(
"reached" => $reached,
"max" => $max));
1517 foreach ($answers as
$key => $value)
1519 $max += $value[
"max"];
1520 $reached += $value[
"reached"];
1524 return $reached / $max;
1540 $result = $ilDB->queryF(
"SELECT title FROM qpl_questions WHERE question_id = %s",
1547 return $row[
"title"];
1563 $result = $ilDB->queryF(
"SELECT question_text FROM qpl_questions WHERE question_id = %s",
1570 return $row[
"question_text"];
1581 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1583 foreach (
$mobs as $mob)
1591 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1593 foreach (
$mobs as $mob)
1606 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1608 $this->page->setId($this->
getId());
1609 $this->page->setParentId($qpl_id);
1610 $this->page->setXMLContent(
"<PageObject><PageContent>".
1611 "<Question QRef=\"il__qst_".$this->
getId().
"\"/>".
1612 "</PageContent></PageObject>");
1613 $this->page->create();
1620 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1623 $xml = str_replace(
"il__qst_".$a_q_id,
"il__qst_".$this->
id,
$page->getXMLContent());
1624 $this->page->setXMLContent($xml);
1625 $this->page->saveMobUsage($xml);
1626 $this->page->updateFromXML();
1632 include_once
"./Services/COPage/classes/class.ilPageObject.php";
1634 return $page->getXMLContent();
1648 if ($question_id < 1)
return "";
1649 $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",
1656 return $data[
"type_tag"];
1675 if ($question_id < 1)
return "";
1677 $result = $ilDB->queryF(
"SELECT title FROM qpl_questions WHERE qpl_questions.question_id = %s",
1684 return $data[
"title"];
1712 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
1714 array($this->
getId())
1716 $this->suggested_solutions = array();
1719 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1723 $this->suggested_solutions[
$row[
"subquestion_index"]] = array(
1724 "type" => $row[
"type"],
1726 "internal_link" => $row[
"internal_link"],
1727 "import_id" => $row[
"import_id"]
1741 global
$ilDB, $ilUser;
1745 $estw_time = sprintf(
"%02d:%02d:%02d", $estw_time[
'h'], $estw_time[
'm'], $estw_time[
's']);
1749 $next_id = $ilDB->nextId(
'qpl_questions');
1750 $affectedRows = $ilDB->insert(
"qpl_questions", array(
1751 "question_id" => array(
"integer", $next_id),
1753 "obj_fi" => array(
"integer",
$obj_id),
1754 "title" => array(
"text", NULL),
1755 "description" => array(
"text", NULL),
1756 "author" => array(
"text", $this->
getAuthor()),
1757 "owner" => array(
"integer", $ilUser->getId()),
1758 "question_text" => array(
"clob", NULL),
1759 "points" => array(
"float", 0),
1760 "nr_of_tries" => array(
"integer", 1),
1761 "working_time" => array(
"text", $estw_time),
1762 "complete" => array(
"text", $complete),
1763 "created" => array(
"integer", time()),
1764 "original_id" => array(
"integer", NULL),
1765 "tstamp" => array(
"integer", 0)
1767 $this->
setId($next_id);
1771 return $this->
getId();
1779 $estw_time = sprintf(
"%02d:%02d:%02d", $estw_time[
'h'], $estw_time[
'm'], $estw_time[
's']);
1782 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1783 if ($this->
getId() == -1)
1786 $next_id = $ilDB->nextId(
'qpl_questions');
1787 $affectedRows = $ilDB->insert(
"qpl_questions", array(
1788 "question_id" => array(
"integer", $next_id),
1790 "obj_fi" => array(
"integer", $this->
getObjId()),
1791 "title" => array(
"text", $this->
getTitle()),
1792 "description" => array(
"text", $this->
getComment()),
1793 "author" => array(
"text", $this->
getAuthor()),
1794 "owner" => array(
"integer", $this->
getOwner()),
1797 "working_time" => array(
"text", $estw_time),
1799 "created" => array(
"integer", time()),
1801 "tstamp" => array(
"integer", time())
1803 $this->
setId($next_id);
1810 $affectedRows = $ilDB->update(
"qpl_questions", array(
1811 "obj_fi" => array(
"integer", $this->
getObjId()),
1812 "title" => array(
"text", $this->
getTitle()),
1813 "description" => array(
"text", $this->
getComment()),
1814 "author" => array(
"text", $this->
getAuthor()),
1818 "working_time" => array(
"text", $estw_time),
1819 "tstamp" => array(
"integer", time())
1821 "question_id" => array(
"integer", $this->
getId())
1848 $affectedRows = $ilDB->manipulateF(
"UPDATE qpl_questions SET tstamp = %s, owner = %s, complete = %s WHERE question_id = %s",
1849 array(
'integer',
'integer',
'integer',
'text'),
1850 array(time(), ($this->
getOwner() <= 0) ? $this->ilias->account->id : $this->getOwner(), $complete, $this->
getId())
1854 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1869 protected function onCopy($source_questionpool_id, $source_question_id)
1881 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s",
1883 array($this->
getId())
1886 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
1888 $this->suggested_solutions = array();
1901 if (array_key_exists($subquestion_index, $this->suggested_solutions))
1903 return $this->suggested_solutions[$subquestion_index];
1921 if (array_key_exists($subquestion_index, $this->suggested_solutions))
1923 $title = $this->suggested_solutions[$subquestion_index][
"internal_link"];
1944 if (strcmp($solution_id,
"") != 0)
1949 $import_id = $solution_id;
1952 $this->suggested_solutions[$subquestion_index] = array(
1953 "internal_link" => $solution_id,
1954 "import_id" => $import_id
1966 foreach ($this->suggested_solutions as $index => $solution)
1968 if (strcmp($solution[
"type"],
"file") == 0)
1971 $filepath_original = str_replace(
"/$this->id/solution",
"/$question_id/solution", $filepath);
1972 if (!file_exists($filepath))
1979 if (!copy($filepath_original .
$filename, $filepath . $filename))
1981 $ilLog->write(
"File could not be duplicated!!!!", $ilLog->ERROR);
1982 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
1997 $filepath_original = str_replace(
"/$this->id/solution",
"/$original_id/solution", $filepath);
1999 foreach ($this->suggested_solutions as $index => $solution)
2001 if (strcmp($solution[
"type"],
"file") == 0)
2003 if (!file_exists($filepath_original))
2010 if (!@copy($filepath .
$filename, $filepath_original . $filename))
2012 $ilLog->write(
"File could not be duplicated!!!!", $ilLog->ERROR);
2013 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
2024 foreach ($this->suggested_solutions as $index => $solution)
2026 if (strcmp($solution[
"type"],
"file") == 0)
2029 $filepath_original = str_replace(
"/$this->obj_id/$this->id/solution",
"/$source_questionpool_id/$source_question_id/solution", $filepath);
2030 if (!file_exists($filepath))
2037 if (!copy($filepath_original .
$filename, $filepath . $filename))
2039 $ilLog->write(
"File could not be copied!!!!", $ilLog->ERROR);
2040 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
2055 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
2056 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s",
2061 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2062 foreach ($this->suggested_solutions as $index => $solution)
2064 $next_id = $ilDB->nextId(
'qpl_sol_sug');
2065 $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)",
2066 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"integer",
"integer"),
2072 $solution[
"internal_link"],
2078 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
2100 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s AND subquestion_index = %s",
2101 array(
"integer",
"integer"),
2108 $next_id = $ilDB->nextId(
'qpl_sol_sug');
2109 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2110 $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)",
2111 array(
"integer",
"integer",
"text",
"text",
"text",
"text",
"integer",
"integer"),
2123 if ($affectedRows == 1)
2125 $this->suggested_solutions[
"subquestion_index"] = array(
2128 "internal_link" => $solution_id,
2137 if (preg_match(
"/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches))
2139 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
2140 include_once
"./Modules/LearningModule/classes/class.ilLMObject.php";
2141 include_once
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
2142 switch ($matches[2])
2160 if (strcmp($resolved_link,
"") == 0)
2162 $resolved_link = $internal_link;
2167 $resolved_link = $internal_link;
2169 return $resolved_link;
2176 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
2184 $internal_link =
$row[
"internal_link"];
2185 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
2187 if (strcmp($internal_link, $resolved_link) != 0)
2190 $affectedRows = $ilDB->manipulateF(
"UPDATE qpl_sol_sug SET internal_link = %s WHERE suggested_solution_id = %s",
2191 array(
'text',
'integer'),
2192 array($resolved_link,
$row[
"suggested_solution_id"])
2203 include_once
"./Services/COPage/classes/class.ilInternalLink.php";
2206 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
2214 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/",
$row[
"internal_link"], $matches))
2227 "lm" =>
"LearningModule",
2228 "pg" =>
"PageObject",
2229 "st" =>
"StructureObject",
2230 "git" =>
"GlossaryItem",
2231 "mob" =>
"MediaObject"
2234 if (preg_match(
"/il__(\w+)_(\d+)/", $target, $matches))
2236 $type = $matches[1];
2238 include_once
"./Services/Utilities/classes/class.ilUtil.php";
2239 switch($linktypes[$matches[1]])
2241 case "LearningModule":
2245 case "StructureObject":
2248 case "GlossaryItem":
2252 $href =
"./ilias.php?baseClass=ilLMPresentationGUI&obj_type=" . $linktypes[
$type] .
"&cmd=media&ref_id=".$_GET[
"ref_id"].
"&mob_id=".
$target_id;
2269 $result = $ilDB->queryF(
"SELECT * FROM qpl_questions WHERE question_id = %s",
2276 if (
$row[
"original_id"] > 0)
2278 return $row[
"original_id"];
2282 return $row[
"question_id"];
2330 if ($question_id < 1)
2335 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE question_id = %s",
2358 if (strcmp($question_id,
"") != 0)
2361 if (!strlen($question_type))
return null;
2377 if (strcmp($this->points,
"") == 0)
2396 $this->points = $a_points;
2427 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
2428 array(
'integer',
'integer'),
2429 array($active_id, $question_id)
2434 return $row[
"maxpass"];
2454 if (($question_id < 1) || ($user_id < 1))
2459 $result = $ilDB->queryF(
"SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
2466 $qpl_object_id =
$row[
"obj_fi"];
2467 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2486 if ($question_id < 1)
return 0;
2487 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE question_fi = %s",
2505 include_once
"./Modules/Test/classes/class.ilObjTest.php";
2507 if ($count_system == 1)
2515 if ($score_cutting == 0)
2540 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
2543 $result = $ilDB->queryF(
"SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
2544 array(
'integer',
'integer',
'integer'),
2545 array($active_id, $question_id,
$pass)
2568 $res = $ilDB->queryF(
"SELECT DISTINCT(question_fi) FROM tst_test_result JOIN tst_active ".
2569 "ON (active_id = active_fi) ".
2570 "WHERE " . $ilDB->in(
'question_fi', $a_question_ids,
false,
'integer') .
2571 " AND user_fi = %s",
2575 return (
$res->numRows() == count($a_question_ids)) ?
true :
false;
2587 if (preg_match(
"/<[^>]*?>/", $a_text))
2605 include_once
"./Services/Utilities/classes/class.ilUtil.php";
2619 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
2621 $material = $a_material->getMaterial($i);
2622 if (strcmp($material[
"type"],
"mattext") == 0)
2624 $result .= $material[
"material"]->getContent();
2626 if (strcmp($material[
"type"],
"matimage") == 0)
2628 $matimage = $material[
"material"];
2629 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
2632 if (!is_array(
$_SESSION[
"import_mob_xhtml"]))
$_SESSION[
"import_mob_xhtml"] = array();
2633 array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(),
"uri" => $matimage->getUri()));
2648 function addQTIMaterial(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE)
2650 include_once
"./Services/RTE/classes/class.ilRTE.php";
2651 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2653 $a_xml_writer->xmlStartTag(
"material");
2655 "texttype" =>
"text/plain"
2657 if ($this->
isHTML($a_material))
2659 $attrs[
"texttype"] =
"text/xhtml";
2665 foreach (
$mobs as $mob)
2667 $moblabel =
"il_" . IL_INST_ID .
"_mob_" . $mob;
2668 if (strpos($a_material,
"mm_$mob") !== FALSE)
2674 "label" => $moblabel,
2675 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
2678 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
2682 if ($close_material_tag) $a_xml_writer->xmlEndTag(
"material");
2688 if (preg_match(
"/.*\.(png|jpg|gif|jpeg)$/i", $image_filename, $matches))
2690 $extension =
"." . $matches[1];
2692 $image_filename = md5($image_filename) . $extension;
2693 return $image_filename;
2719 $result = $ilDB->queryF(
"SELECT points FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
2720 array(
'integer',
'integer',
'integer'),
2721 array($active_id, $question_id,
$pass)
2723 $manual = ($manualscoring) ? 1 : 0;
2727 $old_points =
$row[
"points"];
2728 $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",
2729 array(
'float',
'integer',
'integer',
'integer',
'integer',
'integer'),
2730 array(
$points, $manual, time(), $active_id, $question_id,
$pass)
2735 $next_id = $ilDB->nextId(
'tst_test_result');
2736 $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)",
2737 array(
'integer',
'integer',
'integer',
'float',
'integer',
'integer',
'integer'),
2738 array($next_id, $active_id, $question_id,
$points,
$pass, $manual, time())
2743 include_once
"./Modules/Test/classes/class.ilObjTest.php";
2744 include_once
'./Modules/Course/classes/class.ilCourseObjectiveResult.php';
2747 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
2750 global
$lng, $ilUser;
2751 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
2812 $result = $ilDB->queryF(
"SELECT question_type_id FROM qpl_qst_type WHERE type_tag = %s",
2819 return $row[
"question_type_id"];
2837 switch ($correctness)
2847 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_generic WHERE question_fi = %s AND correctness = %s",
2848 array(
'integer',
'text'),
2849 array($this->
getId(), $correctness)
2851 if (strlen($feedback))
2853 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2854 $next_id = $ilDB->nextId(
'qpl_fb_generic');
2855 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_fb_generic (feedback_id, question_fi, correctness, feedback, tstamp) VALUES (%s, %s, %s, %s, %s)",
2856 array(
'integer',
'integer',
'text',
'text',
'integer'),
2876 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_generic WHERE question_fi = %s AND correctness = %s",
2877 array(
'integer',
'text'),
2878 array($this->
getId(), $correctness)
2883 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2900 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_generic WHERE question_fi = %s",
2908 $next_id = $ilDB->nextId(
'qpl_fb_generic');
2909 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_fb_generic (feedback_id, question_fi, correctness, feedback, tstamp) VALUES (%s, %s, %s, %s, %s)",
2910 array(
'integer',
'integer',
'text',
'text',
'integer'),
2911 array($next_id, $this->
getId(),
$row[
"correctness"],
$row[
"feedback"], time())
2924 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_fb_generic WHERE question_fi = %s",
2926 array($this->original_id)
2930 $result = $ilDB->queryF(
"SELECT * FROM qpl_fb_generic WHERE question_fi = %s",
2932 array($this->
getId())
2940 $next_id = $ilDB->nextId(
'qpl_fb_generic');
2941 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_fb_generic (feedback_id, question_fi, correctness, feedback, tstamp) VALUES (%s, %s, %s, %s, %s)",
2942 array(
'integer',
'integer',
'text',
'text',
'integer'),
2943 array($next_id, $this->original_id,
$row[
"correctness"],
$row[
"feedback"], time())
2960 foreach ($this->suggested_solutions as $solution_array)
2962 $collected .= $solution_array[
"value"];
2974 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2987 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id = %s",
2989 array($this->
getId())
2991 $instances = array();
2995 array_push($ids,
$row[
"question_id"]);
2997 foreach ($ids as $question_id)
3000 $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",
3009 $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",
3018 include_once
"./Modules/Test/classes/class.ilObjTest.php";
3019 foreach ($instances as
$key => $value)
3028 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
3031 if (in_array($questiontype, $scoring))
3051 $result = $ilDB->queryF(
"SELECT * FROM tst_active WHERE active_id = %s",
3058 return array(
"user_id" =>
$row[
"user_fi"],
"test_id" =>
$row[
"test_fi"]);
3075 $type = $question_type;
3076 if ($gui)
$type .=
"GUI";
3077 if (file_exists(
"./Modules/TestQuestionPool/classes/class.".
$type.
".php"))
3079 include_once
"./Modules/TestQuestionPool/classes/class.".$type.
".php";
3083 global $ilPluginAdmin;
3084 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
3085 foreach ($pl_names as $pl_name)
3088 if (strcmp($pl->getQuestionType(), $question_type) == 0)
3090 $pl->includeClass(
"class.".
$type.
".php");
3104 if (file_exists(
"./Modules/TestQuestionPool/classes/class.".$type_tag.
".php"))
3107 return $lng->txt($type_tag);
3111 global $ilPluginAdmin;
3112 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
3113 foreach ($pl_names as $pl_name)
3116 if (strcmp($pl->getQuestionType(), $type_tag) == 0)
3118 return $pl->getQuestionTypeTranslation();
3134 if (strcmp($question_id,
"") != 0)
3137 $question_type_gui = $question_type .
"GUI";
3139 $question_gui =
new $question_type_gui();
3140 $question_gui->object->loadFromDb($question_id);
3141 return $question_gui;
3170 return $this->
getId();
3190 case "est_working_time":
3214 case "suggested_solutions":
3221 if (array_key_exists($value, $this->arrData))
3223 return $this->arrData[$value];
3241 $this->
setId($value);
3261 case "est_working_time":
3262 if (is_array($value))
3283 $this->page =& $value;
3286 $this->arrData[
$key] = $value;
3298 $this->nr_of_tries = $a_nr_of_tries;