4 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
272 $this->original_id = null;
280 $this->author = $this->ilias->account->fullname;
283 if ($this->owner <= 0)
285 $this->owner = $this->ilias->account->id;
289 $this->suggested_solutions = array();
291 $this->nr_of_tries = 0;
294 $this->arrData = array();
297 $this->questionActionCmd =
'handleQuestionAction';
299 $this->lastChange = null;
329 function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
331 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class." . $this->
getQuestionType() .
"Import.php";
333 $import =
new $classname($this);
334 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
343 function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
345 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class." . $this->
getQuestionType() .
"Export.php";
347 $export =
new $classname($this);
348 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
373 $result = $ilDB->queryF(
"SELECT * FROM qpl_questions WHERE obj_fi = %s AND title = %s",
374 array(
'integer',
'text'),
375 array($questionpool_id,
$title)
377 return (
$result->numRows() > 0) ? TRUE : FALSE;
413 $this->test_id =
$id;
472 $this->est_working_time = array(
"h" => (
int)$hour,
"m" => (
int)$min,
"s" => (
int)$sec);
483 $this->est_working_time = array(
484 'h' => (
int)substr($durationString, 0, 2),
485 'm' => (
int)substr($durationString, 3, 2),
486 's' => (
int)substr($durationString, 6, 2)
501 foreach ($array as $key => $value)
503 if (strcmp($key, $searchkey)==0)
523 $author = $this->ilias->account->fullname;
642 if (!$this->est_working_time)
644 $this->est_working_time = array(
"h" => 0,
"m" => 0,
"s" => 0);
710 if(!strlen($this->external_id))
712 if($this->
getId() > 0)
714 return 'il_' . IL_INST_ID .
'_qst_' . $this->
getId();
718 return uniqid(
'',
true);
738 $result = $ilDB->queryF(
"SELECT points FROM qpl_questions WHERE question_id = %s",
760 $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",
766 return $ilDB->fetchAssoc(
$result);
781 $result = $ilDB->queryF(
"SELECT suggested_solution_id FROM qpl_sol_sug WHERE question_fi = %s",
798 return $question->getSuggestedSolutionOutput();
804 foreach ($this->suggested_solutions as $solution)
806 switch ($solution[
"type"])
815 $possible_texts = array_values(array_filter(array(
818 $this->lng->txt(
'tst_show_solution_suggested')
820 array_push($output,
'<a href="' . $this->
getSuggestedSolutionPathWeb() . $solution[
"value"][
"name"] .
'">' . $possible_texts[0] .
'</a>');
827 return join($output,
"<br />");
842 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s AND subquestion_index = %s",
843 array(
'integer',
'integer'),
844 array($question_id, $subquestion_index)
850 "internal_link" =>
$row[
"internal_link"],
851 "import_id" =>
$row[
"import_id"]
884 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
887 $result = $ilDB->queryF(
"SELECT * FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
888 array(
'integer',
'integer',
'integer'),
889 array($active_id, $question_id,
$pass)
938 include_once
"./Modules/Test/classes/class.ilObjTest.php";
948 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
950 $requestsStatisticData = $hintTracking->getRequestStatisticDataByQuestionAndTestpass();
951 $reached_points = $reached_points - $requestsStatisticData->getRequestsPoints();
956 return $reached_points;
974 include_once
"./Modules/Test/classes/class.ilObjTest.php";
982 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
984 $requestsStatisticData = $questionHintTracking->getRequestStatisticDataByQuestionAndTestpass();
985 $reached_points = $reached_points - $requestsStatisticData->getRequestsPoints();
999 if( is_null($reached_points) ) $reached_points = 0;
1004 DELETE FROM tst_test_result
1006 WHERE active_fi = %s
1007 AND question_fi = %s
1011 $types = array(
'integer',
'integer',
'integer');
1012 $values = array($active_id, $this->
getId(),
$pass);
1014 if( $this->
getStep() !== NULL )
1020 $types[] =
'integer';
1024 $affectedRows = $ilDB->manipulateF(
$query, $types, $values);
1026 $next_id = $ilDB->nextId(
"tst_test_result");
1029 'test_result_id' => array(
'integer', $next_id),
1030 'active_fi' => array(
'integer', $active_id),
1031 'question_fi' => array(
'integer', $this->
getId()),
1032 'pass' => array(
'integer',
$pass),
1033 'points' => array(
'float', $reached_points),
1034 'tstamp' => array(
'integer', time()),
1035 'hint_count' => array(
'integer', $requestsStatisticData->getRequestsCount()),
1036 'hint_points' => array(
'float', $requestsStatisticData->getRequestsPoints()),
1037 'answered' => array(
'integer', $isAnswered)
1040 if( $this->
getStep() !== NULL )
1042 $fieldData[
'step'] = array(
'integer', $this->
getStep());
1045 $ilDB->insert(
'tst_test_result', $fieldData);
1049 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1069 include_once
'Modules/Course/classes/class.ilCourseObjectiveResult.php';
1083 if(
$pass === null )
1085 require_once
'Modules/Test/classes/class.ilObjTest.php';
1142 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1143 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
1148 SELECT tst_pass_result.*
1149 FROM tst_pass_result
1150 WHERE active_fi = %s
1155 $query, array(
'integer',
'integer'), array($active_id,
$pass)
1160 $max =
$row[
'maxpoints'];
1161 $reached =
$row[
'points'];
1163 $obligationsAnswered = (int)
$row[
'obligations_answered'];
1165 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
1167 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
1169 $mark = ASS_MarkSchema::_getMatchingMarkFromActiveId($active_id, $percentage);
1171 $isPassed = ( $mark[
"passed"] ? 1 : 0 );
1172 $isFailed = ( !$mark[
"passed"] ? 1 : 0 );
1180 DELETE FROM tst_result_cache
1181 WHERE active_fi = %s
1184 $affectedRows = $ilDB->manipulateF(
1185 $query, array(
'integer'), array($active_id)
1188 $ilDB->insert(
'tst_result_cache', array(
1189 'active_fi'=> array(
'integer', $active_id),
1190 'pass'=> array(
'integer', strlen(
$pass) ?
$pass : 0),
1191 'max_points'=> array(
'float', strlen($max) ? $max : 0),
1192 'reached_points'=> array(
'float', strlen($reached) ? $reached : 0),
1193 'mark_short'=> array(
'text', strlen($mark[
"short_name"]) ? $mark[
"short_name"] :
" "),
1194 'mark_official'=> array(
'text', strlen($mark[
"official_name"]) ? $mark[
"official_name"] :
" "),
1195 'passed'=> array(
'integer', $isPassed),
1196 'failed'=> array(
'integer', $isFailed),
1197 'tstamp'=> array(
'integer', time()),
1198 'hint_count'=> array(
'integer',
$row[
'hint_count']),
1199 'hint_points'=> array(
'float',
$row[
'hint_points']),
1200 'obligations_answered' => array(
'integer', $obligationsAnswered)
1214 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1216 if( self::getResultGateway() !== null )
1231 SELECT SUM(points) reachedpoints,
1232 SUM(hint_count) hint_count,
1233 SUM(hint_points) hint_points,
1234 COUNT(DISTINCT(question_fi)) answeredquestions
1235 FROM tst_test_result
1236 WHERE active_fi = %s
1239 array(
'integer',
'integer'),
1240 array($active_id,
$pass)
1245 if( $obligationsEnabled )
1248 SELECT count(*) cnt,
1249 min( answered ) answ
1250 FROM tst_test_question
1251 INNER JOIN tst_active
1253 AND tst_test_question.test_fi = tst_active.test_fi
1254 LEFT JOIN tst_test_result
1255 ON tst_test_result.active_fi = %s
1256 AND tst_test_result.pass = %s
1257 AND tst_test_question.question_fi = tst_test_result.question_fi
1258 WHERE obligatory = 1';
1260 $result_obligatory = $ilDB->queryF(
1261 $query, array(
'integer',
'integer',
'integer'), array($active_id, $active_id,
$pass)
1264 $row_obligatory = $ilDB->fetchAssoc($result_obligatory);
1266 if ($row_obligatory[
'cnt'] == 0)
1268 $obligations_answered = 1;
1272 $obligations_answered = (int) $row_obligatory[
'answ'];
1277 $obligations_answered = 1;
1282 if(
$row[
'hint_count'] === null )
$row[
'hint_count'] = 0;
1283 if(
$row[
'hint_points'] === null )
$row[
'hint_points'] = 0;
1305 $ilDB->replace(
'tst_pass_result',
1307 'active_fi' => array(
'integer', $active_id),
1308 'pass' => array(
'integer', strlen(
$pass) ?
$pass : 0)),
1310 'points' => array(
'float',
$row[
'reachedpoints'] ?
$row[
'reachedpoints'] : 0),
1311 'maxpoints' => array(
'float', $data[
'points']),
1312 'questioncount' => array(
'integer', $data[
'count']),
1313 'answeredquestions' => array(
'integer', $row[
'answeredquestions']),
1314 'workingtime' => array(
'integer', $time),
1315 'tstamp' => array(
'integer', time()),
1316 'hint_count' => array(
'integer', $row[
'hint_count']),
1317 'hint_points' => array(
'float', $row[
'hint_points']),
1318 'obligations_answered' => array(
'integer', $obligations_answered),
1319 'exam_id' => array(
'text', $exam_identifier)
1349 'active_fi' => $active_id,
1351 'points' => ($row[
"reachedpoints"]) ? $row[
"reachedpoints"] : 0,
1352 'maxpoints' => $data[
"points"],
1353 'questioncount' => $data[
"count"],
1354 'answeredquestions' => $row[
"answeredquestions"],
1355 'workingtime' => $time,
1357 'hint_count' => $row[
'hint_count'],
1358 'hint_points' => $row[
'hint_points'],
1359 'obligations_answered' => $obligations_answered,
1360 'exam_id' => $exam_identifier
1371 function logAction($logtext =
"", $active_id =
"", $question_id =
"")
1376 if (strcmp($question_id,
"") != 0)
1378 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1381 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
1382 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1393 function _logAction($logtext =
"", $active_id =
"", $question_id =
"")
1398 if (strcmp($question_id,
"") != 0)
1400 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1403 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
1404 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1417 $mediatempdir = CLIENT_WEB_DIR .
"/assessment/temp";
1419 $temp_name = tempnam($mediatempdir, $name .
"_____");
1420 $temp_name = str_replace(
"\\",
"/", $temp_name);
1421 @unlink($temp_name);
1438 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/solution/";
1448 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/java/";
1459 if( $question_id === null)
1464 if( $object_id === null)
1474 return CLIENT_WEB_DIR .
"/assessment/{$parentObjectId}/{$questionId}/images/";
1485 return CLIENT_WEB_DIR .
"/assessment/$this->obj_id/$this->id/flash/";
1496 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1508 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1521 if(!$this->export_image_path)
1523 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1541 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1565 if( $this->
getStep() !== NULL )
1567 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND step = %s ORDER BY solution_id",
1568 array(
'integer',
'integer',
'integer',
'integer'),
1569 array($active_id, $this->
getId(), $pass, $this->
getStep())
1574 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s ORDER BY solution_id",
1575 array(
'integer',
'integer',
'integer'),
1576 array($active_id, $this->
getId(), $pass)
1580 while ($row = $ilDB->fetchAssoc(
$result))
1582 array_push($values, $row);
1598 if ($question_id < 1) $question_id = $this->
getId();
1599 $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",
1603 $row = $ilDB->fetchAssoc(
$result);
1604 $count = $row[
"question_count"];
1606 $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",
1625 if ($question_id < 1) $question_id =
$this->id;
1626 $result = $ilDB->queryF(
"SELECT original_id FROM qpl_questions WHERE question_id = %s",
1630 $row = $ilDB->fetchAssoc(
$result);
1631 return ($row[
"original_id"] > 0) ? TRUE : FALSE;
1642 $keys = array_keys($array);
1645 foreach ($keys as $key)
1661 $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",
1665 $data = $ilDB->fetchAssoc(
$result);
1666 return $data[
"type_tag"];
1702 if( !is_array($answer_table_name) )
1704 $answer_table_name = array($answer_table_name);
1707 foreach ($answer_table_name as $table)
1711 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $table WHERE question_fi = %s",
1731 if( !is_array($additional_table_name) )
1733 $additional_table_name = array($additional_table_name);
1736 foreach ($additional_table_name as $table)
1740 $affectedRows = $ilDB->manipulateF(
"DELETE FROM $table WHERE question_fi = %s",
1756 include_once
"./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php";
1768 public function delete($question_id)
1772 if ($question_id < 1)
return true;
1774 $result = $ilDB->queryF(
"SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
1780 $row = $ilDB->fetchAssoc(
$result);
1793 $ilLog->write(
"EXCEPTION: Could not delete page of question $question_id: $e");
1797 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_questions WHERE question_id = %s",
1801 if ($affectedRows == 0)
return false;
1812 $ilLog->write(
"EXCEPTION: Could not delete additional table data of question $question_id: $e");
1819 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE question_fi = %s",
1826 $ilLog->write(
"EXCEPTION: Could not delete delete question $question_id from a test: $e");
1833 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s",
1840 $ilLog->write(
"EXCEPTION: Could not delete suggested solutions of question $question_id: $e");
1846 $directory = CLIENT_WEB_DIR .
"/assessment/" .
$obj_id .
"/$question_id";
1847 if (preg_match(
"/\d+/",
$obj_id) and preg_match(
"/\d+/", $question_id) and is_dir($directory))
1849 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1855 $ilLog->write(
"EXCEPTION: Could not delete question file directory $directory of question $question_id: $e");
1861 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1867 foreach(
$mobs as $mob)
1879 $ilLog->write(
"EXCEPTION: Error deleting the media objects of question $question_id: $e");
1883 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
1886 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintList.php';
1894 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1899 $ilLog->write(
"EXCEPTION: Error updating the question pool question count of question pool " . $this->
getObjId() .
" when deleting question $question_id: $e");
1910 require_once
'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
1911 require_once
'Services/Taxonomy/classes/class.ilTaxNodeAssignment.php';
1914 foreach($taxIds as $taxId)
1917 $taxNodeAssignment->deleteAssignmentsOfItem($this->
getId());
1940 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
1941 array(
'integer',
'integer'),
1942 array($a_q_id, $a_q_id)
1948 $found_id = array();
1949 while ($row = $ilDB->fetchAssoc(
$result))
1951 array_push($found_id, $row[
"question_id"]);
1954 $result = $ilDB->query(
"SELECT * FROM tst_test_result WHERE " . $ilDB->in(
'question_fi', $found_id,
false,
'integer'));
1969 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
1970 array(
'integer',
'integer'),
1971 array($a_q_id, $a_q_id)
1977 $found_id = array();
1978 while ($row = $ilDB->fetchAssoc(
$result))
1980 array_push($found_id, $row[
"question_id"]);
1982 $result = $ilDB->query(
"SELECT * FROM tst_test_result WHERE " . $ilDB->in(
'question_fi', $found_id,
false,
'integer'));
1984 while ($row = $ilDB->fetchAssoc(
$result))
1986 $reached = $row[
"points"];
1987 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1989 array_push($answers, array(
"reached" => $reached,
"max" => $max));
1993 foreach ($answers as $key => $value)
1995 $max += $value[
"max"];
1996 $reached += $value[
"reached"];
2000 return $reached / $max;
2016 $result = $ilDB->queryF(
"SELECT title FROM qpl_questions WHERE question_id = %s",
2022 $row = $ilDB->fetchAssoc(
$result);
2023 return $row[
"title"];
2039 $result = $ilDB->queryF(
"SELECT question_text FROM qpl_questions WHERE question_id = %s",
2045 $row = $ilDB->fetchAssoc(
$result);
2046 return $row[
"question_text"];
2057 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2059 foreach (
$mobs as $mob)
2067 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2069 foreach (
$mobs as $mob)
2082 include_once
"./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php";
2084 $this->page->setId($this->
getId());
2085 $this->page->setParentId($qpl_id);
2086 $this->page->setXMLContent(
"<PageObject><PageContent>".
2087 "<Question QRef=\"il__qst_".$this->
getId().
"\"/>".
2088 "</PageContent></PageObject>");
2089 $this->page->create();
2096 include_once
"./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php";
2099 $xml = str_replace(
"il__qst_".$a_q_id,
"il__qst_".$this->
id,
$page->getXMLContent());
2100 $this->page->setXMLContent($xml);
2101 $this->page->updateFromXML();
2107 include_once
"./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php";
2109 return $page->getXMLContent();
2123 if ($question_id < 1)
return "";
2124 $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",
2130 $data = $ilDB->fetchAssoc(
$result);
2131 return $data[
"type_tag"];
2150 if ($question_id < 1)
return "";
2152 $result = $ilDB->queryF(
"SELECT title FROM qpl_questions WHERE qpl_questions.question_id = %s",
2158 $data = $ilDB->fetchAssoc(
$result);
2159 return $data[
"title"];
2188 "SELECT external_id FROM qpl_questions WHERE question_id = %s",
2194 $data = $ilDB->fetchAssoc(
$result);
2195 $this->external_id = $data[
'external_id'];
2198 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
2200 array($this->
getId())
2202 $this->suggested_solutions = array();
2205 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2206 while ($row = $ilDB->fetchAssoc(
$result))
2209 $this->suggested_solutions[$row[
"subquestion_index"]] = array(
2210 "type" => $row[
"type"],
2212 "internal_link" => $row[
"internal_link"],
2213 "import_id" => $row[
"import_id"]
2231 $estw_time = sprintf(
"%02d:%02d:%02d", $estw_time[
'h'], $estw_time[
'm'], $estw_time[
's']);
2245 $next_id = $ilDB->nextId(
'qpl_questions');
2246 $affectedRows = $ilDB->insert(
"qpl_questions", array(
2247 "question_id" => array(
"integer", $next_id),
2249 "obj_fi" => array(
"integer",
$obj_id),
2250 "title" => array(
"text", NULL),
2251 "description" => array(
"text", NULL),
2252 "author" => array(
"text", $this->
getAuthor()),
2253 "owner" => array(
"integer", $ilUser->getId()),
2254 "question_text" => array(
"clob", NULL),
2255 "points" => array(
"float", 0),
2257 "working_time" => array(
"text", $estw_time),
2258 "complete" => array(
"text", $complete),
2259 "created" => array(
"integer", time()),
2260 "original_id" => array(
"integer", NULL),
2261 "tstamp" => array(
"integer", $tstamp),
2265 $this->
setId($next_id);
2276 return $this->
getId();
2284 $estw_time = sprintf(
"%02d:%02d:%02d", $estw_time[
'h'], $estw_time[
'm'], $estw_time[
's']);
2287 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2288 if ($this->
getId() == -1)
2291 $next_id = $ilDB->nextId(
'qpl_questions');
2292 $affectedRows = $ilDB->insert(
"qpl_questions", array(
2293 "question_id" => array(
"integer", $next_id),
2295 "obj_fi" => array(
"integer", $this->
getObjId()),
2296 "title" => array(
"text", $this->
getTitle()),
2297 "description" => array(
"text", $this->
getComment()),
2298 "author" => array(
"text", $this->
getAuthor()),
2299 "owner" => array(
"integer", $this->
getOwner()),
2302 "working_time" => array(
"text", $estw_time),
2303 "nr_of_tries" => array(
"integer", $this->
getNrOfTries()),
2304 "created" => array(
"integer", time()),
2306 "tstamp" => array(
"integer", time()),
2310 $this->
setId($next_id);
2317 $affectedRows = $ilDB->update(
"qpl_questions", array(
2318 "obj_fi" => array(
"integer", $this->
getObjId()),
2319 "title" => array(
"text", $this->
getTitle()),
2320 "description" => array(
"text", $this->
getComment()),
2321 "author" => array(
"text", $this->
getAuthor()),
2324 "nr_of_tries" => array(
"integer", $this->
getNrOfTries()),
2325 "working_time" => array(
"text", $estw_time),
2326 "tstamp" => array(
"integer", time()),
2327 'complete' => array(
'integer', $this->
isComplete()),
2330 "question_id" => array(
"integer", $this->
getId())
2345 $this->updateSuggestedSolutions();
2357 $affectedRows = $ilDB->manipulateF(
"UPDATE qpl_questions SET tstamp = %s, owner = %s, complete = %s WHERE question_id = %s",
2358 array(
'integer',
'integer',
'integer',
'text'),
2359 array(time(), ($this->
getOwner() <= 0) ? $this->ilias->account->id : $this->getOwner(), $complete, $this->
getId())
2363 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2371 $ilDB->manipulateF(
"UPDATE qpl_questions SET tstamp = %s, original_id = %s WHERE question_id = %s",
2372 array(
'integer',
'integer',
'text'),
2373 array(time(), $newId, $this->
getId())
2380 protected function onDuplicate($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
2385 $this->feedbackOBJ->duplicateFeedback($originalQuestionId, $duplicateQuestionId);
2399 $this->feedbackOBJ->syncFeedback($origQuestionId, $dupQuestionId);
2405 protected function onCopy($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId)
2410 $this->feedbackOBJ->duplicateFeedback($sourceQuestionId, $targetQuestionId);
2423 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s",
2425 array($this->
getId())
2428 include_once
"./Services/Link/classes/class.ilInternalLink.php";
2430 $this->suggested_solutions = array();
2443 if (array_key_exists($subquestion_index, $this->suggested_solutions))
2445 return $this->suggested_solutions[$subquestion_index];
2463 if (array_key_exists($subquestion_index, $this->suggested_solutions))
2465 $title = $this->suggested_solutions[$subquestion_index][
"internal_link"];
2486 if (strcmp($solution_id,
"") != 0)
2491 $import_id = $solution_id;
2494 $this->suggested_solutions[$subquestion_index] = array(
2495 "internal_link" => $solution_id,
2496 "import_id" => $import_id
2508 foreach ($this->suggested_solutions as $index => $solution)
2510 if (strcmp($solution[
"type"],
"file") == 0)
2513 $filepath_original = str_replace(
2514 "/{$this->obj_id}/{$this->id}/solution",
2515 "/$parent_id/$question_id/solution",
2518 if (!file_exists($filepath))
2525 if (!copy($filepath_original .
$filename, $filepath . $filename))
2527 $ilLog->write(
"File could not be duplicated!!!!", $ilLog->ERROR);
2528 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
2543 $filepath_original = str_replace(
"/$this->id/solution",
"/$original_id/solution", $filepath);
2545 foreach ($this->suggested_solutions as $index => $solution)
2547 if (strcmp($solution[
"type"],
"file") == 0)
2549 if (!file_exists($filepath_original))
2556 if (!@copy($filepath .
$filename, $filepath_original . $filename))
2558 $ilLog->write(
"File could not be duplicated!!!!", $ilLog->ERROR);
2559 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
2570 foreach ($this->suggested_solutions as $index => $solution)
2572 if (strcmp($solution[
"type"],
"file") == 0)
2575 $filepath_original = str_replace(
"/$this->obj_id/$this->id/solution",
"/$source_questionpool_id/$source_question_id/solution", $filepath);
2576 if (!file_exists($filepath))
2583 if (!copy($filepath_original .
$filename, $filepath . $filename))
2585 $ilLog->write(
"File could not be copied!!!!", $ilLog->ERROR);
2586 $ilLog->write(
"object: " . print_r($this, TRUE), $ilLog->ERROR);
2596 public function updateSuggestedSolutions(
$original_id =
"")
2601 include_once
"./Services/Link/classes/class.ilInternalLink.php";
2602 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s",
2607 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2608 foreach ($this->suggested_solutions as $index => $solution)
2610 $next_id = $ilDB->nextId(
'qpl_sol_sug');
2612 $ilDB->insert(
'qpl_sol_sug', array(
2613 'suggested_solution_id' => array(
'integer', $next_id ),
2614 'question_fi' => array(
'integer',
$id ),
2615 'type' => array(
'text', $solution[
'type'] ),
2617 'internal_link' => array(
'text', $solution[
'internal_link'] ),
2618 'import_id' => array(
'text', null ),
2619 'subquestion_index' => array(
'integer', $index ),
2620 'tstamp' => array(
'integer', time() ),
2623 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $solution[
"internal_link"], $matches))
2641 function saveSuggestedSolution($type, $solution_id =
"", $subquestion_index = 0, $value =
"")
2645 $affectedRows = $ilDB->manipulateF(
"DELETE FROM qpl_sol_sug WHERE question_fi = %s AND subquestion_index = %s",
2646 array(
"integer",
"integer"),
2653 $next_id = $ilDB->nextId(
'qpl_sol_sug');
2654 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2656 $affectedRows = $ilDB->insert(
'qpl_sol_sug', array(
2657 'suggested_solution_id' => array(
'integer', $next_id ),
2658 'question_fi' => array(
'integer', $this->
getId() ),
2659 'type' => array(
'text', $type ),
2661 'internal_link' => array(
'text', $solution_id ),
2662 'import_id' => array(
'text', null ),
2663 'subquestion_index' => array(
'integer', $subquestion_index ),
2664 'tstamp' => array(
'integer', time() ),
2667 if ($affectedRows == 1)
2669 $this->suggested_solutions[
"subquestion_index"] = array(
2672 "internal_link" => $solution_id,
2681 if (preg_match(
"/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches))
2683 include_once
"./Services/Link/classes/class.ilInternalLink.php";
2684 include_once
"./Modules/LearningModule/classes/class.ilLMObject.php";
2685 include_once
"./Modules/Glossary/classes/class.ilGlossaryTerm.php";
2686 switch ($matches[2])
2704 if (strcmp($resolved_link,
"") == 0)
2706 $resolved_link = $internal_link;
2711 $resolved_link = $internal_link;
2713 return $resolved_link;
2720 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
2726 while ($row = $ilDB->fetchAssoc(
$result))
2728 $internal_link = $row[
"internal_link"];
2729 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
2731 if (strcmp($internal_link, $resolved_link) != 0)
2734 $affectedRows = $ilDB->manipulateF(
"UPDATE qpl_sol_sug SET internal_link = %s WHERE suggested_solution_id = %s",
2735 array(
'text',
'integer'),
2736 array($resolved_link, $row[
"suggested_solution_id"])
2747 include_once
"./Services/Link/classes/class.ilInternalLink.php";
2750 $result = $ilDB->queryF(
"SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
2756 while ($row = $ilDB->fetchAssoc(
$result))
2758 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $row[
"internal_link"], $matches))
2771 "lm" =>
"LearningModule",
2772 "pg" =>
"PageObject",
2773 "st" =>
"StructureObject",
2774 "git" =>
"GlossaryItem",
2775 "mob" =>
"MediaObject"
2778 if (preg_match(
"/il__(\w+)_(\d+)/", $target, $matches))
2780 $type = $matches[1];
2782 include_once
"./Services/Utilities/classes/class.ilUtil.php";
2783 switch($linktypes[$matches[1]])
2785 case "LearningModule":
2786 $href =
"./goto.php?target=" . $type .
"_" .
$target_id;
2789 case "StructureObject":
2790 $href =
"./goto.php?target=" . $type .
"_" .
$target_id;
2792 case "GlossaryItem":
2793 $href =
"./goto.php?target=" . $type .
"_" .
$target_id;
2796 $href =
"./ilias.php?baseClass=ilLMPresentationGUI&obj_type=" . $linktypes[$type] .
"&cmd=media&ref_id=".$_GET[
"ref_id"].
"&mob_id=".
$target_id;
2813 $result = $ilDB->queryF(
"SELECT * FROM qpl_questions WHERE question_id = %s",
2819 $row = $ilDB->fetchAssoc(
$result);
2820 if ($row[
"original_id"] > 0)
2822 return $row[
"original_id"];
2826 return $row[
"question_id"];
2840 SELECT COUNT(dupl.question_id) cnt
2841 FROM qpl_questions dupl
2842 INNER JOIN qpl_questions orig
2843 ON orig.question_id = dupl.original_id
2844 WHERE dupl.question_id = %s
2847 $res = $ilDB->queryF(
$query, array(
'integer'), array($questionId));
2848 $row = $ilDB->fetchAssoc(
$res);
2850 return $row[
'cnt'] > 0;
2864 if ( !$originalObjId )
2885 $this->updateSuggestedSolutions($original);
2907 if ($question_id < 1)
2912 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE question_id = %s",
2937 if ($question_id < 1)
2942 $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'",
2972 if (strcmp($question_id,
"") != 0)
2975 if (!strlen($question_type))
return null;
2982 $question->feedbackOBJ =
new $feedbackObjectClassname(
$question, $ilCtrl, $ilDB, $lng);
2996 if (strcmp($this->points,
"") == 0)
3015 $this->points = $a_points;
3046 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
3047 array(
'integer',
'integer'),
3048 array($active_id, $question_id)
3052 $row = $ilDB->fetchAssoc(
$result);
3053 return $row[
"maxpass"];
3073 if (($question_id < 1) || ($user_id < 1))
3078 $result = $ilDB->queryF(
"SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
3084 $row = $ilDB->fetchAssoc(
$result);
3085 $qpl_object_id = $row[
"obj_fi"];
3086 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
3105 if ($question_id < 1)
return 0;
3106 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE question_fi = %s",
3156 include_once
"./Modules/Test/classes/class.ilObjTest.php";
3158 if ($count_system == 1)
3166 if ($score_cutting == 0)
3191 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
3194 $result = $ilDB->queryF(
"SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
3195 array(
'integer',
'integer',
'integer'),
3196 array($active_id, $question_id, $pass)
3219 $res = $ilDB->queryF(
"SELECT DISTINCT(question_fi) FROM tst_test_result JOIN tst_active ".
3220 "ON (active_id = active_fi) ".
3221 "WHERE " . $ilDB->in(
'question_fi', $a_question_ids,
false,
'integer') .
3222 " AND user_fi = %s",
3226 return (
$res->numRows() == count($a_question_ids)) ?
true :
false;
3239 if (preg_match(
"/<[^>]*?>/", $a_text))
3257 include_once
"./Services/Utilities/classes/class.ilUtil.php";
3271 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
3273 $material = $a_material->getMaterial($i);
3274 if (strcmp($material[
"type"],
"mattext") == 0)
3276 $result .= $material[
"material"]->getContent();
3278 if (strcmp($material[
"type"],
"matimage") == 0)
3280 $matimage = $material[
"material"];
3281 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
3284 if (!is_array(
$_SESSION[
"import_mob_xhtml"]))
$_SESSION[
"import_mob_xhtml"] = array();
3285 array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(),
"uri" => $matimage->getUri()));
3300 function addQTIMaterial(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE)
3302 include_once
"./Services/RTE/classes/class.ilRTE.php";
3303 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
3305 $a_xml_writer->xmlStartTag(
"material");
3307 "texttype" =>
"text/plain"
3309 if ($this->
isHTML($a_material))
3311 $attrs[
"texttype"] =
"text/xhtml";
3317 foreach (
$mobs as $mob)
3319 $moblabel =
"il_" . IL_INST_ID .
"_mob_" . $mob;
3320 if (strpos($a_material,
"mm_$mob") !== FALSE)
3326 "label" => $moblabel,
3327 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
3330 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
3334 if ($close_material_tag) $a_xml_writer->xmlEndTag(
"material");
3341 if (preg_match(
"/.*\.(png|jpg|gif|jpeg)$/i", $image_filename, $matches))
3343 $extension =
"." . $matches[1];
3348 $image_filename = uniqid($image_filename.microtime(
true));
3351 $image_filename = md5($image_filename) . $extension;
3353 return $image_filename;
3379 $result = $ilDB->queryF(
"SELECT points FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
3380 array(
'integer',
'integer',
'integer'),
3381 array($active_id, $question_id, $pass)
3383 $manual = ($manualscoring) ? 1 : 0;
3384 $rowsnum =
$result->numRows();
3387 $row = $ilDB->fetchAssoc(
$result);
3388 $old_points = $row[
"points"];
3391 $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",
3392 array(
'float',
'integer',
'integer',
'integer',
'integer',
'integer'),
3393 array(
$points, $manual, time(), $active_id, $question_id, $pass)
3399 $next_id = $ilDB->nextId(
'tst_test_result');
3400 $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)",
3401 array(
'integer',
'integer',
'integer',
'float',
'integer',
'integer',
'integer'),
3402 array($next_id, $active_id, $question_id,
$points, $pass, $manual, time())
3406 if($old_points !=
$points || !$rowsnum)
3408 assQuestion::_updateTestPassResults($active_id, $pass, $obligationsEnabled);
3410 include_once
"./Modules/Test/classes/class.ilObjTest.php";
3411 include_once
'./Modules/Course/classes/class.ilCourseObjectiveResult.php';
3414 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3418 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
3475 $result = $ilDB->queryF(
"SELECT question_type_id FROM qpl_qst_type WHERE type_tag = %s",
3481 $row = $ilDB->fetchAssoc(
$result);
3482 return $row[
"question_type_id"];
3487 public function syncHints()
3492 $ilDB->manipulateF(
"DELETE FROM qpl_hints WHERE qht_question_fi = %s",
3494 array($this->original_id)
3498 $result = $ilDB->queryF(
"SELECT * FROM qpl_hints WHERE qht_question_fi = %s",
3500 array($this->
getId())
3506 while ($row = $ilDB->fetchAssoc(
$result))
3508 $next_id = $ilDB->nextId(
'qpl_hints');
3510 $ilDB->insert(
'qpl_hints', array(
3511 'qht_hint_id' => array(
'integer', $next_id),
3512 'qht_question_fi' => array(
'integer', $this->original_id),
3513 'qht_hint_index' => array(
'integer', $row[
"qht_hint_index"]),
3514 'qht_hint_points' => array(
'integer', $row[
"qht_hint_points"]),
3515 'qht_hint_text' => array(
'text', $row[
"qht_hint_text"]),
3531 $collected .= $this->feedbackOBJ->getGenericFeedbackContent($this->
getId(),
false);
3532 $collected .= $this->feedbackOBJ->getGenericFeedbackContent($this->
getId(),
true);
3535 $collected .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->
getId(), $i);
3537 foreach ($this->suggested_solutions as $solution_array)
3539 $collected .= $solution_array[
"value"];
3551 include_once(
"./Services/RTE/classes/class.ilRTE.php");
3564 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id = %s",
3566 array($this->
getId())
3568 $instances = array();
3570 while ($row = $ilDB->fetchAssoc(
$result))
3572 array_push($ids, $row[
"question_id"]);
3574 foreach ($ids as $question_id)
3577 $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",
3581 while ($row = $ilDB->fetchAssoc(
$result))
3586 $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",
3590 while ($row = $ilDB->fetchAssoc(
$result))
3595 include_once
"./Modules/Test/classes/class.ilObjTest.php";
3596 foreach ($instances as $key => $value)
3605 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
3608 if (in_array($questiontype, $scoring))
3628 $result = $ilDB->queryF(
"SELECT * FROM tst_active WHERE active_id = %s",
3634 $row = $ilDB->fetchAssoc(
$result);
3635 return array(
"user_id" => $row[
"user_fi"],
"test_id" => $row[
"test_fi"]);
3652 if( self::isCoreQuestionType($question_type) )
3664 return $questionType.
'GUI';
3669 return $questionType;
3674 return str_replace(
'ass',
'ilAss', $questionType).
'Feedback';
3680 return file_exists(
"Modules/TestQuestionPool/classes/class.{$guiClassName}.php");
3688 require_once
"Modules/TestQuestionPool/classes/class.{$guiClassName}.php";
3695 require_once
"Modules/TestQuestionPool/classes/class.{$objectClassName}.php";
3699 require_once
"Modules/TestQuestionPool/classes/feedback/class.{$feedbackClassName}.php";
3704 global $ilPluginAdmin;
3707 self::getObjectClassNameByQuestionType($questionType),
3708 self::getFeedbackClassNameByQuestionType($questionType)
3716 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
3717 foreach ($pl_names as $pl_name)
3720 if (strcmp($pl->getQuestionType(), $questionType) == 0)
3722 foreach($classes as $class)
3724 $pl->includeClass(
"class.{$class}.php");
3740 if (file_exists(
"./Modules/TestQuestionPool/classes/class.".$type_tag.
".php"))
3743 return $lng->txt($type_tag);
3747 global $ilPluginAdmin;
3748 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
3749 foreach ($pl_names as $pl_name)
3752 if (strcmp($pl->getQuestionType(), $type_tag) == 0)
3754 return $pl->getQuestionTypeTranslation();
3786 if (strcmp($a_question_id,
"") != 0)
3793 $question_gui =
new $question_type_gui();
3794 $question_gui->object->loadFromDb($a_question_id);
3797 $question_gui->object->feedbackOBJ =
new $feedbackObjectClassname($question_gui->object, $ilCtrl, $ilDB, $lng);
3799 $assSettings =
new ilSetting(
'assessment');
3800 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
3802 $processLockerFactory->setQuestionId($question_gui->object->getId());
3803 $processLockerFactory->setUserId($ilUser->getId());
3804 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3806 $question_gui->object->setProcessLocker($processLockerFactory->getLocker());
3811 $ilLog->write(
'Instantiate question called without question id. (instantiateQuestionGUI@assQuestion)', $ilLog->WARNING);
3814 return $question_gui;
3842 return $this->
getId();
3862 case "est_working_time":
3886 case "suggested_solutions":
3893 if (array_key_exists($value, $this->arrData))
3895 return $this->arrData[$value];
3913 $this->
setId($value);
3933 case "est_working_time":
3934 if (is_array($value))
3955 $this->page =& $value;
3958 $this->arrData[$key] = $value;
3970 $this->nr_of_tries = $a_nr_of_tries;
3975 $this->export_image_path = (string)$a_path;
3982 if ($question_id < 1)
3987 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE question_fi = %s AND test_fi = %s",
3988 array(
'integer',
'integer'),
4009 include_once(
"./Services/RTE/classes/class.ilRTE.php");
4011 $a_q = str_replace(
"</li><br />",
"</li>", $a_q);
4012 $a_q = str_replace(
"</li><br>",
"</li>", $a_q);
4017 $a_q = str_replace(
'{',
'{', $a_q);
4018 $a_q = str_replace(
'}',
'}', $a_q);
4032 $this->prevent_rte_usage = $a_val;
4052 $this->selfassessmenteditingmode = $a_selfassessmenteditingmode;
4072 $this->defaultnroftries = $a_defaultnroftries;
4096 $query =
"SELECT obj_fi FROM qpl_questions WHERE question_id = %s";
4098 $res = $ilDB->queryF(
$query, array(
'integer'), array((
int)$questionId));
4099 $row = $ilDB->fetchAssoc(
$res);
4101 return $row[
'obj_fi'];
4121 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintList.php';
4126 require_once
'Modules/TestQuestionPool/classes/class.ilAssHintPage.php';
4128 foreach($hintIds as $originalHintId => $duplicateHintId)
4131 $originalXML = $originalPageObject->getXMLContent();
4134 $duplicatePageObject->setId($duplicateHintId);
4135 $duplicatePageObject->setParentId($this->
getId());
4136 $duplicatePageObject->setXMLContent($originalXML);
4137 $duplicatePageObject->createFromXML();
4218 SELECT count(active_fi) cnt
4222 WHERE active_fi = %s
4223 AND question_fi = %s
4227 $res = $ilDB->queryF(
4228 $query, array(
'integer',
'integer',
'integer'),
4229 array($activeId, $questionId, $pass)
4232 $row = $ilDB->fetchAssoc(
$res);
4234 return (
int)$row[
'cnt'];
4258 require_once
'Modules/TestQuestionPool/exceptions/class.ilTestQuestionPoolException.php';
4302 self::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT,
4303 self::ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT
4312 $this->questionChangeListeners[] = $listener;
4327 $listener->notifyQuestionCreated($this);
4335 $listener->notifyQuestionEdited($this);
4343 $listener->notifyQuestionDeleted($this);
4352 require_once
'Services/Html/classes/class.ilHtmlPurifierFactory.php';
4361 require_once
'Services/Html/classes/class.ilHtmlPurifierFactory.php';
4368 SELECT qpl_questions.*,
4369 {$this->getAdditionalTableName()}.*
4371 LEFT JOIN {$this->getAdditionalTableName()}
4372 ON {$this->getAdditionalTableName()}.question_fi = qpl_questions.question_id
4373 WHERE qpl_questions.question_id = %s
4395 protected function getCurrentSolutionResultSet($active_id, $pass)
4402 return $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND step = %s",
4403 array(
'integer',
'integer',
'integer',
'integer'),
4404 array($active_id, $this->
getId(), $pass, $this->
getStep())
4409 return $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
4410 array(
'integer',
'integer',
'integer'),
4411 array($active_id, $this->
getId(), $pass)
4423 protected function removeCurrentSolution($active_id, $pass)
4432 return $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND step = %s",
4433 array(
'integer',
'integer',
'integer',
'integer'),
4434 array($active_id, $this->
getId(), $pass, $this->
getStep())
4439 return $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
4440 array(
'integer',
'integer',
'integer'),
4441 array($active_id, $this->
getId(), $pass)
4455 public function saveCurrentSolution($active_id, $pass, $value1, $value2)
4460 $next_id = $ilDB->nextId(
"tst_solutions");
4463 "solution_id" => array(
"integer", $next_id),
4464 "active_fi" => array(
"integer", $active_id),
4465 "question_fi" => array(
"integer", $this->
getId()),
4466 "value1" => array(
"clob", $value1),
4467 "value2" => array(
"clob", $value2),
4468 "pass" => array(
"integer", $pass),
4469 "tstamp" => array(
"integer", time())
4472 if( $this->
getStep() !== null )
4474 $fieldData[
'step'] = array(
"integer", $this->
getStep());
4477 $aff = $ilDB->insert(
"tst_solutions", $fieldData);
4504 $this->step =
$step;
4524 return gmdate(
'H:i:s', $time);
4534 $time_array = explode(
':',$time);
4535 if(
sizeof($time_array) == 3)
4537 $sec += $time_array[0] * 3600;
4538 $sec += $time_array[1] * 60;
4539 $sec += $time_array[2];
4546 return json_encode(array());