5 include_once
"./classes/class.ilObject.php";
6 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
436 function ilObjTest($a_id = 0,$a_call_by_reference =
true)
440 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
443 $this->author = $ilUser->fullname;
444 $this->introduction =
"";
445 $this->questions = array();
448 $this->instant_verification = 0;
449 $this->answer_feedback_points = 0;
450 $this->reporting_date =
"";
451 $this->nr_of_tries = 0;
453 $this->use_previous_answers = 1;
454 $this->title_output = 0;
455 $this->starting_time =
"";
456 $this->ending_time =
"";
457 $this->processing_time =
"00:00:00";
458 $this->enable_processing_time =
"0";
459 $this->reset_processing_time = 0;
460 $this->ects_output = 0;
461 $this->ects_fx = NULL;
462 $this->random_test = 0;
463 $this->shuffle_questions = TRUE;
464 $this->mailnottype = 0;
465 $this->exportsettings = 0;
466 $this->show_summary = 8;
467 $this->random_question_count =
"";
472 $this->answer_feedback = 0;
473 $this->password =
"";
474 $this->certificate_visibility = 0;
475 $this->allowedUsers =
"";
476 $this->_showfinalstatement = FALSE;
477 $this->_finalstatement =
"";
478 $this->_redirect_after_exam =
"";
479 $this->_redirect_only_kiosk_mode = TRUE;
480 $this->_exam_pdf = TRUE;
481 $this->_showinfo = TRUE;
482 $this->_forcejs = FALSE;
483 $this->_customStyle =
"";
484 $this->allowedUsersTimeGap =
"";
485 $this->anonymity = 0;
486 $this->show_cancel = 1;
488 $this->show_marker = 0;
489 $this->show_serial =
false;
490 $this->fixed_participants = 0;
495 $this->testSession = FALSE;
496 $this->testSequence = FALSE;
497 $this->mailnotification = 0;
499 $lng->loadLanguageModule(
"assessment");
500 $this->mark_schema->createSimpleSchema($lng->txt(
"failed_short"), $lng->txt(
"failed_official"), 0, 0, $lng->txt(
"passed_short"), $lng->txt(
"passed_official"), 50, 1);
501 $this->ects_grades = array(
508 $this->
ilObject($a_id, $a_call_by_reference);
534 if (!parent::update())
561 function read($a_force_db =
false)
577 if (!parent::delete())
604 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s",
608 $active_array = array();
609 while (
$row = $ilDB->fetchAssoc($result))
611 array_push($active_array,
$row[
"active_id"]);
614 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
619 if (count($active_array))
621 foreach ($active_array as $active_id)
623 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_times WHERE active_fi = %s",
628 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
635 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_mark WHERE test_fi = %s",
640 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s",
644 while (
$row = $ilDB->fetchAssoc($result))
649 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_tests WHERE test_id = %s",
654 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
669 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
681 include_once
"./Services/Utilities/classes/class.ilUtil.php";
683 $directory = $tst_data_dir.
"/tst_".$this->
getId();
684 if (is_dir($directory))
686 include_once
"./Services/Utilities/classes/class.ilUtil.php";
689 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
695 foreach(
$mobs as $mob)
734 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
774 if ($a_node_id==
$_GET[
"ref_id"])
776 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
777 $parent_type = $parent_obj->getType();
778 if ($parent_type == $this->
getType())
780 $a_node_id = (int) $tree->getParentId($a_node_id);
784 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
794 include_once
"./Services/Utilities/classes/class.ilUtil.php";
797 if (!is_writable($tst_data_dir))
799 $this->ilias->raiseError(
"Test Data Directory (".$tst_data_dir
800 .
") not writeable.",$this->ilias->error_obj->MESSAGE);
804 $tst_dir = $tst_data_dir.
"/tst_".$this->
getId();
806 if (!@is_dir($tst_dir))
808 $this->ilias->raiseError(
"Creation of Test Directory failed.",$this->ilias->error_obj->MESSAGE);
811 $export_dir = $tst_dir.
"/export";
813 if (!@is_dir($export_dir))
815 $this->ilias->raiseError(
"Creation of Export Directory failed.",$this->ilias->error_obj->MESSAGE);
826 include_once
"./Services/Utilities/classes/class.ilUtil.php";
840 if (!@is_dir(
$dir) or
853 while ($entry =
$dir->read())
855 if ($entry !=
"." and
858 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(test(__results)?(__PDF-Export)?__)*[0-9]+\.[a-z]{1,4}\$", $entry))
884 include_once
"./Services/Utilities/classes/class.ilUtil.php";
888 if (!is_writable($tst_data_dir))
890 $ilias->raiseError(
"Test data directory (".$tst_data_dir
891 .
") not writeable.",$ilias->error_obj->FATAL);
895 $tst_dir = $tst_data_dir.
"/tst_import";
897 if (!@is_dir($tst_dir))
899 $ilias->raiseError(
"Creation of test import directory failed.",$ilias->error_obj->FATAL);
909 if (strlen($a_import_dir))
911 $_SESSION[
"tst_import_dir"] = $a_import_dir;
941 include_once
"./Services/Utilities/classes/class.ilUtil.php";
945 if (!is_writable($tst_data_dir))
947 $this->ilias->raiseError(
"Test Data Directory (".$tst_data_dir
948 .
") not writeable.",$this->ilias->error_obj->FATAL);
952 $tst_dir = $tst_data_dir.
"/tst_import";
954 if (!@is_dir($tst_dir))
956 $ilias->raiseError(
"Creation of test import directory failed.",
$ilias->error_obj->FATAL);
968 if(strlen($this->import_dir))
973 include_once
"./Services/Utilities/classes/class.ilUtil.php";
992 $this->import_dir = $a_import_dir;
1006 $result = $ilDB->queryF(
"SELECT DISTINCT(qpl_qst_type.type_tag) foundtypes FROM qpl_questions, tst_test_result, qpl_qst_type, tst_active WHERE tst_test_result.question_fi = qpl_questions.question_id AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND tst_test_result.active_fi = tst_active.active_id AND tst_active.test_fi = %s",
1011 while (
$row = $ilDB->fetchAssoc($result))
1013 if (strcmp(
$row[
'foundtypes'],
'assSingleChoice') == 0)
1031 $result = $ilDB->queryF(
"SELECT DISTINCT(qpl_qst_type.type_tag) foundtypes FROM qpl_questions, tst_test_result, qpl_qst_type, tst_active WHERE tst_test_result.question_fi = qpl_questions.question_id AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND tst_test_result.active_fi = tst_active.active_id AND tst_active.test_fi = %s",
1035 if ($result->numRows() == 1)
1037 $row = $ilDB->fetchAssoc($result);
1038 if (strcmp(
$row[
'foundtypes'],
'assSingleChoice') == 0)
1062 $result = $ilDB->queryF(
"SELECT DISTINCT(qpl_qst_sc.shuffle) foundshuffles FROM qpl_questions, qpl_qst_sc, tst_test_result, qpl_qst_type, tst_active WHERE tst_test_result.question_fi = qpl_questions.question_id AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND tst_test_result.active_fi = tst_active.active_id AND qpl_questions.question_id = qpl_qst_sc.question_fi AND tst_active.test_fi = %s AND qpl_qst_type.type_tag = %s",
1063 array(
'integer',
'text'),
1064 array($this->
getTestId(),
'assSingleChoice')
1066 if ($result->numRows() == 1)
1068 $row = $ilDB->fetchAssoc($result);
1069 return (
$row[
'foundshuffles'] == 0);
1082 if ((count($this->mark_schema->mark_steps)) and (count($this->questions)))
1096 foreach ($arr as $array)
1098 $count += $array[
"count"];
1119 $test->loadFromDb();
1120 return $test->isComplete();
1131 if ($this->test_id > 0)
1133 $fx_support = preg_replace(
"/,/",
".", $fx_support);
1134 if (preg_match(
"/\d+/", $fx_support))
1136 $fx_support = $fx_support;
1142 $affectedRows = $ilDB->manipulateF(
"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",
1143 array(
'text',
'float',
'float',
'float',
'float',
'float',
'float',
'integer'),
1147 $this->ects_fx = $fx_support;
1165 if ($this->test_id > 0)
1167 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET complete = %s WHERE test_id = %s",
1168 array(
'text',
'integer'),
1169 array($complete, $this->test_id)
1194 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1195 $completecontent =
"";
1198 $completecontent .= $content;
1216 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1217 if ($this->test_id == -1)
1220 $next_id = $ilDB->nextId(
'tst_tests');
1221 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_tests (test_id, obj_fi, author, introduction, " .
1222 "finalstatement, redirect_after_exam, redirect_only_kiosk_mode, exam_pdf, showinfo, forcejs, customstyle, showfinalstatement, sequence_settings, " .
1223 "score_reporting, instant_verification, answer_feedback_points, answer_feedback, anonymity, show_cancel, autosave, show_marker, show_serial, " .
1224 "fixed_participants, nr_of_tries, kiosk, use_previous_answers, title_output, processing_time, enable_processing_time, " .
1225 "reset_processing_time, reporting_date, starting_time, ending_time, complete, ects_output, ects_a, ects_b, ects_c, ects_d, " .
1226 "ects_e, ects_fx, random_test, random_question_count, count_system, mc_scoring, score_cutting, pass_scoring, " .
1227 "shuffle_questions, results_presentation, show_summary, password, allowedusers, mailnottype, exportsettings, " .
1228 "alloweduserstimegap, certificate_visibility, mailnotification, created, tstamp) " .
1229 "VALUES (%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, %s, %s, %s, %s, " .
1230 "%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, %s, %s, %s, %s, %s)",
1232 'integer',
'integer',
'text',
'text',
1233 'text',
'text',
'integer',
'integer',
'integer',
'integer',
'text',
'integer',
'integer',
1234 'integer',
'text',
'text',
'text',
'text',
'text',
'text',
'integer',
'text',
1235 'text',
'integer',
'integer',
'text',
'text',
'text',
'text',
1236 'integer',
'text',
'text',
'text',
'text',
'text',
'float',
'float',
'float',
'float',
1237 'float',
'float',
'text',
'integer',
'text',
'text',
'text',
'text',
1238 'text',
'integer',
'integer',
'text',
'integer',
'integer',
'integer',
1239 'integer',
'text',
'integer',
'integer',
'integer'
1277 strlen($this->ects_grades[
"A"]) ? $this->ects_grades[
"A"] : NULL,
1278 strlen($this->ects_grades[
"B"]) ? $this->ects_grades[
"B"] : NULL,
1279 strlen($this->ects_grades[
"C"]) ? $this->ects_grades[
"C"] : NULL,
1280 strlen($this->ects_grades[
"D"]) ? $this->ects_grades[
"D"] : NULL,
1281 strlen($this->ects_grades[
"E"]) ? $this->ects_grades[
"E"] : NULL,
1303 $this->test_id = $next_id;
1316 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
1318 array($this->test_id)
1320 if ($result->numRows() == 1)
1322 $oldrow = $ilDB->fetchAssoc($result);
1328 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET author = %s, introduction = %s, " .
1329 "finalstatement = %s, redirect_after_exam = %s, redirect_only_kiosk_mode = %s, exam_pdf = %s, showinfo = %s, forcejs = %s, customstyle = %s, showfinalstatement = %s, sequence_settings = %s, " .
1330 "score_reporting = %s, instant_verification = %s, answer_feedback_points = %s, answer_feedback = %s, anonymity = %s, show_cancel = %s, autosave = %s, show_marker = %s, show_serial = %s, " .
1331 "fixed_participants = %s, nr_of_tries = %s, kiosk = %s, use_previous_answers = %s, title_output = %s, processing_time = %s, enable_processing_time = %s, " .
1332 "reset_processing_time = %s, reporting_date = %s, starting_time = %s, ending_time = %s, complete = %s, ects_output = %s, ects_a = %s, ects_b = %s, ects_c = %s, ects_d = %s, " .
1333 "ects_e = %s, ects_fx = %s, random_test = %s, random_question_count = %s, count_system = %s, mc_scoring = %s, score_cutting = %s, pass_scoring = %s, " .
1334 "shuffle_questions = %s, results_presentation = %s, show_summary = %s, password = %s, allowedusers = %s, mailnottype = %s, exportsettings = %s, " .
1335 "alloweduserstimegap = %s, certificate_visibility = %s, mailnotification = %s, tstamp = %s WHERE test_id = %s",
1338 'text',
'text',
'integer',
'integer',
'integer',
'integer',
'text',
'integer',
'integer',
1339 'integer',
'text',
'text',
'text',
'text',
'text',
'text',
'integer',
'text',
1340 'text',
'integer',
'integer',
'text',
'text',
'text',
'text',
1341 'integer',
'text',
'text',
'text',
'text',
'text',
'float',
'float',
'float',
'float',
1342 'float',
'float',
'text',
'integer',
'text',
'text',
'text',
'text',
1343 'text',
'integer',
'integer',
'text',
'integer',
'integer',
'integer',
1344 'integer',
'text',
'integer',
'integer',
'integer'
1380 strlen($this->ects_grades[
"A"]) ? $this->ects_grades[
"A"] : NULL,
1381 strlen($this->ects_grades[
"B"]) ? $this->ects_grades[
"B"] : NULL,
1382 strlen($this->ects_grades[
"C"]) ? $this->ects_grades[
"C"] : NULL,
1383 strlen($this->ects_grades[
"D"]) ? $this->ects_grades[
"D"] : NULL,
1384 strlen($this->ects_grades[
"E"]) ? $this->ects_grades[
"E"] : NULL,
1407 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1410 $logresult = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
1415 if ($logresult->numRows() == 1)
1417 $newrow = $ilDB->fetchAssoc($logresult);
1419 $changed_fields = array();
1420 foreach ($oldrow as $key => $value)
1422 if (strcmp($oldrow[$key], $newrow[$key]) != 0)
1424 array_push($changed_fields,
"$key: " . $oldrow[$key] .
" => " . $newrow[$key]);
1427 $changes = join($changed_fields,
", ");
1428 if (count($changed_fields) > 0)
1439 $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND tries >= %s AND submitted = %s",
1440 array(
'integer',
'integer',
'integer'),
1443 while (
$row = $ilDB->fetchAssoc($aresult))
1445 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
1446 array(
'integer',
'timestamp',
'integer'),
1447 array(1, date(
'Y-m-d H:i:s'),
$row[
"active_id"])
1452 $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND tries < %s AND submitted = %s",
1453 array(
'integer',
'integer',
'integer'),
1456 while (
$row = $ilDB->fetchAssoc($aresult))
1458 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
1459 array(
'integer',
'timestamp',
'integer'),
1460 array(0, NULL,
$row[
"active_id"])
1467 $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND submitted = %s",
1468 array(
'integer',
'integer'),
1471 while (
$row = $ilDB->fetchAssoc($aresult))
1473 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
1474 array(
'integer',
'timestamp',
'integer'),
1475 array(0, NULL,
$row[
"active_id"])
1485 if (!$properties_only)
1490 $ilias->raiseError($result->getMessage());
1498 $this->mark_schema->saveToDb($this->test_id);
1513 $oldquestions = array();
1514 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
1517 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence",
1521 if ($result->numRows() > 0)
1523 while (
$row = $ilDB->fetchAssoc($result))
1525 array_push($oldquestions,
$row[
"question_fi"]);
1531 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
1536 foreach ($this->questions as $key => $value)
1538 $next_id = $ilDB->nextId(
'tst_test_question');
1539 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
1540 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
1541 array($next_id, $this->
getTestId(), $value, $key, time())
1544 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1547 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence",
1551 $newquestions = array();
1552 if ($result->numRows() > 0)
1554 while (
$row = $ilDB->fetchAssoc($result))
1556 array_push($newquestions,
$row[
"question_fi"]);
1559 foreach ($oldquestions as $index => $question_id)
1561 if (strcmp($newquestions[$index], $question_id) != 0)
1563 $pos = array_search($question_id, $newquestions);
1574 foreach ($newquestions as $index => $question_id)
1576 if (array_search($question_id, $oldquestions) === FALSE)
1590 $result = $ilDB->queryF(
'SELECT copy_id FROM tst_rnd_cpy WHERE tst_fi = %s',
1594 return $result->numRows() > 0;
1609 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
1610 array(
'integer',
'integer'),
1611 array($active_id,
$pass)
1613 if ($result->numRows() < $maxcount)
1615 $duplicate_id = $question_id;
1619 if ($duplicate_id === FALSE)
1624 $next_id = $ilDB->nextId(
'tst_test_rnd_qst');
1625 $result = $ilDB->manipulateF(
"INSERT INTO tst_test_rnd_qst (test_random_question_id, active_fi, question_fi, sequence, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
1626 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
1627 array($next_id,$active_id, $duplicate_id, $result->numRows()+1,
$pass, time())
1645 $result = $ilDB->queryF(
"SELECT qpl_questions.question_id FROM qpl_questions, tst_test_rnd_qst WHERE qpl_questions.original_id = %s AND tst_test_rnd_qst.question_fi = qpl_questions.question_id AND tst_test_rnd_qst.active_fi = %s",
1646 array(
'integer',
'integer'),
1647 array($question_id, $active_id)
1649 $num = $result->numRows();
1652 $row = $ilDB->fetchAssoc($result);
1653 return $row[
"question_id"];
1670 $result = $ilDB->queryF(
"SELECT test_result_id FROM tst_test_result WHERE active_fi = %s AND pass = %s",
1671 array(
'integer',
'integer'),
1672 array($active_id,
$pass)
1674 return $result->numRows();
1688 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
1689 array(
'integer',
'integer'),
1690 array($active_id,
$pass)
1692 return ($result->numRows() > 0) ?
true :
false;
1729 $ilias->raiseError(sprintf($this->lng->txt(
"error_random_question_generation"), $ilUser->getId(), $this->
getTestId()), $ilErr->FATAL);
1737 $allquestions = array();
1738 foreach ($rndquestions as $question_id)
1740 array_push($allquestions, $question_id);
1744 srand ((
float)microtime()*1000000);
1745 shuffle($allquestions);
1749 foreach ($qpls as
$data)
1751 $maxcount += $data[
"contains"];
1753 if ($num > $maxcount) $num = $maxcount;
1754 foreach ($allquestions as $question_id)
1762 $allquestions = array();
1764 foreach ($qpls as $key => $value)
1766 if ($value[
"count"] > 0)
1769 foreach ($rndquestions as $question_id)
1771 array_push($allquestions, $question_id);
1774 $add = ($value[
"count"] <= $value[
"contains"]) ? $value[
"count"] : $value[
"contains"];
1779 srand ((
float)microtime()*1000000);
1780 shuffle($allquestions);
1782 foreach ($allquestions as $question_id)
1799 if (strlen($total_questions))
1803 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET random_question_count = %s, tstamp = %s WHERE test_id = %s",
1804 array(
'integer',
'integer',
'integer'),
1807 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1827 $result = $ilDB->queryF(
"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 sequence, test_random_id",
1831 if ($result->numRows())
1833 while (
$row = $ilDB->fetchAssoc($result))
1835 $qpls[$counter] = array(
1836 "index" => $counter,
1837 "count" =>
$row[
"num_of_q"],
1838 "qpl" =>
$row[
"questionpool_fi"],
1839 "contains" =>
$row[
"questioncount"]
1854 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1856 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
1868 foreach ($this->random_questionpool_data as $idx =>
$data)
1873 $next_id = $ilDB->nextId(
'tst_test_random');
1874 $result = $ilDB->manipulateF(
"INSERT INTO tst_test_random (test_random_id, test_fi, questionpool_fi, num_of_q, tstamp, sequence) VALUES (%s, %s, %s, %s, %s, %s)",
1875 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
1895 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_cpy WHERE tst_fi = %s',
1899 while (
$row = $ilDB->fetchAssoc($result))
1902 $question->delete(
$row[
'qst_fi']);
1905 $affectedRows = $ilDB->manipulateF(
'DELETE FROM tst_rnd_cpy WHERE tst_fi = %s',
1910 $affectedRows = $ilDB->manipulateF(
'DELETE FROM tst_rnd_qpl_title WHERE tst_fi = %s',
1924 $result = $ilDB->queryF(
'SELECT tst_rnd_cpy.*, tst_test_random.num_of_q FROM tst_rnd_cpy, tst_test_random WHERE tst_rnd_cpy.tst_fi = %s AND tst_rnd_cpy.tst_fi = tst_test_random.test_fi AND tst_rnd_cpy.qpl_fi = tst_test_random.questionpool_fi',
1929 while (
$row = $ilDB->fetchAssoc($result))
1931 if (is_array($pools[
$row[
'qpl_fi']]))
1933 $pools[$row[
'qpl_fi']][
'count']++;
1937 $pools[$row[
'qpl_fi']][
'count'] = 1;
1939 $pools[$row[
'qpl_fi']][
'num_of_q'] = $row[
'num_of_q'];
1941 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_qpl_title WHERE tst_fi = %s',
1946 while (
$row = $ilDB->fetchAssoc($result))
1948 $pools[
$row[
'qpl_fi']][
'title'] = $row[
'qpl_title'];
1954 $result = $ilDB->queryF(
'SELECT tst_test_random.* FROM tst_test_random WHERE tst_test_random.test_fi = %s ORDER BY sequence, test_random_id',
1959 while (
$row = $ilDB->fetchAssoc($result))
1961 $pools[
$row[
'questionpool_fi']][
'count'] = $row[
'num_of_q'];
1962 $pools[$row[
'questionpool_fi']][
'num_of_q'] = $row[
'num_of_q'];
1964 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_qpl_title WHERE tst_fi = %s',
1969 while (
$row = $ilDB->fetchAssoc($result))
1971 $pools[
$row[
'qpl_fi']][
'title'] = $row[
'qpl_title'];
1983 $result = $ilDB->queryF(
'SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND complete = %s AND original_id IS NULL',
1984 array(
'integer',
'text'),
1985 array($questionpool_id, 1)
1987 $saved_titles = array();
1988 while (
$row = $ilDB->fetchAssoc($result))
1991 $duplicate_id = $question->duplicate(
true);
1992 if ($duplicate_id > 0)
1994 $next_id = $ilDB->nextId(
'tst_rnd_cpy');
1995 $ilDB->manipulateF(
'INSERT INTO tst_rnd_cpy (copy_id, tst_fi, qst_fi, qpl_fi) VALUES (%s, %s, %s, %s)',
1996 array(
'integer',
'integer',
'integer',
'integer'),
1997 array($next_id, $this->
getTestId(), $duplicate_id, $questionpool_id)
1999 if (!array_key_exists($questionpool_id, $saved_titles))
2001 $next_id = $ilDB->nextId(
'tst_rnd_qpl_title');
2002 $ilDB->manipulateF(
'INSERT INTO tst_rnd_qpl_title (title_id, tst_fi, qpl_fi, qpl_title) VALUES (%s, %s, %s, %s)',
2003 array(
'integer',
'integer',
'integer',
'text'),
2006 $saved_titles[$questionpool_id] = 1;
2014 include_once
"./Modules/Test/classes/class.ilRandomTestData.php";
2015 if (array_key_exists($position, $this->random_questionpool_data))
2017 $newitems = array();
2018 for ($i = 0; $i < $position; $i++)
2020 array_push($newitems, $this->random_questionpool_data[$i]);
2023 for ($i = $position; $i < count($this->random_questionpool_data); $i++)
2025 array_push($newitems, $this->random_questionpool_data[$i]);
2027 $this->random_questionpool_data = $newitems;
2031 array_push($this->random_questionpool_data,
new ilRandomTestData($count, $qpl));
2037 if (array_key_exists($position, $this->random_questionpool_data))
2039 unset($this->random_questionpool_data[$position]);
2045 $this->random_questionpool_data = $a_data;
2063 $result = $ilDB->queryF(
"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 sequence, test_random_id",
2067 include_once
"./Modules/Test/classes/class.ilRandomTestData.php";
2068 if ($result->numRows())
2070 while (
$row = $ilDB->fetchAssoc($result))
2089 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE obj_fi = %s",
2091 array($this->
getId())
2093 if ($result->numRows() == 1)
2095 $data = $ilDB->fetchObject($result);
2102 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2141 "A" =>
$data->ects_a,
2142 "B" =>
$data->ects_b,
2143 "C" =>
$data->ects_c,
2144 "D" =>
$data->ects_d,
2145 "E" =>
$data->ects_e
2151 $this->mark_schema->flush();
2152 $this->mark_schema->loadFromDb($this->
getTestId());
2179 $this->questions = array();
2180 if (strcmp($active_id,
"") == 0)
2190 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.* FROM tst_test_rnd_qst, qpl_questions WHERE tst_test_rnd_qst.active_fi = %s AND qpl_questions.question_id = tst_test_rnd_qst.question_fi AND tst_test_rnd_qst.pass = %s ORDER BY sequence",
2191 array(
'integer',
'integer'),
2192 array($active_id,
$pass)
2198 if ($result->numRows() == 0)
2200 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.* FROM tst_test_rnd_qst, qpl_questions WHERE tst_test_rnd_qst.active_fi = %s AND qpl_questions.question_id = tst_test_rnd_qst.question_fi AND tst_test_rnd_qst.pass = 0 ORDER BY sequence",
2208 $result = $ilDB->queryF(
"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",
2210 array($this->test_id)
2214 while (
$data = $ilDB->fetchAssoc($result))
2216 $this->questions[$index++] =
$data[
"question_fi"];
2241 $this->_finalstatement = $a_statement;
2256 $this->_redirect_after_exam = $a_url;
2270 $this->_redirect_only_kiosk_mode = ($a_int) ? 1 : 0;
2284 $this->_exam_pdf = ($a_int) ? 1 : 0;
2296 $this->_showinfo = ($a_info) ? 1 : 0;
2308 $this->_forcejs = ($a_js) ? 1 : 0;
2320 $this->_customStyle = $a_customStyle;
2332 return (strlen($this->_customStyle)) ? $this->_customStyle : NULL;
2345 $css_path = str_replace(
"ta.css",
"customstyles", $css_path) .
"/";
2346 $customstyles = array();
2347 if (is_dir($css_path))
2350 include_once
"./Services/Utilities/classes/class.ilFileUtils.php";
2356 if (strpos($filename,
".css"))
2358 array_push($customstyles, $filename);
2363 return $customstyles;
2378 $custom = str_replace(
"ta.css",
"customstyles/" . $this->
getCustomStyle(), $default);
2379 if (file_exists($custom))
2382 $custom = str_replace(
"ta.css",
"customstyles/" . $this->
getCustomStyle(), $custom);
2405 $this->_showfinalstatement = ($show) ? 1 : 0;
2418 return ($this->random_test) ? 1 : 0;
2431 $query =
"SELECT random_test FROM tst_tests ".
2432 "WHERE obj_fi = ".$ilDB->quote($a_obj_id,
'integer');
2436 return $row->random_test ?
true :
false;
2450 return ($this->random_question_count) ? $this->random_question_count : 0;
2461 return (strlen($this->introduction)) ? $this->introduction : NULL;
2472 return (strlen($this->_finalstatement)) ? $this->_finalstatement : NULL;
2484 return (strlen($this->_redirect_after_exam)) ? $this->_redirect_after_exam : NULL;
2496 return ($this->_redirect_only_kiosk_mode) ? 1 : 0;
2508 return ($this->_exam_pdf) ? 1 : 0;
2520 return ($this->_showinfo) ? 1 : 0;
2532 return ($this->_forcejs) ? 1 : 0;
2544 return ($this->_showfinalstatement) ? 1 : 0;
2568 return ($this->ects_output) ? 1 : 0;
2580 $this->ects_output = $a_ects_output ? 1 : 0;
2592 return (strlen($this->ects_fx)) ? $this->ects_fx : NULL;
2604 $this->ects_fx = $a_ects_fx;
2628 if (is_array($a_ects_grades))
2630 $this->ects_grades = $a_ects_grades;
2667 switch ($instant_feedback)
2670 $this->instant_verification = 1;
2673 $this->instant_verification = 0;
2690 $this->answer_feedback = 1;
2693 $this->answer_feedback = 0;
2710 $this->answer_feedback_points = 1;
2713 $this->answer_feedback_points = 0;
2727 $this->random_test = $a_random_test;
2739 $this->random_question_count = $a_random_question_count;
2753 $this->reporting_date =
"";
2754 $this->ects_output = 0;
2771 return ($this->sequence_settings) ? $this->sequence_settings : 0;
2783 return ($this->score_reporting) ? $this->score_reporting : 0;
2795 return ($this->instant_verification) ? $this->instant_verification : 0;
2807 return ($this->answer_feedback) ? $this->answer_feedback : 0;
2819 return ($this->answer_feedback_points) ? $this->answer_feedback_points : 0;
2831 return ($this->count_system) ? $this->count_system : 0;
2844 $result = $ilDB->queryF(
"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",
2848 if ($result->numRows())
2850 $row = $ilDB->fetchAssoc($result);
2851 return $row[
"count_system"];
2865 return ($this->mc_scoring) ? $this->mc_scoring : 0;
2877 return ($this->score_cutting) ? $this->score_cutting : 0;
2889 return (strlen($this->password)) ? $this->password : NULL;
2901 return ($this->pass_scoring) ? $this->pass_scoring : 0;
2914 $result = $ilDB->queryF(
"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",
2918 if ($result->numRows())
2920 $row = $ilDB->fetchAssoc($result);
2921 return $row[
"pass_scoring"];
2936 $result = $ilDB->queryF(
"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",
2940 if ($result->numRows())
2942 $row = $ilDB->fetchAssoc($result);
2943 return $row[
"mc_scoring"];
2958 $result = $ilDB->queryF(
"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",
2962 if ($result->numRows())
2964 $row = $ilDB->fetchAssoc($result);
2965 return $row[
"score_cutting"];
2979 return (strlen($this->reporting_date)) ? $this->reporting_date : NULL;
2991 return ($this->nr_of_tries) ? $this->nr_of_tries : 0;
3003 return ($this->_kiosk) ? $this->_kiosk : 0;
3016 $this->_kiosk = $kiosk;
3028 if (($this->_kiosk & 1) > 0)
3049 $this->_kiosk = $this->_kiosk | 1;
3055 $this->_kiosk = $this->_kiosk ^ 1;
3069 if (($this->_kiosk & 2) > 0)
3089 $this->_kiosk = $this->_kiosk | 2;
3095 $this->_kiosk = $this->_kiosk ^ 2;
3109 if (($this->_kiosk & 4) > 0)
3129 $this->_kiosk = $this->_kiosk | 4;
3135 $this->_kiosk = $this->_kiosk ^ 4;
3149 return ($this->use_previous_answers) ? $this->use_previous_answers : 0;
3161 return ($this->title_output) ? $this->title_output : 0;
3176 $result = $ilDB->queryF(
"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",
3180 if ($result->numRows())
3182 $row = $ilDB->fetchAssoc($result);
3183 return $row[
"title_output"];
3204 $result = $ilDB->queryF(
"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",
3208 if ($result->numRows())
3210 $row = $ilDB->fetchAssoc($result);
3216 if ($user_active_user_setting)
3218 $res = $ilUser->getPref(
"tst_use_previous_answers");
3237 return (strlen($this->processing_time)) ? $this->processing_time : NULL;
3248 if (strlen($this->processing_time))
3250 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/is", $this->processing_time, $matches))
3252 if ((
int)$matches[1]+(
int)$matches[2]+(
int)$matches[3] == 0)
3259 'hh' => $matches[1],
3260 'mm' => $matches[2],
3261 'ss' => $matches[3],
3278 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $this->
getProcessingTime(), $matches))
3281 return ($matches[1] * 3600) + ($matches[2] * 60) + $matches[3] + $extratime;
3298 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndingTime(), $matches))
3300 $ending = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
3302 return $ending - $now;
3319 return ($this->enable_processing_time) ? $this->enable_processing_time : 0;
3331 return ($this->reset_processing_time) ? $this->reset_processing_time : 0;
3343 return (strlen($this->starting_time)) ? $this->starting_time : NULL;
3355 return (strlen($this->ending_time)) ? $this->ending_time : NULL;
3381 $this->use_previous_answers = 1;
3385 $this->use_previous_answers = 0;
3401 $this->title_output = 1;
3404 $this->title_output = 2;
3407 $this->title_output = 0;
3434 $this->enable_processing_time =
"1";
3436 $this->enable_processing_time =
"0";
3451 $this->reset_processing_time = 1;
3455 $this->reset_processing_time = 0;
3492 $this->count_system = $a_count_system;
3504 $this->password = $a_password;
3516 $this->score_cutting = $a_score_cutting;
3528 $this->mc_scoring = $a_mc_scoring;
3540 switch ($a_pass_scoring)
3561 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3566 $question->delete($question_id);
3585 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE tst_solutions.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s) AND tst_solutions.question_fi = %s",
3586 array(
'integer',
'integer'),
3589 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE tst_qst_solved.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s) AND tst_qst_solved.question_fi = %s",
3590 array(
'integer',
'integer'),
3593 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE tst_test_result.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s) AND tst_test_result.question_fi = %s",
3594 array(
'integer',
'integer'),
3597 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE tst_pass_result.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3604 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE tst_solutions.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3608 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE tst_qst_solved.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3612 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE tst_test_result.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3616 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE tst_pass_result.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3620 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3626 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE tst_sequence.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3633 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_rnd_qst WHERE tst_test_rnd_qst.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3640 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
3646 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE keyword = %s",
3648 array(
"tst_password_".$this->
getTestId())
3653 if (@is_dir(CLIENT_WEB_DIR .
"/assessment/tst_" . $this->
getTestId()))
3664 foreach ($active_ids as $active_id)
3666 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s",
3670 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s",
3674 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE active_fi = %s",
3678 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE active_fi = %s",
3685 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_rnd_qst WHERE active_fi = %s",
3691 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3699 foreach ($active_ids as $active_id)
3703 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE active_id = %s",
3708 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
3716 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
3717 array(
'integer',
'text'),
3724 if (@is_dir(CLIENT_WEB_DIR .
"/assessment/tst_" . $this->
getTestId() .
"/$active_id"))
3738 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s",
3742 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s",
3746 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE active_fi = %s",
3750 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE active_fi = %s",
3757 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_rnd_qst WHERE active_fi = %s",
3763 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3769 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
3775 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE active_id = %s",
3783 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
3784 array(
'integer',
'text'),
3785 array($user_id,
"tst_password_".$this->
getTestId())
3791 if (@is_dir(CLIENT_WEB_DIR .
"/assessment/tst_" . $this->
getTestId() .
"/$active_id"))
3809 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s",
3810 array(
'integer',
'integer'),
3813 $data = $ilDB->fetchObject($result);
3814 if (
$data->sequence > 1)
3817 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s",
3818 array(
'integer',
'integer'),
3821 $data_previous = $ilDB->fetchObject($result);
3823 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3824 array(
'integer',
'integer'),
3825 array(
$data->sequence, $data_previous->test_question_id)
3828 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3829 array(
'integer',
'integer'),
3830 array(
$data->sequence - 1,
$data->test_question_id)
3832 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3853 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s",
3854 array(
'integer',
'integer'),
3857 $data = $ilDB->fetchObject($result);
3858 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s",
3859 array(
'integer',
'integer'),
3862 if ($result->numRows() == 1)
3865 $data_next = $ilDB->fetchObject($result);
3867 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3868 array(
'integer',
'integer'),
3869 array(
$data->sequence, $data_next->test_question_id)
3872 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3873 array(
'integer',
'integer'),
3874 array(
$data->sequence + 1,
$data->test_question_id)
3876 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3896 $duplicate_id = $question->duplicate(
true);
3898 return $duplicate_id;
3914 $result = $ilDB->queryF(
"SELECT MAX(sequence) seq FROM tst_test_question WHERE test_fi=%s",
3920 if ($result->numRows() == 1)
3922 $data = $ilDB->fetchObject($result);
3923 $sequence =
$data->seq + 1;
3926 $next_id = $ilDB->nextId(
'tst_test_question');
3927 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
3928 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
3929 array($next_id, $this->
getTestId(), $duplicate_id, $sequence, time())
3931 if ($affectedRows == 1)
3933 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3940 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
3961 $result = $ilDB->queryF(
"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",
3965 while (
$row = $ilDB->fetchAssoc($result))
3967 array_push($titles,
$row[
"title"]);
3986 $result = $ilDB->queryF(
"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",
3990 while (
$row = $ilDB->fetchAssoc($result))
3992 $titles[
$row[
'question_id']] = $row[
"title"];
4004 $query = sprintf(
"SELECT qpl_questions.question_id, qpl_questions.original_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",
4005 $ilDB->quote($this->getTestId() .
"")
4007 $result = $ilDB->query(
$query);
4008 while (
$row = $ilDB->fetchAssoc($result))
4010 $oids[
$row[
'question_id']] = $row[
"original_id"];
4028 return $this->lng->txt(
"ass_question");
4048 $result = $ilDB->queryF(
"SELECT qpl_questions.*, qpl_qst_type.type_tag FROM qpl_questions, qpl_qst_type WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
4052 $row = $ilDB->fetchObject($result);
4067 $existing_questions = array();
4072 $result = $ilDB->queryF(
"SELECT qpl_questions.original_id FROM qpl_questions, tst_test_rnd_qst WHERE tst_test_rnd_qst.active_fi = %s AND tst_test_rnd_qst.question_fi = qpl_questions.question_id AND tst_test_rnd_qst.pass = %s",
4073 array(
'integer',
'integer'),
4074 array($active_id,
$pass)
4079 $result = $ilDB->queryF(
"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",
4084 while (
$data = $ilDB->fetchObject($result))
4086 array_push($existing_questions,
$data->original_id);
4088 return $existing_questions;
4102 if ($question_id < 1)
return -1;
4103 $result = $ilDB->queryF(
"SELECT type_tag FROM qpl_questions, qpl_qst_type WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
4107 if ($result->numRows() == 1)
4109 $data = $ilDB->fetchObject($result);
4110 return $data->type_tag;
4128 $next_id = $ilDB->nextId(
'tst_times');
4129 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_times (times_id, active_fi, started, finished, pass, question_fi, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
4130 array(
'integer',
'integer',
'timestamp',
'timestamp',
'integer',
'integer',
'integer'),
4131 array($next_id, $active_id, strftime(
"%Y-%m-%d %H:%M:%S"), strftime(
"%Y-%m-%d %H:%M:%S"),
$pass, $question_id, time())
4146 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_times SET finished = %s, tstamp = %s WHERE times_id = %s",
4147 array(
'timestamp',
'integer',
'integer'),
4148 array(strftime(
"%Y-%m-%d %H:%M:%S"), time(), $times_id)
4165 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_solutions WHERE active_fi = %s AND pass = %s GROUP BY question_fi",
4166 array(
'integer',
'integer'),
4167 array($active_id, 0)
4172 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_solutions WHERE active_fi = %s AND pass = %s GROUP BY question_fi",
4173 array(
'integer',
'integer'),
4174 array($active_id,
$pass)
4177 $result_array = array();
4178 while (
$row = $ilDB->fetchAssoc($result))
4180 array_push($result_array,
$row[
"question_fi"]);
4182 return $result_array;
4196 return ((($currentpass > 0) && ($num == 0)) || $this->
isTestFinished($active_id)) ?
true :
false;
4210 $result_array = array();
4215 if (count($this->questions) == 0)
return $result_array;
4220 $result = $ilDB->queryF(
"SELECT qpl_questions.* FROM qpl_questions, tst_test_rnd_qst WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id AND tst_test_rnd_qst.active_fi = %s AND tst_test_rnd_qst.pass = %s AND " . $ilDB->in(
'qpl_questions.question_id', $this->questions,
false,
'integer'),
4221 array(
'integer',
'integer'),
4222 array($active_id,
$pass)
4227 if (count($this->questions) == 0)
return $result_array;
4228 $result = $ilDB->query(
"SELECT qpl_questions.* FROM qpl_questions, tst_test_question WHERE tst_test_question.question_fi = qpl_questions.question_id AND " . $ilDB->in(
'qpl_questions.question_id', $this->questions,
false,
'integer'));
4230 while (
$row = $ilDB->fetchAssoc($result))
4232 $result_array[
$row[
"question_id"]] =
$row;
4234 return $result_array;
4250 if (!$user_id) $user_id = $ilUser->getId();
4253 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
4254 array(
'integer',
'integer',
'text'),
4258 else if (strlen($anonymous_id))
4260 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
4261 array(
'integer',
'integer',
'text'),
4262 array($user_id, $this->test_id, $anonymous_id)
4267 if (
$_SESSION[
"AccountId"] == ANONYMOUS_USER_ID)
4271 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s",
4272 array(
'integer',
'integer'),
4273 array($user_id, $this->test_id)
4276 if ($result->numRows())
4278 $row = $ilDB->fetchAssoc($result);
4279 return $row[
"active_id"];
4301 $user_id = $ilUser->id;
4307 $result = $ilDB->queryF(
"SELECT tst_active.active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s",
4308 array(
'integer',
'integer'),
4311 if ($result->numRows())
4313 $row = $ilDB->fetchAssoc($result);
4314 return $row[
"active_id"];
4330 $keys = array_keys($array);
4333 foreach ($keys as $key)
4335 $result[$key] = $array[$key];
4359 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
4361 $sequence = array();
4362 if ($ordered_sequence)
4370 $arrResults = array();
4371 $solutionresult = $ilDB->queryF(
"SELECT tst_test_result.question_fi, tst_test_result.points reached, tst_solutions.solution_id workedthru FROM tst_test_result LEFT JOIN tst_solutions ON tst_solutions.active_fi = tst_test_result.active_fi AND tst_solutions.question_fi = tst_test_result.question_fi WHERE tst_test_result.active_fi = %s AND tst_test_result.pass = %s",
4372 array(
'integer',
'integer'),
4373 array($active_id,
$pass)
4375 while (
$row = $ilDB->fetchAssoc($solutionresult))
4377 $arrResults[
$row[
'question_fi']] =
$row;
4380 require_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
4381 $result = $ilDB->query(
"SELECT qpl_questions.*, qpl_qst_type.type_tag, qpl_sol_sug.question_fi has_sug_sol FROM qpl_qst_type, qpl_questions LEFT JOIN qpl_sol_sug ON qpl_sol_sug.question_fi = qpl_questions.question_id WHERE qpl_qst_type.question_type_id = qpl_questions.question_type_fi AND " . $ilDB->in(
'qpl_questions.question_id', $sequence,
false,
'integer'));
4383 $unordered = array();
4387 while (
$row = $ilDB->fetchAssoc($result))
4389 $percentvalue = (
$row[
'points']) ? $arrResults[
$row[
'question_id']][
'reached'] /
$row[
'points'] : 0;
4390 if ($percentvalue < 0) $percentvalue = 0.0;
4394 "max" => round(
$row[
'points'], 2),
4395 "reached" => round($arrResults[
$row[
'question_id']][
'reached'],2),
4396 "percent" => sprintf(
"%2.2f ", ($percentvalue) * 100) .
"%",
4398 "type" => $row[
"type_tag"],
4399 "qid" => $row[
'question_id'],
4400 "original_id" => $row[
"original_id"],
4401 "workedthrough" => ($arrResults[$row[
'question_id']][
'workedthru']) ? 1 : 0
4403 $pass_max += round($row[
'points'], 2);
4404 $pass_reached += round($arrResults[$row[
'question_id']][
'reached'], 2);
4405 $unordered[$row[
'question_id']] =
$data;
4409 foreach ($sequence as $qid)
4411 $unordered[$qid][
'nr'] = $key;
4412 array_push($found, $unordered[$qid]);
4418 if (
$results[
'reached_points'] < 0)
4422 if ($pass_reached < 0) $pass_reached = 0;
4424 $found[
'pass'][
'total_max_points'] = $pass_max;
4425 $found[
'pass'][
'total_reached_points'] = $pass_reached;
4426 $found[
'pass'][
'percent'] = ($pass_max > 0) ? $pass_reached / $pass_max : 0;
4427 $found[
"test"][
"total_max_points"] =
$results[
'max_points'];
4428 $found[
"test"][
"total_reached_points"] =
$results[
'reached_points'];
4429 $found[
"test"][
"result_pass"] =
$results[
'pass'];
4430 if ((!$total_reached_points) or (!$total_max_points))
4436 $percentage = ($total_reached_points / $total_max_points) * 100.0;
4437 if ($percentage < 0) $percentage = 0.0;
4439 $found[
"test"][
"passed"] =
$results[
'passed'];
4453 $result = $ilDB->queryF(
"SELECT COUNT(active_id) total FROM tst_active WHERE test_fi = %s",
4457 $row = $ilDB->fetchAssoc($result);
4458 return $row[
"total"];
4471 $result = $ilDB->queryF(
"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",
4472 array(
'integer',
'integer'),
4476 while (
$row = $ilDB->fetchAssoc($result))
4478 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4479 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4480 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4481 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4482 $time += ($epoch_2 - $epoch_1);
4509 $result = $ilDB->queryF(
"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",
4515 while (
$row = $ilDB->fetchAssoc($result))
4517 if (!array_key_exists(
$row[
"active_fi"], $times))
4519 $times[
$row[
"active_fi"]] = 0;
4521 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4522 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4523 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4524 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4525 $times[
$row[
"active_fi"]] += ($epoch_2 - $epoch_1);
4540 $result = $ilDB->queryF(
"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",
4541 array(
'integer',
'integer'),
4545 while (
$row = $ilDB->fetchAssoc($result))
4547 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4548 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4549 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4550 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4551 $time += ($epoch_2 - $epoch_1);
4566 $result = $ilDB->queryF(
"SELECT * FROM tst_times WHERE active_fi = %s AND pass = %s ORDER BY started",
4567 array(
'integer',
'integer'),
4568 array($active_id,
$pass)
4571 while (
$row = $ilDB->fetchAssoc($result))
4573 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4574 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4575 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4576 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4577 $time += ($epoch_2 - $epoch_1);
4606 $result = $ilDB->queryF(
"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",
4607 array(
'integer',
'integer'),
4612 while (
$row = $ilDB->fetchAssoc($result))
4614 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4615 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4616 if ($firstvisit == 0 || $epoch_1 < $firstvisit) $firstvisit = $epoch_1;
4617 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4618 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4619 if ($epoch_2 > $lastvisit) $lastvisit = $epoch_2;
4621 return array(
"firstvisit" => $firstvisit,
"lastvisit" => $lastvisit);
4636 $result = $ilDB->queryF(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.active_id = %s AND tst_active.active_id = tst_times.active_fi",
4643 while (
$row = $ilDB->fetchObject($result))
4645 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->started, $matches);
4646 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4647 if (!$first_visit) {
4648 $first_visit = $epoch_1;
4650 if ($epoch_1 < $first_visit) {
4651 $first_visit = $epoch_1;
4653 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->finished, $matches);
4654 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4656 $last_visit = $epoch_2;
4658 if ($epoch_2 > $last_visit) {
4659 $last_visit = $epoch_2;
4661 $times[
$row->active_fi] += ($epoch_2 - $epoch_1);
4664 foreach ($times as $key => $value) {
4665 $max_time += $value;
4667 if ((!$test_result[
"test"][
"total_reached_points"]) or (!$test_result[
"test"][
"total_max_points"]))
4673 $percentage = ($test_result[
"test"][
"total_reached_points"] / $test_result[
"test"][
"total_max_points"]) * 100.0;
4674 if ($percentage < 0) $percentage = 0.0;
4676 $mark_obj = $this->mark_schema->getMatchingMark($percentage);
4677 $first_date = getdate($first_visit);
4678 $last_date = getdate($last_visit);
4679 $qworkedthrough = 0;
4680 foreach ($test_result as $key => $value)
4682 if (preg_match(
"/\d+/", $key))
4684 $qworkedthrough += $value[
"workedthrough"];
4687 if (!$qworkedthrough)
4693 $atimeofwork = $max_time / $qworkedthrough;
4699 $result_mark = $mark_obj->getShortName();
4700 if ($mark_obj->getPassed())
4709 $percent_worked_through = 0;
4710 if (count($this->questions))
4712 $percent_worked_through = $qworkedthrough / count($this->questions);
4714 $result_array = array(
4715 "qworkedthrough" => $qworkedthrough,
4716 "qmax" => count($this->questions),
4717 "pworkedthrough" => $percent_worked_through,
4718 "timeofwork" => $max_time,
4719 "atimeofwork" => $atimeofwork,
4720 "firstvisit" => $first_date,
4721 "lastvisit" => $last_date,
4722 "resultspoints" => $test_result[
"test"][
"total_reached_points"],
4723 "maxpoints" => $test_result[
"test"][
"total_max_points"],
4724 "resultsmarks" => $result_mark,
4725 "passed" => $passed,
4726 "distancemedian" =>
"0"
4728 foreach ($test_result as $key => $value)
4730 if (preg_match(
"/\d+/", $key))
4732 $result_array[$key] = $value;
4735 return $result_array;
4747 $totalpoints_array = array();
4749 foreach ($all_users as $active_id => $user_name)
4752 $reached = $test_result[
"test"][
"total_reached_points"];
4753 $total = $test_result[
"test"][
"total_max_points"];
4755 $mark = $this->mark_schema->getMatchingMark($percentage*100.0);
4758 if ($mark->getPassed())
4760 array_push($totalpoints_array, $test_result[
"test"][
"total_reached_points"]);
4764 return $totalpoints_array;
4776 $result = $ilDB->queryF(
"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",
4780 $persons_array = array();
4781 while (
$row = $ilDB->fetchAssoc($result))
4783 $name = $this->lng->txt(
"unknown");
4784 $fullname = $this->lng->txt(
"unknown");
4788 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
4790 $name = $this->lng->txt(
"deleted_user");
4791 $fullname = $this->lng->txt(
"deleted_user");
4792 $login = $this->lng->txt(
"unknown");
4796 $login = $row[
"login"];
4797 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4799 $name = $this->lng->txt(
"unknown");
4800 $fullname = $this->lng->txt(
"unknown");
4804 $name = trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]);
4805 $fullname = trim($row[
"title"] .
" " . $row[
"firstname"] .
" " . $row[
"lastname"]);
4809 $persons_array[
$row[
"active_id"]] = array(
4811 "fullname" => $fullname,
4815 return $persons_array;
4827 $result = $ilDB->queryF(
"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),
4831 $persons_array = array();
4832 while (
$row = $ilDB->fetchAssoc($result))
4836 $persons_array[
$row[
"active_id"]] = $this->lng->txt(
"unknown");
4840 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
4842 $persons_array[$row[
"active_id"]] = $this->lng->txt(
"deleted_user");
4846 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4848 $persons_array[$row[
"active_id"]] = $row[
"lastname"];
4852 $persons_array[$row[
"active_id"]] = trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]);
4857 return $persons_array;
4869 $result = $ilDB->queryF(
"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),
4873 $persons_array = array();
4874 while (
$row = $ilDB->fetchAssoc($result))
4878 $persons_array[
$row[
"active_id"]] = array(
"name" => $this->lng->txt(
"unknown"));
4882 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
4884 $persons_array[$row[
"active_id"]] = array(
"name" => $this->lng->txt(
"deleted_user"));
4888 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4890 $persons_array[$row[
"active_id"]] = array(
"name" => $row[
"lastname"]);
4894 $persons_array[$row[
"active_id"]] = array(
"name" => trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]),
"login" => $row[
"login"]);
4899 return $persons_array;
4912 $result = $ilDB->queryF(
"SELECT COUNT(active_id) total FROM tst_active WHERE test_fi = %s AND submitted = %s",
4913 array(
'integer',
'integer'),
4916 $row = $ilDB->fetchAssoc($result);
4917 return $row[
"total"];
4932 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, " .
4933 "tst_test_rnd_qst.pass, qpl_questions.points " .
4934 "FROM tst_test_rnd_qst, qpl_questions " .
4935 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
4936 "AND tst_test_rnd_qst.active_fi = %s ORDER BY tst_test_rnd_qst.sequence",
4943 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4944 "qpl_questions.points " .
4945 "FROM tst_test_question, tst_active, qpl_questions " .
4946 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4947 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi",
4953 if ($result->numRows())
4955 while (
$row = $ilDB->fetchAssoc($result))
4957 array_push($qtest,
$row);
4975 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, " .
4976 "qpl_questions.points " .
4977 "FROM tst_test_rnd_qst, qpl_questions " .
4978 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
4979 "AND tst_test_rnd_qst.active_fi = %s AND tst_test_rnd_qst.pass = %s " .
4980 "ORDER BY tst_test_rnd_qst.sequence",
4981 array(
'integer',
'integer'),
4982 array($active_id,
$pass)
4987 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4988 "qpl_questions.points " .
4989 "FROM tst_test_question, tst_active, qpl_questions " .
4990 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4991 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi",
4997 if ($result->numRows())
4999 while (
$row = $ilDB->fetchAssoc($result))
5001 array_push($qpass,
$row);
5010 include_once
"./Modules/Test/classes/class.ilTestEvaluationPassData.php";
5011 include_once
"./Modules/Test/classes/class.ilTestEvaluationUserData.php";
5012 include_once
"./Modules/Test/classes/class.ilTestEvaluationData.php";
5014 $result = $ilDB->queryF(
"SELECT tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
5015 "qpl_questions.points maxpoints " .
5016 "FROM tst_test_result, qpl_questions, tst_active " .
5017 "WHERE tst_active.active_id = tst_test_result.active_fi " .
5018 "AND qpl_questions.question_id = tst_test_result.question_fi " .
5019 "AND tst_active.test_fi = %s " .
5020 "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
5027 while (
$row = $ilDB->fetchAssoc($result))
5029 $data->getParticipant(
$row[
"active_fi"])->getPass(
$row[
"pass"])->addAnsweredQuestion(
$row[
"question_fi"],
$row[
"maxpoints"],
$row[
"points"]);
5032 foreach (array_keys(
$data->getParticipants()) as $active_id)
5036 for ($testpass = 0; $testpass <=
$data->getParticipant($active_id)->getLastPass(); $testpass++)
5039 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, qpl_questions.original_id, " .
5040 "tst_test_rnd_qst.pass, qpl_questions.points, qpl_questions.title " .
5041 "FROM tst_test_rnd_qst, qpl_questions " .
5042 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
5043 "AND tst_test_rnd_qst.pass = %s " .
5044 "AND tst_test_rnd_qst.active_fi = %s ORDER BY tst_test_rnd_qst.sequence",
5045 array(
'integer',
'integer'),
5046 array($testpass, $active_id)
5048 if ($result->numRows())
5050 while (
$row = $ilDB->fetchAssoc($result))
5052 $tpass = array_key_exists(
"pass",
$row) ?
$row[
"pass"] : 0;
5053 $data->getParticipant($active_id)->addQuestion(
$row[
"original_id"] ?
$row[
"original_id"] :
$row[
"question_fi"], $row[
"question_fi"], $row[
"points"], $row[
"sequence"], $tpass);
5054 $data->addQuestionTitle($row[
"question_fi"], $row[
"title"]);
5061 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
5062 "qpl_questions.points, qpl_questions.title, qpl_questions.original_id " .
5063 "FROM tst_test_question, tst_active, qpl_questions " .
5064 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
5065 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi ORDER BY tst_test_question.sequence",
5069 if ($result->numRows())
5071 $questionsbysequence = array();
5072 while (
$row = $ilDB->fetchAssoc($result))
5074 $questionsbysequence[
$row[
"sequence"]] =
$row;
5076 $seqresult = $ilDB->queryF(
"SELECT * FROM tst_sequence WHERE active_fi = %s",
5080 while ($seqrow = $ilDB->fetchAssoc($seqresult))
5082 $questionsequence = unserialize($seqrow[
"sequence"]);
5083 foreach ($questionsequence as $sidx => $seq)
5085 $qsid = $questionsbysequence[$seq][
"original_id"] ? $questionsbysequence[$seq][
"original_id"] : $questionsbysequence[$seq][
"question_fi"];
5086 $data->getParticipant($active_id)->addQuestion($qsid, $questionsbysequence[$seq][
"question_fi"], $questionsbysequence[$seq][
"points"], $sidx + 1, $seqrow[
"pass"]);
5087 $data->addQuestionTitle($questionsbysequence[$seq][
"question_fi"], $questionsbysequence[$seq][
"title"]);
5094 if ($this->ects_output)
5098 foreach (array_keys(
$data->getParticipants()) as $active_id)
5100 $percentage =
$data->getParticipant($active_id)->getReachedPointsInPercent();
5101 $mark = $this->mark_schema->getMatchingMark($percentage);
5102 if (is_object($mark))
5104 $data->getParticipant($active_id)->setMark($mark->getShortName());
5105 $data->getParticipant($active_id)->setMarkOfficial($mark->getOfficialName());
5106 $data->getParticipant($active_id)->setPassed($mark->getPassed());
5108 if ($this->ects_output)
5110 $ects_mark = $this->
getECTSGrade($passed_array,
$data->getParticipant($active_id)->getReached(),
$data->getParticipant($active_id)->getMaxPoints());
5111 $data->getParticipant($active_id)->setECTSMark($ects_mark);
5114 $data->getParticipant($active_id)->setFirstVisit($visitingTime[
"firstvisit"]);
5115 $data->getParticipant($active_id)->setLastVisit($visitingTime[
"lastvisit"]);
5126 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.pass, COUNT(tst_test_rnd_qst.question_fi) qcount, " .
5127 "SUM(qpl_questions.points) qsum FROM tst_test_rnd_qst, qpl_questions " .
5128 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id AND " .
5129 "tst_test_rnd_qst.active_fi = %s and pass = %s GROUP BY tst_test_rnd_qst.active_fi, " .
5130 "tst_test_rnd_qst.pass",
5131 array(
'integer',
'integer'),
5132 array($active_id,
$pass)
5137 $result = $ilDB->queryF(
"SELECT COUNT(tst_test_question.question_fi) qcount, " .
5138 "SUM(qpl_questions.points) qsum FROM tst_test_question, qpl_questions, tst_active " .
5139 "WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = tst_active.test_fi AND " .
5140 "tst_active.active_id = %s GROUP BY tst_test_question.test_fi",
5145 if ($result->numRows())
5147 $row = $ilDB->fetchAssoc($result);
5148 return array(
"count" =>
$row[
"qcount"],
"points" =>
$row[
"qsum"]);
5152 return array(
"count" => 0,
"points" => 0);
5158 include_once
"./Modules/Test/classes/class.ilTestEvaluationData.php";
5159 include_once
"./Modules/Test/classes/class.ilTestEvaluationPassData.php";
5160 include_once
"./Modules/Test/classes/class.ilTestEvaluationUserData.php";
5162 if ($withStatistics)
5164 $data->calculateStatistics();
5166 $data->setFilter($filterby, $filtertext);
5191 $result = $ilDB->queryF(
"SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
5192 "tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
5193 "qpl_questions.points maxpoints " .
5194 "FROM tst_test_result, qpl_questions, tst_active " .
5195 "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
5196 "WHERE tst_active.active_id = tst_test_result.active_fi " .
5197 "AND qpl_questions.question_id = tst_test_result.question_fi " .
5198 "AND tst_active.test_fi = %s " .
5199 "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
5203 $overview = array();
5204 while (
$row = $ilDB->fetchAssoc($result))
5206 if (!array_key_exists(
$row[
"active_fi"], $overview))
5208 $overview[
$row[
"active_fi"]] = array();
5209 $overview[$row[
"active_fi"]][
"firstname"] = $row[
"firstname"];
5210 $overview[$row[
"active_fi"]][
"lastname"] = $row[
"lastname"];
5211 $overview[$row[
"active_fi"]][
"title"] = $row[
"title"];
5212 $overview[$row[
"active_fi"]][
"login"] = $row[
"login"];
5213 $overview[$row[
"active_fi"]][
"usr_id"] = $row[
"usr_id"];
5214 $overview[$row[
"active_fi"]][
"started"] = $row[
"started"];
5215 $overview[$row[
"active_fi"]][
"finished"] = $row[
"finished"];
5217 if (!array_key_exists(
$row[
"pass"], $overview[
$row[
"active_fi"]]))
5219 $overview[$row[
"active_fi"]][$row[
"pass"]] = array();
5220 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] = 0;
5221 $overview[$row[
"active_fi"]][$row[
"pass"]][
"maxpoints"] = $row[
"maxpoints"];
5223 array_push($overview[$row[
"active_fi"]][$row[
"pass"]], $row);
5224 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] += $row[
"points"];
5240 $result = $ilDB->queryF(
"SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
5241 "tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
5242 "qpl_questions.points maxpoints " .
5243 "FROM tst_test_result, qpl_questions, tst_active " .
5244 "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
5245 "WHERE tst_active.active_id = tst_test_result.active_fi " .
5246 "AND qpl_questions.question_id = tst_test_result.question_fi " .
5247 "AND tst_active.test_fi = %s AND tst_active.active_id = %s" .
5248 "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
5249 array(
'integer',
'integer'),
5252 $overview = array();
5253 while (
$row = $ilDB->fetchAssoc($result))
5255 if (!array_key_exists(
$row[
"active_fi"], $overview))
5257 $overview[
$row[
"active_fi"]] = array();
5258 $overview[$row[
"active_fi"]][
"firstname"] = $row[
"firstname"];
5259 $overview[$row[
"active_fi"]][
"lastname"] = $row[
"lastname"];
5260 $overview[$row[
"active_fi"]][
"title"] = $row[
"title"];
5261 $overview[$row[
"active_fi"]][
"login"] = $row[
"login"];
5262 $overview[$row[
"active_fi"]][
"usr_id"] = $row[
"usr_id"];
5263 $overview[$row[
"active_fi"]][
"started"] = $row[
"started"];
5264 $overview[$row[
"active_fi"]][
"finished"] = $row[
"finished"];
5266 if (!array_key_exists(
$row[
"pass"], $overview[
$row[
"active_fi"]]))
5268 $overview[$row[
"active_fi"]][$row[
"pass"]] = array();
5269 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] = 0;
5270 $overview[$row[
"active_fi"]][$row[
"pass"]][
"maxpoints"] = $row[
"maxpoints"];
5272 array_push($overview[$row[
"active_fi"]][$row[
"pass"]], $row);
5273 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] += $row[
"points"];
5294 if (strlen($firstname.$lastname.$title) == 0)
5296 $name = $lng->txt(
"deleted_user");
5300 if ($user_id == ANONYMOUS_USER_ID)
5306 $name = trim($lastname .
", " . $firstname .
" " .
$title);
5310 $name = $lng->txt(
"anonymous");
5332 if (strlen($firstname.$lastname.$title) == 0)
5334 $name = $lng->txt(
"deleted_user");
5338 if ($user_id == ANONYMOUS_USER_ID)
5344 $name = trim($lastname .
", " . $firstname .
" " .
$title);
5348 $name = $lng->txt(
"anonymous");
5364 $result = $ilDB->queryF(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi",
5369 while (
$row = $ilDB->fetchObject($result))
5371 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->started, $matches);
5372 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5373 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->finished, $matches);
5374 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5375 $times[
$row->active_fi] += ($epoch_2 - $epoch_1);
5379 foreach ($times as $key => $value)
5381 $max_time += $value;
5386 $average_time = round($max_time / $counter);
5392 return $average_time;
5401 function &
getAvailableQuestionpools($use_object_id =
false, $equal_points =
false, $could_be_offline =
false, $show_path = FALSE, $with_questioncount = FALSE, $permission =
"read")
5403 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5415 $time_in_seconds = 0;
5416 foreach ($this->questions as $question_id)
5419 $est_time = $question->getEstimatedWorkingTime();
5420 $time_in_seconds += $est_time[
"h"] * 3600 + $est_time[
"m"] * 60 + $est_time[
"s"];
5422 $hours = (int)($time_in_seconds / 3600) ;
5423 $time_in_seconds = $time_in_seconds - ($hours * 3600);
5424 $minutes = (int)($time_in_seconds / 60);
5425 $time_in_seconds = $time_in_seconds - ($minutes * 60);
5426 $result = array(
"hh" => $hours,
"mm" => $minutes,
"ss" => $time_in_seconds);
5442 foreach ($qpls as $arr) array_push($qplids, $arr[
'qpl']);
5443 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_cpy WHERE tst_fi = %s AND ' . $ilDB->in(
'qpl_fi', $qplids,
false,
'integer'),
5447 if ($result->numRows())
5450 while (
$row = $ilDB->fetchAssoc($result)) array_push($ids,
$row[
'qst_fi']);
5451 $nr = ($nr > count($ids)) ? count($ids) : $nr;
5452 if ($nr == 0)
return array();
5453 $rand_keys = array_rand($ids, $nr);
5454 $selection = array();
5455 if (is_array($rand_keys))
5457 foreach ($rand_keys as $key)
5459 $selection[$ids[$key]] = $ids[$key];
5464 $selection[$ids[$rand_keys]] = $ids[$rand_keys];
5494 $result = $ilDB->queryF(
"SELECT qpl_questions.original_id FROM qpl_questions, tst_test_question WHERE qpl_questions.question_id = tst_test_question.question_fi AND qpl_questions.tstamp > 0 AND tst_test_question.test_fi = %s",
5498 $original_ids = array();
5499 $paramtypes = array();
5500 $paramvalues = array();
5501 while (
$row = $ilDB->fetchAssoc($result))
5503 array_push($original_ids,
$row[
'original_id']);
5508 if (($questionpool == 0) && (!is_array($qpls)))
5510 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5512 if (count($available_pools))
5514 $available =
" AND " . $ilDB->in(
'obj_fi', $available_pools,
false,
'integer');
5522 $constraint_qpls =
"";
5523 $result_array = array();
5524 if ($questionpool == 0)
5526 if (is_array($qpls))
5528 if (count($qpls) > 0)
5530 $constraint_qpls =
" AND " . $ilDB->in(
'obj_fi', $qpls,
false,
'integer');
5535 $original_clause =
"";
5536 if (count($original_ids))
5538 $original_clause =
" AND " . $ilDB->in(
'question_id', $original_ids,
true,
'integer');
5541 if ($questionpool == 0)
5543 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id IS NULL $available $constraint_qpls AND owner > %s AND complete = %s $original_clause",
5544 array(
'integer',
'text'),
5550 $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id IS NULL AND obj_fi = %s AND owner > %s AND complete = %s $original_clause",
5551 array(
'integer',
'integer',
'text'),
5552 array($questionpool, 0,
"1")
5555 $found_ids = array();
5556 while (
$row = $ilDB->fetchAssoc($result))
5558 array_push($found_ids,
$row[
'question_id']);
5560 $nr_of_questions = ($nr_of_questions > count($found_ids)) ? count($found_ids) : $nr_of_questions;
5561 if ($nr_of_questions == 0)
return array();
5562 $rand_keys = array_rand($found_ids, $nr_of_questions);
5564 if (is_array($rand_keys))
5566 foreach ($rand_keys as $key)
5568 $result[$found_ids[$key]] = $found_ids[$key];
5573 $result[$found_ids[$rand_keys]] = $found_ids[$rand_keys];
5586 return CLIENT_WEB_DIR .
"/assessment/" . $this->
getId() .
"/images/";
5597 include_once
"./Services/Utilities/classes/class.ilUtil.php";
5612 if ((!$question_type) and ($question_id > 0))
5616 if (!strlen($question_type))
return null;
5617 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
5619 $question_type_gui = $question_type .
"GUI";
5620 $question =
new $question_type_gui();
5621 if ($question_id > 0)
5623 $question->object->loadFromDb($question_id);
5637 if (strcmp($question_id,
"") != 0)
5639 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
5654 $this->questions = array_values($this->questions);
5655 $array_pos = array_search($target_index, $this->questions);
5656 if ($insert_mode == 0)
5658 $part1 = array_slice($this->questions, 0, $array_pos);
5659 $part2 = array_slice($this->questions, $array_pos);
5661 else if ($insert_mode == 1)
5663 $part1 = array_slice($this->questions, 0, $array_pos + 1);
5664 $part2 = array_slice($this->questions, $array_pos + 1);
5666 foreach ($move_questions as $question_id)
5668 if (!(array_search($question_id, $part1) === FALSE))
5670 unset($part1[array_search($question_id, $part1)]);
5672 if (!(array_search($question_id, $part2) === FALSE))
5674 unset($part2[array_search($question_id, $part2)]);
5677 $part1 = array_values($part1);
5678 $part2 = array_values($part2);
5679 $new_array = array_values(array_merge($part1, $move_questions, $part2));
5680 $this->questions = array();
5682 foreach ($new_array as $question_id)
5684 $this->questions[$counter] = $question_id;
5702 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartingTime(), $matches))
5704 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5706 if ($now < $epoch_time)
5727 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndingTime(), $matches))
5729 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5731 if ($now > $epoch_time)
5751 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5754 if (count($available_pools))
5756 $available =
" AND " . $ilDB->in(
'qpl_questions.obj_fi', $available_pools,
false,
'integer');
5764 $available .=
" AND qpl_questions.complete = " . $ilDB->quote(
"1",
'text');
5768 if (is_array($arrFilter))
5770 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
5772 $where .=
" AND " . $ilDB->like(
'qpl_questions.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
5774 if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description']))
5776 $where .=
" AND " . $ilDB->like(
'qpl_questions.description',
'text',
"%%" . $arrFilter[
'description'] .
"%%");
5778 if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author']))
5780 $where .=
" AND " . $ilDB->like(
'qpl_questions.author',
'text',
"%%" . $arrFilter[
'author'] .
"%%");
5782 if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type']))
5784 $where .=
" AND qpl_qst_type.type_tag = " . $ilDB->quote($arrFilter[
'type'],
'text');
5786 if (array_key_exists(
'qpl', $arrFilter) && strlen($arrFilter[
'qpl']))
5788 $where .=
" AND " . $ilDB->like(
'object_data.title',
'text',
"%%" . $arrFilter[
'qpl'] .
"%%");
5793 $original_clause =
" qpl_questions.original_id IS NULL";
5794 if (count($original_ids))
5796 $original_clause =
" qpl_questions.original_id IS NULL AND " . $ilDB->in(
'qpl_questions.question_id', $original_ids,
true,
'integer');
5799 $query_result = $ilDB->query(
5800 "SELECT qpl_questions.*, qpl_questions.tstamp, qpl_qst_type.type_tag, qpl_qst_type.plugin, object_data.title qpl " .
5801 "FROM qpl_questions, qpl_qst_type, object_data WHERE $original_clause $available AND " .
5802 "object_data.obj_id = qpl_questions.obj_fi AND qpl_questions.tstamp > 0 AND " .
5803 "qpl_questions.question_type_fi = qpl_qst_type.question_type_id$where");
5806 if ($query_result->numRows())
5808 while (
$row = $ilDB->fetchAssoc($query_result))
5810 $row[
'ttype'] = $types[
$row[
'type_tag']];
5815 array_push($rows, $row);
5820 array_push($rows, $row);
5832 global $ilPluginAdmin;
5834 $lng->loadLanguageModule(
"assessment");
5835 $result = $ilDB->query(
"SELECT * FROM qpl_qst_type");
5837 while (
$row = $ilDB->fetchAssoc($result))
5839 if (
$row[
"plugin"] == 0)
5841 $types[
$row[
'type_tag']] = $lng->txt($row[
"type_tag"]);
5845 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
5846 foreach ($pl_names as $pl_name)
5849 if (strcmp($pl->getQuestionType(),
$row[
"type_tag"]) == 0)
5851 $types[
$row[
'type_tag']] = $pl->getQuestionTypeTranslation();
5871 $this->
setTitle($assessment->getTitle());
5873 foreach ($assessment->objectives as $objectives)
5875 foreach ($objectives->materials as $material)
5880 if ($assessment->getPresentationMaterial())
5885 foreach ($assessment->assessmentcontrol as $assessmentcontrol)
5887 switch ($assessmentcontrol->getSolutionswitch())
5898 foreach ($assessment->qtimetadata as
$metadata)
5900 switch ($metadata[
"label"])
5904 $type = $metadata[
"entry"];
5925 case "sequence_settings":
5935 $this->
setKiosk($metadata[
"entry"]);
5937 case "showfinalstatement":
5940 case "redirect_after_exam":
5943 case "redirect_only_kiosk_mode":
5958 case "hide_previous_results":
5959 if ($metadata[
"entry"] == 0)
5968 case "use_previous_answers":
5971 case "answer_feedback":
5974 case "hide_title_points":
5977 case "title_output":
5983 case "random_question_count":
5986 case "results_presentation":
5989 case "reset_processing_time":
5992 case "instant_verification":
5995 case "answer_feedback_points":
6013 case "fixed_participants":
6016 case "score_reporting":
6019 case "shuffle_questions":
6022 case "count_system":
6028 case "mailnotification":
6034 case "exportsettings":
6037 case "score_cutting":
6043 case "allowedUsers":
6046 case "allowedUsersTimeGap":
6049 case "pass_scoring":
6052 case "show_summary":
6055 case "reporting_date":
6056 $iso8601period = $metadata[
"entry"];
6057 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
6059 $this->
setReportingDate(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
6062 case "processing_time":
6065 case "enable_processing_time":
6068 case "starting_time":
6069 $iso8601period = $metadata[
"entry"];
6070 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
6072 $this->
setStartingTime(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
6076 $iso8601period = $metadata[
"entry"];
6077 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
6079 $this->
setEndingTime(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
6083 if (preg_match(
"/mark_step_\d+/", $metadata[
"label"]))
6085 $xmlmark = $metadata[
"entry"];
6086 preg_match(
"/<short>(.*?)<\/short>/", $xmlmark, $matches);
6087 $mark_short = $matches[1];
6088 preg_match(
"/<official>(.*?)<\/official>/", $xmlmark, $matches);
6089 $mark_official = $matches[1];
6090 preg_match(
"/<percentage>(.*?)<\/percentage>/", $xmlmark, $matches);
6091 $mark_percentage = $matches[1];
6092 preg_match(
"/<passed>(.*?)<\/passed>/", $xmlmark, $matches);
6093 $mark_passed = $matches[1];
6094 $this->mark_schema->addMarkStep($mark_short, $mark_official, $mark_percentage, $mark_passed);
6098 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
6100 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
6101 include_once
"./Services/RTE/classes/class.ilRTE.php";
6102 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
6103 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
6106 if (file_exists($importfile))
6116 $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
6133 $this->mob_ids = array();
6134 $this->file_ids = array();
6137 $attrs[
"Type"] =
"Test";
6138 $a_xml_writer->xmlStartTag(
"ContentObject", $attrs);
6144 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Page Objects");
6145 $ilBench->start(
"ContentObjectExport",
"exportPageObjects");
6147 $ilBench->stop(
"ContentObjectExport",
"exportPageObjects");
6148 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Page Objects");
6151 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Media Objects");
6152 $ilBench->start(
"ContentObjectExport",
"exportMediaObjects");
6154 $ilBench->stop(
"ContentObjectExport",
"exportMediaObjects");
6155 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Media Objects");
6158 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export File Items");
6159 $ilBench->start(
"ContentObjectExport",
"exportFileItems");
6161 $ilBench->stop(
"ContentObjectExport",
"exportFileItems");
6162 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export File Items");
6164 $a_xml_writer->xmlEndTag(
"ContentObject");
6175 include_once
"./Services/MetaData/classes/class.ilMD2XML.php";
6177 $md2xml->setExportMode(
true);
6178 $md2xml->startExport();
6179 $a_xml_writer->appendXML($md2xml->getXML());
6189 if ($a_tag ==
"Identifier" && $a_param ==
"Entry")
6191 include_once
"./Services/Utilities/classes/class.ilUtil.php";
6209 include_once
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
6211 foreach ($this->questions as $question_id)
6213 $ilBench->start(
"ContentObjectExport",
"exportPageObject");
6214 $expLog->write(date(
"[y-m-d H:i:s] ").
"Page Object ".$question_id);
6217 $a_xml_writer->xmlStartTag(
"PageObject", $attrs);
6221 $ilBench->start(
"ContentObjectExport",
"exportPageObject_XML");
6223 $page_object->buildDom();
6224 $page_object->insertInstIntoIDs($a_inst);
6225 $mob_ids = $page_object->collectMediaObjects(
false);
6226 $file_ids = $page_object->collectFileItems();
6227 $xml = $page_object->getXMLFromDom(
false,
false,
false,
"",
true);
6228 $xml = str_replace(
"&",
"&", $xml);
6229 $a_xml_writer->appendXML($xml);
6230 $page_object->freeDom();
6231 unset ($page_object);
6233 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_XML");
6236 $ilBench->start(
"ContentObjectExport",
"exportPageObject_CollectMedia");
6238 foreach($mob_ids as $mob_id)
6240 $this->mob_ids[$mob_id] = $mob_id;
6242 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_CollectMedia");
6245 $ilBench->start(
"ContentObjectExport",
"exportPageObject_CollectFileItems");
6247 foreach($file_ids as $file_id)
6249 $this->file_ids[$file_id] = $file_id;
6251 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_CollectFileItems");
6253 $a_xml_writer->xmlEndTag(
"PageObject");
6256 $ilBench->stop(
"ContentObjectExport",
"exportPageObject");
6270 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
6272 foreach ($this->mob_ids as $mob_id)
6274 $expLog->write(date(
"[y-m-d H:i:s] ").
"Media Object ".$mob_id);
6278 $media_obj->exportXML($a_xml_writer, $a_inst);
6279 $media_obj->exportFiles($a_target_dir);
6291 include_once
"./Modules/File/classes/class.ilObjFile.php";
6293 foreach ($this->file_ids as $file_id)
6295 $expLog->write(date(
"[y-m-d H:i:s] ").
"File Item ".$file_id);
6296 $file_obj =
new ilObjFile($file_id,
false);
6297 $file_obj->export($a_target_dir);
6308 if (!is_array($this->import_mapping))
6314 return $this->import_mapping;
6329 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);
6340 function _getECTSGrade($points_passed, $reached_points, $max_points, $a, $b, $c,
$d, $e, $fx)
6342 include_once
"./classes/class.ilStatistics.php";
6345 $passed_statistics->setData($points_passed);
6346 $ects_percentiles = array
6348 "A" => $passed_statistics->quantile($a),
6349 "B" => $passed_statistics->quantile($b),
6350 "C" => $passed_statistics->quantile($c),
6351 "D" => $passed_statistics->quantile(
$d),
6352 "E" => $passed_statistics->quantile($e)
6354 if (count($points_passed) && ($reached_points >= $ects_percentiles[
"A"]))
6358 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"B"]))
6362 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"C"]))
6366 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"D"]))
6370 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"E"]))
6374 else if (strcmp($fx,
"") != 0)
6376 if ($max_points > 0)
6378 $percentage = ($reached_points / $max_points) * 100.0;
6379 if ($percentage < 0) $percentage = 0.0;
6385 if ($percentage >= $fx)
6402 return $this->mark_schema->checkMarks();
6434 $md_life =& $md->getLifecycle();
6437 if (strlen($a_author) == 0)
6440 $a_author = $ilUser->getFullname();
6443 $md_life =& $md->addLifecycle();
6445 $con =& $md_life->addContribute();
6446 $con->setRole(
"Author");
6448 $ent =& $con->addEntity();
6449 $ent->setEntity($a_author);
6475 include_once
"./Services/MetaData/classes/class.ilMD.php";
6477 $md_life =& $md->getLifecycle();
6480 $ids =& $md_life->getContributeIds();
6481 foreach ($ids as
$id)
6483 $md_cont =& $md_life->getContribute($id);
6484 if (strcmp($md_cont->getRole(),
"Author") == 0)
6486 $entids =& $md_cont->getEntityIds();
6487 foreach ($entids as $entid)
6489 $md_ent =& $md_cont->getEntity($entid);
6490 array_push(
$author, $md_ent->getEntity());
6508 include_once
"./Services/MetaData/classes/class.ilMD.php";
6509 $md =&
new ilMD($obj_id, 0,
"tst");
6510 $md_life =& $md->getLifecycle();
6513 $ids =& $md_life->getContributeIds();
6514 foreach ($ids as
$id)
6516 $md_cont =& $md_life->getContribute($id);
6517 if (strcmp($md_cont->getRole(),
"Author") == 0)
6519 $entids =& $md_cont->getEntityIds();
6520 foreach ($entids as $entid)
6522 $md_ent =& $md_cont->getEntity($entid);
6523 array_push(
$author, $md_ent->getEntity());
6542 $result_array = array();
6552 $result_array[$obj_id] = $titles[
$ref_id];
6560 return $result_array;
6575 $result = $ilDB->queryF(
"SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY sequence, test_random_id",
6579 if ($result->numRows())
6581 while (
$row = $ilDB->fetchAssoc($result))
6583 $next_id = $ilDB->nextId(
'tst_test_random');
6584 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_random (test_random_id, test_fi, questionpool_fi, num_of_q, tstamp, sequence) VALUES (%s, %s, %s, %s, %s, %s)",
6585 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
6586 array($next_id, $new_id,
$row[
"questionpool_fi"],
$row[
"num_of_q"], time(),
$row[
'sequence'])
6635 $newObj->setKiosk($this->
getKiosk());
6660 $newObj->saveToDb();
6663 include_once
"./Services/Certificate/classes/class.ilCertificate.php";
6664 include_once
"./Modules/Test/classes/class.ilTestCertificateAdapter.php";
6667 $cert->cloneCertificate($newcert);
6671 $newObj->saveRandomQuestionCount($newObj->getRandomQuestionCount());
6676 include_once(
"./Services/CopyWizard/classes/class.ilCopyWizardOptions.php");
6680 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
6681 foreach ($this->questions as $key => $question_id)
6684 $newObj->questions[$key] = $question->duplicate();
6687 $question->saveToDb($original_id);
6691 $cwo->appendMapping($this->
getRefId().
'_'.$question_id,$newObj->getRefId().
'_'.$newObj->questions[$key]);
6692 $ilLog->write(__METHOD__.
': Added mapping '.$this->getRefId().
'_'.$question_id.
' <-> ' .
6693 $newObj->getRefId().
'_'.$newObj->questions[$key]);
6696 $newObj->saveToDb();
6717 foreach ($qpls as
$data)
6719 $maxcount += $data[
"contains"];
6721 if ($num > $maxcount) $num = $maxcount;
6726 foreach ($qpls as
$data)
6728 $add = ($data[
"count"] <= $data[
"contains"]) ? $data[
"count"] : $data[
"contains"];
6735 $num = count($this->questions);
6752 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
6756 if (!$result->numRows())
6760 $test = $ilDB->fetchAssoc($result);
6762 if (
$test[
"random_test"] == 1)
6766 $result = $ilDB->queryF(
"SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY sequence, test_random_id",
6770 if ($result->numRows())
6772 while (
$row = $ilDB->fetchAssoc($result))
6774 $countresult = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND qpl_questions.tstamp > 0 AND original_id IS NULL",
6776 $row[
"questionpool_fi"]
6778 $contains = $countresult->numRows();
6779 $qpls[$counter] = array(
6780 "index" => $counter,
6781 "count" =>
$row[
"num_of_q"],
6782 "qpl" =>
$row[
"questionpool_fi"],
6783 "contains" => $contains
6788 if (
$test[
"random_question_count"] > 0)
6790 $num =
$test[
"random_question_count"];
6792 foreach ($qpls as
$data)
6794 $maxcount += $data[
"contains"];
6796 if ($num > $maxcount) $num = $maxcount;
6801 foreach ($qpls as
$data)
6803 $add = ($data[
"count"] <= $data[
"contains"]) ? $data[
"count"] : $data[
"contains"];
6810 $result = $ilDB->queryF(
"SELECT test_question_id FROM tst_test_question WHERE test_fi = %s",
6814 $num = $result->numRows();
6830 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
6834 $this->questions = array();
6848 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
6852 $this->questions = array();
6868 if (strcmp($question_id,
"") != 0)
6870 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
6873 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
6888 $result = $ilDB->queryF(
"SELECT obj_fi FROM tst_tests WHERE test_id = %s",
6892 if ($result->numRows())
6894 $row = $ilDB->fetchAssoc($result);
6895 $object_id =
$row[
"obj_fi"];
6911 $result = $ilDB->queryF(
"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",
6915 if ($result->numRows())
6917 $row = $ilDB->fetchAssoc($result);
6918 $object_id =
$row[
"obj_fi"];
6934 $result = $ilDB->queryF(
"SELECT test_id FROM tst_tests WHERE obj_fi = %s",
6938 if ($result->numRows())
6940 $row = $ilDB->fetchAssoc($result);
6959 if (($active_id) && ($question_id))
6963 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
6966 $result = $ilDB->queryF(
"SELECT value1 FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
6967 array(
'integer',
'integer',
'integer'),
6968 array($active_id, $question_id,
$pass)
6970 if ($result->numRows() == 1)
6972 $row = $ilDB->fetchAssoc($result);
6993 $result = $ilDB->queryF(
"SELECT question_text FROM qpl_questions WHERE question_id = %s",
6997 if ($result->numRows() == 1)
6999 $row = $ilDB->fetchAssoc($result);
7016 $result_array = array();
7020 if (is_numeric($user_id))
7022 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, %s login, %s lastname, %s firstname, tst_invited_user.clientip, " .
7023 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7024 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7025 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
7027 array(
'text',
'text',
'text',
'integer',
'integer'),
7028 array(
"", $this->lng->txt(
"unknown"),
"", $this->
getTestId(), $user_id)
7033 $result = $ilDB->queryF(
"SELECT tst_active.active_id, usr_id, %s login, %s lastname, %s firstname, tst_invited_user.clientip, " .
7034 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7035 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7036 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
7038 array(
'text',
'text',
'text',
'integer'),
7039 array(
"", $this->lng->txt(
"unknown"),
"", $this->
getTestId())
7045 if (is_numeric($user_id))
7047 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
7048 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7049 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi " .
7050 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
7052 array(
'integer',
'integer'),
7058 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
7059 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7060 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi " .
7061 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
7068 $result_array = array();
7069 while (
$row = $ilDB->fetchAssoc($result))
7071 $result_array[
$row[
'usr_id']]=
$row;
7073 return $result_array;
7088 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, tst_active.user_fi usr_id, %s login, %s lastname, %s firstname, tst_active.submitted test_finished, usr_data.matriculation, usr_data.active ".
7089 "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),
7090 array(
'text',
'text',
'text',
'integer'),
7091 array(
"", $this->lng->txt(
"unknown"),
"", $this->
getTestId())
7096 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, tst_active.user_fi usr_id, usr_data.login, usr_data.lastname, usr_data.firstname, tst_active.submitted test_finished, usr_data.matriculation, usr_data.active ".
7097 "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),
7103 while (
$row = $ilDB->fetchAssoc($result))
7107 foreach (
$data as $index => $participant)
7109 if (strlen(trim($participant[
"firstname"].$participant[
"lastname"])) == 0)
7111 $data[$index][
"lastname"] = $this->lng->txt(
"deleted_user");
7121 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
7123 if (count($scoring) == 0)
return array();
7126 $filtered_participants = array();
7127 foreach ($participants as $active_id => $participant)
7129 $result = $ilDB->queryF(
"SELECT tst_test_result.manual FROM tst_test_result,qpl_questions WHERE tst_test_result.question_fi = qpl_questions.question_id AND " . $ilDB->in(
'qpl_questions.question_type_fi', $scoring,
false,
'integer') .
" AND tst_test_result.active_fi = %s",
7133 $count = $result->numRows();
7139 if ($participant->active) $filtered_participants[$active_id] = $participant;
7142 if (!$participant->active) $filtered_participants[$active_id] = $participant;
7145 $filtered_participants[$active_id] = $participant;
7160 $assessmentSetting =
new ilSetting(
"assessment");
7161 $manscoring_done = $assessmentSetting->get(
"manscoring_done_" . $active_id);
7162 if ($manscoring_done) $filtered_participants[$active_id] = $participant;
7174 $assessmentSetting =
new ilSetting(
"assessment");
7175 $manscoring_done = $assessmentSetting->get(
"manscoring_done_" . $active_id);
7176 if (!$manscoring_done) $filtered_participants[$active_id] = $participant;
7182 while (
$row = $ilDB->fetchAssoc($result))
7184 if (
$row[
"manual"]) $found++;
7186 if (($found > 0) && ($found < $count)) $filtered_participants[$active_id] = $participant;
7189 $filtered_participants[$active_id] = $participant;
7194 return $filtered_participants;
7209 if (!is_array($ids) || count($ids) ==0)
return array();
7213 $result = $ilDB->queryF(
"SELECT usr_id, %s login, %s lastname, %s firstname, client_ip clientip FROM usr_data WHERE " . $ilDB->in(
'usr_id', $ids,
false,
'integer') .
" ORDER BY login",
7214 array(
'text',
'text',
'text'),
7215 array(
"", $lng->txt(
"unknown"),
"")
7220 $result = $ilDB->query(
"SELECT usr_id, login, lastname, firstname, client_ip clientip FROM usr_data WHERE " . $ilDB->in(
'usr_id', $ids,
false,
'integer') .
" ORDER BY login");
7223 $result_array = array();
7224 while (
$row = $ilDB->fetchAssoc($result))
7226 $result_array[
$row[
"usr_id"]]=
$row;
7228 return $result_array;
7233 if (!is_array($ids) || count($ids) ==0)
return array();
7245 if (!is_array($ids) || count($ids) ==0)
return array();
7247 foreach ($ids as $obj_id)
7263 include_once
"./Modules/Group/classes/class.ilObjGroup.php";
7265 $members = $group->getGroupMemberIds();
7266 include_once
'./Services/User/classes/class.ilObjUser.php';
7267 foreach ($members as $user_id)
7282 $members = $rbacreview->assignedUsers($role_id,
"usr_id");
7283 include_once
'./Services/User/classes/class.ilObjUser.php';
7284 foreach ($members as $user_id)
7302 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
7303 array(
'integer',
'integer'),
7318 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
7319 array(
'integer',
'integer'),
7322 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_invited_user (test_fi, user_fi, clientip, tstamp) VALUES (%s, %s, %s, %s)",
7323 array(
'integer',
'integer',
'text',
'integer'),
7324 array($this->
getTestId(), $user_id, (strlen($client_ip)) ? $client_ip : NULL, time())
7333 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_invited_user SET clientip = %s, tstamp = %s WHERE test_fi=%s and user_fi=%s",
7334 array(
'text',
'integer',
'integer',
'integer'),
7335 array((strlen($client_ip)) ? $client_ip : NULL, time(), $this->
getTestId(), $user_id)
7347 if (is_numeric($question_fi))
7349 $result = $ilDB->queryF(
"SELECT question_fi, solved FROM tst_qst_solved WHERE active_fi = %s AND question_fi=%s",
7350 array(
'integer',
'integer'),
7351 array($active_id, $question_fi)
7356 $result = $ilDB->queryF(
"SELECT question_fi, solved FROM tst_qst_solved WHERE active_fi = %s",
7361 $result_array = array();
7362 while (
$row = $ilDB->fetchAssoc($result))
7364 $result_array[
$row[
"question_fi"]]=
$row;
7366 return $result_array;
7378 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s AND question_fi = %s",
7379 array(
'integer',
'integer'),
7380 array($active_id, $question_id)
7382 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_qst_solved (solved, question_fi, active_fi) VALUES (%s, %s, %s)",
7383 array(
'integer',
'integer',
'integer'),
7384 array($value, $question_id, $active_id)
7396 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s, tstamp = %s WHERE test_fi = %s AND user_fi = %s",
7397 array(
'integer',
'timestamp',
'integer',
'integer',
'integer'),
7398 array(1, date(
'Y-m-d H:i:s'), time(), $this->
getTestId(), $user_id)
7400 $this->testSession = NULL;
7410 $result = $ilDB->queryF(
"SELECT submitted FROM tst_active WHERE active_id=%s AND submitted=%s",
7411 array(
'integer',
'integer'),
7412 array($active_id, 1)
7414 return $result->numRows() == 1;
7425 if (!is_numeric($user_id))
7426 $user_id = $ilUser->getId();
7428 $result = $ilDB->queryF(
"SELECT submitted FROM tst_active WHERE test_fi=%s AND user_fi=%s AND submitted=%s",
7429 array(
'integer',
'integer',
'integer'),
7432 return $result->numRows() == 1;
7468 "user_id" => $lng->txt(
"user_id"),
7469 "matriculation" => $lng->txt(
"matriculation"),
7470 "lastname" => $lng->txt(
"lastname"),
7471 "firstname" => $lng->txt(
"firstname"),
7472 "login" =>$lng->txt(
"login"),
7473 "reached_points" => $lng->txt(
"tst_reached_points"),
7474 "max_points" => $lng->txt(
"tst_maximum_points"),
7475 "percent_value" => $lng->txt(
"tst_percent_solved"),
7476 "mark" => $lng->txt(
"tst_mark"),
7477 "ects" => $lng->txt(
"ects_grade")
7480 if (count($participants))
7482 if ($this->ects_output)
7486 foreach ($participants as $active_id => $user_rec)
7489 $reached_points = 0;
7491 foreach ($this->questions as $value)
7494 if (is_object($question))
7496 $max_points += $question->getMaximumPoints();
7497 $reached_points += $question->getReachedPoints($active_id);
7500 if ($max_points > 0)
7502 $percentvalue = $reached_points / $max_points;
7503 if ($percentvalue < 0) $percentvalue = 0.0;
7509 $mark_obj = $this->mark_schema->getMatchingMark($percentvalue * 100);
7513 $mark = $mark_obj->getOfficialName();
7514 $ects_mark = $this->
getECTSGrade($passed_array, $reached_points, $max_points);
7518 $user_rec[
'firstname'] =
"";
7519 $user_rec[
'lastname'] = $lng->txt(
"unknown");
7522 "user_id"=>$user_rec[
'usr_id'],
7523 "matriculation" => $user_rec[
'matriculation'],
7524 "lastname" => $user_rec[
'lastname'],
7525 "firstname" => $user_rec[
'firstname'],
7526 "login"=>$user_rec[
'login'],
7527 "reached_points" => $reached_points,
7528 "max_points" => $max_points,
7529 "percent_value" => $percentvalue,
7531 "ects" => $ects_mark
7551 $resultarray = array();
7552 foreach (
$row as $rowindex => $entry)
7559 if (strpos($entry,
"\"") !== FALSE)
7561 $entry = str_replace(
"\"",
"\"\"", $entry);
7569 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
7572 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
7576 $resultarray[$rowindex] = utf8_decode($entry);
7579 return $resultarray;
7593 $result = $ilDB->queryF(
"SELECT tries FROM tst_active WHERE active_id = %s",
7597 if ($result->numRows())
7599 $row = $ilDB->fetchAssoc($result);
7600 return $row[
"tries"];
7620 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s",
7624 if ($result->numRows())
7626 $row = $ilDB->fetchAssoc($result);
7627 $max =
$row[
"maxpass"];
7648 $result = $ilDB->queryF(
"SELECT * FROM tst_pass_result WHERE active_fi = %s",
7652 if ($result->numRows())
7656 while (
$row = $ilDB->fetchAssoc($result))
7658 if (
$row[
"points"] > $bestpoints)
7661 $bestpoints =
$row[
"points"];
7664 if (is_array($bestrow))
7666 return $bestrow[
"pass"];
7689 $counted_pass = NULL;
7698 return $counted_pass;
7716 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
7718 foreach ($this->questions as $value)
7722 $workedthrough += 1;
7725 return $workedthrough;
7741 $result = $ilDB->queryF(
"SELECT tst_test_result.tstamp FROM tst_test_result WHERE active_fi = %s AND pass = %s ORDER BY tst_test_result.tstamp DESC",
7742 array(
'integer',
'integer'),
7743 array($active_id,
$pass)
7745 if ($result->numRows())
7747 $row = $ilDB->fetchAssoc($result);
7748 return $row[
"tstamp"];
7766 "executable" =>
true,
7767 "errormessage" =>
""
7771 $result[
"executable"] =
false;
7777 $result[
"executable"] =
false;
7806 $result[
"executable"] =
false;
7807 $result[
"errormessage"] = $this->lng->txt(
"detail_max_processing_time_reached");
7817 $result[
"executable"] =
false;
7818 $result[
"errormessage"] = $this->lng->txt(
"maximum_nr_of_tries_reached");
7824 $result[
"executable"] = FALSE;
7825 $result[
"errormessage"] = $this->lng->txt(
"maximum_nr_of_tries_reached");
7846 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getReportingDate(), $matches))
7848 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
7850 if ($now < $epoch_time)
7866 $notimeleft = FALSE;
7891 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getReportingDate(), $matches))
7893 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
7895 if ($now < $epoch_time)
7914 $result = $ilDB->query(
"SELECT tst_times.active_fi, tst_times.started FROM tst_times, tst_active WHERE tst_times.active_fi = tst_active.active_id ORDER BY tst_times.tstamp DESC");
7915 while (
$row = $ilDB->fetchAssoc($result))
7917 $times[
$row[
'active_fi']] = $row[
'started'];
7927 $result = $ilDB->queryF(
"SELECT tst_addtime.active_fi, tst_addtime.additionaltime FROM tst_addtime, tst_active WHERE tst_addtime.active_fi = tst_active.active_id AND tst_active.test_fi = %s",
7931 while (
$row = $ilDB->fetchAssoc($result))
7933 $times[
$row[
'active_fi']] = $row[
'additionaltime'];
7949 if ($active_id < 1)
return FALSE;
7951 $result = $ilDB->queryF(
"SELECT tst_times.started FROM tst_times WHERE tst_times.active_fi = %s AND tst_times.pass = %s ORDER BY tst_times.started",
7952 array(
'integer',
'integer'),
7953 array($active_id,
$pass)
7955 if ($result->numRows())
7957 $row = $ilDB->fetchAssoc($result);
7958 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches))
7960 return mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
8005 $query_result = $ilDB->queryF(
"SELECT qpl_questions.*, qpl_qst_type.type_tag, tst_test_question.sequence FROM qpl_questions, qpl_qst_type, tst_test_question WHERE qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND tst_test_question.test_fi = %s AND tst_test_question.question_fi = qpl_questions.question_id ORDER BY tst_test_question.sequence",
8009 $removableQuestions = array();
8010 while (
$row = $ilDB->fetchAssoc($query_result))
8012 array_push($removableQuestions,
$row);
8014 return $removableQuestions;
8025 return ($this->shuffle_questions) ? 1 : 0;
8036 $this->shuffle_questions = ($a_shuffle) ? 1 : 0;
8053 return ($this->show_summary) ? $this->show_summary : 0;
8070 $this->show_summary = $a_value;
8081 if (($this->show_summary & 1) > 0)
8101 $this->show_summary = 1;
8105 $this->show_summary = 0;
8117 if (($this->show_summary & 2) > 0)
8137 $this->show_summary = $this->show_summary | 2;
8143 $this->show_summary = $this->show_summary ^ 2;
8156 if (($this->show_summary & 4) > 0)
8176 $this->show_summary = $this->show_summary | 4;
8182 $this->show_summary = $this->show_summary ^ 4;
8195 if (($this->show_summary & 8) > 0)
8215 $this->show_summary = $this->show_summary | 8;
8221 $this->show_summary = $this->show_summary ^ 8;
8234 return ($this->results_presentation) ? $this->results_presentation : 0;
8245 if (($this->results_presentation & 1) > 0)
8263 if (($this->results_presentation & 2) > 0)
8281 if (($this->results_presentation & 4) > 0)
8299 if (($this->results_presentation & 8) > 0)
8317 if (($this->results_presentation & 16) > 0)
8335 if (($this->results_presentation & 32) > 0)
8351 if (($this->results_presentation & 64) > 0)
8367 if (($this->results_presentation & 128) > 0)
8383 if (($this->results_presentation & 256) > 0)
8401 $this->results_presentation = $a_results_presentation;
8416 $this->results_presentation = $this->results_presentation | 1;
8422 $this->results_presentation = $this->results_presentation ^ 1;
8437 $this->results_presentation = $this->results_presentation | 2;
8443 $this->results_presentation = $this->results_presentation ^ 2;
8458 $this->results_presentation = $this->results_presentation | 4;
8464 $this->results_presentation = $this->results_presentation ^ 4;
8479 $this->results_presentation = $this->results_presentation | 8;
8485 $this->results_presentation = $this->results_presentation ^ 8;
8500 $this->results_presentation = $this->results_presentation | 16;
8506 $this->results_presentation = $this->results_presentation ^ 16;
8521 $this->results_presentation = $this->results_presentation | 32;
8527 $this->results_presentation = $this->results_presentation ^ 32;
8542 $this->results_presentation = $this->results_presentation | 64;
8548 $this->results_presentation = $this->results_presentation ^ 64;
8563 $this->results_presentation = $this->results_presentation | 128;
8569 $this->results_presentation = $this->results_presentation ^ 128;
8584 $this->results_presentation = $this->results_presentation | 256;
8590 $this->results_presentation = $this->results_presentation ^ 256;
8603 $codestring =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
8606 for ($i = 1; $i <=5; $i++)
8608 $index = mt_rand(0, strlen($codestring)-1);
8609 $code .= substr($codestring, $index, 1);
8623 $result = $ilDB->queryF(
"SELECT anonymous_id FROM tst_active WHERE test_fi = %s AND anonymous_id = %s",
8624 array(
'integer',
'text'),
8627 return ($result->numRows() > 0) ?
true :
false;
8633 $result = $ilDB->queryF(
"SELECT user_fi FROM tst_active WHERE active_id = %s",
8637 if ($result->numRows())
8639 $row = $ilDB->fetchAssoc($result);
8640 return $row[
"user_fi"];
8651 if (!is_array(
$_SESSION[
"tst_access_code"]))
8657 return $_SESSION[
"tst_access_code"][
"$id"];
8664 if (!is_array(
$_SESSION[
"tst_access_code"]))
8668 $_SESSION[
"tst_access_code"][
"$id"] = $access_code;
8674 unset(
$_SESSION[
"tst_access_code"][
"$id"]);
8679 return ($this->allowedUsers) ? $this->allowedUsers : 0;
8684 $this->allowedUsers = $a_allowed_users;
8689 return ($this->allowedUsersTimeGap) ? $this->allowedUsersTimeGap : 0;
8694 $this->allowedUsersTimeGap = $a_allowed_users_time_gap;
8703 if (($nr_of_users > 0) && ($time_gap > 0))
8706 $time_border = $now - $time_gap;
8707 $str_time_border = strftime(
"%Y%m%d%H%M%S", $time_border);
8708 $result = $ilDB->queryF(
"SELECT DISTINCT tst_times.active_fi FROM tst_times, tst_active WHERE tst_times.tstamp > %s AND tst_times.active_fi = tst_active.active_id AND tst_active.test_fi = %s",
8709 array(
'integer',
'integer'),
8712 if ($result->numRows() >= $nr_of_users)
8714 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
8733 $result = $ilDB->queryF(
"SELECT finished FROM tst_times WHERE active_fi = %s ORDER BY finished DESC",
8737 if ($result->numRows())
8739 $row = $ilDB->fetchAssoc($result);
8740 return $row[
"finished"];
8754 if (preg_match(
"/<[^>]*?>/", $a_text))
8774 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
8776 $material = $a_material->getMaterial($i);
8777 if (strcmp($material[
"type"],
"mattext") == 0)
8779 $result .= $material[
"material"]->getContent();
8781 if (strcmp($material[
"type"],
"matimage") == 0)
8783 $matimage = $material[
"material"];
8784 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
8787 if (!is_array(
$_SESSION[
"import_mob_xhtml"]))
$_SESSION[
"import_mob_xhtml"] = array();
8788 array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(),
"uri" => $matimage->getUri()));
8793 $ilLog->write(print_r(
$_SESSION[
"import_mob_xhtml"],
true));
8805 include_once
"./Services/Utilities/classes/class.ilUtil.php";
8819 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET certificate_visibility = %s, tstamp = %s WHERE test_id = %s",
8820 array(
'text',
'integer',
'integer'),
8821 array($a_value, time(), $this->
getTestId())
8833 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
8844 $this->certificate_visibility = $a_value;
8855 return ($this->anonymity) ? 1 : 0;
8869 $this->anonymity = 1;
8872 $this->anonymity = 0;
8885 return ($this->show_cancel) ? 1 : 0;
8899 $this->show_cancel = 1;
8902 $this->show_cancel = 0;
8915 return ($this->autosave) ? 1 : 0;
8929 $this->autosave = 1;
8932 $this->autosave = 0;
8945 return ($this->show_marker) ? 1 : 0;
8959 $this->show_marker = 1;
8962 $this->show_marker = 0;
8975 return ($this->fixed_participants) ? 1 : 0;
8989 $this->fixed_participants = 1;
8992 $this->fixed_participants = 0;
9008 $result = $ilDB->queryF(
"SELECT anonymity FROM tst_tests WHERE obj_fi = %s",
9012 while(
$row = $ilDB->fetchAssoc($result))
9014 return $row[
'anonymity'];
9030 $result = $ilDB->queryF(
"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",
9034 while(
$row = $ilDB->fetchAssoc($result))
9036 return $row[
'random_test'];
9055 return $lng->txt(
"unknown") . $suffix;
9059 include_once
'./Services/User/classes/class.ilObjUser.php';
9061 if (strlen($uname[
"firstname"].$uname[
"lastname"]) == 0) $uname[
"firstname"] = $lng->txt(
"deleted_user");
9064 return trim($uname[
"lastname"] .
", " . $uname[
"firstname"]) . $suffix;
9068 return trim($uname[
"firstname"] .
" " . $uname[
"lastname"]) . $suffix;
9086 $active_pass = $this->
_getPass($active_id);
9090 if ($active_pass == 0)
9092 return $this->lng->txt(
"tst_start_test");
9096 return $this->lng->txt(
"tst_start_new_test_pass");
9101 return $this->lng->txt(
"tst_resume_test");
9118 $result = $ilDB->queryF(
"SELECT * FROM tst_test_defaults WHERE user_fi = %s ORDER BY $sortby $sortorder",
9120 array($ilUser->getId())
9122 $defaults = array();
9123 while (
$row = $ilDB->fetchAssoc($result))
9125 $defaults[
$row[
"test_defaults_id"]] =
$row;
9141 $result = $ilDB->queryF(
"SELECT * FROM tst_test_defaults WHERE test_defaults_id = %s",
9143 array($test_defaults_id)
9145 if ($result->numRows() == 1)
9147 $row = $ilDB->fetchAssoc($result);
9165 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_defaults WHERE test_defaults_id = %s",
9167 array($test_default_id)
9181 $testsettings = array(
9229 $next_id = $ilDB->nextId(
'tst_test_defaults');
9230 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_defaults (test_defaults_id, name, user_fi, defaults, marks, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
9231 array(
'integer',
'text',
'integer',
'text',
'text',
'integer'),
9232 array($next_id, $a_name, $ilUser->getId(), serialize($testsettings), serialize($this->mark_schema), time())
9251 $testsettings = unserialize($defaults[
"defaults"]);
9252 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
9253 $this->mark_schema = unserialize($defaults[
"marks"]);
9286 $this->
setKiosk($testsettings[
"Kiosk"]);
9290 $this->
setECTSFX($testsettings[
"ECTSFX"]);
9315 $content = preg_replace(
"/href=\".*?\"/",
"", $content);
9316 $printbody =
new ilTemplate(
"tpl.il_as_tst_print_body.html", TRUE, TRUE,
"Modules/Test");
9318 $printbody->setVariable(
"ADM_CONTENT", $content);
9319 $printbody->setCurrentBlock(
"css_file");
9321 $printbody->parseCurrentBlock();
9322 $printbody->setCurrentBlock(
"css_file");
9324 $printbody->parseCurrentBlock();
9325 $printoutput = $printbody->get();
9326 $html = str_replace(
"href=\"./",
"href=\"" . ILIAS_HTTP_PATH .
"/", $printoutput);
9327 $html = str_replace(
"img src=\"./",
"img src=\"" . ILIAS_HTTP_PATH .
"/", $html);
9328 $html = preg_replace(
"/<div id=\"dontprint\">.*?<\\/div>/ims",
"", $html);
9329 if (extension_loaded(
"tidy"))
9333 "output-xml" =>
true,
9334 "numeric-entities" =>
true
9338 $tidy->cleanRepair();
9339 $html = tidy_get_output(
$tidy);
9340 $html = preg_replace(
"/^.*?(<html)/",
"\\1", $html);
9344 $html = str_replace(
" ",
" ", $html);
9345 $html = str_replace(
"⊗",
"X", $html);
9350 $active_id =
$_GET[
"active_id"];
9351 include_once
'./Services/User/classes/class.ilObjUser.php';
9354 $filename_pdf = $uname[
'lastname'].
"_".$uname[
'firstname'].
"_".$uname[
'login'].
"_";
9359 include_once
"./Services/PDF/classes/class.ilHTMLToPDF.php";
9360 $transformer = null;
9361 switch ($pdfSetting->get(
'html_to_pdf_method'))
9364 include_once
"./Services/PDF/classes/class.ilHTMLToPDFTransformerUsingFOP.php";
9365 $transformer =
new ilHTMLtoPDFTransformerUsingFOP($filename_pdf .
$title .
'.pdf');
9366 $transformer->xsl =
"./Modules/Test/xml/question2fo.xsl";
9369 include_once
"./Services/PDF/classes/class.ilHTMLToPDFTransformerUsingWebkit.php";
9370 $transformer =
new ilHTMLtoPDFTransformerUsingWebkit($filename_pdf . $title .
'.pdf');
9373 if (is_object($transformer))
9375 $generator =
new ilHTMLtoPDF($transformer);
9378 $generator->createPDFFileFromHTMLString($html,
$filename);
9382 $generator->deliverPDFFromHTMLString($html);
9400 $result = $ilDB->queryF(
"SELECT feedback FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s",
9401 array(
'integer',
'integer',
'integer'),
9402 array($active_id, $question_id,
$pass)
9404 if ($result->numRows())
9406 $row = $ilDB->fetchAssoc($result);
9407 include_once(
"./Services/RTE/classes/class.ilRTE.php");
9427 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s",
9428 array(
'integer',
'integer',
'integer'),
9429 array($active_id, $question_id,
$pass)
9432 if (strlen($feedback))
9434 $next_id = $ilDB->nextId(
'tst_manual_fb');
9435 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_manual_fb (manual_feedback_id, active_fi, question_fi, pass, feedback, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
9436 array(
'integer',
'integer',
'integer',
'integer',
'text',
'integer'),
9439 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
9442 global
$lng, $ilUser;
9443 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
9445 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
9452 $ilias->raiseError($result->getMessage());
9470 if (strcmp(
$_GET[
"tst_javascript"],
"0") == 0)
return FALSE;
9472 $assessmentSetting =
new ilSetting(
"assessment");
9473 return ($ilUser->getPref(
"tst_javascript") === FALSE) ? $assessmentSetting->get(
"use_javascript") : $ilUser->getPref(
"tst_javascript");
9486 include_once
"./Modules/Test/classes/class.ilTestSession.php";
9505 $this->test_id = $a_id;
9517 if (is_object($this->testSession) && ($this->testSession->getActiveId() > 0))
return $this->testSession;
9521 include_once
"./Modules/Test/classes/class.ilTestSession.php";
9546 if (is_object($this->testSession) && ($this->testSession->getActiveId() > 0))
return $this->testSession;
9552 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
9554 if (!$this->testSequence->hasSequence())
9556 $this->testSequence->createNewSequence($this->
getQuestionCount(), $shuffle);
9557 $this->testSequence->saveToDb();
9563 if (is_object($this->testSequence) && ($this->testSequence->getActiveId() > 0))
return $this->testSequence;
9565 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
9566 if (($active_id > 0) && (strlen(
$pass)))
9582 foreach ($result as $sequence => $question)
9584 if (is_numeric($sequence))
9586 if ($question[
"reached"] == $question[
"max"])
9609 if (count($participants))
9611 foreach ($participants as $active_id => $user_rec)
9614 $reached_points = 0;
9616 foreach ($this->questions as $value)
9619 if (is_object($question))
9621 $max_points += $question->getMaximumPoints();
9622 $reached_points += $question->getReachedPoints($active_id);
9623 if ($max_points > 0)
9625 $percentvalue = $reached_points / $max_points;
9626 if ($percentvalue < 0) $percentvalue = 0.0;
9634 $user_rec[
'firstname'] =
"";
9635 $user_rec[
'lastname'] = $lng->txt(
"unknown");
9638 "user_id"=>$user_rec[
'usr_id'],
9639 "matriculation" => $user_rec[
'matriculation'],
9640 "lastname" => $user_rec[
'lastname'],
9641 "firstname" => $user_rec[
'firstname'],
9642 "login"=>$user_rec[
'login'],
9643 "question_id" => $question->getId(),
9644 "question_title" => $question->getTitle(),
9645 "reached_points" => $reached_points,
9646 "max_points" => $max_points
9663 $result = $ilDB->queryF(
"SELECT t.obj_fi obj_id FROM tst_test_question q, tst_tests t WHERE q.test_fi = t.test_id AND q.question_fi = %s",
9667 $rec = $ilDB->fetchAssoc($result);
9668 return $rec[
"obj_id"];
9679 global $ilPluginAdmin;
9680 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE,
"TestQuestionPool",
"qst", $a_pname))
9697 $assessmentSetting =
new ilSetting(
"assessment");
9698 $assessmentSetting->set(
"evalFields_" . $this->
getId(), serialize($fields));
9708 include_once
"./Modules/Test/classes/class.ilObjTestGUI.php";
9709 include_once
"./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
9711 return $table_gui->getSelectedColumns();
9718 $result = $ilDB->queryF(
"SELECT passed FROM tst_result_cache WHERE active_fi = %s",
9722 if ($result->numRows())
9724 $row = $ilDB->fetchAssoc($result);
9725 return $row[
'passed'];
9730 $result_array =& $this->
getTestResult($active_id, $counted_pass);
9731 return $result_array[
"test"][
"passed"];
9744 include_once
"./Services/Certificate/classes/class.ilCertificate.php";
9745 include_once
"./Modules/Test/classes/class.ilTestCertificateAdapter.php";
9747 if ($cert->isComplete())
9798 $result = $ilDB->queryF(
"SELECT tst_test_result.active_fi, tst_test_result.question_fi, tst_test_result.pass FROM tst_test_result, tst_active, usr_data WHERE tst_active.active_id = tst_test_result.active_fi AND tst_active.test_fi = %s AND tst_test_result.question_fi = %s AND tst_active.user_fi=usr_data.usr_id ORDER BY usr_data.lastname ASC",
9799 array(
'integer',
'integer'),
9802 $foundusers = array();
9803 while (
$row = $ilDB->fetchAssoc($result))
9805 if (!array_key_exists(
$row[
"active_fi"], $foundusers))
9807 $foundusers[
$row[
"active_fi"]] = array();
9809 array_push($foundusers[
$row[
"active_fi"]], array(
"pass" => $row[
"pass"],
"qid" => $row[
"question_fi"]));
9822 $foundParticipants =&
$data->getParticipants();
9823 $results = array(
"overview" => array(),
"questions" => array());
9824 if (count($foundParticipants))
9826 $results[
"overview"][$this->lng->txt(
"tst_eval_total_persons")] = count($foundParticipants);
9828 $results[
"overview"][$this->lng->txt(
"tst_eval_total_finished")] = $total_finished;
9830 $diff_seconds = $average_time;
9831 $diff_hours = floor($diff_seconds/3600);
9832 $diff_seconds -= $diff_hours * 3600;
9833 $diff_minutes = floor($diff_seconds/60);
9834 $diff_seconds -= $diff_minutes * 60;
9835 $results[
"overview"][$this->lng->txt(
"tst_eval_total_finished_average_time")] = sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
9837 $total_passed_reached = 0;
9838 $total_passed_max = 0;
9839 $total_passed_time = 0;
9840 foreach ($foundParticipants as $userdata)
9842 if ($userdata->getPassed())
9845 $total_passed_reached += $userdata->getReached();
9846 $total_passed_max += $userdata->getMaxpoints();
9847 $total_passed_time += $userdata->getTimeOfWork();
9850 $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
9851 $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
9852 $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
9853 $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed")] = $total_passed;
9854 $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);
9855 $average_time = $average_passed_time;
9856 $diff_seconds = $average_time;
9857 $diff_hours = floor($diff_seconds/3600);
9858 $diff_seconds -= $diff_hours * 3600;
9859 $diff_minutes = floor($diff_seconds/60);
9860 $diff_seconds -= $diff_minutes * 60;
9861 $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed_average_time")] = sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
9864 foreach (
$data->getQuestionTitles() as $question_id => $question_title)
9869 foreach ($foundParticipants as $userdata)
9871 for ($i = 0; $i <= $userdata->getLastPass(); $i++)
9873 if (is_object($userdata->getPass($i)))
9875 $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
9876 if (is_array($question))
9879 $reached += $question[
"reached"];
9880 $max += $question[
"points"];
9885 $percent = $max ? $reached/$max * 100.0 : 0;
9887 $results[
"questions"][$question_id] = array(
9889 sprintf(
"%.2f", $answered ? $reached / $answered : 0) .
" " . strtolower($this->lng->txt(
"of")) .
" " . sprintf(
"%.2f", $answered ? $max / $answered : 0),
9890 sprintf(
"%.2f", $percent) .
"%",
9892 sprintf(
"%.2f", $answered ? $reached / $answered : 0),
9893 sprintf(
"%.2f", $answered ? $max / $answered : 0),
9905 include_once(
"./Modules/Test/classes/class.ilTestExport.php");
9907 return $test_exp->buildExportFile();
9925 $this->mailnotification = $a_notification;
9930 include_once
"./Services/Mail/classes/class.ilMail.php";
9931 $mail =
new ilMail(ANONYMOUS_USER_ID);
9934 $message =
new ilTemplate(
"tpl.il_as_tst_finish_notification_simple.html", TRUE, TRUE,
"Modules/Test");
9935 $message->setVariable(
'TEXT_TEST_TITLE', $this->lng->txt(
'title'));
9936 $message->setVariable(
'VALUE_TEST_TITLE', $this->
getTitle());
9937 $message->setVariable(
'TEXT_USER_NAME', $this->lng->txt(
'username'));
9938 $message->setVariable(
'VALUE_USER_NAME', $usr_data);
9939 $message->setVariable(
'TEXT_FINISH_TIME', $this->lng->txt(
'tst_finished'));
9943 $res = $mail->sendMail(
9947 sprintf($this->lng->txt(
'tst_user_finished_test'), $this->
getTitle()),
9952 global
$ilLog; $ilLog->write(
"sending mail: " .
$res);
9958 include_once
"./Services/Mail/classes/class.ilMail.php";
9959 $mail =
new ilMail(ANONYMOUS_USER_ID);
9962 $message =
new ilTemplate(
"tpl.il_as_tst_finish_notification_simple.html", TRUE, TRUE,
"Modules/Test");
9963 $message->setVariable(
'TEXT_TEST_TITLE', $this->lng->txt(
'title'));
9964 $message->setVariable(
'VALUE_TEST_TITLE', $this->
getTitle());
9965 $message->setVariable(
'TEXT_USER_NAME', $this->lng->txt(
'username'));
9966 $message->setVariable(
'VALUE_USER_NAME', $usr_data);
9967 $message->setVariable(
'TEXT_FINISH_TIME', $this->lng->txt(
'tst_finished'));
9971 include_once
"./Modules/Test/classes/class.ilTestExport.php";
9973 $file = $exportObj->exportToExcel($deliver = FALSE,
'active_id', $active_id, $passedonly = FALSE);
9974 include_once
"./classes/class.ilFileDataMail.php";
9976 $fd->copyAttachmentFile(
$file,
"result_" . $active_id .
".xls");
9977 $file_names[] =
"result_" . $active_id .
".xls";
9978 $result = $mail->sendMail(
9982 sprintf($this->lng->txt(
'tst_user_finished_test'), $this->
getTitle()),
9984 count($file_names) ? $file_names : array(),
9987 if(count($file_names))
9989 $fd->unlinkFiles($file_names);
10000 $query =
"SELECT usr_id FROM usr_data";
10001 $result = $ilDB->query(
$query);
10002 while (
$data = $ilDB->fetchAssoc($result))
10004 $activequery = sprintf(
"SELECT user_fi FROM tst_active WHERE test_fi = %s AND user_fi = %s",
10005 $ilDB->quote($this->getTestId()),
10006 $ilDB->quote(
$data[
'usr_id'])
10008 $activeresult = $ilDB->query($activequery);
10009 if ($activeresult->numRows() == 0)
10011 $user_id =
$data[
'usr_id'];
10012 if ($user_id != 13)
10014 include_once
"./Modules/Test/classes/class.ilTestSession.php";
10022 $nr_of_passes = rand(1, $passes);
10026 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
10033 for ($seq = 1; $seq <= count($this->questions); $seq++)
10035 $question_id =
$testSequence->getQuestionForSequence($seq);
10039 if (
$pass < $nr_of_passes - 1)
10051 if ($number == 0)
return;
10061 $result = $ilDB->queryF(
"SELECT * FROM tst_result_cache WHERE active_fi = %s",
10065 if (!$result->numRows())
10067 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
10069 $result = $ilDB->queryF(
"SELECT * FROM tst_result_cache WHERE active_fi = %s",
10074 $row = $ilDB->fetchAssoc($result);
10088 $ilLog->write(
"Metafiles: ".print_r($metafiles,
true));
10091 foreach ($metafiles as $metafile)
10093 if (preg_match(
'/(\d\d\d\d-\d\d-\d\d)\_' . $testid .
'/',$metafile, $matches))
10095 $dates[] = $matches[1];
10110 $dates_out = array();
10113 foreach($dates_in as $date)
10115 if (file_exists(
ARCHIVE_PDF_DIR .
"/" . $date .
'_' . $testid .
'.zip'))
10117 $dates_out[] = $date;
10137 return in_array($date, $dates, TRUE);
10150 return in_array($date, $dates, TRUE);
10164 if (!preg_match(
"/^\d\d\d\d-\d\d-\d\d$/", $date))
10166 $ilLog->write(
"$date doesn't seem to be a date in YYYY-MM-DD format");
10171 if (!($this->
hasRun($date)))
10173 $ilLog->write(
"no run for $date");
10178 $ilLog->write(
"run for $date already packaged, returning");
10183 $archive_id = $date .
"_" . $testid;
10186 if(empty($html_files))
10188 $ilLog->write(
"No HTML archives found for run");
10195 if (file_exists($pdfdir))
10197 if (!is_dir($pdfdir))
10202 if(!unlink($pdfdir))
10204 $ilLog->write(
"Could not delete bogus file blocking location for PDF output directory ($pdfdir)");
10210 $ilLog->write(
"PDF output directory for run already exists");
10215 $oldumask = umask(0);
10216 if (!mkdir($pdfdir, 0755))
10218 $ilLog->write(
"Could not create PDF output directory for run");
10225 include_once
"./Services/PDF/classes/class.ilHTMLToPDF.php";
10226 $transformer = null;
10227 switch ($pdfSetting->get(
'html_to_pdf_method'))
10230 include_once
"./Services/PDF/classes/class.ilHTMLToPDFTransformerUsingFOP.php";
10231 $transformer =
new ilHTMLtoPDFTransformerUsingFOP($pdf_file);
10232 $transformer->xsl =
"./Modules/Test/xml/question2fo.xsl";
10235 include_once
"./Services/PDF/classes/class.ilHTMLToPDFTransformerUsingWebkit.php";
10236 $transformer =
new ilHTMLtoPDFTransformerUsingWebkit($pdf_file);
10239 if (is_object($transformer))
10241 $generator =
new ilHTMLtoPDF($transformer);
10245 $ilLog->write(
"Could not generate PDF transformer");
10251 $keylines = array();
10252 $pdf_filenames = array();
10253 $pdf_filelocalnames = array();
10254 foreach($html_files as $html_filename)
10256 $html_file_parts = pathinfo($html_filename);
10257 $pdf_file_basename = $html_file_parts[
'filename'] .
".pdf";
10258 $pdf_filename = $pdfdir .
"/" . $pdf_file_basename;
10259 $pdf_filelocalname = $archive_id .
"/" . $pdf_file_basename;
10260 $ilLog->write(
"Converting HTML file ".$html_filename.
" into PDF file ".$pdf_filename);
10261 $generator->createPDFFileFromHTMLFile($html_filename, $pdf_filename);
10262 $keylines[] = (hash(
'sha512', file_get_contents($pdf_filename)).
" ".$pdf_file_basename);
10263 $pdf_filenames[] = $pdf_filename;
10264 $pdf_filelocalnames[] = $pdf_filelocalname;
10268 $keyfilename = $pdfdir .
"/" . $archive_id .
".key";
10269 $keyfilelocalname = $archive_id .
"/" . $archive_id .
".key";
10270 $keyfile = fopen($keyfilename,
'w');
10273 $ilLog->write(
"Could not write key file");
10276 foreach ($keylines as $line)
10278 fwrite($keyfile, $line .
"\n");
10282 $metafile_basename = $archive_id .
".metafile";
10284 $metafile_target = $pdfdir .
"/" . $metafile_basename;
10285 $metafile_localname = $archive_id .
"/" . $metafile_basename;
10286 if (!copy($metafile_source, $metafile_target))
10288 $ilLog->write(
"Could not copy $metafile_source to $metafile_target");
10292 include_once
"./Modules/Test/classes/class.ilTestExport.php";
10294 $excelfile = $exporter->exportToExcel($deliver = FALSE);
10295 $excelfile_target = $pdfdir .
"/" . $archive_id .
"_results.xls";
10296 $excelfile_localname = $archive_id .
"/" . $archive_id .
"_results.xls";
10297 if (!rename($excelfile, $excelfile_target))
10299 $ilLog->write(
"Could not move $excelfile to $excelfile_target");
10307 $this->lng->loadLanguageModule(
"assessment");
10308 $scoring_template = $pdfdir .
"/" . $archive_id .
"_scoring.pdf";
10309 $scoring_template_localname = $archive_id .
"/" . $archive_id .
"_scoring.pdf";
10315 $template =
new ilTemplate(
"tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE,
"Modules/Test");
10318 $template->setCurrentBlock(
"pdf_export");
10321 $template->setVariable(
"PDF_TEXT", $this->lng->txt(
"pdf_export"));
10322 $template->setVariable(
"PDF_IMG_ALT", $this->lng->txt(
"pdf_export"));
10324 $template->parseCurrentBlock();
10328 $print_date = date(
"c");
10332 foreach ($this->questions as $question)
10334 $template->setCurrentBlock(
"question");
10336 $template->setVariable(
"COUNTER_QUESTION", $counter.
".");
10337 $template->setVariable(
"QUESTION_ID", $question_gui->object->getId());
10339 if ($question_gui->object->getMaximumPoints() == 1)
10341 $template->setVariable(
"QUESTION_POINTS", $question_gui->object->getMaximumPoints() .
" " . $this->lng->txt(
"point"));
10345 $template->setVariable(
"QUESTION_POINTS", $question_gui->object->getMaximumPoints() .
" " . $this->lng->txt(
"points"));
10347 $result_output = $question_gui->getSolutionOutput(
"", NULL, FALSE, TRUE, FALSE, $this->
getShowSolutionFeedback());
10348 if (strlen($result_output) == 0) $result_output = $question_gui->getPreview(FALSE);
10349 $result_html = str_replace(
"src=\"../",
"src=\"" . ILIAS_HTTP_PATH .
"/",$result_output);
10350 $template->setVariable(
"SOLUTION_OUTPUT", $result_html);
10351 $template->parseCurrentBlock(
"question");
10353 $max_points += $question_gui->object->getMaximumPoints();
10373 $zip =
new ZipArchive();
10374 $zipfilebasename = $archive_id .
".zip";
10376 if (TRUE !== $zip->open($zipfilename, ZIPARCHIVE::CREATE))
10378 $ilLog->write(
"Could not create ZIP file $zipfilename");
10381 for ($i=0; $i<count($pdf_filenames); $i++)
10383 $zip->addFile($pdf_filenames[$i], $pdf_filelocalnames[$i]);
10385 $zip->addFile($keyfilename, $keyfilelocalname);
10386 $zip->addFile($metafile_target, $metafile_localname);
10387 $zip->addFile($excelfile_target, $excelfile_localname);
10388 $zip->addFile($scoring_template, $scoring_template_localname);
10412 if (
'' === $packagefilename)
10418 unlink ($packagefilename);
10421 $pdfdirname = substr($packagefilename, 0, -4);
10424 $diriterator =
new RecursiveDirectoryIterator($pdfdirname);
10425 $diriterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
10427 new RecursiveIteratorIterator($diriterator,
10428 RecursiveIteratorIterator::CHILD_FIRST);
10429 foreach ($iterator as
$file)
10431 if ($file->isDir())
10433 rmdir($file->getPathname());
10437 unlink($file->getPathname());
10440 rmdir($pdfdirname);
10456 if (!preg_match(
"/^\d\d\d\d-\d\d-\d\d$/", $date))
10458 $ilLog->write(
"$date doesn't seem to be a date in YYYY-MM-DD format");
10463 if (!($this->
hasRun($date)))
10465 $ilLog->write(
"no run for $date");
10470 $ilLog->write(
"run for $date has package, deleting it");
10474 $archive_id = $date .
"_" . $testid;
10476 $files_to_delete = glob(
ARCHIVE_HTML_DIR .
"/" . $archive_id .
"_*.html");
10478 if(empty($files_to_delete))
10480 $ilLog->write(
"No HTML archives or metafile found for run");
10485 foreach ($files_to_delete as $file_to_delete)
10487 unlink($file_to_delete);
10495 if ($this->mailnottype == 1)
10509 $this->mailnottype = 1;
10513 $this->mailnottype = 0;
10519 if ($this->exportsettings)
10533 $this->exportsettings = $a_settings;
10537 $this->exportsettings = 0;
10543 if (($this->exportsettings & 1) > 0)
10557 $this->exportsettings = $this->exportsettings | 1;
10563 $this->exportsettings = $this->exportsettings ^ 1;
10570 if (($this->exportsettings & 2) > 0)
10584 $this->exportsettings = $this->exportsettings | 2;
10590 $this->exportsettings = $this->exportsettings ^ 2;
10604 $result = $ilDB->queryF(
"SELECT additionaltime FROM tst_addtime WHERE active_fi = %s",
10608 if ($result->numRows() > 0)
10610 $row = $ilDB->fetchAssoc($result);
10611 return $row[
'additionaltime'];
10620 $participants = array();
10621 if ($active_id == 0)
10623 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s",
10627 while (
$row = $ilDB->fetchAssoc($result))
10629 array_push($participants,
$row[
'active_id']);
10634 array_push($participants, $active_id);
10636 foreach ($participants as $active_id)
10638 $result = $ilDB->queryF(
"SELECT active_fi FROM tst_addtime WHERE active_fi = %s",
10642 if ($result->numRows() > 0)
10644 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_addtime WHERE active_fi = %s",
10650 $result = $ilDB->manipulateF(
"UPDATE tst_active SET tries = %s, submitted = %s, submittimestamp = %s WHERE active_id = %s",
10651 array(
'integer',
'integer',
'timestamp',
'integer'),
10652 array(0, 0, NULL, $active_id)
10655 $result = $ilDB->manipulateF(
"INSERT INTO tst_addtime (active_fi, additionaltime, tstamp) VALUES (%s, %s, %s)",
10656 array(
'integer',
'integer',
'integer'),
10657 array($active_id, $minutes, time())
10670 if (is_array($participants))
10672 require_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
10673 foreach ($participants as $active_id => $userdata)
10675 if (is_object($userdata) && is_array($userdata->getPasses()))
10677 $passes = $userdata->getPasses();
10678 foreach ($passes as
$pass => $passdata)
10680 if (is_object($passdata))
10682 $questions = $passdata->getAnsweredQuestions();
10688 if (is_object($question_gui))
10690 $reached = $question_gui->object->calculateReachedPoints($active_id,
$pass);
10704 return ($this->show_serial) ? 1 : 0;
10712 $this->show_serial = 1;
10715 $this->show_serial = 0;