34 include_once
"./classes/class.ilObject.php";
35 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
472 function ilObjTest($a_id = 0,$a_call_by_reference =
true)
476 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
479 $this->author = $ilUser->fullname;
480 $this->introduction =
"";
481 $this->questions = array();
484 $this->instant_verification = 0;
485 $this->answer_feedback_points = 0;
486 $this->reporting_date =
"";
487 $this->nr_of_tries = 0;
489 $this->use_previous_answers = 1;
490 $this->title_output = 0;
491 $this->starting_time =
"";
492 $this->ending_time =
"";
493 $this->processing_time =
"00:00:00";
494 $this->enable_processing_time =
"0";
495 $this->reset_processing_time = 0;
496 $this->ects_output = 0;
498 $this->random_test = 0;
499 $this->shuffle_questions = FALSE;
500 $this->show_summary = 8;
501 $this->random_question_count =
"";
506 $this->answer_feedback = 0;
507 $this->password =
"";
508 $this->certificate_visibility = 0;
509 $this->allowedUsers =
"";
510 $this->_showfinalstatement = FALSE;
511 $this->_finalstatement =
"";
512 $this->_showinfo = TRUE;
513 $this->_forcejs = FALSE;
514 $this->_customStyle =
"";
515 $this->allowedUsersTimeGap =
"";
516 $this->anonymity = 0;
517 $this->show_cancel = 1;
518 $this->show_marker = 0;
519 $this->fixed_participants = 0;
524 $this->testSession = FALSE;
525 $this->testSequence = FALSE;
527 $lng->loadLanguageModule(
"assessment");
528 $this->mark_schema->createSimpleSchema($lng->txt(
"failed_short"), $lng->txt(
"failed_official"), 0, 0, $lng->txt(
"passed_short"), $lng->txt(
"passed_official"), 50, 1);
529 $this->ects_grades = array(
536 $this->
ilObject($a_id, $a_call_by_reference);
562 if (!parent::update())
591 function read($a_force_db =
false)
607 if (!parent::delete())
632 $query = sprintf(
"SELECT active_id FROM tst_active WHERE test_fi = %s",
633 $ilDB->quote($this->getTestId())
635 $result = $ilDB->query($query);
636 $active_array = array();
637 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
639 array_push($active_array, $row[
"active_id"]);
642 $query = sprintf(
"DELETE FROM tst_active WHERE test_fi = %s",
643 $ilDB->quote($this->getTestId())
645 $result = $ilDB->query($query);
647 if (count($active_array))
649 foreach ($active_array as $active_id)
651 $query = sprintf(
"DELETE FROM tst_times WHERE active_fi = %s",
652 $ilDB->quote($active_id)
654 $result = $ilDB->query($query);
656 $query = sprintf(
"DELETE FROM tst_sequence WHERE active_fi = %s",
657 $ilDB->quote($active_id)
659 $result = $ilDB->query($query);
663 $query = sprintf(
"DELETE FROM tst_mark WHERE test_fi = %s",
664 $ilDB->quote($this->getTestId())
666 $result = $ilDB->query($query);
668 $query = sprintf(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s",
669 $ilDB->quote($this->getTestId())
671 $result = $ilDB->query($query);
672 while ($row =
$result->fetchRow(MDB2_FETCHMODE_OBJECT))
677 $query = sprintf(
"DELETE FROM tst_tests WHERE test_id = %s",
678 $ilDB->quote($this->getTestId())
680 $result = $ilDB->query($query);
682 $query = sprintf(
"DELETE FROM tst_test_random WHERE test_fi = %s",
683 $ilDB->quote($this->getTestId())
685 $result = $ilDB->query($query);
687 $query = sprintf(
"DELETE FROM tst_test_random_question USING tst_test_random_question, tst_active WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_test_random_question.active_fi",
688 $ilDB->quote($this->getTestId())
690 $result = $ilDB->query($query);
694 $query = sprintf(
"DELETE FROM tst_test_question WHERE test_fi = %s",
695 $ilDB->quote($this->getTestId())
697 $result = $ilDB->query($query);
700 include_once
"./Services/Utilities/classes/class.ilUtil.php";
702 $directory = $tst_data_dir.
"/tst_".$this->
getId();
703 if (is_dir($directory))
705 include_once
"./Services/Utilities/classes/class.ilUtil.php";
708 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
714 foreach(
$mobs as $mob)
748 return $roles ? $roles : array();
764 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
804 if ($a_node_id==
$_GET[
"ref_id"])
806 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
807 $parent_type = $parent_obj->getType();
808 if($parent_type == $this->
getType())
810 $a_node_id = (int) $tree->getParentId($a_node_id);
814 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
824 include_once
"./Services/Utilities/classes/class.ilUtil.php";
827 if(!is_writable($tst_data_dir))
829 $this->ilias->raiseError(
"Test Data Directory (".$tst_data_dir
830 .
") not writeable.",$this->ilias->error_obj->MESSAGE);
834 $tst_dir = $tst_data_dir.
"/tst_".$this->
getId();
836 if(!@is_dir($tst_dir))
838 $this->ilias->raiseError(
"Creation of Test Directory failed.",$this->ilias->error_obj->MESSAGE);
841 $export_dir = $tst_dir.
"/export";
843 if(!@is_dir($export_dir))
845 $this->ilias->raiseError(
"Creation of Export Directory failed.",$this->ilias->error_obj->MESSAGE);
858 include_once
"./Services/Utilities/classes/class.ilUtil.php";
874 if (!@is_dir(
$dir) or
887 while ($entry =
$dir->read())
889 if ($entry !=
"." and
892 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(test(__results)?__)*[0-9]+\.[a-z]{1,3}\$", $entry))
918 include_once
"./Services/Utilities/classes/class.ilUtil.php";
922 if(!is_writable($tst_data_dir))
924 $ilias->raiseError(
"Test data directory (".$tst_data_dir
925 .
") not writeable.",$ilias->error_obj->FATAL);
929 $tst_dir = $tst_data_dir.
"/tst_import";
931 if(!@is_dir($tst_dir))
933 $ilias->raiseError(
"Creation of test import directory failed.",$ilias->error_obj->FATAL);
947 include_once
"./Services/Utilities/classes/class.ilUtil.php";
949 if(@is_dir($import_dir))
966 include_once
"./Services/Utilities/classes/class.ilUtil.php";
970 if(!is_writable($tst_data_dir))
972 $this->ilias->raiseError(
"Test Data Directory (".$tst_data_dir
973 .
") not writeable.",$this->ilias->error_obj->FATAL);
977 $tst_dir = $tst_data_dir.
"/tst_import";
979 if(!@is_dir($tst_dir))
981 $ilias->raiseError(
"Creation of test import directory failed.",
$ilias->error_obj->FATAL);
995 include_once
"./Services/Utilities/classes/class.ilUtil.php";
997 if(@is_dir($import_dir))
1021 $query = sprintf(
"SELECT * FROM object_data WHERE title = %s AND type = %s",
1025 $result = $ilDB->query($query);
1026 if ($result->numRows() == 1)
1043 $query = sprintf(
"SELECT DISTINCT(qpl_question_type.type_tag) foundtypes FROM qpl_questions, tst_test_result, qpl_question_type, tst_active WHERE tst_test_result.question_fi = qpl_questions.question_id AND qpl_questions.question_type_fi = qpl_question_type.question_type_id AND tst_test_result.active_fi = tst_active.active_id AND tst_active.test_fi = %s AND qpl_question_type.type_tag = %s",
1044 $ilDB->quote($this->getTestId()),
1045 $ilDB->quote(
"assSingleChoice")
1047 $result = $ilDB->query($query);
1048 if ($result->numRows() == 1)
1050 $row = $ilDB->fetchAssoc($result);
1051 if (strcmp($row[
'foundtypes'],
'assSingleChoice') == 0)
1073 $query = sprintf(
"SELECT DISTINCT(qpl_question_singlechoice.shuffle) foundshuffles FROM qpl_questions, qpl_question_singlechoice, tst_test_result, qpl_question_type, tst_active WHERE tst_test_result.question_fi = qpl_questions.question_id AND qpl_questions.question_type_fi = qpl_question_type.question_type_id AND tst_test_result.active_fi = tst_active.active_id AND qpl_questions.question_id = qpl_question_singlechoice.question_fi AND tst_active.test_fi = %s AND qpl_question_type.type_tag = %s",
1074 $ilDB->quote($this->getTestId()),
1075 $ilDB->quote(
"assSingleChoice")
1077 $result = $ilDB->query($query);
1078 if ($result->numRows() == 1)
1080 $row = $ilDB->fetchAssoc($result);
1081 return ($row[
'foundshuffles'] == 0);
1096 if ((count($this->mark_schema->mark_steps)) and (count($this->questions)))
1110 foreach ($arr as $array)
1112 $count += $array[
"count"];
1134 $test->loadFromDb();
1135 return $test->isComplete();
1148 if ($this->test_id > 0) {
1149 $fx_support = preg_replace(
"/,/",
".", $fx_support);
1150 if (preg_match(
"/\d+/", $fx_support))
1152 $fx_support = $fx_support;
1156 $fx_support =
"NULL";
1158 $query = sprintf(
"UPDATE tst_tests SET ects_output = %s, ects_a = %s, ects_b = %s, ects_c = %s, ects_d = %s, ects_e = %s, ects_fx = %s WHERE test_id = %s",
1159 $ilDB->quote(
"$ects_output"),
1160 $ilDB->quote($ects_a .
""),
1161 $ilDB->quote($ects_b .
""),
1162 $ilDB->quote($ects_c .
""),
1163 $ilDB->quote($ects_d .
""),
1164 $ilDB->quote($ects_e .
""),
1168 $result = $ilDB->query($query);
1170 $this->ects_fx = $fx_support;
1190 if ($this->test_id > 0)
1192 $query = sprintf(
"UPDATE tst_tests SET complete = %s WHERE test_id = %s",
1193 $ilDB->quote(
"$complete"),
1194 $ilDB->quote($this->test_id)
1196 $result = $ilDB->query($query);
1224 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1225 $completecontent =
"";
1228 $completecontent .= $content;
1252 if (preg_match(
"/\d+/", $this->ects_fx))
1257 if ($this->random_question_count > 0)
1287 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1288 if ($this->test_id == -1)
1292 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
1293 $query = sprintf(
"INSERT INTO tst_tests (test_id, obj_fi, author, introduction, finalstatement, showinfo, forcejs, customstyle, showfinalstatement, sequence_settings, " .
1294 "score_reporting, instant_verification, answer_feedback_points, answer_feedback, anonymity, show_cancel, show_marker, " .
1295 "fixed_participants, nr_of_tries, kiosk, use_previous_answers, title_output, processing_time, enable_processing_time, reset_processing_time, " .
1296 "reporting_date, starting_time, ending_time, complete, ects_output, ects_a, ects_b, ects_c, ects_d, ects_e, " .
1297 "ects_fx, random_test, random_question_count, count_system, mc_scoring, score_cutting, pass_scoring, " .
1298 "shuffle_questions, results_presentation, show_summary, password, allowedUsers, " .
1299 "allowedUsersTimeGap, certificate_visibility, created, TIMESTAMP) " .
1300 "VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, " .
1301 "%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)",
1302 $ilDB->quote($this->getId() .
""),
1303 $ilDB->quote($this->getAuthor() .
""),
1306 $ilDB->quote((($this->
getShowInfo()) ?
"1" :
"0")),
1307 $ilDB->quote((($this->
getForceJS()) ?
"1" :
"0")),
1308 (strlen($this->
getCustomStyle())) ? $ilDB->quote($this->getCustomStyle()) :
"NULL",
1309 $ilDB->quote((($this->getShowFinalStatement()) ?
"1" :
"0")),
1310 $ilDB->quote($this->sequence_settings .
""),
1311 $ilDB->quote($this->score_reporting .
""),
1319 $ilDB->quote(sprintf(
"%d", $this->
getNrOfTries()) .
""),
1320 $ilDB->quote($this->
getKiosk() .
""),
1323 $ilDB->quote($this->processing_time .
""),
1324 $ilDB->quote(
"$this->enable_processing_time"),
1326 $ilDB->quote($this->reporting_date .
""),
1327 $ilDB->quote($this->starting_time .
""),
1328 $ilDB->quote($this->ending_time .
""),
1329 $ilDB->quote(
"$complete"),
1330 $ilDB->quote($this->ects_output .
""),
1331 $ilDB->quote($this->ects_grades[
"A"] .
""),
1332 $ilDB->quote($this->ects_grades[
"B"] .
""),
1333 $ilDB->quote($this->ects_grades[
"C"] .
""),
1334 $ilDB->quote($this->ects_grades[
"D"] .
""),
1335 $ilDB->quote($this->ects_grades[
"E"] .
""),
1337 $ilDB->quote(sprintf(
"%d", $this->random_test) .
""),
1339 $ilDB->quote($this->count_system .
""),
1340 $ilDB->quote($this->mc_scoring .
""),
1350 $ilDB->quote($created)
1357 $result = $ilDB->query($query);
1361 $ilias->raiseError(
$result->getMessage());
1365 $this->test_id = $ilDB->getLastInsertId();
1374 $query = sprintf(
"SELECT * FROM tst_tests WHERE test_id = %s",
1375 $ilDB->quote($this->test_id)
1377 $result = $ilDB->query($query);
1378 if ($result->numRows() == 1)
1380 $oldrow = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
1383 $query = sprintf(
"UPDATE tst_tests SET author = %s, introduction = %s, finalstatement = %s, showinfo = %s, forcejs = %s, customstyle = %s, showfinalstatement = %s, sequence_settings = %s, score_reporting = %s, instant_verification = %s, answer_feedback_points = %s, answer_feedback = %s, anonymity = %s, show_cancel = %s, show_marker = %s, fixed_participants = %s, nr_of_tries = %s, kiosk = %s, use_previous_answers = %s, title_output = %s, processing_time = %s, enable_processing_time = %s, reset_processing_time = %s, reporting_date = %s, starting_time = %s, ending_time = %s, ects_output = %s, ects_a = %s, ects_b = %s, ects_c = %s, ects_d = %s, ects_e = %s, ects_fx = %s, random_test = %s, complete = %s, count_system = %s, mc_scoring = %s, score_cutting = %s, pass_scoring = %s, shuffle_questions = %s, results_presentation = %s, show_summary = %s, password = %s, allowedUsers = %s, allowedUsersTimeGap = %s, certificate_visibility = %s WHERE test_id = %s",
1384 $ilDB->quote($this->getAuthor() .
""),
1387 $ilDB->quote((($this->
getShowInfo()) ?
"1" :
"0")),
1388 $ilDB->quote((($this->
getForceJS()) ?
"1" :
"0")),
1389 (strlen($this->
getCustomStyle())) ? $ilDB->quote($this->getCustomStyle()) :
"NULL",
1390 $ilDB->quote((($this->getShowFinalStatement()) ?
"1" :
"0")),
1391 $ilDB->quote($this->sequence_settings .
""),
1392 $ilDB->quote($this->score_reporting .
""),
1400 $ilDB->quote(sprintf(
"%d", $this->
getNrOfTries()) .
""),
1401 $ilDB->quote($this->
getKiosk() .
""),
1404 $ilDB->quote($this->processing_time .
""),
1405 $ilDB->quote(
"$this->enable_processing_time"),
1407 $ilDB->quote($this->reporting_date .
""),
1408 $ilDB->quote($this->starting_time .
""),
1409 $ilDB->quote($this->ending_time .
""),
1410 $ilDB->quote($this->ects_output .
""),
1411 $ilDB->quote($this->ects_grades[
"A"] .
""),
1412 $ilDB->quote($this->ects_grades[
"B"] .
""),
1413 $ilDB->quote($this->ects_grades[
"C"] .
""),
1414 $ilDB->quote($this->ects_grades[
"D"] .
""),
1415 $ilDB->quote($this->ects_grades[
"E"] .
""),
1417 $ilDB->quote(sprintf(
"%d", $this->random_test) .
""),
1418 $ilDB->quote(
"$complete"),
1419 $ilDB->quote($this->count_system .
""),
1420 $ilDB->quote($this->mc_scoring .
""),
1430 $ilDB->quote($this->test_id)
1432 $result = $ilDB->query($query);
1433 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1436 $query = sprintf(
"SELECT * FROM tst_tests WHERE test_id = %s",
1437 $ilDB->quote($this->test_id)
1439 $logresult = $ilDB->query($query);
1441 if ($logresult->numRows() == 1)
1443 $newrow = $logresult->fetchRow(MDB2_FETCHMODE_ASSOC);
1445 $changed_fields = array();
1446 foreach ($oldrow as $key => $value)
1448 if (strcmp($oldrow[$key], $newrow[$key]) != 0)
1450 array_push($changed_fields,
"$key: " . $oldrow[$key] .
" => " . $newrow[$key]);
1453 $changes = join($changed_fields,
", ");
1454 if (count($changed_fields) > 0)
1466 $query = sprintf(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND tries >= %s AND submitted = 0",
1467 $ilDB->quote($this->getTestId() .
""),
1468 $ilDB->quote($this->getNrOfTries() .
"")
1470 $aresult = $ilDB->query($query);
1471 while ($row = $aresult->fetchRow(MDB2_FETCHMODE_ASSOC))
1473 $newquery = sprintf(
"UPDATE tst_active SET submitted = 1, submittimestamp = NOW() WHERE active_id = %s",
1474 $ilDB->quote($row[
"active_id"] .
"")
1476 $newresult = $ilDB->query($newquery);
1480 $query = sprintf(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND tries < %s AND submitted = 1",
1481 $ilDB->quote($this->getTestId() .
""),
1482 $ilDB->quote($this->getNrOfTries() .
"")
1484 $aresult = $ilDB->query($query);
1485 while ($row = $aresult->fetchRow(MDB2_FETCHMODE_ASSOC))
1487 $newquery = sprintf(
"UPDATE tst_active SET submitted = 0, submittimestamp = NULL WHERE active_id = %s",
1488 $ilDB->quote($row[
"active_id"] .
"")
1490 $newresult = $ilDB->query($newquery);
1496 $query = sprintf(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND submitted = 1",
1497 $ilDB->quote($this->getTestId() .
"")
1499 $aresult = $ilDB->query($query);
1500 while ($row = $aresult->fetchRow(MDB2_FETCHMODE_ASSOC))
1502 $newquery = sprintf(
"UPDATE tst_active SET submitted = 0, submittimestamp = NULL WHERE active_id = %s",
1503 $ilDB->quote($row[
"active_id"] .
"")
1505 $newresult = $ilDB->query($newquery);
1510 if (!$properties_only)
1515 $ilias->raiseError(
$result->getMessage());
1523 $this->mark_schema->saveToDb($this->test_id);
1540 $oldquestions = array();
1541 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
1544 $query = sprintf(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence",
1545 $ilDB->quote($this->getTestId())
1547 $result = $ilDB->query($query);
1550 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
1552 array_push($oldquestions, $row[
"question_fi"]);
1558 $query = sprintf(
"DELETE FROM tst_test_question WHERE test_fi = %s",
1559 $ilDB->quote($this->getTestId())
1561 $result = $ilDB->query($query);
1563 foreach ($this->questions as $key => $value) {
1564 $query = sprintf(
"INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
1565 $ilDB->quote($this->getTestId() .
""),
1566 $ilDB->quote($value .
""),
1567 $ilDB->quote($key .
"")
1569 $result = $ilDB->query($query);
1571 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1574 $query = sprintf(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence",
1575 $ilDB->quote($this->getTestId())
1577 $result = $ilDB->query($query);
1578 $newquestions = array();
1581 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
1583 array_push($newquestions, $row[
"question_fi"]);
1586 foreach ($oldquestions as $index => $question_id)
1588 if (strcmp($newquestions[$index], $question_id) != 0)
1590 $pos = array_search($question_id, $newquestions);
1601 foreach ($newquestions as $index => $question_id)
1603 if (array_search($question_id, $oldquestions) === FALSE)
1625 $query = sprintf(
"SELECT test_random_question_id FROM tst_test_random_question WHERE active_fi = %s AND pass = %s",
1626 $ilDB->quote($active_id .
""),
1627 $ilDB->quote(
$pass .
"")
1629 $result = $ilDB->query($query);
1630 if ($result->numRows() < $maxcount)
1633 if ($duplicate_id === FALSE)
1638 $query = sprintf(
"INSERT INTO tst_test_random_question (test_random_question_id, active_fi, question_fi, sequence, pass, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
1639 $ilDB->quote($active_id .
""),
1640 $ilDB->quote($duplicate_id .
""),
1641 $ilDB->quote(($result->numRows()+1) .
""),
1642 $ilDB->quote(
$pass .
"")
1644 $result = $ilDB->query($query);
1663 $query = sprintf(
"SELECT qpl_questions.question_id FROM qpl_questions, tst_test_random_question WHERE qpl_questions.original_id = %s AND tst_test_random_question.question_fi = qpl_questions.question_id AND tst_test_random_question.active_fi = %s",
1664 $ilDB->quote($question_id .
""),
1665 $ilDB->quote($active_id .
"")
1667 $result = $ilDB->query($query);
1668 $num = $result->numRows();
1671 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
1672 return $row[
"question_id"];
1691 $query = sprintf(
"SELECT test_result_id FROM tst_test_result WHERE active_fi = %s AND pass = %s",
1692 $ilDB->quote($active_id .
""),
1693 $ilDB->quote(
$pass .
"")
1695 $result = $ilDB->query($query);
1696 return $result->numRows();
1712 $query = sprintf(
"SELECT test_random_question_id FROM tst_test_random_question WHERE active_fi = %s AND pass = %s",
1713 $ilDB->quote($active_id .
""),
1714 $ilDB->quote(
$pass .
"")
1716 $result = $ilDB->query($query);
1717 if ($result->numRows() > 0)
1763 $ilias->raiseError(sprintf($this->lng->txt(
"error_random_question_generation"), $ilUser->getId(), $this->
getTestId()), $ilErr->FATAL);
1771 $allquestions = array();
1772 foreach ($rndquestions as $question_id)
1774 array_push($allquestions, $question_id);
1778 srand ((
float)microtime()*1000000);
1779 shuffle($allquestions);
1783 foreach ($qpls as
$data)
1785 $maxcount += $data[
"contains"];
1787 if ($num > $maxcount) $num = $maxcount;
1788 foreach ($allquestions as $question_id)
1796 $allquestions = array();
1798 foreach ($qpls as $key => $value)
1800 if ($value[
"count"] > 0)
1803 foreach ($rndquestions as $question_id)
1805 array_push($allquestions, $question_id);
1808 $add = ($value[
"count"] <= $value[
"contains"]) ? $value[
"count"] : $value[
"contains"];
1813 srand ((
float)microtime()*1000000);
1814 shuffle($allquestions);
1816 foreach ($allquestions as $question_id)
1835 if (strcmp($total_questions,
"NULL") != 0)
1838 $total_questions = $ilDB->quote($total_questions);
1840 $query = sprintf(
"UPDATE tst_tests SET random_question_count = %s WHERE test_id = %s",
1842 $ilDB->quote($this->getTestId() .
"")
1844 $result = $ilDB->query($query);
1845 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1848 if (strcmp($total_questions,
"NULL") == 0) $total_questions =
'0';
1866 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1868 $query = sprintf(
"DELETE FROM tst_test_random WHERE test_fi = %s",
1869 $ilDB->quote($this->getTestId())
1871 $result = $ilDB->query($query);
1877 foreach ($qpl_array as $key => $value) {
1878 if ($value[
"qpl"] > -1)
1880 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1882 if ($value[
"count"] > $count)
1884 $value[
"count"] = $count;
1886 $query = sprintf(
"INSERT INTO tst_test_random (test_random_id, test_fi, questionpool_fi, num_of_q, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
1887 $ilDB->quote($this->getTestId() .
""),
1888 $ilDB->quote($value[
"qpl"] .
""),
1889 $ilDB->quote(sprintf(
"%d", $value[
"count"]) .
"")
1891 $result = $ilDB->query($query);
1915 $query = sprintf(
"SELECT tst_test_random.*, qpl_questionpool.questioncount FROM tst_test_random, qpl_questionpool WHERE tst_test_random.test_fi = %s AND tst_test_random.questionpool_fi = qpl_questionpool.obj_fi ORDER BY test_random_id",
1916 $ilDB->quote($this->getTestId() .
"")
1918 $result = $ilDB->query($query);
1921 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
1923 $qpls[$counter] = array(
1924 "index" => $counter,
1925 "count" => $row[
"num_of_q"],
1926 "qpl" => $row[
"questionpool_fi"],
1927 "contains" => $row[
"questioncount"]
1948 $query = sprintf(
"SELECT * FROM tst_tests WHERE obj_fi = %s",
1949 $ilDB->quote($this->getId())
1951 $result = $ilDB->query($query);
1955 $this->test_id =
$data->test_id;
1961 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1968 $this->sequence_settings =
$data->sequence_settings;
1969 $this->score_reporting =
$data->score_reporting;
1970 $this->instant_verification =
$data->instant_verification;
1971 $this->answer_feedback_points =
$data->answer_feedback_points;
1972 $this->answer_feedback =
$data->answer_feedback;
1973 $this->anonymity =
$data->anonymity;
1974 $this->show_cancel =
$data->show_cancel;
1975 $this->show_marker =
$data->show_marker;
1976 $this->fixed_participants =
$data->fixed_participants;
1977 $this->nr_of_tries =
$data->nr_of_tries;
1981 $this->processing_time =
$data->processing_time;
1982 $this->enable_processing_time =
$data->enable_processing_time;
1983 $this->reset_processing_time =
$data->reset_processing_time;
1984 $this->reporting_date =
$data->reporting_date;
1988 $this->starting_time =
$data->starting_time;
1989 $this->ending_time =
$data->ending_time;
1990 $this->ects_output =
$data->ects_output;
1991 $this->ects_grades = array(
1992 "A" =>
$data->ects_a,
1993 "B" =>
$data->ects_b,
1994 "C" =>
$data->ects_c,
1995 "D" =>
$data->ects_d,
1996 "E" =>
$data->ects_e
1998 $this->ects_fx =
$data->ects_fx;
1999 $this->random_test =
$data->random_test;
2000 $this->random_question_count =
$data->random_question_count;
2001 $this->mark_schema->flush();
2002 $this->mark_schema->loadFromDb($this->test_id);
2003 $this->count_system =
$data->count_system;
2004 $this->mc_scoring =
$data->mc_scoring;
2028 $this->questions = array();
2029 if (strcmp($active_id,
"") == 0)
2039 $query = sprintf(
"SELECT tst_test_random_question.* FROM tst_test_random_question, qpl_questions WHERE tst_test_random_question.active_fi = %s AND qpl_questions.question_id = tst_test_random_question.question_fi AND tst_test_random_question.pass = %s ORDER BY sequence",
2040 $ilDB->quote($active_id .
""),
2041 $ilDB->quote(
$pass .
"")
2043 $result = $ilDB->query($query);
2048 if ($result->numRows() == 0)
2050 $query = sprintf(
"SELECT tst_test_random_question.* FROM tst_test_random_question, qpl_questions WHERE tst_test_random_question.active_fi = %s AND qpl_questions.question_id = tst_test_random_question.question_fi AND tst_test_random_question.pass = 0 ORDER BY sequence",
2051 $ilDB->quote($active_id .
"")
2053 $result = $ilDB->query($query);
2058 $query = sprintf(
"SELECT tst_test_question.* FROM tst_test_question, qpl_questions WHERE tst_test_question.test_fi = %s AND qpl_questions.question_id = tst_test_question.question_fi ORDER BY sequence",
2059 $ilDB->quote($this->test_id .
"")
2061 $result = $ilDB->query($query);
2064 while (
$data =
$result->fetchRow(MDB2_FETCHMODE_OBJECT))
2066 $this->questions[$index++] =
$data->question_fi;
2095 $this->_finalstatement = $a_statement;
2109 $this->_showinfo = TRUE;
2113 $this->_showinfo = FALSE;
2128 $this->_forcejs = TRUE;
2132 $this->_forcejs = FALSE;
2145 $this->_customStyle = $a_customStyle;
2170 $css_path = str_replace(
"ta.css",
"customstyles", $css_path) .
"/";
2171 $customstyles = array();
2172 if (is_dir($css_path))
2175 include_once
"./Services/Utilities/classes/class.ilFileUtils.php";
2181 if (strpos($filename,
".css"))
2183 array_push($customstyles, $filename);
2188 return $customstyles;
2203 $custom = str_replace(
"ta.css",
"customstyles/" . $this->
getCustomStyle(), $default);
2204 if (file_exists($custom))
2207 $custom = str_replace(
"ta.css",
"customstyles/" . $this->
getCustomStyle(), $custom);
2232 $this->_showfinalstatement = TRUE;
2236 $this->_showfinalstatement = FALSE;
2370 $this->ects_output = $a_ects_output ? 1 : 0;
2398 $this->ects_fx = $a_ects_fx;
2426 if (is_array($a_ects_grades))
2428 $this->ects_grades = $a_ects_grades;
2471 switch ($instant_feedback)
2474 $this->instant_verification = 1;
2477 $this->instant_verification = 0;
2496 $this->answer_feedback = 1;
2499 $this->answer_feedback = 0;
2518 $this->answer_feedback_points = 1;
2521 $this->answer_feedback_points = 0;
2537 $this->random_test = $a_random_test;
2551 $this->random_question_count = $a_random_question_count;
2567 $this->reporting_date =
"";
2568 $this->ects_output = 0;
2672 $query = sprintf(
"SELECT tst_tests.count_system FROM tst_tests, tst_active WHERE tst_active.active_id = %s AND tst_active.test_fi = tst_tests.test_id",
2673 $ilDB->quote($active_id)
2675 $result = $ilDB->query($query);
2676 if ($result->numRows())
2678 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
2679 return $row[
"count_system"];
2752 $query = sprintf(
"SELECT tst_tests.pass_scoring FROM tst_tests, tst_active WHERE tst_tests.test_id = tst_active.test_fi AND tst_active.active_id = %s",
2753 $ilDB->quote($active_id .
"")
2755 $result = $ilDB->query($query);
2756 if ($result->numRows())
2758 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
2759 return $row[
"pass_scoring"];
2776 $query = sprintf(
"SELECT tst_tests.mc_scoring FROM tst_tests, tst_active WHERE tst_active.active_id = %s AND tst_active.test_fi = tst_tests.test_id",
2777 $ilDB->quote($active_id)
2779 $result = $ilDB->query($query);
2780 if ($result->numRows())
2782 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
2783 return $row[
"mc_scoring"];
2800 $query = sprintf(
"SELECT tst_tests.score_cutting FROM tst_tests, tst_active WHERE tst_active.active_id = %s AND tst_tests.test_id = tst_active.test_fi",
2801 $ilDB->quote($active_id)
2803 $result = $ilDB->query($query);
2804 if ($result->numRows())
2806 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
2807 return $row[
"score_cutting"];
2866 $this->_kiosk = $kiosk;
2880 if (($this->_kiosk & 1) > 0)
2903 $this->_kiosk = $this->_kiosk | 1;
2909 $this->_kiosk = $this->_kiosk ^ 1;
2925 if (($this->_kiosk & 2) > 0)
2947 $this->_kiosk = $this->_kiosk | 2;
2953 $this->_kiosk = $this->_kiosk ^ 2;
2969 if (($this->_kiosk & 4) > 0)
2991 $this->_kiosk = $this->_kiosk | 4;
2997 $this->_kiosk = $this->_kiosk ^ 4;
3044 $query = sprintf(
"SELECT tst_tests.title_output FROM tst_tests, tst_active WHERE tst_tests.test_id = tst_active.test_fi AND tst_active.active_id = %s",
3045 $ilDB->quote($active_id .
"")
3047 $result = $ilDB->query($query);
3048 if ($result->numRows())
3050 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
3051 return $row[
"title_output"];
3074 $query = sprintf(
"SELECT tst_tests.use_previous_answers FROM tst_tests, tst_active WHERE tst_tests.test_id = tst_active.test_fi AND tst_active.active_id = %s",
3075 $ilDB->quote($active_id .
"")
3077 $result = $ilDB->query($query);
3078 if ($result->numRows())
3080 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
3086 if ($user_active_user_setting)
3088 $res = $ilUser->getPref(
"tst_use_previous_answers");
3123 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $this->
getProcessingTime(), $matches))
3125 return ($matches[1] * 3600) + ($matches[2] * 60) + $matches[3];
3144 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndingTime(), $matches))
3146 $ending = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
3148 return $ending - $now;
3239 $this->use_previous_answers = 1;
3243 $this->use_previous_answers = 0;
3261 $this->title_output = 1;
3264 $this->title_output = 2;
3267 $this->title_output = 0;
3298 $this->enable_processing_time =
"1";
3300 $this->enable_processing_time =
"0";
3317 $this->reset_processing_time = 1;
3321 $this->reset_processing_time = 0;
3364 $this->count_system = $a_count_system;
3378 $this->password = $a_password;
3392 $this->score_cutting = $a_score_cutting;
3406 $this->mc_scoring = $a_mc_scoring;
3420 switch ($a_pass_scoring)
3443 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3448 $question->delete($question_id);
3471 $query = sprintf(
"DELETE FROM tst_solutions USING tst_solutions, tst_active where tst_solutions.active_fi = tst_active.active_id AND tst_active.test_fi = %s AND tst_solutions.question_fi = %s",
3472 $ilDB->quote($this->getTestId()),
3473 $ilDB->quote($question_id)
3475 $query2 = sprintf(
"DELETE FROM tst_active_qst_sol_settings USING tst_active_qst_sol_settings, tst_active where tst_active_qst_sol_settings.active_fi = tst_active.active_id AND tst_active.test_fi = %s AND tst_active_qst_sol_settings.question_fi = %s",
3476 $ilDB->quote($this->getTestId()),
3477 $ilDB->quote($question_id)
3479 $query3 = sprintf(
"DELETE FROM tst_test_result USING tst_test_result, tst_active WHERE tst_active.test_fi = %s AND tst_test_result.question_fi = %s AND tst_active.active_id = tst_test_result.active_fi",
3480 $ilDB->quote($this->getTestId()),
3481 $ilDB->quote($question_id)
3483 $query4 = sprintf(
"DELETE FROM tst_test_pass_result USING tst_test_pass_result, tst_active WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_test_pass_result.active_fi",
3484 $ilDB->quote($this->getTestId())
3489 $query = sprintf(
"DELETE FROM tst_solutions USING tst_solutions, tst_active where tst_solutions.active_fi = tst_active.active_id AND tst_active.test_fi = %s",
3490 $ilDB->quote($this->getTestId())
3492 $query2 = sprintf(
"DELETE FROM tst_active_qst_sol_settings USING tst_active_qst_sol_settings, tst_active where tst_active_qst_sol_settings.active_fi = tst_active.active_id AND tst_active.test_fi = %s",
3493 $ilDB->quote($this->getTestId())
3495 $query3 = sprintf(
"DELETE FROM tst_test_result USING tst_test_result, tst_active WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_test_result.active_fi",
3496 $ilDB->quote($this->getTestId())
3498 $query4 = sprintf(
"DELETE FROM tst_test_pass_result USING tst_test_pass_result, tst_active WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_test_pass_result.active_fi",
3499 $ilDB->quote($this->getTestId())
3501 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3507 $query5 = sprintf(
"DELETE FROM tst_sequence USING tst_sequence, tst_active WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_sequence.active_fi",
3508 $ilDB->quote($this->getTestId())
3510 $result = $ilDB->query($query);
3511 $result = $ilDB->query($query2);
3512 $result = $ilDB->query($query3);
3513 $result = $ilDB->query($query4);
3514 $result = $ilDB->query($query5);
3518 $query = sprintf(
"DELETE FROM tst_test_random_question USING tst_test_random_question, tst_active WHERE tst_active.test_fi = %s AND tst_test_random_question.active_fi = tst_active.active_id",
3519 $ilDB->quote($this->getTestId())
3521 $result = $ilDB->query($query);
3525 $query = sprintf(
"DELETE FROM tst_active WHERE test_fi = %s",
3526 $ilDB->quote($this->getTestId())
3528 $result = $ilDB->query($query);
3531 $query = sprintf(
"DELETE FROM usr_pref WHERE keyword = %s",
3532 $ilDB->quote(
"tst_password_".$this->getTestId())
3534 $result = $ilDB->query($query);
3542 foreach ($active_ids as $active_id)
3544 $query = sprintf(
"DELETE FROM tst_solutions WHERE active_fi = %s",
3545 $ilDB->quote($active_id .
"")
3547 $query2 = sprintf(
"DELETE FROM tst_active_qst_sol_settings WHERE active_fi = %s",
3548 $ilDB->quote($active_id .
"")
3550 $query3 = sprintf(
"DELETE FROM tst_test_result WHERE active_fi = %s",
3551 $ilDB->quote($active_id .
"")
3553 $query4 = sprintf(
"DELETE FROM tst_test_pass_result WHERE active_fi = %s",
3554 $ilDB->quote($active_id .
"")
3556 $result = $ilDB->query($query);
3557 $result = $ilDB->query($query2);
3558 $result = $ilDB->query($query3);
3559 $result = $ilDB->query($query4);
3563 $query = sprintf(
"DELETE FROM tst_test_random_question WHERE active_fi = %s",
3564 $ilDB->quote($active_id .
"")
3566 $result = $ilDB->query($query);
3569 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3577 foreach ($active_ids as $active_id)
3581 $query = sprintf(
"DELETE FROM tst_active WHERE active_id = %s",
3582 $ilDB->quote($active_id .
"")
3584 $result = $ilDB->query($query);
3586 $query = sprintf(
"DELETE FROM tst_sequence WHERE active_fi = %s",
3587 $ilDB->quote($active_id)
3589 $result = $ilDB->query($query);
3594 $query = sprintf(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
3595 $ilDB->quote($usr_id),
3596 $ilDB->quote(
"tst_password_".$this->
getTestId())
3598 $result = $ilDB->query($query);
3610 $query = sprintf(
"DELETE FROM tst_solutions WHERE active_fi = %s",
3611 $ilDB->quote($active_id .
"")
3613 $query2 = sprintf(
"DELETE FROM tst_active_qst_sol_settings WHERE active_fi = %s",
3614 $ilDB->quote($active_id .
"")
3616 $query3 = sprintf(
"DELETE FROM tst_test_result WHERE active_fi = %s",
3617 $ilDB->quote($active_id .
"")
3619 $query4 = sprintf(
"DELETE FROM tst_test_pass_result WHERE active_fi = %s",
3620 $ilDB->quote($active_id .
"")
3622 $result = $ilDB->query($query);
3623 $result = $ilDB->query($query2);
3624 $result = $ilDB->query($query3);
3625 $result = $ilDB->query($query4);
3629 $query = sprintf(
"DELETE FROM tst_test_random_question WHERE active_fi = %s",
3630 $ilDB->quote($active_id .
"")
3632 $result = $ilDB->query($query);
3635 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3641 $query = sprintf(
"DELETE FROM tst_sequence WHERE active_fi = %s",
3642 $ilDB->quote($active_id)
3644 $result = $ilDB->query($query);
3647 $query = sprintf(
"DELETE FROM tst_active WHERE active_id = %s",
3648 $ilDB->quote($active_id .
"")
3650 $result = $ilDB->query($query);
3655 $query = sprintf(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
3656 $ilDB->quote($user_id),
3657 $ilDB->quote(
"tst_password_".$this->
getTestId())
3659 $result = $ilDB->query($query);
3677 $query = sprintf(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s",
3678 $ilDB->quote($this->getTestId()),
3679 $ilDB->quote($question_id)
3681 $result = $ilDB->query($query);
3682 $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
3683 if (
$data->sequence > 1) {
3685 $query = sprintf(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s",
3686 $ilDB->quote($this->getTestId()),
3687 $ilDB->quote(
$data->sequence - 1)
3689 $result = $ilDB->query($query);
3690 $data_previous = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
3692 $query = sprintf(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3693 $ilDB->quote(
$data->sequence),
3694 $ilDB->quote($data_previous->test_question_id)
3696 $result = $ilDB->query($query);
3698 $query = sprintf(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3699 $ilDB->quote(
$data->sequence - 1),
3700 $ilDB->quote(
$data->test_question_id)
3702 $result = $ilDB->query($query);
3703 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3724 $query = sprintf(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s",
3725 $ilDB->quote($this->getTestId()),
3726 $ilDB->quote($question_id)
3728 $result = $ilDB->query($query);
3729 $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
3730 $query = sprintf(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s",
3731 $ilDB->quote($this->getTestId()),
3732 $ilDB->quote(
$data->sequence + 1)
3734 $result = $ilDB->query($query);
3735 if ($result->numRows() == 1)
3738 $data_next = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
3740 $query = sprintf(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3741 $ilDB->quote(
$data->sequence),
3742 $ilDB->quote($data_next->test_question_id)
3744 $result = $ilDB->query($query);
3746 $query = sprintf(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3747 $ilDB->quote(
$data->sequence + 1),
3748 $ilDB->quote(
$data->test_question_id)
3750 $result = $ilDB->query($query);
3751 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3773 $duplicate_id = $question->duplicate(
true);
3775 return $duplicate_id;
3793 $query = sprintf(
"SELECT MAX(sequence) AS seq FROM tst_test_question WHERE test_fi=%s",
3794 $ilDB->quote($this->getTestId())
3796 $result = $ilDB->query($query);
3802 $sequence =
$data->seq + 1;
3805 $query = sprintf(
"INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
3806 $ilDB->quote($this->getTestId()),
3807 $ilDB->quote($duplicate_id),
3808 $ilDB->quote($sequence)
3810 $result = $ilDB->query($query);
3811 if (PEAR::isError($result))
3814 $ilias->raiseError($result->getMessage());
3818 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3825 $query = sprintf(
"DELETE FROM tst_active WHERE test_fi = %s",
3826 $ilDB->quote($this->getTestId())
3828 $result = $ilDB->query($query);
3846 $query = sprintf(
"SELECT qpl_questions.title FROM tst_test_question, qpl_questions WHERE tst_test_question.test_fi = %s AND tst_test_question.question_fi = qpl_questions.question_id ORDER BY tst_test_question.sequence",
3847 $ilDB->quote($this->getTestId() .
"")
3849 $result = $ilDB->query($query);
3850 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
3852 array_push($titles, $row[
"title"]);
3871 $query = sprintf(
"SELECT qpl_questions.title, qpl_questions.question_id FROM tst_test_question, qpl_questions WHERE tst_test_question.test_fi = %s AND tst_test_question.question_fi = qpl_questions.question_id ORDER BY tst_test_question.sequence",
3872 $ilDB->quote($this->getTestId() .
"")
3874 $result = $ilDB->query($query);
3875 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
3877 $titles[$row[
'question_id']] = $row[
"title"];
3897 return $this->lng->txt(
"ass_question");
3919 $query = sprintf(
"SELECT qpl_questions.*, qpl_question_type.type_tag FROM qpl_questions, qpl_question_type WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_question_type.question_type_id",
3920 $ilDB->quote(
"$question_id")
3922 $result = $ilDB->query($query);
3923 $row = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
3940 $existing_questions = array();
3945 $query = sprintf(
"SELECT qpl_questions.original_id FROM qpl_questions, tst_test_random_question WHERE tst_test_random_question.active_fi = %s AND tst_test_random_question.question_fi = qpl_questions.question_id AND tst_test_random_question.pass = %s",
3946 $ilDB->quote($active_id .
""),
3947 $ilDB->quote(
$pass .
"")
3952 $query = sprintf(
"SELECT qpl_questions.original_id FROM qpl_questions, tst_test_question WHERE tst_test_question.test_fi = %s AND tst_test_question.question_fi = qpl_questions.question_id",
3953 $ilDB->quote($this->getTestId())
3956 $result = $ilDB->query($query);
3957 while (
$data =
$result->fetchRow(MDB2_FETCHMODE_OBJECT)) {
3958 array_push($existing_questions,
$data->original_id);
3960 return $existing_questions;
3976 if ($question_id < 1)
3978 $query = sprintf(
"SELECT type_tag FROM qpl_questions, qpl_question_type WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_question_type.question_type_id",
3979 $ilDB->quote($question_id)
3981 $result = $ilDB->query($query);
3982 if ($result->numRows() == 1) {
3983 $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
3984 return $data->type_tag;
4002 $q = sprintf(
"INSERT INTO tst_times (times_id, active_fi, started, finished, pass, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
4003 $ilDB->quote($active_id),
4004 $ilDB->quote(strftime(
"%Y-%m-%d %H:%M:%S")),
4005 $ilDB->quote(strftime(
"%Y-%m-%d %H:%M:%S")),
4009 return $ilDB->getLastInsertId();
4024 $q = sprintf(
"UPDATE tst_times SET finished = %s WHERE times_id = %s",
4025 $ilDB->quote(strftime(
"%Y-%m-%d %H:%M:%S")),
4026 $ilDB->quote($times_id)
4046 $query = sprintf(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND pass = 0 GROUP BY question_fi",
4047 $ilDB->quote($active_id .
"")
4052 $query = sprintf(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND pass = %s GROUP BY question_fi",
4053 $ilDB->quote($active_id .
""),
4054 $ilDB->quote(
$pass .
"")
4057 $result = $ilDB->query($query);
4058 $result_array = array();
4059 while ($row =
$result->fetchRow(MDB2_FETCHMODE_OBJECT))
4061 array_push($result_array, $row->question_fi);
4063 return $result_array;
4079 if (($currentpass > 0) && ($num == 0))
4102 $result_array = array();
4107 if (count($this->questions) == 0)
return $result_array;
4112 $query = sprintf(
"SELECT qpl_questions.* FROM qpl_questions, tst_test_random_question WHERE tst_test_random_question.question_fi = qpl_questions.question_id AND tst_test_random_question.active_fi = %s AND tst_test_random_question.pass = %s AND qpl_questions.question_id IN ('" . join($this->questions,
"','") .
"')",
4113 $ilDB->quote($active_id .
""),
4114 $ilDB->quote(
$pass .
"")
4119 if (count($this->questions) == 0)
return $result_array;
4120 $query =
"SELECT qpl_questions.* FROM qpl_questions, tst_test_question WHERE tst_test_question.question_fi = qpl_questions.question_id AND qpl_questions.question_id IN ('" . join($this->questions,
"','") .
"')";
4122 $result = $ilDB->query($query);
4123 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
4125 $result_array[$row[
"question_id"]] = $row;
4127 return $result_array;
4145 if (!$user_id) $user_id = $ilUser->getId();
4148 $query = sprintf(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
4149 $ilDB->quote($user_id),
4150 $ilDB->quote($this->test_id),
4154 else if (strlen($anonymous_id))
4156 $query = sprintf(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
4157 $ilDB->quote($user_id),
4158 $ilDB->quote($this->test_id),
4159 $ilDB->quote($anonymous_id)
4164 if (
$_SESSION[
"AccountId"] == ANONYMOUS_USER_ID)
4168 $query = sprintf(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s",
4169 $ilDB->quote($user_id),
4170 $ilDB->quote($this->test_id)
4173 $result = $ilDB->query($query);
4176 $row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC);
4177 return $row[
"active_id"];
4201 $user_id = $ilUser->id;
4207 $query = sprintf(
"SELECT tst_active.active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s",
4208 $ilDB->quote($user_id .
""),
4212 $result = $ilDB->query($query);
4213 if ($result->numRows())
4215 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
4216 return $row[
"active_id"];
4234 mt_srand((
double)microtime()*1000000);
4240 $j = mt_rand(0, $i);
4245 $array[$j] = $array[$i];
4265 $total_max_points = 0;
4266 $total_reached_points = 0;
4269 $result_array = array();
4270 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
4277 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
4279 $sequence = array();
4280 if ($ordered_sequence)
4288 foreach ($sequence as $sequenceindex)
4290 $value =
$testSequence->getQuestionForSequence($sequenceindex);
4292 $total_max_points += $max_points;
4302 $total_reached_points += $reached_points;
4303 if ($max_points > 0)
4305 $percentvalue = $reached_points / $max_points;
4311 if ($percentvalue < 0) $percentvalue = 0.0;
4319 $href =
"see_details_for_further_information";
4326 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4330 "max" => $max_points,
4331 "reached" => $reached_points,
4332 "percent" => sprintf(
"%2.2f ", ($percentvalue) * 100) .
"%",
4333 "solution" => $href,
4334 "type" => $info[
"type_tag"],
4336 "original_id" => $info[
"original_id"],
4337 "workedthrough" => $workedthrough
4339 array_push($result_array, $row);
4345 if ($total_reached_points < 0)
4347 $total_reached_points = 0;
4350 $result_array[
"test"][
"total_max_points"] = $total_max_points;
4351 $result_array[
"test"][
"total_reached_points"] = $total_reached_points;
4352 if ((!$total_reached_points) or (!$total_max_points))
4358 $percentage = ($total_reached_points / $total_max_points) * 100.0;
4359 if ($percentage < 0) $percentage = 0.0;
4361 $mark_obj = $this->mark_schema->getMatchingMark($percentage);
4365 if ($mark_obj->getPassed())
4374 $result_array[
"test"][
"passed"] = $passed;
4375 return $result_array;
4390 $q = sprintf(
"SELECT COUNT(*) as total FROM tst_active WHERE test_fi = %s",
4391 $ilDB->quote($this->getTestId())
4394 $row =
$result->fetchRow(MDB2_FETCHMODE_OBJECT);
4410 $q = sprintf(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi AND tst_active.user_fi = %s",
4411 $ilDB->quote($this->getTestId()),
4412 $ilDB->quote($user_id)
4416 while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
4418 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row->started, $matches);
4419 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4420 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row->finished, $matches);
4421 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4422 $time += ($epoch_2 - $epoch_1);
4453 $query = sprintf(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi ORDER BY tst_times.active_fi, tst_times.started",
4456 $result = $ilDB->query($query);
4459 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
4461 if (!array_key_exists($row[
"active_fi"], $times))
4463 $times[$row[
"active_fi"]] = 0;
4465 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row[
"started"], $matches);
4466 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4467 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row[
"finished"], $matches);
4468 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4469 $times[$row[
"active_fi"]] += ($epoch_2 - $epoch_1);
4486 $query = sprintf(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi AND tst_active.active_id = %s ORDER BY tst_times.active_fi, tst_times.started",
4487 $ilDB->quote($this->getTestId() .
""),
4488 $ilDB->quote($active_id .
"")
4490 $result = $ilDB->query($query);
4492 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
4494 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row[
"started"], $matches);
4495 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4496 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row[
"finished"], $matches);
4497 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4498 $time += ($epoch_2 - $epoch_1);
4515 $query = sprintf(
"SELECT * FROM tst_times WHERE active_fi = %s AND pass = %s ORDER BY started",
4516 $ilDB->quote($active_id .
""),
4517 $ilDB->quote(
$pass .
"")
4519 $result = $ilDB->query($query);
4521 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
4523 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row[
"started"], $matches);
4524 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4525 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row[
"finished"], $matches);
4526 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4527 $time += ($epoch_2 - $epoch_1);
4560 $query = sprintf(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi AND tst_active.active_id = %s ORDER BY tst_times.started",
4562 $ilDB->quote($active_id .
"")
4564 $result = $ilDB->query($query);
4567 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
4569 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row[
"started"], $matches);
4570 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4571 if ($firstvisit == 0 || $epoch_1 < $firstvisit) $firstvisit = $epoch_1;
4572 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row[
"finished"], $matches);
4573 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4574 if ($epoch_2 > $lastvisit) $lastvisit = $epoch_2;
4576 return array(
"firstvisit" => $firstvisit,
"lastvisit" => $lastvisit);
4593 $q = sprintf(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.active_id = %s AND tst_active.active_id = tst_times.active_fi",
4594 $ilDB->quote($active_id)
4600 while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT)) {
4601 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row->started, $matches);
4602 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4603 if (!$first_visit) {
4604 $first_visit = $epoch_1;
4606 if ($epoch_1 < $first_visit) {
4607 $first_visit = $epoch_1;
4609 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row->finished, $matches);
4610 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4612 $last_visit = $epoch_2;
4614 if ($epoch_2 > $last_visit) {
4615 $last_visit = $epoch_2;
4617 $times[$row->active_fi] += ($epoch_2 - $epoch_1);
4620 foreach ($times as $key => $value) {
4621 $max_time += $value;
4623 if ((!$test_result[
"test"][
"total_reached_points"]) or (!$test_result[
"test"][
"total_max_points"]))
4629 $percentage = ($test_result[
"test"][
"total_reached_points"] / $test_result[
"test"][
"total_max_points"]) * 100.0;
4630 if ($percentage < 0) $percentage = 0.0;
4632 $mark_obj = $this->mark_schema->getMatchingMark($percentage);
4633 $first_date = getdate($first_visit);
4634 $last_date = getdate($last_visit);
4635 $qworkedthrough = 0;
4636 foreach ($test_result as $key => $value)
4638 if (preg_match(
"/\d+/", $key))
4640 $qworkedthrough += $value[
"workedthrough"];
4643 if (!$qworkedthrough)
4649 $atimeofwork = $max_time / $qworkedthrough;
4655 $result_mark = $mark_obj->getShortName();
4656 if ($mark_obj->getPassed())
4665 $percent_worked_through = 0;
4666 if (count($this->questions))
4668 $percent_worked_through = $qworkedthrough / count($this->questions);
4670 $result_array = array(
4671 "qworkedthrough" => $qworkedthrough,
4672 "qmax" => count($this->questions),
4673 "pworkedthrough" => $percent_worked_through,
4674 "timeofwork" => $max_time,
4675 "atimeofwork" => $atimeofwork,
4676 "firstvisit" => $first_date,
4677 "lastvisit" => $last_date,
4678 "resultspoints" => $test_result[
"test"][
"total_reached_points"],
4679 "maxpoints" => $test_result[
"test"][
"total_max_points"],
4680 "resultsmarks" => $result_mark,
4681 "passed" => $passed,
4682 "distancemedian" =>
"0"
4684 foreach ($test_result as $key => $value)
4686 if (preg_match(
"/\d+/", $key))
4688 $result_array[$key] = $value;
4691 return $result_array;
4705 $totalpoints_array = array();
4707 foreach ($all_users as $active_id => $user_name)
4710 $reached = $test_result[
"test"][
"total_reached_points"];
4711 $total = $test_result[
"test"][
"total_max_points"];
4713 $mark = $this->mark_schema->getMatchingMark($percentage*100.0);
4716 if ($mark->getPassed())
4718 array_push($totalpoints_array, $test_result[
"test"][
"total_reached_points"]);
4722 return $totalpoints_array;
4736 $q = sprintf(
"SELECT tst_active.active_id, usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login FROM tst_active LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id WHERE tst_active.test_fi = %s ORDER BY usr_data.lastname ASC",
4737 $ilDB->quote($this->getTestId())
4740 $persons_array = array();
4741 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
4743 $name = $this->lng->txt(
"unknown");
4744 $fullname = $this->lng->txt(
"unknown");
4748 if (strlen($row[
"firstname"].$row[
"lastname"].$row[
"title"]) == 0)
4750 $name = $this->lng->txt(
"deleted_user");
4751 $fullname = $this->lng->txt(
"deleted_user");
4752 $login = $this->lng->txt(
"unknown");
4756 $login = $row[
"login"];
4757 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4759 $name = $this->lng->txt(
"unknown");
4760 $fullname = $this->lng->txt(
"unknown");
4764 $name = trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]);
4765 $fullname = trim($row[
"title"] .
" " . $row[
"firstname"] .
" " . $row[
"lastname"]);
4769 $persons_array[$row[
"active_id"]] = array(
4771 "fullname" => $fullname,
4775 return $persons_array;
4789 $q = sprintf(
"SELECT tst_active.active_id, usr_data.firstname, usr_data.lastname, usr_data.title FROM tst_active LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id WHERE tst_active.test_fi = %s ORDER BY usr_data.lastname " . strtoupper($name_sort_order),
4790 $ilDB->quote($this->getTestId())
4793 $persons_array = array();
4794 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
4798 $persons_array[$row[
"active_id"]] = $this->lng->txt(
"unknown");
4802 if (strlen($row[
"firstname"].$row[
"lastname"].$row[
"title"]) == 0)
4804 $persons_array[$row[
"active_id"]] = $this->lng->txt(
"deleted_user");
4808 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4810 $persons_array[$row[
"active_id"]] = $row[
"lastname"];
4814 $persons_array[$row[
"active_id"]] = trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]);
4819 return $persons_array;
4833 $q = sprintf(
"SELECT tst_active.active_id, usr_data.login, usr_data.firstname, usr_data.lastname, usr_data.title FROM tst_active LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id WHERE tst_active.test_fi = %s ORDER BY usr_data.lastname " . strtoupper($name_sort_order),
4834 $ilDB->quote($this->getTestId())
4837 $persons_array = array();
4838 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
4842 $persons_array[$row[
"active_id"]] = array(
"name" => $this->lng->txt(
"unknown"));
4846 if (strlen($row[
"firstname"].$row[
"lastname"].$row[
"title"]) == 0)
4848 $persons_array[$row[
"active_id"]] = array(
"name" => $this->lng->txt(
"deleted_user"));
4852 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4854 $persons_array[$row[
"active_id"]] = array(
"name" => $row[
"lastname"]);
4858 $persons_array[$row[
"active_id"]] = array(
"name" => trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]),
"login" => $row[
"login"]);
4863 return $persons_array;
4878 $q = sprintf(
"SELECT COUNT(*) as total FROM tst_active WHERE test_fi = %s AND tries > 0",
4879 $ilDB->quote($this->getTestId())
4882 $row =
$result->fetchRow(MDB2_FETCHMODE_OBJECT);
4899 $query = sprintf(
"SELECT tst_test_random_question.sequence, tst_test_random_question.question_fi, " .
4900 "tst_test_random_question.pass, qpl_questions.points " .
4901 "FROM tst_test_random_question, qpl_questions " .
4902 "WHERE tst_test_random_question.question_fi = qpl_questions.question_id " .
4903 "AND tst_test_random_question.active_fi = %s ORDER BY tst_test_random_question.sequence LIMIT 0, %s",
4904 $ilDB->quote($active_id .
""),
4910 $query = sprintf(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4911 "qpl_questions.points " .
4912 "FROM tst_test_question, tst_active, qpl_questions " .
4913 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4914 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi",
4915 $ilDB->quote($active_id .
"")
4918 $result = $ilDB->query($query);
4922 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
4924 array_push($qtest, $row);
4943 $query = sprintf(
"SELECT tst_test_random_question.sequence, tst_test_random_question.question_fi, " .
4944 "qpl_questions.points " .
4945 "FROM tst_test_random_question, qpl_questions " .
4946 "WHERE tst_test_random_question.question_fi = qpl_questions.question_id " .
4947 "AND tst_test_random_question.active_fi = %s AND tst_test_random_question.pass = %s " .
4948 "ORDER BY tst_test_random_question.sequence LIMIT 0, %s",
4949 $ilDB->quote($active_id .
""),
4950 $ilDB->quote(
$pass .
""),
4956 $query = sprintf(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4957 "qpl_questions.points " .
4958 "FROM tst_test_question, tst_active, qpl_questions " .
4959 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4960 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi",
4961 $ilDB->quote($active_id .
"")
4964 $result = $ilDB->query($query);
4968 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
4970 array_push($qpass, $row);
4980 $query =
"SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua AS ua ".
4981 "JOIN rbac_fa AS fa ON ua.rol_id = fa.rol_id ".
4982 "JOIN tree AS t1 ON t1.child = fa.parent ".
4983 "JOIN object_reference AS obr ON t1.parent = obr.ref_id ".
4984 "JOIN object_data AS obd ON obr.obj_id = obd.obj_id ".
4985 "WHERE obd.type = ".$ilDB->quote($a_type).
" ".
4986 "AND fa.assign = 'y' ".
4987 "AND ua.usr_id = ".$ilDB->quote($a_usr_id).
" ";
4988 $res = $ilDB->query($query);
4992 $ref_ids[] = $row->obj_id;
4995 return $ref_ids ? $ref_ids : array();
5001 include_once
"./Modules/Test/classes/class.ilTestEvaluationPassData.php";
5002 include_once
"./Modules/Test/classes/class.ilTestEvaluationUserData.php";
5003 include_once
"./Modules/Test/classes/class.ilTestEvaluationData.php";
5005 $query = sprintf(
"SELECT tst_test_result.*, qpl_questions.original_id, qpl_questions.title AS questiontitle, " .
5006 "qpl_questions.points AS maxpoints " .
5007 "FROM tst_test_result, qpl_questions, tst_active " .
5008 "WHERE tst_active.active_id = tst_test_result.active_fi " .
5009 "AND qpl_questions.question_id = tst_test_result.question_fi " .
5010 "AND tst_active.test_fi = %s " .
5011 "ORDER BY active_id, pass, TIMESTAMP",
5012 $ilDB->quote($this->getTestId() .
"")
5014 $result = $ilDB->query($query);
5020 $data->getParticipant($row[
"active_fi"])->getPass($row[
"pass"])->addAnsweredQuestion($row[
"original_id"] ? $row[
"original_id"] : $row[
"question_fi"], $row[
"maxpoints"], $row[
"points"]);
5023 foreach (array_keys(
$data->getParticipants()) as $active_id)
5027 for ($testpass = 0; $testpass <=
$data->getParticipant($active_id)->getLastPass(); $testpass++)
5029 $query = sprintf(
"SELECT tst_test_random_question.sequence, tst_test_random_question.question_fi, qpl_questions.original_id, " .
5030 "tst_test_random_question.pass, qpl_questions.points, qpl_questions.title " .
5031 "FROM tst_test_random_question, qpl_questions " .
5032 "WHERE tst_test_random_question.question_fi = qpl_questions.question_id " .
5033 "AND tst_test_random_question.pass = %s " .
5034 "AND tst_test_random_question.active_fi = %s ORDER BY tst_test_random_question.sequence LIMIT 0, %s",
5035 $ilDB->quote($testpass .
""),
5036 $ilDB->quote($active_id .
""),
5039 $result = $ilDB->query($query);
5040 if ($result->numRows())
5044 $tpass = array_key_exists(
"pass", $row) ? $row[
"pass"] : 0;
5045 $data->getParticipant($active_id)->addQuestion($row[
"original_id"] ? $row[
"original_id"] : $row[
"question_fi"], $row[
"question_fi"], $row[
"points"], $row[
"sequence"], $tpass);
5046 $data->addQuestionTitle($row[
"original_id"] ? $row[
"original_id"] : $row[
"question_fi"], $row[
"title"]);
5053 $query = sprintf(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
5054 "qpl_questions.points, qpl_questions.title, qpl_questions.original_id " .
5055 "FROM tst_test_question, tst_active, qpl_questions " .
5056 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
5057 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi ORDER BY tst_test_question.sequence",
5058 $ilDB->quote($active_id .
"")
5060 $result = $ilDB->query($query);
5061 if ($result->numRows())
5063 $questionsbysequence = array();
5066 $questionsbysequence[$row[
"sequence"]] = $row;
5068 $sequery = sprintf(
"SELECT * FROM tst_sequence WHERE active_fi = %s",
5069 $ilDB->quote($active_id)
5071 $seqresult = $ilDB->query($sequery);
5074 $questionsequence = unserialize($seqrow[
"sequence"]);
5075 foreach ($questionsequence as $sidx => $seq)
5077 $qsid = $questionsbysequence[$seq][
"original_id"] ? $questionsbysequence[$seq][
"original_id"] : $questionsbysequence[$seq][
"question_fi"];
5078 $data->getParticipant($active_id)->addQuestion($qsid, $questionsbysequence[$seq][
"question_fi"], $questionsbysequence[$seq][
"points"], $sidx + 1, $seqrow[
"pass"]);
5079 $data->addQuestionTitle($qsid, $questionsbysequence[$seq][
"title"]);
5086 if ($this->ects_output)
5090 foreach (array_keys(
$data->getParticipants()) as $active_id)
5092 $percentage =
$data->getParticipant($active_id)->getReachedPointsInPercent();
5093 $mark = $this->mark_schema->getMatchingMark($percentage);
5094 if (is_object($mark))
5096 $data->getParticipant($active_id)->setMark($mark->getShortName());
5097 $data->getParticipant($active_id)->setMarkOfficial($mark->getOfficialName());
5098 $data->getParticipant($active_id)->setPassed($mark->getPassed());
5100 if ($this->ects_output)
5102 $ects_mark = $this->
getECTSGrade($passed_array,
$data->getParticipant($active_id)->getReached(),
$data->getParticipant($active_id)->getMaxPoints());
5103 $data->getParticipant($active_id)->setECTSMark($ects_mark);
5106 $data->getParticipant($active_id)->setFirstVisit($visitingTime[
"firstvisit"]);
5107 $data->getParticipant($active_id)->setLastVisit($visitingTime[
"lastvisit"]);
5118 $query = sprintf(
"SELECT tst_test_random_question.pass, COUNT(tst_test_random_question.question_fi) AS qcount, " .
5119 "SUM(qpl_questions.points) AS qsum FROM tst_test_random_question, qpl_questions " .
5120 "WHERE tst_test_random_question.question_fi = qpl_questions.question_id AND " .
5121 "tst_test_random_question.active_fi = %s and pass = %s GROUP BY tst_test_random_question.active_fi, " .
5122 "tst_test_random_question.pass",
5123 $ilDB->quote($active_id),
5129 $query = sprintf(
"SELECT COUNT(tst_test_question.question_fi) AS qcount, " .
5130 "SUM(qpl_questions.points) AS qsum FROM tst_test_question, qpl_questions, tst_active " .
5131 "WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = tst_active.test_fi AND " .
5132 "tst_active.active_id = %s GROUP BY tst_test_question.test_fi",
5133 $ilDB->quote($active_id)
5136 $result = $ilDB->query($query);
5140 return array(
"count" => $row[
"qcount"],
"points" => $row[
"qsum"]);
5144 return array(
"count" => 0,
"points" => 0);
5150 include_once
"./Modules/Test/classes/class.ilTestEvaluationData.php";
5151 include_once
"./Modules/Test/classes/class.ilTestEvaluationPassData.php";
5152 include_once
"./Modules/Test/classes/class.ilTestEvaluationUserData.php";
5154 if ($withStatistics)
5156 $data->calculateStatistics();
5158 $data->setFilter($filterby, $filtertext);
5187 $query = sprintf(
"SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
5188 "tst_test_result.*, qpl_questions.original_id, qpl_questions.title AS questiontitle, " .
5189 "qpl_questions.points AS maxpoints " .
5190 "FROM tst_test_result, qpl_questions, tst_active " .
5191 "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
5192 "WHERE tst_active.active_id = tst_test_result.active_fi " .
5193 "AND qpl_questions.question_id = tst_test_result.question_fi " .
5194 "AND tst_active.test_fi = %s " .
5195 "ORDER BY active_id, pass, TIMESTAMP",
5198 $result = $ilDB->query($query);
5199 $overview = array();
5200 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
5202 if (!array_key_exists($row[
"active_fi"], $overview))
5204 $overview[$row[
"active_fi"]] = array();
5205 $overview[$row[
"active_fi"]][
"firstname"] = $row[
"firstname"];
5206 $overview[$row[
"active_fi"]][
"lastname"] = $row[
"lastname"];
5207 $overview[$row[
"active_fi"]][
"title"] = $row[
"title"];
5208 $overview[$row[
"active_fi"]][
"login"] = $row[
"login"];
5209 $overview[$row[
"active_fi"]][
"usr_id"] = $row[
"usr_id"];
5210 $overview[$row[
"active_fi"]][
"started"] = $row[
"started"];
5211 $overview[$row[
"active_fi"]][
"finished"] = $row[
"finished"];
5213 if (!array_key_exists($row[
"pass"], $overview[$row[
"active_fi"]]))
5215 $overview[$row[
"active_fi"]][$row[
"pass"]] = array();
5216 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] = 0;
5217 $overview[$row[
"active_fi"]][$row[
"pass"]][
"maxpoints"] = $row[
"maxpoints"];
5219 array_push($overview[$row[
"active_fi"]][$row[
"pass"]], $row);
5220 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] += $row[
"points"];
5238 $query = sprintf(
"SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
5239 "tst_test_result.*, qpl_questions.original_id, qpl_questions.title AS questiontitle, " .
5240 "qpl_questions.points AS maxpoints " .
5241 "FROM tst_test_result, qpl_questions, tst_active " .
5242 "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
5243 "WHERE tst_active.active_id = tst_test_result.active_fi " .
5244 "AND qpl_questions.question_id = tst_test_result.question_fi " .
5245 "AND tst_active.test_fi = %s AND tst_active.active_id = %s" .
5246 "ORDER BY active_id, pass, TIMESTAMP",
5247 $ilDB->quote($this->getTestId() .
""),
5248 $ilDB->quote($active_id .
"")
5250 $result = $ilDB->query($query);
5251 $overview = array();
5252 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
5254 if (!array_key_exists($row[
"active_fi"], $overview))
5256 $overview[$row[
"active_fi"]] = array();
5257 $overview[$row[
"active_fi"]][
"firstname"] = $row[
"firstname"];
5258 $overview[$row[
"active_fi"]][
"lastname"] = $row[
"lastname"];
5259 $overview[$row[
"active_fi"]][
"title"] = $row[
"title"];
5260 $overview[$row[
"active_fi"]][
"login"] = $row[
"login"];
5261 $overview[$row[
"active_fi"]][
"usr_id"] = $row[
"usr_id"];
5262 $overview[$row[
"active_fi"]][
"started"] = $row[
"started"];
5263 $overview[$row[
"active_fi"]][
"finished"] = $row[
"finished"];
5265 if (!array_key_exists($row[
"pass"], $overview[$row[
"active_fi"]]))
5267 $overview[$row[
"active_fi"]][$row[
"pass"]] = array();
5268 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] = 0;
5269 $overview[$row[
"active_fi"]][$row[
"pass"]][
"maxpoints"] = $row[
"maxpoints"];
5271 array_push($overview[$row[
"active_fi"]][$row[
"pass"]], $row);
5272 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] += $row[
"points"];
5293 if (strlen($firstname.$lastname.$title) == 0)
5295 $name = $this->lng->txt(
"deleted_user");
5299 if ($user_id == ANONYMOUS_USER_ID)
5305 $name = trim($lastname .
", " . $firstname .
" " .
$title);
5309 $name = $this->lng->txt(
"anonymous");
5333 if (strlen($firstname.$lastname.$title) == 0)
5335 $name = $lng->txt(
"deleted_user");
5339 if ($user_id == ANONYMOUS_USER_ID)
5345 $name = trim($lastname .
", " . $firstname .
" " .
$title);
5349 $name = $lng->txt(
"anonymous");
5367 $q = sprintf(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi",
5368 $ilDB->quote($this->getTestId())
5372 while ($row =
$result->fetchRow(MDB2_FETCHMODE_OBJECT))
5374 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row->started, $matches);
5375 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5376 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row->finished, $matches);
5377 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5378 $times[$row->active_fi] += ($epoch_2 - $epoch_1);
5382 foreach ($times as $key => $value)
5384 $max_time += $value;
5389 $average_time = round($max_time / $counter);
5395 return $average_time;
5406 function &
getAvailableQuestionpools($use_object_id =
false, $equal_points =
false, $could_be_offline =
false, $show_path = FALSE, $with_questioncount = FALSE, $permission =
"read")
5408 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5422 $time_in_seconds = 0;
5423 foreach ($this->questions as $question_id)
5426 $est_time = $question->getEstimatedWorkingTime();
5427 $time_in_seconds += $est_time[
"h"] * 3600 + $est_time[
"m"] * 60 + $est_time[
"s"];
5429 $hours = (int)($time_in_seconds / 3600) ;
5430 $time_in_seconds = $time_in_seconds - ($hours * 3600);
5431 $minutes = (int)($time_in_seconds / 60);
5432 $time_in_seconds = $time_in_seconds - ($minutes * 60);
5433 $result = array(
"h" => $hours,
"m" => $minutes,
"s" => $time_in_seconds);
5454 if ($questionpool != 0)
5459 $query = sprintf(
"SELECT obj_id FROM object_reference WHERE ref_id = %s",
5460 $ilDB->quote(
"$questionpool")
5462 $result = $ilDB->query($query);
5463 $row = $result->fetchRow(DB_FETCHMODE_ARRAY);
5464 $questionpool = $row[0];
5469 $query = sprintf(
"SELECT qpl_questions.original_id FROM qpl_questions, tst_test_question WHERE qpl_questions.question_id = tst_test_question.question_fi AND tst_test_question.test_fi = %s",
5470 $ilDB->quote($this->getTestId() .
"")
5472 $result = $ilDB->query($query);
5473 $original_ids = array();
5474 while ($row =
$result->fetchRow(DB_FETCHMODE_ARRAY))
5476 if (strcmp($row[0],
"") != 0)
5478 array_push($original_ids, $row[0]);
5481 $original_clause =
"";
5482 if (count($original_ids))
5484 $original_clause =
" AND ISNULL(qpl_questions.original_id) AND qpl_questions.question_id NOT IN ('" . join($original_ids,
"','") .
"')";
5488 if (($questionpool == 0) && (!is_array($qpls)))
5490 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5493 $constraint_qpls =
"";
5494 if (count($available_pools))
5496 $available =
" AND qpl_questions.obj_fi IN ('" . join($available_pools,
"','") .
"')";
5504 $result_array = array();
5505 if ($questionpool == 0)
5507 if (is_array($qpls))
5509 if (count($qpls) > 0)
5512 foreach ($qpls as $idx => $arr)
5514 array_push($qplidx, $arr[
"qpl"]);
5516 $constraint_qpls =
" AND qpl_questions.obj_fi IN ('" . join($qplidx,
"','") .
"')";
5519 $query =
"SELECT COUNT(question_id) FROM qpl_questions, object_data WHERE ISNULL(qpl_questions.original_id) AND object_data.type = 'qpl' AND object_data.obj_id = qpl_questions.obj_fi$available$constraint_qpls AND qpl_questions.complete = '1'$original_clause";
5523 $query = sprintf(
"SELECT COUNT(question_id) FROM qpl_questions WHERE ISNULL(qpl_questions.original_id) AND obj_fi = %s$original_clause",
5524 $ilDB->quote(
"$questionpool")
5527 $result = $ilDB->query($query);
5528 $row =
$result->fetchRow(DB_FETCHMODE_ARRAY);
5529 if (($row[0]) <= $nr_of_questions)
5532 if ($questionpool == 0)
5534 $query =
"SELECT question_id FROM qpl_questions, object_data WHERE ISNULL(qpl_questions.original_id) AND object_data.type = 'qpl' AND object_data.obj_id = qpl_questions.obj_fi$available$constraint_qpls AND qpl_questions.complete = '1'$original_clause";
5538 $query = sprintf(
"SELECT question_id FROM qpl_questions WHERE ISNULL(qpl_questions.original_id) AND obj_fi = %s AND qpl_questions.complete = '1'$original_clause",
5539 $ilDB->quote(
"$questionpool")
5542 $result = $ilDB->query($query);
5543 while ($row =
$result->fetchRow(DB_FETCHMODE_ARRAY))
5545 if ((!in_array($row[0], $this->questions)) && (strcmp($row[0],
"") != 0))
5547 $result_array[$row[0]] = $row[0];
5554 mt_srand((
double)microtime()*1000000);
5555 $random_number = mt_rand(0, $row[0] - 1);
5556 $securitycounter = 500;
5557 while ((count($result_array) < $nr_of_questions) && ($securitycounter > 0))
5559 if ($questionpool == 0)
5561 $query =
"SELECT question_id FROM qpl_questions, object_data WHERE ISNULL(qpl_questions.original_id) AND object_data.type = 'qpl' AND object_data.obj_id = qpl_questions.obj_fi$available$constraint_qpls AND qpl_questions.complete = '1'$original_clause LIMIT $random_number, 1";
5565 $query = sprintf(
"SELECT question_id FROM qpl_questions WHERE ISNULL(qpl_questions.original_id) AND obj_fi = %s AND qpl_questions.complete = '1'$original_clause LIMIT $random_number, 1",
5566 $ilDB->quote(
"$questionpool")
5569 $result = $ilDB->query($query);
5570 $result_row =
$result->fetchRow(DB_FETCHMODE_ARRAY);
5571 if ((!in_array($result_row[0], $this->questions)) && (strcmp($result_row[0],
"") != 0))
5573 $result_array[$result_row[0]] = $result_row[0];
5575 $random_number = mt_rand(0, $row[0] - 1);
5579 return $result_array;
5592 return CLIENT_WEB_DIR .
"/assessment/" . $this->
getId() .
"/images/";
5605 include_once
"./Services/Utilities/classes/class.ilUtil.php";
5622 if ((!$question_type) and ($question_id > 0))
5626 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
5628 $question_type_gui = $question_type .
"GUI";
5629 $question =
new $question_type_gui();
5630 if ($question_id > 0)
5632 $question->object->loadFromDb($question_id);
5648 if (strcmp($question_id,
"") != 0)
5650 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
5667 $this->questions = array_values($this->questions);
5668 $array_pos = array_search($target_index, $this->questions);
5669 if ($insert_mode == 0)
5671 $part1 = array_slice($this->questions, 0, $array_pos);
5672 $part2 = array_slice($this->questions, $array_pos);
5674 else if ($insert_mode == 1)
5676 $part1 = array_slice($this->questions, 0, $array_pos + 1);
5677 $part2 = array_slice($this->questions, $array_pos + 1);
5679 foreach ($move_questions as $question_id)
5681 if (!(array_search($question_id, $part1) === FALSE))
5683 unset($part1[array_search($question_id, $part1)]);
5685 if (!(array_search($question_id, $part2) === FALSE))
5687 unset($part2[array_search($question_id, $part2)]);
5690 $part1 = array_values($part1);
5691 $part2 = array_values($part2);
5692 $new_array = array_values(array_merge($part1, $move_questions, $part2));
5693 $this->questions = array();
5695 foreach ($new_array as $question_id)
5697 $this->questions[$counter] = $question_id;
5717 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartingTime(), $matches))
5719 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5721 if ($now < $epoch_time)
5744 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndingTime(), $matches))
5746 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5748 if ($now > $epoch_time)
5765 function getQuestionsTable($sort, $sortorder, $textfilter, $startrow = 0, $completeonly = 0, $filter_question_type =
"", $filter_questionpool =
"")
5771 foreach ($textfilter as $sel_filter_type => $filter_text)
5773 if (strlen($filter_text) > 0)
5775 switch($sel_filter_type)
5778 $where .=
" AND qpl_questions.title LIKE " . $ilDB->quote(
"%" . $filter_text .
"%");
5781 $where .=
" AND qpl_questions.comment LIKE " . $ilDB->quote(
"%" . $filter_text .
"%");
5784 $where .=
" AND qpl_questions.author LIKE " . $ilDB->quote(
"%" . $filter_text .
"%");
5787 $where .=
" AND object_data.title LIKE " . $ilDB->quote(
"%" . $filter_text .
"%");
5793 if ($filter_question_type && (strcmp($filter_question_type,
"all") != 0))
5795 $where .=
" AND qpl_question_type.type_tag = " . $ilDB->quote($filter_question_type);
5798 if ($filter_questionpool && (strcmp($filter_questionpool,
"all") != 0))
5800 $where .=
" AND qpl_questions.obj_fi = $filter_questionpool";
5806 include_once
"./Services/Utilities/classes/class.ilUtil.php";
5810 $order =
" ORDER BY qpl_questions.title $sortorder";
5811 $images[
"title"] =
" <img src=\"" .
ilUtil::getImagePath(strtolower($sortorder) .
"_order.gif") .
"\" alt=\"" . $this->lng->txt(strtolower($sortorder) .
"ending_order").
"\" />";
5814 $order =
" ORDER BY comment $sortorder";
5815 $images[
"comment"] =
" <img src=\"" .
ilUtil::getImagePath(strtolower($sortorder) .
"_order.gif") .
"\" alt=\"" . $this->lng->txt(strtolower($sortorder) .
"ending_order").
"\" />";
5818 $order =
" ORDER BY question_type_id $sortorder";
5819 $images[
"type"] =
" <img src=\"" .
ilUtil::getImagePath(strtolower($sortorder) .
"_order.gif") .
"\" alt=\"" . $this->lng->txt(strtolower($sortorder) .
"ending_order").
"\" />";
5822 $order =
" ORDER BY author $sortorder";
5823 $images[
"author"] =
" <img src=\"" .
ilUtil::getImagePath(strtolower($sortorder) .
"_order.gif") .
"\" alt=\"" . $this->lng->txt(strtolower($sortorder) .
"ending_order").
"\" />";
5826 $order =
" ORDER BY created $sortorder";
5827 $images[
"created"] =
" <img src=\"" .
ilUtil::getImagePath(strtolower($sortorder) .
"_order.gif") .
"\" alt=\"" . $this->lng->txt(strtolower($sortorder) .
"ending_order").
"\" />";
5830 $order =
" ORDER BY timestamp14 $sortorder";
5831 $images[
"updated"] =
" <img src=\"" .
ilUtil::getImagePath(strtolower($sortorder) .
"_order.gif") .
"\" alt=\"" . $this->lng->txt(strtolower($sortorder) .
"ending_order").
"\" />";
5834 $order =
" ORDER BY UPPER(object_data.title) $sortorder";
5835 $images[
"qpl"] =
" <img src=\"" .
ilUtil::getImagePath(strtolower($sortorder) .
"_order.gif") .
"\" alt=\"" . $this->lng->txt(strtolower($sortorder) .
"ending_order").
"\" />";
5838 $maxentries = $ilUser->prefs[
"hits_per_page"];
5839 if ($maxentries < 1)
5843 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5846 if (count($available_pools))
5848 $available =
" AND qpl_questions.obj_fi IN ('" . join($available_pools,
"','") .
"')";
5856 $available .=
" AND qpl_questions.complete = " . $ilDB->quote(
"1");
5860 $query = sprintf(
"SELECT qpl_questions.original_id, qpl_questions.TIMESTAMP + 0 AS timestamp14 FROM qpl_questions, tst_test_question, object_data WHERE qpl_questions.question_id = tst_test_question.question_fi AND object_data.obj_id = qpl_questions.obj_fi AND tst_test_question.test_fi = %s",
5861 $ilDB->quote($this->getTestId() .
"")
5863 $result = $ilDB->query($query);
5864 $original_ids = array();
5865 while ($row =
$result->fetchRow(DB_FETCHMODE_ARRAY))
5867 if (strcmp($row[0],
"") != 0)
5869 array_push($original_ids, $row[0]);
5872 $original_clause =
" ISNULL(qpl_questions.original_id)";
5873 if (count($original_ids))
5875 $original_clause =
" ISNULL(qpl_questions.original_id) AND qpl_questions.question_id NOT IN ('" . join($original_ids,
"','") .
"')";
5878 $query =
"SELECT qpl_questions.question_id, qpl_questions.TIMESTAMP + 0 AS timestamp14 FROM qpl_questions, qpl_question_type, object_data WHERE $original_clause$available AND object_data.obj_id = qpl_questions.obj_fi AND qpl_questions.question_type_fi = qpl_question_type.question_type_id $where$order$limit";
5879 $query_result = $ilDB->query($query);
5880 $max = $query_result->numRows();
5881 if ($startrow > $max -1)
5883 $startrow = $max - ($max % $maxentries);
5885 else if ($startrow < 0)
5889 $limit =
" LIMIT $startrow, $maxentries";
5890 $query =
"SELECT qpl_questions.*, qpl_questions.TIMESTAMP + 0 AS timestamp14, qpl_question_type.type_tag, qpl_question_type.plugin FROM qpl_questions, qpl_question_type, object_data WHERE $original_clause $available AND object_data.obj_id = qpl_questions.obj_fi AND qpl_questions.question_type_fi = qpl_question_type.question_type_id $where$order$limit";
5891 $query_result = $ilDB->query($query);
5893 if ($query_result->numRows())
5895 while ($row = $query_result->fetchRow(MDB2_FETCHMODE_ASSOC))
5901 array_push($rows, $row);
5906 array_push($rows, $row);
5910 $nextrow = $startrow + $maxentries;
5911 if ($nextrow > $max - 1)
5913 $nextrow = $startrow;
5915 $prevrow = $startrow - $maxentries;
5922 "images" => $images,
5923 "startrow" => $startrow,
5924 "nextrow" => $nextrow,
5925 "prevrow" => $prevrow,
5926 "step" => $maxentries,
5944 $this->
setTitle($assessment->getTitle());
5946 foreach ($assessment->objectives as $objectives)
5948 foreach ($objectives->materials as $material)
5953 if ($assessment->getPresentationMaterial())
5958 foreach ($assessment->assessmentcontrol as $assessmentcontrol)
5960 switch ($assessmentcontrol->getSolutionswitch())
5971 foreach ($assessment->qtimetadata as
$metadata)
5973 switch ($metadata[
"label"])
5977 $type = $metadata[
"entry"];
5998 case "sequence_settings":
6008 $this->
setKiosk($metadata[
"entry"]);
6010 case "showfinalstatement":
6022 case "hide_previous_results":
6023 if ($metadata[
"entry"] == 0)
6032 case "use_previous_answers":
6035 case "answer_feedback":
6038 case "hide_title_points":
6041 case "title_output":
6047 case "random_question_count":
6050 case "results_presentation":
6053 case "reset_processing_time":
6056 case "show_solution_details":
6059 case "show_solution_printview":
6062 case "show_solution_feedback":
6065 case "instant_verification":
6068 case "answer_feedback_points":
6080 case "fixed_participants":
6083 case "score_reporting":
6086 case "shuffle_questions":
6089 case "count_system":
6095 case "score_cutting":
6101 case "allowedUsers":
6104 case "allowedUsersTimeGap":
6107 case "pass_scoring":
6110 case "show_summary":
6113 case "reporting_date":
6114 $iso8601period = $metadata[
"entry"];
6115 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
6117 $this->
setReportingDate(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
6120 case "processing_time":
6123 case "starting_time":
6124 $iso8601period = $metadata[
"entry"];
6125 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
6127 $this->
setStartingTime(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
6131 $iso8601period = $metadata[
"entry"];
6132 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
6134 $this->
setEndingTime(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
6138 if (preg_match(
"/mark_step_\d+/", $metadata[
"label"]))
6140 $xmlmark = $metadata[
"entry"];
6141 preg_match(
"/<short>(.*?)<\/short>/", $xmlmark, $matches);
6142 $mark_short = $matches[1];
6143 preg_match(
"/<official>(.*?)<\/official>/", $xmlmark, $matches);
6144 $mark_official = $matches[1];
6145 preg_match(
"/<percentage>(.*?)<\/percentage>/", $xmlmark, $matches);
6146 $mark_percentage = $matches[1];
6147 preg_match(
"/<passed>(.*?)<\/passed>/", $xmlmark, $matches);
6148 $mark_passed = $matches[1];
6149 $this->mark_schema->addMarkStep($mark_short, $mark_official, $mark_percentage, $mark_passed);
6153 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
6155 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
6156 include_once
"./Services/RTE/classes/class.ilRTE.php";
6157 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
6158 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
6161 if (file_exists($importfile))
6171 $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
6188 include_once(
"./classes/class.ilXmlWriter.php");
6192 $a_xml_writer->xmlSetDtdDef(
"<!DOCTYPE questestinterop SYSTEM \"ims_qtiasiv1p2p1.dtd\">");
6193 $a_xml_writer->xmlStartTag(
"questestinterop");
6196 "ident" =>
"il_".IL_INST_ID.
"_tst_".$this->getTestId(),
6199 $a_xml_writer->xmlStartTag(
"assessment", $attrs);
6201 $a_xml_writer->xmlElement(
"qticomment", NULL, $this->
getDescription());
6204 if ($this->enable_processing_time)
6206 preg_match(
"/(\d+):(\d+):(\d+)/", $this->processing_time, $matches);
6207 $a_xml_writer->xmlElement(
"duration", NULL, sprintf(
"P0Y0M0DT%dH%dM%dS", $matches[1], $matches[2], $matches[3]));
6211 $a_xml_writer->xmlStartTag(
"qtimetadata");
6212 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6213 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ILIAS_VERSION");
6214 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->ilias->getSetting(
"ilias_version"));
6215 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6218 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6219 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"anonymity");
6220 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getAnonymity()));
6221 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6224 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6225 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"random_test");
6226 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
isRandomTest()));
6227 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6230 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6231 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"sequence_settings");
6233 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6236 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6237 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"author");
6238 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getAuthor());
6239 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6242 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6243 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"reset_processing_time");
6245 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6248 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6249 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"count_system");
6250 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getCountSystem());
6251 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6254 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6255 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mc_scoring");
6256 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getMCScoring());
6257 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6260 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6261 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"score_cutting");
6262 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getScoreCutting());
6263 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6266 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6267 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"password");
6268 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getPassword());
6269 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6272 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6273 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"allowedUsers");
6274 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getAllowedUsers());
6275 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6278 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6279 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"allowedUsersTimeGap");
6281 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6284 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6285 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"pass_scoring");
6286 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getPassScoring());
6287 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6292 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6293 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"reporting_date");
6294 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->reporting_date, $matches);
6295 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
6296 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6299 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6300 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"nr_of_tries");
6301 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getNrOfTries()));
6302 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6305 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6306 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"kiosk");
6307 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getKiosk()));
6308 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6311 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6312 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"use_previous_answers");
6314 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6317 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6318 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"title_output");
6319 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getTitleOutput()));
6320 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6323 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6324 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"random_question_count");
6326 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6329 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6330 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"results_presentation");
6332 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6335 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6336 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"show_summary");
6338 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6341 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6342 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"score_reporting");
6343 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getScoreReporting()));
6344 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6347 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6348 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"instant_verification");
6350 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6353 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6354 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"answer_feedback");
6355 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getAnswerFeedback()));
6356 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6359 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6360 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"answer_feedback_points");
6362 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6365 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6366 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"show_cancel");
6367 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShowCancel()));
6368 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6371 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6372 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"show_marker");
6373 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShowMarker()));
6374 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6377 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6378 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"fixed_participants");
6380 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6383 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6384 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"showfinalstatement");
6385 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getShowFinalStatement()) ?
"1" :
"0")));
6386 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6389 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6390 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"showinfo");
6391 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getShowInfo()) ?
"1" :
"0")));
6392 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6395 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6396 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"forcejs");
6397 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getForceJS()) ?
"1" :
"0")));
6398 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6401 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6402 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"customstyle");
6403 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getCustomStyle());
6404 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6407 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6408 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"shuffle_questions");
6409 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShuffleQuestions()));
6410 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6413 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6414 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"processing_time");
6416 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6421 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6422 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"starting_time");
6423 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->starting_time, $matches);
6424 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
6425 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6430 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6431 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ending_time");
6432 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->ending_time, $matches);
6433 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
6434 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6436 foreach ($this->mark_schema->mark_steps as $index => $mark)
6439 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6440 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mark_step_$index");
6441 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"<short>%s</short><official>%s</official><percentage>%.2f</percentage><passed>%d</passed>", $mark->getShortName(), $mark->getOfficialName(), $mark->getMinimumLevel(), $mark->getPassed()));
6442 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6444 $a_xml_writer->xmlEndTag(
"qtimetadata");
6447 $a_xml_writer->xmlStartTag(
"objectives");
6449 $a_xml_writer->xmlEndTag(
"objectives");
6455 "solutionswitch" =>
"Yes"
6462 $a_xml_writer->xmlElement(
"assessmentcontrol", $attrs, NULL);
6467 $a_xml_writer->xmlStartTag(
"presentation_material");
6468 $a_xml_writer->xmlStartTag(
"flow_mat");
6470 $a_xml_writer->xmlEndTag(
"flow_mat");
6471 $a_xml_writer->xmlEndTag(
"presentation_material");
6477 $a_xml_writer->xmlElement(
"section", $attrs, NULL);
6478 $a_xml_writer->xmlEndTag(
"assessment");
6479 $a_xml_writer->xmlEndTag(
"questestinterop");
6481 $xml = $a_xml_writer->xmlDumpMem(FALSE);
6483 foreach ($this->questions as $question_id)
6486 $qti_question = $question->toXML(
false);
6487 $qti_question = preg_replace(
"/<questestinterop>/",
"", $qti_question);
6488 $qti_question = preg_replace(
"/<\/questestinterop>/",
"", $qti_question);
6489 if (strpos($xml,
"</section>") !==
false)
6491 $xml = str_replace(
"</section>",
"$qti_question</section>", $xml);
6495 $xml = str_replace(
"<section ident=\"1\"/>",
"<section ident=\"1\">\n$qti_question</section>", $xml);
6511 $this->mob_ids = array();
6512 $this->file_ids = array();
6515 $attrs[
"Type"] =
"Test";
6516 $a_xml_writer->xmlStartTag(
"ContentObject", $attrs);
6522 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Page Objects");
6523 $ilBench->start(
"ContentObjectExport",
"exportPageObjects");
6525 $ilBench->stop(
"ContentObjectExport",
"exportPageObjects");
6526 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Page Objects");
6529 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Media Objects");
6530 $ilBench->start(
"ContentObjectExport",
"exportMediaObjects");
6532 $ilBench->stop(
"ContentObjectExport",
"exportMediaObjects");
6533 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Media Objects");
6536 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export File Items");
6537 $ilBench->start(
"ContentObjectExport",
"exportFileItems");
6539 $ilBench->stop(
"ContentObjectExport",
"exportFileItems");
6540 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export File Items");
6542 $a_xml_writer->xmlEndTag(
"ContentObject");
6553 include_once
"./Services/MetaData/classes/class.ilMD2XML.php";
6555 $md2xml->setExportMode(
true);
6556 $md2xml->startExport();
6557 $a_xml_writer->appendXML($md2xml->getXML());
6569 if ($a_tag ==
"Identifier" && $a_param ==
"Entry")
6571 include_once
"./Services/Utilities/classes/class.ilUtil.php";
6589 include_once
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
6591 foreach ($this->questions as $question_id)
6593 $ilBench->start(
"ContentObjectExport",
"exportPageObject");
6594 $expLog->write(date(
"[y-m-d H:i:s] ").
"Page Object ".$question_id);
6597 $a_xml_writer->xmlStartTag(
"PageObject", $attrs);
6601 $ilBench->start(
"ContentObjectExport",
"exportPageObject_XML");
6603 $page_object->buildDom();
6604 $page_object->insertInstIntoIDs($a_inst);
6605 $mob_ids = $page_object->collectMediaObjects(
false);
6606 $file_ids = $page_object->collectFileItems();
6607 $xml = $page_object->getXMLFromDom(
false,
false,
false,
"",
true);
6608 $xml = str_replace(
"&",
"&", $xml);
6609 $a_xml_writer->appendXML($xml);
6610 $page_object->freeDom();
6611 unset ($page_object);
6613 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_XML");
6616 $ilBench->start(
"ContentObjectExport",
"exportPageObject_CollectMedia");
6618 foreach($mob_ids as $mob_id)
6620 $this->mob_ids[$mob_id] = $mob_id;
6622 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_CollectMedia");
6625 $ilBench->start(
"ContentObjectExport",
"exportPageObject_CollectFileItems");
6627 foreach($file_ids as $file_id)
6629 $this->file_ids[$file_id] = $file_id;
6631 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_CollectFileItems");
6633 $a_xml_writer->xmlEndTag(
"PageObject");
6636 $ilBench->stop(
"ContentObjectExport",
"exportPageObject");
6650 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
6652 foreach ($this->mob_ids as $mob_id)
6654 $expLog->write(date(
"[y-m-d H:i:s] ").
"Media Object ".$mob_id);
6658 $media_obj->exportXML($a_xml_writer, $a_inst);
6659 $media_obj->exportFiles($a_target_dir);
6671 include_once
"./Modules/File/classes/class.ilObjFile.php";
6673 foreach ($this->file_ids as $file_id)
6675 $expLog->write(date(
"[y-m-d H:i:s] ").
"File Item ".$file_id);
6676 $file_obj =
new ilObjFile($file_id,
false);
6677 $file_obj->export($a_target_dir);
6688 if (!is_array($this->import_mapping))
6694 return $this->import_mapping;
6709 return ilObjTest::_getECTSGrade($passed_array, $reached_points, $max_points, $this->ects_grades[
"A"], $this->ects_grades[
"B"], $this->ects_grades[
"C"], $this->ects_grades[
"D"], $this->ects_grades[
"E"], $this->ects_fx);
6722 function _getECTSGrade($points_passed, $reached_points, $max_points, $a, $b, $c,
$d, $e, $fx)
6724 include_once
"./classes/class.ilStatistics.php";
6727 $passed_statistics->setData($points_passed);
6728 $ects_percentiles = array
6730 "A" => $passed_statistics->quantile($a),
6731 "B" => $passed_statistics->quantile($b),
6732 "C" => $passed_statistics->quantile($c),
6733 "D" => $passed_statistics->quantile(
$d),
6734 "E" => $passed_statistics->quantile($e)
6736 if (count($points_passed) && ($reached_points >= $ects_percentiles[
"A"]))
6740 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"B"]))
6744 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"C"]))
6748 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"D"]))
6752 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"E"]))
6756 else if (strcmp($fx,
"") != 0)
6758 if ($max_points > 0)
6760 $percentage = ($reached_points / $max_points) * 100.0;
6761 if ($percentage < 0) $percentage = 0.0;
6767 if ($percentage >= $fx)
6784 return $this->mark_schema->checkMarks();
6820 $md_life =& $md->getLifecycle();
6823 if (strlen($a_author) == 0)
6826 $a_author = $ilUser->getFullname();
6829 $md_life =& $md->addLifecycle();
6831 $con =& $md_life->addContribute();
6832 $con->setRole(
"Author");
6834 $ent =& $con->addEntity();
6835 $ent->setEntity($a_author);
6865 include_once
"./Services/MetaData/classes/class.ilMD.php";
6867 $md_life =& $md->getLifecycle();
6870 $ids =& $md_life->getContributeIds();
6871 foreach ($ids as
$id)
6873 $md_cont =& $md_life->getContribute($id);
6874 if (strcmp($md_cont->getRole(),
"Author") == 0)
6876 $entids =& $md_cont->getEntityIds();
6877 foreach ($entids as $entid)
6879 $md_ent =& $md_cont->getEntity($entid);
6880 array_push(
$author, $md_ent->getEntity());
6900 include_once
"./Services/MetaData/classes/class.ilMD.php";
6901 $md =&
new ilMD($obj_id, 0,
"tst");
6902 $md_life =& $md->getLifecycle();
6905 $ids =& $md_life->getContributeIds();
6906 foreach ($ids as
$id)
6908 $md_cont =& $md_life->getContribute($id);
6909 if (strcmp($md_cont->getRole(),
"Author") == 0)
6911 $entids =& $md_cont->getEntityIds();
6912 foreach ($entids as $entid)
6914 $md_ent =& $md_cont->getEntity($entid);
6915 array_push(
$author, $md_ent->getEntity());
6936 $result_array = array();
6941 $query = sprintf(
"SELECT object_data.*, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_reference.ref_id IN ('%s') ORDER BY object_data.title",
6944 $result = $ilDB->query($query);
6945 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
6949 $result_array[$row[
"obj_id"]] = $titles[$row[
"ref_id"]];
6953 $result_array[$row[
"ref_id"]] = $titles[$row[
"ref_id"]];
6957 return $result_array;
6974 $query = sprintf(
"SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY test_random_id",
6975 $ilDB->quote($this->getTestId() .
"")
6977 $result = $ilDB->query($query);
6980 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
6982 $query = sprintf(
"INSERT INTO tst_test_random (test_random_id, test_fi, questionpool_fi, num_of_q, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
6983 $ilDB->quote($new_id .
""),
6984 $ilDB->quote($row[
"questionpool_fi"] .
""),
6985 $ilDB->quote($row[
"num_of_q"] .
"")
6987 $insertresult = $ilDB->query($query);
7052 $newObj->saveToDb();
7054 include_once
"./Modules/Test/classes/class.ilTestCertificate.php";
7056 $cert->cloneCertificate($newObj->getId());
7060 $newObj->saveRandomQuestionCount($newObj->getRandomQuestionCount());
7065 include_once(
"./Services/CopyWizard/classes/class.ilCopyWizardOptions.php");
7069 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
7070 foreach ($this->questions as $key => $question_id)
7073 $newObj->questions[$key] = $question->duplicate();
7076 $question->saveToDb($original_id);
7080 $cwo->appendMapping($this->
getRefId().
'_'.$question_id,$newObj->getRefId().
'_'.$newObj->questions[$key]);
7081 $ilLog->write(__METHOD__.
': Added mapping '.$this->getRefId().
'_'.$question_id.
' <-> ' .
7082 $newObj->getRefId().
'_'.$newObj->questions[$key]);
7085 $newObj->saveToDb();
7093 $query = sprintf(
"SELECT ref_id FROM object_reference WHERE obj_id=%s",
7094 $ilDB->quote($obj_id)
7097 $result = $ilDB->query($query);
7098 if ($result->numRows())
7100 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
7101 return $row[
"ref_id"];
7125 foreach ($qpls as
$data)
7127 $maxcount += $data[
"contains"];
7129 if ($num > $maxcount) $num = $maxcount;
7134 foreach ($qpls as
$data)
7136 $add = ($data[
"count"] <= $data[
"contains"]) ? $data[
"count"] : $data[
"contains"];
7143 $num = count($this->questions);
7162 $query = sprintf(
"SELECT * FROM tst_tests WHERE test_id = %s",
7165 $result = $ilDB->query($query);
7166 if (!$result->numRows())
7170 $test = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
7172 if (
$test[
"random_test"] == 1)
7176 $query = sprintf(
"SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY test_random_id",
7179 $result = $ilDB->query($query);
7180 if ($result->numRows())
7182 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
7184 $countquery = sprintf(
"SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND original_id IS NULL",
7185 $ilDB->quote($row[
"questionpool_fi"] .
"")
7187 $countresult = $ilDB->query($countquery);
7188 $contains = $countresult->numRows();
7189 $qpls[$counter] = array(
7190 "index" => $counter,
7191 "count" => $row[
"num_of_q"],
7192 "qpl" => $row[
"questionpool_fi"],
7193 "contains" => $contains
7198 if (
$test[
"random_question_count"] > 0)
7200 $num =
$test[
"random_question_count"];
7202 foreach ($qpls as
$data)
7204 $maxcount += $data[
"contains"];
7206 if ($num > $maxcount) $num = $maxcount;
7211 foreach ($qpls as
$data)
7213 $add = ($data[
"count"] <= $data[
"contains"]) ? $data[
"count"] : $data[
"contains"];
7220 $query = sprintf(
"SELECT test_question_id FROM tst_test_question WHERE test_fi = %s",
7223 $result = $ilDB->query($query);
7224 $num = $result->numRows();
7242 $query = sprintf(
"DELETE FROM tst_test_question WHERE test_fi = %s",
7243 $ilDB->quote($this->getTestId())
7245 $result = $ilDB->query($query);
7246 $this->questions = array();
7262 $query = sprintf(
"DELETE FROM tst_test_random WHERE test_fi = %s",
7263 $ilDB->quote($this->getTestId())
7265 $result = $ilDB->query($query);
7266 $this->questions = array();
7284 if (strcmp($question_id,
"") != 0)
7286 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
7289 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
7306 $query = sprintf(
"SELECT obj_fi FROM tst_tests WHERE test_id = %s",
7309 $result = $ilDB->query($query);
7310 if ($result->numRows())
7312 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
7313 $object_id = $row[
"obj_fi"];
7331 $query = sprintf(
"SELECT tst_tests.obj_fi FROM tst_tests, tst_active WHERE tst_tests.test_id = tst_active.test_fi AND tst_active.active_id = %s",
7332 $ilDB->quote($active_id .
"")
7334 $result = $ilDB->query($query);
7335 if ($result->numRows())
7337 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
7338 $object_id = $row[
"obj_fi"];
7356 $query = sprintf(
"SELECT test_id FROM tst_tests WHERE obj_fi = %s",
7357 $ilDB->quote($object_id .
"")
7359 $result = $ilDB->query($query);
7360 if ($result->numRows())
7362 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
7383 if (($active_id) && ($question_id))
7387 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
7390 $query = sprintf(
"SELECT value1 FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
7391 $ilDB->quote($active_id .
""),
7392 $ilDB->quote($question_id .
""),
7393 $ilDB->quote(
$pass .
"")
7395 $result = $ilDB->query($query);
7396 if ($result->numRows() == 1)
7398 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
7399 $res = $row[
"value1"];
7421 $query = sprintf(
"SELECT question_text FROM qpl_questions WHERE question_id = %s",
7422 $ilDB->quote($question_id .
"")
7424 $result = $ilDB->query($query);
7425 if ($result->numRows() == 1)
7427 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
7428 $res = $row[
"question_text"];
7446 $result_array = array();
7450 if (is_numeric($user_id))
7452 $query = sprintf(
"SELECT tst_active.active_id, tst_active.tries, usr_id, '' AS login, %s AS lastname, '' AS firstname, tst_invited_user.clientip, " .
7453 "tst_active.submitted as test_finished, matriculation, IF(tst_active.active_id IS NULL,0,1) as test_started " .
7454 "FROM usr_data, tst_invited_user " .
7455 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7456 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
7458 $ilDB->quote($this->lng->txt(
"unknown")),
7459 $ilDB->quote($this->test_id),
7466 $query = sprintf(
"SELECT tst_active.active_id, usr_id, '' AS login, %s AS lastname, '' AS firstname, tst_invited_user.clientip, " .
7467 "tst_active.submitted as test_finished, matriculation, IF(tst_active.active_id IS NULL,0,1) as test_started " .
7468 "FROM usr_data, tst_invited_user " .
7469 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7470 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
7472 $ilDB->quote($this->lng->txt(
"unknown")),
7473 $ilDB->quote($this->test_id),
7480 if (is_numeric($user_id))
7482 $query = sprintf(
"SELECT tst_active.active_id, tst_active.tries, usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
7483 "tst_active.submitted as test_finished, matriculation, IF(tst_active.active_id IS NULL,0,1) as test_started " .
7484 "FROM usr_data, tst_invited_user " .
7485 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7486 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
7488 $ilDB->quote($this->test_id),
7495 $query = sprintf(
"SELECT tst_active.active_id, tst_active.tries, usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
7496 "tst_active.submitted as test_finished, matriculation, IF(tst_active.active_id IS NULL,0,1) as test_started " .
7497 "FROM usr_data, tst_invited_user " .
7498 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7499 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
7501 $ilDB->quote($this->test_id),
7523 $q = sprintf(
"SELECT tst_active.active_id, tst_active.tries, tst_active.user_fi AS usr_id, '' AS login, %s AS lastname, '' AS firstname, tst_active.submitted as test_finished, usr_data.matriculation, usr_data.active, IF(tst_active.active_id IS NULL,0,1) as test_started ".
7524 "FROM tst_active LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id WHERE tst_active.test_fi = %s ORDER BY usr_data.lastname " . strtoupper($name_sort_order),
7525 $ilDB->quote($this->lng->txt(
"unknown")),
7526 $ilDB->quote($this->getTestId())
7531 $q = sprintf(
"SELECT tst_active.active_id, tst_active.tries, tst_active.user_fi AS usr_id, usr_data.login, usr_data.lastname, usr_data.firstname, tst_active.submitted as test_finished, usr_data.matriculation, usr_data.active, IF(tst_active.active_id IS NULL,0,1) as test_started ".
7532 "FROM tst_active LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id WHERE tst_active.test_fi = %s ORDER BY usr_data.lastname " . strtoupper($name_sort_order),
7533 $ilDB->quote($this->getTestId())
7537 foreach (
$data as $index => $participant)
7539 if (strlen(trim($participant->firstname.$participant->lastname)) == 0)
7541 $data[$index]->lastname = $this->lng->txt(
"deleted_user");
7558 if (!is_array($ids) || count($ids) ==0)
7561 $result_array = array();
7565 $query = sprintf(
"SELECT usr_id, '' AS login, %s AS lastname, '' AS firstname, client_ip as clientip FROM usr_data WHERE usr_id IN ('%s') ORDER BY login",
7566 $ilDB->quote($this->lng->txt(
"unknown")),
7572 $query = sprintf(
"SELECT usr_id, login, lastname, firstname, client_ip as clientip FROM usr_data WHERE usr_id IN ('%s') ORDER BY login",
7598 $result = $ilDB->query($query);
7599 while ($row =
$result->fetchRow(MDB2_FETCHMODE_OBJECT))
7601 $result_array[$row->$id_field]= $row;
7603 return ($result_array)?$result_array:array();
7608 if (!is_array($ids) || count($ids) ==0)
7611 $result_array = array();
7613 $query = sprintf(
"SELECT ref_id, title, description FROM `grp_settings` g, object_data o, object_reference r WHERE o.obj_id=g.obj_id AND o.obj_id = r.obj_id AND ref_id IN ('%s')",
7622 if (!is_array($ids) || count($ids) ==0)
7625 $result_array = array();
7627 $query = sprintf(
"SELECT obj_id, description, title FROM role_data, object_data o WHERE o.obj_id=role_id AND role_id IN ('%s')",
7645 include_once
"./Modules/Group/classes/class.ilObjGroup.php";
7647 $members = $group->getGroupMemberIds();
7648 include_once
'./Services/User/classes/class.ilObjUser.php';
7649 foreach ($members as $user_id)
7666 $members = $rbacreview->assignedUsers($role_id,
"usr_id");
7667 include_once
'./Services/User/classes/class.ilObjUser.php';
7668 foreach ($members as $user_id)
7688 $query = sprintf(
"DELETE FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
7689 $ilDB->quote($this->test_id),
7690 $ilDB->quote($user_id)
7692 $result = $ilDB->query($query);
7707 $query = sprintf(
"INSERT IGNORE INTO tst_invited_user (test_fi, user_fi, clientip) VALUES (%s, %s, %s)",
7708 $ilDB->quote($this->test_id),
7709 $ilDB->quote($user_id),
7710 $ilDB->quote($client_ip)
7712 $result = $ilDB->query($query);
7720 $query = sprintf(
"UPDATE tst_invited_user SET clientip=%s WHERE test_fi=%s and user_fi=%s",
7721 $ilDB->quote($client_ip),
7722 $ilDB->quote($this->test_id),
7723 $ilDB->quote($user_id)
7725 $insertresult = $ilDB->query($query);
7736 if (is_numeric($question_fi))
7737 $query = sprintf(
"SELECT question_fi, solved FROM tst_active_qst_sol_settings " .
7738 "WHERE active_fi = %s AND question_fi=%s",
7739 $ilDB->quote($active_id),
7742 else $query = sprintf(
"SELECT question_fi, solved FROM tst_active_qst_sol_settings " .
7743 "WHERE active_fi = %s",
7744 $ilDB->quote($active_id)
7758 $query = sprintf(
"REPLACE INTO tst_active_qst_sol_settings SET solved=%s, question_fi=%s, active_fi = %s",
7759 $ilDB->quote($value),
7760 $ilDB->quote($question_id),
7761 $ilDB->quote($active_id)
7764 $ilDB->query($query);
7775 $query = sprintf(
"UPDATE tst_active SET submitted = 1, submittimestamp = NOW() WHERE test_fi = %s AND user_fi = %s",
7776 $ilDB->quote($this->getTestId() .
""),
7777 $ilDB->quote($user_id .
"")
7779 $result = $ilDB->query($query);
7780 $this->testSession = NULL;
7791 if (!is_numeric($user_id))
7792 $user_id = $ilUser->getId();
7794 $query = sprintf(
"SELECT submitted FROM tst_active WHERE test_fi=%s AND user_fi=%s AND submitted=1",
7795 $ilDB->quote($this->test_id),
7796 $ilDB->quote($user_id)
7798 $result = $ilDB->query($query);
7800 return $result->numRows() == 1;
7834 "user_id" => $this->lng->txt(
"user_id"),
7835 "matriculation" => $this->lng->txt(
"matriculation"),
7836 "lastname" => $this->lng->txt(
"lastname"),
7837 "firstname" => $this->lng->txt(
"firstname"),
7838 "login" =>$this->lng->txt(
"login"),
7839 "reached_points" => $this->lng->txt(
"tst_reached_points"),
7840 "max_points" => $this->lng->txt(
"tst_maximum_points"),
7841 "percent_value" => $this->lng->txt(
"tst_percent_solved"),
7842 "mark" => $this->lng->txt(
"tst_mark"),
7843 "ects" => $this->lng->txt(
"ects_grade")
7846 #print_r($participants);
7847 if (count($participants))
7849 if ($this->ects_output)
7853 foreach ($participants as $active_id => $user_rec)
7856 $reached_points = 0;
7858 foreach ($this->questions as $value)
7861 if (is_object($question))
7863 $max_points += $question->getMaximumPoints();
7864 $reached_points += $question->getReachedPoints($active_id);
7867 if ($max_points > 0)
7869 $percentvalue = $reached_points / $max_points;
7870 if ($percentvalue < 0) $percentvalue = 0.0;
7876 $mark_obj = $this->mark_schema->getMatchingMark($percentvalue * 100);
7880 $mark = $mark_obj->getOfficialName();
7881 $ects_mark = $this->
getECTSGrade($passed_array, $reached_points, $max_points);
7885 $user_rec->firstname =
"";
7886 $user_rec->lastname = $this->lng->txt(
"unknown");
7889 "user_id"=>$user_rec->usr_id,
7890 "matriculation" => $user_rec->matriculation,
7891 "lastname" => $user_rec->lastname,
7892 "firstname" => $user_rec->firstname,
7893 "login"=>$user_rec->login,
7894 "reached_points" => $reached_points,
7895 "max_points" => $max_points,
7896 "percent_value" => $percentvalue,
7898 "ects" => $ects_mark
7900 $results[] = $prepareForCSV ? $this->
processCSVRow ($row,
true) : $row;
7920 $resultarray = array();
7921 foreach ($row as $rowindex => $entry)
7928 if (strpos($entry,
"\"") !== FALSE)
7930 $entry = str_replace(
"\"",
"\"\"", $entry);
7938 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
7941 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
7945 $resultarray[$rowindex] = utf8_decode($entry);
7948 return $resultarray;
7964 $query = sprintf(
"SELECT tries FROM tst_active WHERE active_id = %s",
7965 $ilDB->quote($active_id .
"")
7967 $result = $ilDB->query($query);
7968 if ($result->numRows())
7970 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
7971 return $row[
"tries"];
7993 $query = sprintf(
"SELECT MAX(pass) as maxpass FROM tst_test_result WHERE active_fi = %s",
7994 $ilDB->quote($active_id .
"")
7996 $result = $ilDB->query($query);
7997 if ($result->numRows())
7999 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
8000 $max = $row[
"maxpass"];
8023 $query = sprintf(
"SELECT * FROM tst_test_pass_result WHERE active_fi = %s",
8024 $ilDB->quote($active_id .
"")
8026 $result = $ilDB->query($query);
8027 if ($result->numRows())
8031 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
8033 if ($row[
"points"] > $bestpoints)
8036 $bestpoints = $row[
"points"];
8039 if (is_array($bestrow))
8041 return $bestrow[
"pass"];
8066 $counted_pass = NULL;
8075 return $counted_pass;
8095 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
8097 foreach ($this->questions as $value)
8101 $workedthrough += 1;
8104 return $workedthrough;
8122 $query = sprintf(
"SELECT tst_test_result.TIMESTAMP + 0 AS timestamp14 FROM tst_test_result WHERE active_fi = %s AND pass = %s ORDER BY tst_test_result.TIMESTAMP DESC",
8123 $ilDB->quote($active_id .
""),
8124 $ilDB->quote(
$pass .
"")
8126 $result = $ilDB->query($query);
8127 if ($result->numRows())
8129 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
8130 return $row[
"timestamp14"];
8150 "executable" =>
true,
8151 "errormessage" =>
""
8155 $result[
"executable"] =
false;
8161 $result[
"executable"] =
false;
8190 $result[
"executable"] =
false;
8191 $result[
"errormessage"] = $this->lng->txt(
"detail_max_processing_time_reached");
8201 $result[
"executable"] =
false;
8202 $result[
"errormessage"] = $this->lng->txt(
"maximum_nr_of_tries_reached");
8208 $result[
"executable"] = FALSE;
8209 $result[
"errormessage"] = $this->lng->txt(
"maximum_nr_of_tries_reached");
8231 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getReportingDate(), $matches))
8233 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
8235 if ($now < $epoch_time)
8252 $notimeleft = FALSE;
8276 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getReportingDate(), $matches))
8278 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
8280 if ($now < $epoch_time)
8307 if ($active_id < 1)
return FALSE;
8309 $query = sprintf(
"SELECT tst_times.started FROM tst_times WHERE tst_times.active_fi = %s AND tst_times.pass = %s ORDER BY tst_times.started",
8310 $ilDB->quote($active_id .
""),
8311 $ilDB->quote(
$pass .
"")
8313 $result = $ilDB->query($query);
8314 if ($result->numRows())
8316 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
8317 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row[
"started"], $matches))
8319 return mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
8366 $query = sprintf(
"SELECT qpl_questions.*, qpl_question_type.type_tag FROM qpl_questions, qpl_question_type, tst_test_question WHERE qpl_questions.question_type_fi = qpl_question_type.question_type_id AND tst_test_question.test_fi = %s AND tst_test_question.question_fi = qpl_questions.question_id ORDER BY sequence",
8367 $ilDB->quote($this->getTestId() .
"")
8369 $query_result = $ilDB->query($query);
8370 $removableQuestions = array();
8371 while ($row = $query_result->fetchRow(MDB2_FETCHMODE_ASSOC))
8373 array_push($removableQuestions, $row);
8375 return $removableQuestions;
8403 $this->shuffle_questions = TRUE;
8407 $this->shuffle_questions = FALSE;
8446 $this->show_summary = $a_value;
8459 if (($this->show_summary & 1) > 0)
8481 $this->show_summary = 1;
8485 $this->show_summary = 0;
8499 if (($this->show_summary & 2) > 0)
8521 $this->show_summary = $this->show_summary | 2;
8527 $this->show_summary = $this->show_summary ^ 2;
8542 if (($this->show_summary & 4) > 0)
8564 $this->show_summary = $this->show_summary | 4;
8570 $this->show_summary = $this->show_summary ^ 4;
8585 if (($this->show_summary & 8) > 0)
8607 $this->show_summary = $this->show_summary | 8;
8613 $this->show_summary = $this->show_summary ^ 8;
8641 if (($this->results_presentation & 1) > 0)
8661 if (($this->results_presentation & 2) > 0)
8681 if (($this->results_presentation & 4) > 0)
8701 if (($this->results_presentation & 8) > 0)
8721 if (($this->results_presentation & 16) > 0)
8741 if (($this->results_presentation & 32) > 0)
8761 $this->results_presentation = $a_results_presentation;
8776 $this->results_presentation = $this->results_presentation | 1;
8782 $this->results_presentation = $this->results_presentation ^ 1;
8799 $this->results_presentation = $this->results_presentation | 2;
8805 $this->results_presentation = $this->results_presentation ^ 2;
8835 $this->results_presentation = $this->results_presentation | 4;
8841 $this->results_presentation = $this->results_presentation ^ 4;
8858 $this->results_presentation = $this->results_presentation | 8;
8864 $this->results_presentation = $this->results_presentation ^ 8;
8881 $this->results_presentation = $this->results_presentation | 16;
8887 $this->results_presentation = $this->results_presentation ^ 16;
8904 $this->results_presentation = $this->results_presentation | 32;
8910 $this->results_presentation = $this->results_presentation ^ 32;
8923 $codestring =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
8926 for ($i = 1; $i <=5; $i++)
8928 $index = mt_rand(0, strlen($codestring)-1);
8929 $code .= substr($codestring, $index, 1);
8943 $query = sprintf(
"SELECT anonymous_id FROM tst_active WHERE test_fi = %s AND anonymous_id = %s",
8944 $ilDB->quote($this->getTestId() .
""),
8945 $ilDB->quote($code .
"")
8947 $result = $ilDB->query($query);
8948 if ($result->numRows() > 0)
8961 $query = sprintf(
"SELECT user_fi FROM tst_active WHERE active_id = %s",
8962 $ilDB->quote($active_id .
"")
8964 $result = $ilDB->query($query);
8965 if ($result->numRows())
8967 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
8968 return $row[
"user_fi"];
8979 if (!is_array(
$_SESSION[
"tst_access_code"]))
8985 return $_SESSION[
"tst_access_code"][
"$id"];
8992 if (!is_array(
$_SESSION[
"tst_access_code"]))
8996 $_SESSION[
"tst_access_code"][
"$id"] = $access_code;
9002 unset(
$_SESSION[
"tst_access_code"][
"$id"]);
9012 $this->allowedUsers = $a_allowed_users;
9022 $this->allowedUsersTimeGap = $a_allowed_users_time_gap;
9031 if (($nr_of_users > 0) && ($time_gap > 0))
9034 $time_border = $now - $time_gap;
9035 $str_time_border = strftime(
"%Y%m%d%H%M%S", $time_border);
9036 $query = sprintf(
"SELECT DISTINCT tst_times.active_fi FROM tst_times, tst_active WHERE tst_times.TIMESTAMP > %s AND tst_times.active_fi = tst_active.active_id AND tst_active.test_fi = %s",
9037 $ilDB->quote($str_time_border),
9040 $result = $ilDB->query($query);
9041 if ($result->numRows() >= $nr_of_users)
9043 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
9062 $query = sprintf(
"SELECT finished FROM tst_times WHERE active_fi = %s ORDER BY finished DESC",
9063 $ilDB->quote($active_id .
"")
9065 $result = $ilDB->query($query);
9066 if ($result->numRows())
9068 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
9069 return $row[
"finished"];
9083 if (preg_match(
"/<[^>]*?>/", $a_text))
9103 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
9105 $material = $a_material->getMaterial($i);
9106 if (strcmp($material[
"type"],
"mattext") == 0)
9108 $result .= $material[
"material"]->getContent();
9110 if (strcmp($material[
"type"],
"matimage") == 0)
9112 $matimage = $material[
"material"];
9113 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
9116 if (!is_array(
$_SESSION[
"import_mob_xhtml"]))
$_SESSION[
"import_mob_xhtml"] = array();
9117 array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(),
"uri" => $matimage->getUri()));
9122 $ilLog->write(print_r(
$_SESSION[
"import_mob_xhtml"],
true));
9136 include_once
"./Services/RTE/classes/class.ilRTE.php";
9137 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
9139 $a_xml_writer->xmlStartTag(
"material");
9141 "texttype" =>
"text/plain"
9143 if ($this->
isHTML($a_material))
9145 $attrs[
"texttype"] =
"text/xhtml";
9150 foreach (
$mobs as $mob)
9152 $moblabel =
"il_" . IL_INST_ID .
"_mob_" . $mob;
9153 if (strpos($a_material,
"mm_$mob") !== FALSE)
9159 "label" => $moblabel,
9160 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
9163 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
9166 $a_xml_writer->xmlEndTag(
"material");
9177 include_once
"./Services/Utilities/classes/class.ilUtil.php";
9193 $query = sprintf(
"UPDATE tst_tests SET certificate_visibility = %s WHERE test_id = %s",
9194 $ilDB->quote($a_value),
9197 $result = $ilDB->query($query);
9223 $this->certificate_visibility = $a_value;
9252 $this->anonymity = 1;
9255 $this->anonymity = 0;
9286 $this->show_cancel = 1;
9289 $this->show_cancel = 0;
9320 $this->show_marker = 1;
9323 $this->show_marker = 0;
9354 $this->fixed_participants = 1;
9357 $this->fixed_participants = 0;
9375 $query =
"SELECT anonymity FROM tst_tests ".
9376 "WHERE obj_fi = '".$a_obj_id.
"'";
9377 $res = $ilDB->query($query);
9378 while($row =
$res->fetchRow(MDB2_FETCHMODE_ASSOC))
9380 return $row[
'anonymity'];
9398 $query = sprintf(
"SELECT tst_tests.random_test FROM tst_tests, tst_active WHERE tst_active.active_id = %s AND tst_active.test_fi = tst_tests.test_id",
9399 $ilDB->quote($active_id .
"")
9401 $res = $ilDB->query($query);
9402 while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))
9404 return $row[
'random_test'];
9423 return $this->lng->txt(
"unknown") . $suffix;
9427 include_once
'./Services/User/classes/class.ilObjUser.php';
9429 if (strlen($uname[
"firstname"].$uname[
"lastname"]) == 0) $uname[
"firstname"] = $this->lng->txt(
"deleted_user");
9432 return trim($uname[
"lastname"] .
", " . $uname[
"firstname"]) . $suffix;
9436 return trim($uname[
"firstname"] .
" " . $uname[
"lastname"]) . $suffix;
9454 return $this->lng->txt(
"tst_start_test");
9456 $active_pass = $this->
_getPass($active_id);
9460 if ($active_pass == 0)
9462 return $this->lng->txt(
"tst_start_test");
9466 return $this->lng->txt(
"tst_start_new_test_pass");
9471 return $this->lng->txt(
"tst_resume_test");
9490 $query = sprintf(
"SELECT * FROM tst_test_defaults WHERE user_fi = %s ORDER BY $sortby $sortorder",
9491 $ilDB->quote($ilUser->getId() .
"")
9493 $result = $ilDB->query($query);
9494 $defaults = array();
9495 while ($row =
$result->fetchRow(MDB2_FETCHMODE_ASSOC))
9497 $defaults[$row[
"test_defaults_id"]] = $row;
9515 $query = sprintf(
"SELECT * FROM tst_test_defaults WHERE test_defaults_id = %s",
9516 $ilDB->quote($test_defaults_id .
"")
9518 $result = $ilDB->query($query);
9519 if ($result->numRows() == 1)
9521 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
9541 $query = sprintf(
"DELETE FROM tst_test_defaults WHERE test_defaults_id = %s",
9542 $ilDB->quote($test_default_id .
"")
9544 $result = $ilDB->query($query);
9559 $testsettings = array(
9595 $query = sprintf(
"INSERT INTO tst_test_defaults (test_defaults_id, name, user_fi, defaults, marks) VALUES (NULL, %s, %s, %s, %s)",
9596 $ilDB->quote($a_name .
""),
9597 $ilDB->quote($ilUser->getId().
""),
9598 $ilDB->quote(serialize($testsettings)),
9599 $ilDB->quote(serialize($this->mark_schema))
9601 $result = $ilDB->query($query);
9621 $testsettings = unserialize($defaults[
"defaults"]);
9622 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
9623 $this->mark_schema = unserialize($defaults[
"marks"]);
9648 $this->
setKiosk($testsettings[
"Kiosk"]);
9651 $this->
setECTSFX($testsettings[
"ECTSFX"]);
9675 if (extension_loaded(
"tidy"))
9679 "output-xml" =>
true,
9680 "numeric-entities" =>
true
9684 $tidy->cleanRepair();
9685 $print_output = tidy_get_output(
$tidy);
9686 $print_output = preg_replace(
"/^.*?(<html)/",
"\\1", $print_output);
9690 $print_output = str_replace(
" ",
" ", $print_output);
9691 $print_output = str_replace(
"⊗",
"X", $print_output);
9694 $xsl = file_get_contents(
"./Modules/Test/xml/question2fo.xsl");
9695 $args = array(
'/_xml' => $print_output,
'/_xsl' => $xsl );
9698 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, $params);
9712 include_once
"./Services/Utilities/classes/class.ilUtil.php";
9714 $fp = fopen($fo_file,
"w"); fwrite($fp, $fo); fclose($fp);
9715 include_once
"./Services/Transformation/classes/class.ilFO2PDF.php";
9717 $fo2pdf->setFOString($fo);
9738 $query = sprintf(
"SELECT feedback FROM tst_manual_feedback WHERE active_fi = %s AND question_fi = %s AND pass = %s",
9739 $ilDB->quote($active_id .
""),
9740 $ilDB->quote($question_id .
""),
9741 $ilDB->quote(
$pass .
"")
9743 $result = $ilDB->query($query);
9744 if ($result->numRows())
9746 $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
9747 include_once(
"./Services/RTE/classes/class.ilRTE.php");
9769 $query = sprintf(
"DELETE FROM tst_manual_feedback WHERE active_fi = %s AND question_fi = %s AND pass = %s",
9770 $ilDB->quote($active_id .
""),
9771 $ilDB->quote($question_id .
""),
9772 $ilDB->quote(
$pass .
"")
9774 $result = $ilDB->query($query);
9776 if (strlen($feedback))
9778 $query = sprintf(
"INSERT INTO tst_manual_feedback (active_fi, question_fi, pass, feedback) VALUES (%s, %s, %s, %s)",
9779 $ilDB->quote($active_id .
""),
9780 $ilDB->quote($question_id .
""),
9781 $ilDB->quote(
$pass .
""),
9784 $result = $ilDB->query($query);
9786 if (PEAR::isError($result))
9789 $ilias->raiseError($result->getMessage());
9807 if (strcmp(
$_GET[
"tst_javascript"],
"0") == 0)
return FALSE;
9809 $assessmentSetting =
new ilSetting(
"assessment");
9810 return ($ilUser->getPref(
"tst_javascript") === FALSE) ? $assessmentSetting->get(
"use_javascript") : $ilUser->getPref(
"tst_javascript");
9823 include_once
"./Modules/Test/classes/class.ilTestSession.php";
9843 if (is_object($this->testSession) && ($this->testSession->getActiveId() > 0))
return $this->testSession;
9847 include_once
"./Modules/Test/classes/class.ilTestSession.php";
9870 if (is_object($this->testSession) && ($this->testSession->getActiveId() > 0))
return $this->testSession;
9876 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
9878 if (!$this->testSequence->hasSequence())
9880 $this->testSequence->createNewSequence($this->
getQuestionCount(), $shuffle);
9881 $this->testSequence->saveToDb();
9887 if (is_object($this->testSequence) && ($this->testSequence->getActiveId() > 0))
return $this->testSequence;
9889 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
9890 if (($active_id > 0) && (strlen(
$pass)))
9906 foreach (
$result as $sequence => $question)
9908 if (is_numeric($sequence))
9910 if ($question[
"reached"] == $question[
"max"])
9931 if (count($participants))
9933 foreach ($participants as $active_id => $user_rec)
9936 $reached_points = 0;
9938 foreach ($this->questions as $value)
9941 if (is_object($question))
9943 $max_points += $question->getMaximumPoints();
9944 $reached_points += $question->getReachedPoints($active_id);
9945 if ($max_points > 0)
9947 $percentvalue = $reached_points / $max_points;
9948 if ($percentvalue < 0) $percentvalue = 0.0;
9956 $user_rec->firstname =
"";
9957 $user_rec->lastname = $this->lng->txt(
"unknown");
9960 "user_id"=>$user_rec->usr_id,
9961 "matriculation" => $user_rec->matriculation,
9962 "lastname" => $user_rec->lastname,
9963 "firstname" => $user_rec->firstname,
9964 "login"=>$user_rec->login,
9965 "question_id" => $question->getId(),
9966 "question_title" => $question->getTitle(),
9967 "reached_points" => $reached_points,
9968 "max_points" => $max_points
9985 $set = $ilDB->query(
"SELECT t.obj_fi AS obj_id FROM tst_test_question AS q, tst_tests AS t WHERE".
9986 " q.test_fi = t.test_id AND q.question_fi = ".$ilDB->quote($a_q_id));
9988 return $rec[
"obj_id"];
9999 global $ilPluginAdmin;
10000 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE,
"TestQuestionPool",
"qst", $a_pname))
10017 $assessmentSetting =
new ilSetting(
"assessment");
10018 $assessmentSetting->set(
"evalFields_" . $this->
getId(), serialize($fields));
10028 $assessmentSetting =
new ilSetting(
"assessment");
10029 $found = $assessmentSetting->get(
"evalFields_" . $this->
getId());
10031 if (strlen($found)) $fields = unserialize($found);
10032 if (is_array($fields))
return $fields;
else return array();
10047 $result_array =& $this->
getTestResult($active_id, $counted_pass);
10049 include_once
"./Modules/Test/classes/class.ilTestCertificate.php";
10051 if ($cert->isComplete())
10061 if ($result_array[
"test"][
"passed"] == 1)
10098 $query = sprintf(
"SELECT tst_test_result.active_fi, tst_test_result.question_fi, tst_test_result.pass FROM tst_test_result, tst_active, qpl_questions WHERE tst_active.active_id = tst_test_result.active_fi AND tst_active.test_fi = %s AND tst_test_result.question_fi = qpl_questions.question_id AND qpl_questions.original_id = %s",
10100 $ilDB->quote($question_id)
10102 $result = $ilDB->query($query);
10103 $foundusers = array();
10106 if (!array_key_exists($row[
"active_fi"], $foundusers))
10108 $foundusers[$row[
"active_fi"]] = array();
10110 array_push($foundusers[$row[
"active_fi"]], array(
"pass" => $row[
"pass"],
"qid" => $row[
"question_fi"]));
10112 return $foundusers;
10123 if ((strlen($ilias->getSetting(
"rpc_server_host"))) && (strlen($ilias->getSetting(
"rpc_server_port"))))
10141 $foundParticipants =&
$data->getParticipants();
10142 $results = array(
"overview" => array(),
"questions" => array());
10143 if (count($foundParticipants))
10145 $results[
"overview"][$this->lng->txt(
"tst_eval_total_persons")] = count($foundParticipants);
10147 $results[
"overview"][$this->lng->txt(
"tst_eval_total_finished")] = $total_finished;
10149 $diff_seconds = $average_time;
10150 $diff_hours = floor($diff_seconds/3600);
10151 $diff_seconds -= $diff_hours * 3600;
10152 $diff_minutes = floor($diff_seconds/60);
10153 $diff_seconds -= $diff_minutes * 60;
10154 $results[
"overview"][$this->lng->txt(
"tst_eval_total_finished_average_time")] = sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
10156 $total_passed_reached = 0;
10157 $total_passed_max = 0;
10158 $total_passed_time = 0;
10159 foreach ($foundParticipants as $userdata)
10161 if ($userdata->getPassed())
10164 $total_passed_reached += $userdata->getReached();
10165 $total_passed_max += $userdata->getMaxpoints();
10166 $total_passed_time += $userdata->getTimeOfWork();
10169 $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
10170 $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
10171 $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
10172 $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed")] = $total_passed;
10173 $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed_average_points")] = sprintf(
"%2.2f", $average_passed_reached) .
" " . strtolower($this->lng->txt(
"of")) .
" " . sprintf(
"%2.2f", $average_passed_max);
10174 $average_time = $average_passed_time;
10175 $diff_seconds = $average_time;
10176 $diff_hours = floor($diff_seconds/3600);
10177 $diff_seconds -= $diff_hours * 3600;
10178 $diff_minutes = floor($diff_seconds/60);
10179 $diff_seconds -= $diff_minutes * 60;
10180 $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed_average_time")] = sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
10183 foreach (
$data->getQuestionTitles() as $question_id => $question_title)
10188 foreach ($foundParticipants as $userdata)
10190 for ($i = 0; $i <= $userdata->getLastPass(); $i++)
10192 if (is_object($userdata->getPass($i)))
10194 $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
10195 if (is_array($question))
10198 $reached += $question[
"reached"];
10199 $max += $question[
"points"];
10204 $percent = $max ? $reached/$max * 100.0 : 0;
10206 $results[
"questions"][$question_id] = array(
10208 sprintf(
"%.2f", $answered ? $reached / $answered : 0) .
" " . strtolower($this->lng->txt(
"of")) .
" " . sprintf(
"%.2f", $answered ? $max / $answered : 0),
10209 sprintf(
"%.2f", $percent) .
"%",
10211 sprintf(
"%.2f", $answered ? $reached / $answered : 0),
10212 sprintf(
"%.2f", $answered ? $max / $answered : 0),