34 include_once
"./classes/class.ilObject.php";
35 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
423 function ilObjTest($a_id = 0,$a_call_by_reference =
true)
427 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
430 $this->author = $ilUser->fullname;
431 $this->introduction =
"";
432 $this->questions = array();
435 $this->instant_verification = 0;
436 $this->answer_feedback_points = 0;
437 $this->reporting_date =
"";
438 $this->nr_of_tries = 0;
440 $this->use_previous_answers = 1;
441 $this->title_output = 0;
442 $this->starting_time =
"";
443 $this->ending_time =
"";
444 $this->processing_time =
"00:00:00";
445 $this->enable_processing_time =
"0";
446 $this->reset_processing_time = 0;
447 $this->ects_output = 0;
448 $this->ects_fx = NULL;
449 $this->random_test = 0;
450 $this->shuffle_questions = FALSE;
451 $this->show_summary = 8;
452 $this->random_question_count =
"";
457 $this->answer_feedback = 0;
458 $this->password =
"";
459 $this->certificate_visibility = 0;
460 $this->allowedUsers =
"";
461 $this->_showfinalstatement = FALSE;
462 $this->_finalstatement =
"";
463 $this->_showinfo = TRUE;
464 $this->_forcejs = FALSE;
465 $this->_customStyle =
"";
466 $this->allowedUsersTimeGap =
"";
467 $this->anonymity = 0;
468 $this->show_cancel = 1;
469 $this->show_marker = 0;
470 $this->fixed_participants = 0;
475 $this->testSession = FALSE;
476 $this->testSequence = FALSE;
477 $this->mailnotification = 0;
479 $lng->loadLanguageModule(
"assessment");
480 $this->mark_schema->createSimpleSchema($lng->txt(
"failed_short"), $lng->txt(
"failed_official"), 0, 0, $lng->txt(
"passed_short"), $lng->txt(
"passed_official"), 50, 1);
481 $this->ects_grades = array(
488 $this->
ilObject($a_id, $a_call_by_reference);
514 if (!parent::update())
541 function read($a_force_db =
false)
557 if (!parent::delete())
580 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s",
584 $active_array = array();
587 array_push($active_array,
$row[
"active_id"]);
590 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
595 if (count($active_array))
597 foreach ($active_array as $active_id)
599 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_times WHERE active_fi = %s",
604 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
611 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_mark WHERE test_fi = %s",
616 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s",
625 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_tests WHERE test_id = %s",
630 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
635 $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)",
642 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
654 include_once
"./Services/Utilities/classes/class.ilUtil.php";
656 $directory = $tst_data_dir.
"/tst_".$this->
getId();
657 if (is_dir($directory))
659 include_once
"./Services/Utilities/classes/class.ilUtil.php";
662 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
668 foreach(
$mobs as $mob)
707 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
747 if ($a_node_id==
$_GET[
"ref_id"])
749 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
750 $parent_type = $parent_obj->getType();
751 if ($parent_type == $this->
getType())
753 $a_node_id = (int) $tree->getParentId($a_node_id);
757 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
767 include_once
"./Services/Utilities/classes/class.ilUtil.php";
770 if (!is_writable($tst_data_dir))
772 $this->ilias->raiseError(
"Test Data Directory (".$tst_data_dir
773 .
") not writeable.",$this->ilias->error_obj->MESSAGE);
777 $tst_dir = $tst_data_dir.
"/tst_".$this->
getId();
779 if (!@is_dir($tst_dir))
781 $this->ilias->raiseError(
"Creation of Test Directory failed.",$this->ilias->error_obj->MESSAGE);
784 $export_dir = $tst_dir.
"/export";
786 if (!@is_dir($export_dir))
788 $this->ilias->raiseError(
"Creation of Export Directory failed.",$this->ilias->error_obj->MESSAGE);
799 include_once
"./Services/Utilities/classes/class.ilUtil.php";
813 if (!@is_dir(
$dir) or
826 while ($entry =
$dir->read())
828 if ($entry !=
"." and
831 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(test(__results)?__)*[0-9]+\.[a-z]{1,3}\$", $entry))
857 include_once
"./Services/Utilities/classes/class.ilUtil.php";
861 if (!is_writable($tst_data_dir))
863 $ilias->raiseError(
"Test data directory (".$tst_data_dir
864 .
") not writeable.",$ilias->error_obj->FATAL);
868 $tst_dir = $tst_data_dir.
"/tst_import";
870 if (!@is_dir($tst_dir))
872 $ilias->raiseError(
"Creation of test import directory failed.",$ilias->error_obj->FATAL);
884 include_once
"./Services/Utilities/classes/class.ilUtil.php";
886 if (@is_dir($import_dir))
903 include_once
"./Services/Utilities/classes/class.ilUtil.php";
907 if (!is_writable($tst_data_dir))
909 $this->ilias->raiseError(
"Test Data Directory (".$tst_data_dir
910 .
") not writeable.",$this->ilias->error_obj->FATAL);
914 $tst_dir = $tst_data_dir.
"/tst_import";
916 if (!@is_dir($tst_dir))
918 $ilias->raiseError(
"Creation of test import directory failed.",
$ilias->error_obj->FATAL);
930 include_once
"./Services/Utilities/classes/class.ilUtil.php";
932 if (@is_dir($import_dir))
952 $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",
959 if (strcmp(
$row[
'foundtypes'],
'assSingleChoice') == 0)
983 $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",
990 return (
$row[
'foundshuffles'] == 0);
1003 if ((count($this->mark_schema->mark_steps)) and (count($this->questions)))
1017 foreach ($arr as $array)
1019 $count += $array[
"count"];
1040 $test->loadFromDb();
1041 return $test->isComplete();
1052 if ($this->test_id > 0)
1054 $fx_support = preg_replace(
"/,/",
".", $fx_support);
1055 if (preg_match(
"/\d+/", $fx_support))
1057 $fx_support = $fx_support;
1063 $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",
1064 array(
'text',
'float',
'float',
'float',
'float',
'float',
'float',
'integer'),
1068 $this->ects_fx = $fx_support;
1086 if ($this->test_id > 0)
1088 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET complete = %s WHERE test_id = %s",
1089 array(
'text',
'integer'),
1090 array($complete, $this->test_id)
1115 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1116 $completecontent =
"";
1119 $completecontent .= $content;
1138 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1139 if ($this->test_id == -1)
1142 $next_id = $ilDB->nextId(
'tst_tests');
1143 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_tests (test_id, obj_fi, author, introduction, " .
1144 "finalstatement, showinfo, forcejs, customstyle, showfinalstatement, sequence_settings, " .
1145 "score_reporting, instant_verification, answer_feedback_points, answer_feedback, anonymity, show_cancel, show_marker, " .
1146 "fixed_participants, nr_of_tries, kiosk, use_previous_answers, title_output, processing_time, enable_processing_time, " .
1147 "reset_processing_time, reporting_date, starting_time, ending_time, complete, ects_output, ects_a, ects_b, ects_c, ects_d, " .
1148 "ects_e, ects_fx, random_test, random_question_count, count_system, mc_scoring, score_cutting, pass_scoring, " .
1149 "shuffle_questions, results_presentation, show_summary, password, allowedusers, " .
1150 "alloweduserstimegap, certificate_visibility, mailnotification, created, tstamp) " .
1151 "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, " .
1152 "%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)",
1154 'integer',
'integer',
'text',
'text',
1155 'text',
'integer',
'integer',
'text',
'integer',
'integer',
1156 'integer',
'text',
'text',
'text',
'text',
'text',
'integer',
1157 'text',
'integer',
'integer',
'text',
'text',
'text',
'text',
1158 'integer',
'text',
'text',
'text',
'text',
'text',
'float',
'float',
'float',
'float',
1159 'float',
'float',
'text',
'integer',
'text',
'text',
'text',
'text',
1160 'text',
'integer',
'integer',
'text',
'integer',
1161 'integer',
'text',
'integer',
'integer',
'integer'
1194 strlen($this->ects_grades[
"A"]) ? $this->ects_grades[
"A"] : NULL,
1195 strlen($this->ects_grades[
"B"]) ? $this->ects_grades[
"B"] : NULL,
1196 strlen($this->ects_grades[
"C"]) ? $this->ects_grades[
"C"] : NULL,
1197 strlen($this->ects_grades[
"D"]) ? $this->ects_grades[
"D"] : NULL,
1198 strlen($this->ects_grades[
"E"]) ? $this->ects_grades[
"E"] : NULL,
1218 $this->test_id = $next_id;
1231 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
1233 array($this->test_id)
1237 $oldrow = $ilDB->fetchAssoc(
$result);
1241 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET author = %s, introduction = %s, " .
1242 "finalstatement = %s, showinfo = %s, forcejs = %s, customstyle = %s, showfinalstatement = %s, sequence_settings = %s, " .
1243 "score_reporting = %s, instant_verification = %s, answer_feedback_points = %s, answer_feedback = %s, anonymity = %s, show_cancel = %s, show_marker = %s, " .
1244 "fixed_participants = %s, nr_of_tries = %s, kiosk = %s, use_previous_answers = %s, title_output = %s, processing_time = %s, enable_processing_time = %s, " .
1245 "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, " .
1246 "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, " .
1247 "shuffle_questions = %s, results_presentation = %s, show_summary = %s, password = %s, allowedusers = %s, " .
1248 "alloweduserstimegap = %s, certificate_visibility = %s, mailnotification = %s, tstamp = %s WHERE test_id = %s",
1251 'text',
'integer',
'integer',
'text',
'integer',
'integer',
1252 'integer',
'text',
'text',
'text',
'text',
'text',
'integer',
1253 'text',
'integer',
'integer',
'text',
'text',
'text',
'text',
1254 'integer',
'text',
'text',
'text',
'text',
'text',
'float',
'float',
'float',
'float',
1255 'float',
'float',
'text',
'integer',
'text',
'text',
'text',
'text',
1256 'text',
'integer',
'integer',
'text',
'integer',
1257 'integer',
'text',
'integer',
'integer',
'integer'
1288 strlen($this->ects_grades[
"A"]) ? $this->ects_grades[
"A"] : NULL,
1289 strlen($this->ects_grades[
"B"]) ? $this->ects_grades[
"B"] : NULL,
1290 strlen($this->ects_grades[
"C"]) ? $this->ects_grades[
"C"] : NULL,
1291 strlen($this->ects_grades[
"D"]) ? $this->ects_grades[
"D"] : NULL,
1292 strlen($this->ects_grades[
"E"]) ? $this->ects_grades[
"E"] : NULL,
1313 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1316 $logresult = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
1321 if ($logresult->numRows() == 1)
1323 $newrow = $ilDB->fetchAssoc($logresult);
1325 $changed_fields = array();
1326 foreach ($oldrow as
$key => $value)
1328 if (strcmp($oldrow[
$key], $newrow[$key]) != 0)
1330 array_push($changed_fields,
"$key: " . $oldrow[$key] .
" => " . $newrow[$key]);
1333 $changes = join($changed_fields,
", ");
1334 if (count($changed_fields) > 0)
1345 $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND tries >= %s AND submitted = %s",
1346 array(
'integer',
'integer',
'integer'),
1349 while (
$row = $ilDB->fetchAssoc($aresult))
1351 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
1352 array(
'integer',
'timestamp',
'integer'),
1353 array(1, date(
'Y-m-d H:i:s'),
$row[
"active_id"])
1358 $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND tries < %s AND submitted = %s",
1359 array(
'integer',
'integer',
'integer'),
1362 while (
$row = $ilDB->fetchAssoc($aresult))
1364 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
1365 array(
'integer',
'timestamp',
'integer'),
1366 array(0, NULL,
$row[
"active_id"])
1373 $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND submitted = %s",
1374 array(
'integer',
'integer'),
1377 while (
$row = $ilDB->fetchAssoc($aresult))
1379 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
1380 array(
'integer',
'timestamp',
'integer'),
1381 array(0, NULL,
$row[
"active_id"])
1391 if (!$properties_only)
1396 $ilias->raiseError(
$result->getMessage());
1404 $this->mark_schema->saveToDb($this->test_id);
1419 $oldquestions = array();
1420 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
1423 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence",
1431 array_push($oldquestions,
$row[
"question_fi"]);
1437 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
1442 foreach ($this->questions as
$key => $value)
1444 $next_id = $ilDB->nextId(
'tst_test_question');
1445 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
1446 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
1450 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1453 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence",
1457 $newquestions = array();
1462 array_push($newquestions,
$row[
"question_fi"]);
1465 foreach ($oldquestions as $index => $question_id)
1467 if (strcmp($newquestions[$index], $question_id) != 0)
1469 $pos = array_search($question_id, $newquestions);
1480 foreach ($newquestions as $index => $question_id)
1482 if (array_search($question_id, $oldquestions) === FALSE)
1496 $result = $ilDB->queryF(
'SELECT copy_id FROM tst_rnd_cpy WHERE tst_fi = %s',
1500 return $result->numRows() > 0;
1515 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
1516 array(
'integer',
'integer'),
1517 array($active_id,
$pass)
1519 if (
$result->numRows() < $maxcount)
1521 $duplicate_id = $question_id;
1525 if ($duplicate_id === FALSE)
1530 $next_id = $ilDB->nextId(
'tst_test_rnd_qst');
1531 $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)",
1532 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
1533 array($next_id,$active_id, $duplicate_id,
$result->numRows()+1,
$pass, time())
1551 $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",
1552 array(
'integer',
'integer'),
1553 array($question_id, $active_id)
1559 return $row[
"question_id"];
1576 $result = $ilDB->queryF(
"SELECT test_result_id FROM tst_test_result WHERE active_fi = %s AND pass = %s",
1577 array(
'integer',
'integer'),
1578 array($active_id,
$pass)
1594 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
1595 array(
'integer',
'integer'),
1596 array($active_id,
$pass)
1598 return (
$result->numRows() > 0) ?
true :
false;
1635 $ilias->raiseError(sprintf($this->lng->txt(
"error_random_question_generation"), $ilUser->getId(), $this->
getTestId()), $ilErr->FATAL);
1643 $allquestions = array();
1644 foreach ($rndquestions as $question_id)
1646 array_push($allquestions, $question_id);
1650 srand ((
float)microtime()*1000000);
1651 shuffle($allquestions);
1655 foreach ($qpls as
$data)
1657 $maxcount += $data[
"contains"];
1659 if ($num > $maxcount) $num = $maxcount;
1660 foreach ($allquestions as $question_id)
1668 $allquestions = array();
1670 foreach ($qpls as
$key => $value)
1672 if ($value[
"count"] > 0)
1675 foreach ($rndquestions as $question_id)
1677 array_push($allquestions, $question_id);
1680 $add = ($value[
"count"] <= $value[
"contains"]) ? $value[
"count"] : $value[
"contains"];
1685 srand ((
float)microtime()*1000000);
1686 shuffle($allquestions);
1688 foreach ($allquestions as $question_id)
1705 if (strlen($total_questions))
1709 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET random_question_count = %s, tstamp = %s WHERE test_id = %s",
1710 array(
'integer',
'integer',
'integer'),
1713 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1733 $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",
1741 $qpls[$counter] = array(
1742 "index" => $counter,
1743 "count" =>
$row[
"num_of_q"],
1744 "qpl" =>
$row[
"questionpool_fi"],
1745 "contains" =>
$row[
"questioncount"]
1760 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1762 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
1774 foreach ($this->random_questionpool_data as $idx =>
$data)
1779 $next_id = $ilDB->nextId(
'tst_test_random');
1780 $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)",
1781 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
1801 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_cpy WHERE tst_fi = %s',
1808 $question->delete(
$row[
'qst_fi']);
1811 $affectedRows = $ilDB->manipulateF(
'DELETE FROM tst_rnd_cpy WHERE tst_fi = %s',
1816 $affectedRows = $ilDB->manipulateF(
'DELETE FROM tst_rnd_qpl_title WHERE tst_fi = %s',
1830 $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',
1837 if (is_array($pools[
$row[
'qpl_fi']]))
1839 $pools[$row[
'qpl_fi']][
'count']++;
1843 $pools[$row[
'qpl_fi']][
'count'] = 1;
1845 $pools[$row[
'qpl_fi']][
'num_of_q'] = $row[
'num_of_q'];
1847 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_qpl_title WHERE tst_fi = %s',
1854 $pools[
$row[
'qpl_fi']][
'title'] = $row[
'qpl_title'];
1860 $result = $ilDB->queryF(
'SELECT tst_test_random.* FROM tst_test_random WHERE tst_test_random.test_fi = %s ORDER BY sequence, test_random_id',
1867 $pools[
$row[
'questionpool_fi']][
'count'] = $row[
'num_of_q'];
1868 $pools[$row[
'questionpool_fi']][
'num_of_q'] = $row[
'num_of_q'];
1870 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_qpl_title WHERE tst_fi = %s',
1877 $pools[
$row[
'qpl_fi']][
'title'] = $row[
'qpl_title'];
1889 $result = $ilDB->queryF(
'SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND complete = %s AND original_id IS NULL',
1890 array(
'integer',
'text'),
1891 array($questionpool_id, 1)
1893 $saved_titles = array();
1897 $duplicate_id = $question->duplicate(
true);
1898 if ($duplicate_id > 0)
1900 $next_id = $ilDB->nextId(
'tst_rnd_cpy');
1901 $ilDB->manipulateF(
'INSERT INTO tst_rnd_cpy (copy_id, tst_fi, qst_fi, qpl_fi) VALUES (%s, %s, %s, %s)',
1902 array(
'integer',
'integer',
'integer',
'integer'),
1903 array($next_id, $this->
getTestId(), $duplicate_id, $questionpool_id)
1905 if (!array_key_exists($questionpool_id, $saved_titles))
1907 $next_id = $ilDB->nextId(
'tst_rnd_qpl_title');
1908 $ilDB->manipulateF(
'INSERT INTO tst_rnd_qpl_title (title_id, tst_fi, qpl_fi, qpl_title) VALUES (%s, %s, %s, %s)',
1909 array(
'integer',
'integer',
'integer',
'text'),
1912 $saved_titles[$questionpool_id] = 1;
1920 if (array_key_exists($position, $this->random_questionpool_data))
1922 $newitems = array();
1923 for ($i = 0; $i < $position; $i++)
1925 array_push($newitems, $this->random_questionpool_data[$i]);
1928 for ($i = $position; $i < count($this->random_questionpool_data); $i++)
1930 array_push($newitems, $this->random_questionpool_data[$i]);
1932 $this->random_questionpool_data = $newitems;
1936 array_push($this->random_questionpool_data,
new ilRandomTestData($count, $qpl));
1942 if (array_key_exists($position, $this->random_questionpool_data))
1944 unset($this->random_questionpool_data[$position]);
1950 $this->random_questionpool_data = $a_data;
1968 $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",
1972 include_once
"./Modules/Test/classes/class.ilRandomTestData.php";
1994 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE obj_fi = %s",
1996 array($this->
getId())
2007 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2039 "A" =>
$data->ects_a,
2040 "B" =>
$data->ects_b,
2041 "C" =>
$data->ects_c,
2042 "D" =>
$data->ects_d,
2043 "E" =>
$data->ects_e
2049 $this->mark_schema->flush();
2050 $this->mark_schema->loadFromDb($this->
getTestId());
2075 $this->questions = array();
2076 if (strcmp($active_id,
"") == 0)
2086 $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",
2087 array(
'integer',
'integer'),
2088 array($active_id,
$pass)
2096 $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",
2104 $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",
2106 array($this->test_id)
2112 $this->questions[$index++] =
$data[
"question_fi"];
2137 $this->_finalstatement = $a_statement;
2149 $this->_showinfo = ($a_info) ? 1 : 0;
2161 $this->_forcejs = ($a_js) ? 1 : 0;
2173 $this->_customStyle = $a_customStyle;
2185 return (strlen($this->_customStyle)) ? $this->_customStyle : NULL;
2198 $css_path = str_replace(
"ta.css",
"customstyles", $css_path) .
"/";
2199 $customstyles = array();
2200 if (is_dir($css_path))
2203 include_once
"./Services/Utilities/classes/class.ilFileUtils.php";
2209 if (strpos($filename,
".css"))
2211 array_push($customstyles, $filename);
2216 return $customstyles;
2231 $custom = str_replace(
"ta.css",
"customstyles/" . $this->
getCustomStyle(), $default);
2232 if (file_exists($custom))
2235 $custom = str_replace(
"ta.css",
"customstyles/" . $this->
getCustomStyle(), $custom);
2258 $this->_showfinalstatement = ($show) ? 1 : 0;
2271 return ($this->random_test) ? 1 : 0;
2284 $query =
"SELECT random_test FROM tst_tests ".
2285 "WHERE obj_fi = ".$ilDB->quote($a_obj_id,
'integer');
2289 return $row->random_test ?
true :
false;
2303 return ($this->random_question_count) ? $this->random_question_count : 0;
2314 return (strlen($this->introduction)) ? $this->introduction : NULL;
2325 return (strlen($this->_finalstatement)) ? $this->_finalstatement : NULL;
2337 return ($this->_showinfo) ? 1 : 0;
2349 return ($this->_forcejs) ? 1 : 0;
2361 return ($this->_showfinalstatement) ? 1 : 0;
2385 return ($this->ects_output) ? 1 : 0;
2397 $this->ects_output = $a_ects_output ? 1 : 0;
2409 return (strlen($this->ects_fx)) ? $this->ects_fx : NULL;
2421 $this->ects_fx = $a_ects_fx;
2445 if (is_array($a_ects_grades))
2447 $this->ects_grades = $a_ects_grades;
2484 switch ($instant_feedback)
2487 $this->instant_verification = 1;
2490 $this->instant_verification = 0;
2507 $this->answer_feedback = 1;
2510 $this->answer_feedback = 0;
2527 $this->answer_feedback_points = 1;
2530 $this->answer_feedback_points = 0;
2544 $this->random_test = $a_random_test;
2556 $this->random_question_count = $a_random_question_count;
2570 $this->reporting_date =
"";
2571 $this->ects_output = 0;
2588 return ($this->sequence_settings) ? $this->sequence_settings : 0;
2600 return ($this->score_reporting) ? $this->score_reporting : 0;
2612 return ($this->instant_verification) ? $this->instant_verification : 0;
2624 return ($this->answer_feedback) ? $this->answer_feedback : 0;
2636 return ($this->answer_feedback_points) ? $this->answer_feedback_points : 0;
2648 return ($this->count_system) ? $this->count_system : 0;
2661 $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",
2668 return $row[
"count_system"];
2682 return ($this->mc_scoring) ? $this->mc_scoring : 0;
2694 return ($this->score_cutting) ? $this->score_cutting : 0;
2706 return (strlen($this->password)) ? $this->password : NULL;
2718 return ($this->pass_scoring) ? $this->pass_scoring : 0;
2731 $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",
2738 return $row[
"pass_scoring"];
2753 $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",
2760 return $row[
"mc_scoring"];
2775 $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",
2782 return $row[
"score_cutting"];
2796 return (strlen($this->reporting_date)) ? $this->reporting_date : NULL;
2808 return ($this->nr_of_tries) ? $this->nr_of_tries : 0;
2820 return ($this->_kiosk) ? $this->_kiosk : 0;
2833 $this->_kiosk = $kiosk;
2845 if (($this->_kiosk & 1) > 0)
2866 $this->_kiosk = $this->_kiosk | 1;
2872 $this->_kiosk = $this->_kiosk ^ 1;
2886 if (($this->_kiosk & 2) > 0)
2906 $this->_kiosk = $this->_kiosk | 2;
2912 $this->_kiosk = $this->_kiosk ^ 2;
2926 if (($this->_kiosk & 4) > 0)
2946 $this->_kiosk = $this->_kiosk | 4;
2952 $this->_kiosk = $this->_kiosk ^ 4;
2966 return ($this->use_previous_answers) ? $this->use_previous_answers : 0;
2978 return ($this->title_output) ? $this->title_output : 0;
2993 $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",
3000 return $row[
"title_output"];
3021 $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",
3033 if ($user_active_user_setting)
3035 $res = $ilUser->getPref(
"tst_use_previous_answers");
3054 return (strlen($this->processing_time)) ? $this->processing_time : NULL;
3065 if (strlen($this->processing_time))
3067 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/is", $this->processing_time, $matches))
3069 if ((
int)$matches[1]+(
int)$matches[2]+(
int)$matches[3] == 0)
3076 'hh' => $matches[1],
3077 'mm' => $matches[2],
3078 'ss' => $matches[3],
3095 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $this->
getProcessingTime(), $matches))
3097 return ($matches[1] * 3600) + ($matches[2] * 60) + $matches[3];
3114 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndingTime(), $matches))
3116 $ending = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
3118 return $ending - $now;
3135 return ($this->enable_processing_time) ? $this->enable_processing_time : 0;
3147 return ($this->reset_processing_time) ? $this->reset_processing_time : 0;
3159 return (strlen($this->starting_time)) ? $this->starting_time : NULL;
3171 return (strlen($this->ending_time)) ? $this->ending_time : NULL;
3197 $this->use_previous_answers = 1;
3201 $this->use_previous_answers = 0;
3217 $this->title_output = 1;
3220 $this->title_output = 2;
3223 $this->title_output = 0;
3250 $this->enable_processing_time =
"1";
3252 $this->enable_processing_time =
"0";
3267 $this->reset_processing_time = 1;
3271 $this->reset_processing_time = 0;
3308 $this->count_system = $a_count_system;
3320 $this->password = $a_password;
3332 $this->score_cutting = $a_score_cutting;
3344 $this->mc_scoring = $a_mc_scoring;
3356 switch ($a_pass_scoring)
3377 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3382 $question->delete($question_id);
3401 $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",
3402 array(
'integer',
'integer'),
3405 $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",
3406 array(
'integer',
'integer'),
3409 $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",
3410 array(
'integer',
'integer'),
3413 $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)",
3420 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE tst_solutions.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3424 $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)",
3428 $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)",
3432 $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)",
3436 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3442 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE tst_sequence.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3449 $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)",
3456 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
3462 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE keyword = %s",
3464 array(
"tst_password_".$this->
getTestId())
3469 if (@is_dir(CLIENT_WEB_DIR .
"/assessment/tst_" . $this->
getTestId()))
3480 foreach ($active_ids as $active_id)
3482 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s",
3486 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s",
3490 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE active_fi = %s",
3494 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE active_fi = %s",
3501 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_rnd_qst WHERE active_fi = %s",
3507 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3515 foreach ($active_ids as $active_id)
3519 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE active_id = %s",
3524 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
3532 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
3533 array(
'integer',
'text'),
3540 if (@is_dir(CLIENT_WEB_DIR .
"/assessment/tst_" . $this->
getTestId() .
"/$active_id"))
3554 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s",
3558 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s",
3562 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE active_fi = %s",
3566 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE active_fi = %s",
3573 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_rnd_qst WHERE active_fi = %s",
3579 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3585 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
3591 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE active_id = %s",
3599 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
3600 array(
'integer',
'text'),
3601 array($user_id,
"tst_password_".$this->
getTestId())
3607 if (@is_dir(CLIENT_WEB_DIR .
"/assessment/tst_" . $this->
getTestId() .
"/$active_id"))
3625 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s",
3626 array(
'integer',
'integer'),
3630 if (
$data->sequence > 1)
3633 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s",
3634 array(
'integer',
'integer'),
3637 $data_previous = $ilDB->fetchObject(
$result);
3639 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3640 array(
'integer',
'integer'),
3641 array(
$data->sequence, $data_previous->test_question_id)
3644 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3645 array(
'integer',
'integer'),
3646 array(
$data->sequence - 1,
$data->test_question_id)
3648 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3669 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s",
3670 array(
'integer',
'integer'),
3674 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s",
3675 array(
'integer',
'integer'),
3681 $data_next = $ilDB->fetchObject(
$result);
3683 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3684 array(
'integer',
'integer'),
3685 array(
$data->sequence, $data_next->test_question_id)
3688 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3689 array(
'integer',
'integer'),
3690 array(
$data->sequence + 1,
$data->test_question_id)
3692 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3712 $duplicate_id = $question->duplicate(
true);
3714 return $duplicate_id;
3730 $result = $ilDB->queryF(
"SELECT MAX(sequence) seq FROM tst_test_question WHERE test_fi=%s",
3739 $sequence =
$data->seq + 1;
3742 $next_id = $ilDB->nextId(
'tst_test_question');
3743 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
3744 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
3745 array($next_id, $this->
getTestId(), $duplicate_id, $sequence, time())
3747 if ($affectedRows == 1)
3749 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3756 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
3777 $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",
3783 array_push($titles,
$row[
"title"]);
3802 $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",
3808 $titles[
$row[
'question_id']] = $row[
"title"];
3826 return $this->lng->txt(
"ass_question");
3846 $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",
3865 $existing_questions = array();
3870 $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",
3871 array(
'integer',
'integer'),
3872 array($active_id,
$pass)
3877 $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",
3884 array_push($existing_questions,
$data->original_id);
3886 return $existing_questions;
3900 if ($question_id < 1)
return -1;
3901 $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",
3908 return $data->type_tag;
3926 $next_id = $ilDB->nextId(
'tst_times');
3927 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_times (times_id, active_fi, started, finished, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
3928 array(
'integer',
'integer',
'timestamp',
'timestamp',
'integer',
'integer'),
3929 array($next_id, $active_id, strftime(
"%Y-%m-%d %H:%M:%S"), strftime(
"%Y-%m-%d %H:%M:%S"),
$pass, time())
3944 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_times SET finished = %s, tstamp = %s WHERE times_id = %s",
3945 array(
'timestamp',
'integer',
'integer'),
3946 array(strftime(
"%Y-%m-%d %H:%M:%S"), time(), $times_id)
3963 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_solutions WHERE active_fi = %s AND pass = %s GROUP BY question_fi",
3964 array(
'integer',
'integer'),
3965 array($active_id, 0)
3970 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_solutions WHERE active_fi = %s AND pass = %s GROUP BY question_fi",
3971 array(
'integer',
'integer'),
3972 array($active_id,
$pass)
3975 $result_array = array();
3978 array_push($result_array,
$row[
"question_fi"]);
3980 return $result_array;
3994 return ((($currentpass > 0) && ($num == 0)) || $this->
isTestFinished($active_id)) ?
true :
false;
4008 $result_array = array();
4013 if (count($this->questions) == 0)
return $result_array;
4018 $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'),
4019 array(
'integer',
'integer'),
4020 array($active_id,
$pass)
4025 if (count($this->questions) == 0)
return $result_array;
4026 $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'));
4030 $result_array[
$row[
"question_id"]] =
$row;
4032 return $result_array;
4048 if (!$user_id) $user_id = $ilUser->getId();
4051 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
4052 array(
'integer',
'integer',
'text'),
4056 else if (strlen($anonymous_id))
4058 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
4059 array(
'integer',
'integer',
'text'),
4060 array($user_id, $this->test_id, $anonymous_id)
4065 if (
$_SESSION[
"AccountId"] == ANONYMOUS_USER_ID)
4069 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s",
4070 array(
'integer',
'integer'),
4071 array($user_id, $this->test_id)
4077 return $row[
"active_id"];
4099 $user_id = $ilUser->id;
4105 $result = $ilDB->queryF(
"SELECT tst_active.active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s",
4106 array(
'integer',
'integer'),
4112 return $row[
"active_id"];
4128 $keys = array_keys($array);
4131 foreach ($keys as
$key)
4154 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
4156 $sequence = array();
4157 if ($ordered_sequence)
4165 $arrResults = array();
4166 $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",
4167 array(
'integer',
'integer'),
4168 array($active_id,
$pass)
4170 while (
$row = $ilDB->fetchAssoc($solutionresult))
4172 $arrResults[
$row[
'question_fi']] =
$row;
4175 require_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
4176 $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'));
4178 $unordered = array();
4184 $percentvalue = (
$row[
'points']) ? $arrResults[
$row[
'question_id']][
'reached'] /
$row[
'points'] : 0;
4185 if ($percentvalue < 0) $percentvalue = 0.0;
4189 "max" => round(
$row[
'points'], 2),
4190 "reached" => round($arrResults[
$row[
'question_id']][
'reached'],2),
4191 "percent" => sprintf(
"%2.2f ", ($percentvalue) * 100) .
"%",
4193 "type" => $row[
"type_tag"],
4194 "qid" => $row[
'question_id'],
4195 "original_id" => $row[
"original_id"],
4196 "workedthrough" => ($arrResults[$row[
'question_id']][
'workedthru']) ? 1 : 0
4198 $pass_max += round($row[
'points'], 2);
4199 $pass_reached += round($arrResults[$row[
'question_id']][
'reached'], 2);
4200 $unordered[$row[
'question_id']] =
$data;
4204 foreach ($sequence as $qid)
4206 $unordered[$qid][
'nr'] =
$key;
4207 array_push($found, $unordered[$qid]);
4213 if (
$results[
'reached_points'] < 0)
4217 if ($pass_reached < 0) $pass_reached = 0;
4219 $found[
'pass'][
'total_max_points'] = $pass_max;
4220 $found[
'pass'][
'total_reached_points'] = $pass_reached;
4221 $found[
'pass'][
'percent'] = ($pass_max > 0) ? $pass_reached / $pass_max : 0;
4222 $found[
"test"][
"total_max_points"] =
$results[
'max_points'];
4223 $found[
"test"][
"total_reached_points"] =
$results[
'reached_points'];
4224 $found[
"test"][
"result_pass"] =
$results[
'pass'];
4225 if ((!$total_reached_points) or (!$total_max_points))
4231 $percentage = ($total_reached_points / $total_max_points) * 100.0;
4232 if ($percentage < 0) $percentage = 0.0;
4234 $found[
"test"][
"passed"] =
$results[
'passed'];
4248 $result = $ilDB->queryF(
"SELECT COUNT(active_id) total FROM tst_active WHERE test_fi = %s",
4253 return $row[
"total"];
4266 $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",
4267 array(
'integer',
'integer'),
4273 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4274 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4275 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4276 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4277 $time += ($epoch_2 - $epoch_1);
4304 $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",
4312 if (!array_key_exists(
$row[
"active_fi"], $times))
4314 $times[
$row[
"active_fi"]] = 0;
4316 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4317 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4318 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4319 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4320 $times[
$row[
"active_fi"]] += ($epoch_2 - $epoch_1);
4335 $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",
4336 array(
'integer',
'integer'),
4342 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4343 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4344 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4345 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4346 $time += ($epoch_2 - $epoch_1);
4361 $result = $ilDB->queryF(
"SELECT * FROM tst_times WHERE active_fi = %s AND pass = %s ORDER BY started",
4362 array(
'integer',
'integer'),
4363 array($active_id,
$pass)
4368 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4369 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4370 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4371 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4372 $time += ($epoch_2 - $epoch_1);
4401 $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",
4402 array(
'integer',
'integer'),
4409 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4410 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4411 if ($firstvisit == 0 || $epoch_1 < $firstvisit) $firstvisit = $epoch_1;
4412 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4413 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4414 if ($epoch_2 > $lastvisit) $lastvisit = $epoch_2;
4416 return array(
"firstvisit" => $firstvisit,
"lastvisit" => $lastvisit);
4431 $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",
4440 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->started, $matches);
4441 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4442 if (!$first_visit) {
4443 $first_visit = $epoch_1;
4445 if ($epoch_1 < $first_visit) {
4446 $first_visit = $epoch_1;
4448 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->finished, $matches);
4449 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4451 $last_visit = $epoch_2;
4453 if ($epoch_2 > $last_visit) {
4454 $last_visit = $epoch_2;
4456 $times[
$row->active_fi] += ($epoch_2 - $epoch_1);
4459 foreach ($times as
$key => $value) {
4460 $max_time += $value;
4462 if ((!$test_result[
"test"][
"total_reached_points"]) or (!$test_result[
"test"][
"total_max_points"]))
4468 $percentage = ($test_result[
"test"][
"total_reached_points"] / $test_result[
"test"][
"total_max_points"]) * 100.0;
4469 if ($percentage < 0) $percentage = 0.0;
4471 $mark_obj = $this->mark_schema->getMatchingMark($percentage);
4472 $first_date = getdate($first_visit);
4473 $last_date = getdate($last_visit);
4474 $qworkedthrough = 0;
4475 foreach ($test_result as
$key => $value)
4477 if (preg_match(
"/\d+/",
$key))
4479 $qworkedthrough += $value[
"workedthrough"];
4482 if (!$qworkedthrough)
4488 $atimeofwork = $max_time / $qworkedthrough;
4494 $result_mark = $mark_obj->getShortName();
4495 if ($mark_obj->getPassed())
4504 $percent_worked_through = 0;
4505 if (count($this->questions))
4507 $percent_worked_through = $qworkedthrough / count($this->questions);
4509 $result_array = array(
4510 "qworkedthrough" => $qworkedthrough,
4511 "qmax" => count($this->questions),
4512 "pworkedthrough" => $percent_worked_through,
4513 "timeofwork" => $max_time,
4514 "atimeofwork" => $atimeofwork,
4515 "firstvisit" => $first_date,
4516 "lastvisit" => $last_date,
4517 "resultspoints" => $test_result[
"test"][
"total_reached_points"],
4518 "maxpoints" => $test_result[
"test"][
"total_max_points"],
4519 "resultsmarks" => $result_mark,
4520 "passed" => $passed,
4521 "distancemedian" =>
"0"
4523 foreach ($test_result as
$key => $value)
4525 if (preg_match(
"/\d+/",
$key))
4527 $result_array[
$key] = $value;
4530 return $result_array;
4542 $totalpoints_array = array();
4544 foreach ($all_users as $active_id => $user_name)
4547 $reached = $test_result[
"test"][
"total_reached_points"];
4548 $total = $test_result[
"test"][
"total_max_points"];
4550 $mark = $this->mark_schema->getMatchingMark($percentage*100.0);
4553 if ($mark->getPassed())
4555 array_push($totalpoints_array, $test_result[
"test"][
"total_reached_points"]);
4559 return $totalpoints_array;
4571 $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",
4575 $persons_array = array();
4578 $name = $this->lng->txt(
"unknown");
4579 $fullname = $this->lng->txt(
"unknown");
4583 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
4585 $name = $this->lng->txt(
"deleted_user");
4586 $fullname = $this->lng->txt(
"deleted_user");
4587 $login = $this->lng->txt(
"unknown");
4592 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4594 $name = $this->lng->txt(
"unknown");
4595 $fullname = $this->lng->txt(
"unknown");
4599 $name = trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]);
4600 $fullname = trim($row[
"title"] .
" " . $row[
"firstname"] .
" " . $row[
"lastname"]);
4604 $persons_array[
$row[
"active_id"]] = array(
4606 "fullname" => $fullname,
4610 return $persons_array;
4622 $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),
4626 $persons_array = array();
4631 $persons_array[
$row[
"active_id"]] = $this->lng->txt(
"unknown");
4635 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
4637 $persons_array[$row[
"active_id"]] = $this->lng->txt(
"deleted_user");
4641 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4643 $persons_array[$row[
"active_id"]] = $row[
"lastname"];
4647 $persons_array[$row[
"active_id"]] = trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]);
4652 return $persons_array;
4664 $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),
4668 $persons_array = array();
4673 $persons_array[
$row[
"active_id"]] = array(
"name" => $this->lng->txt(
"unknown"));
4677 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
4679 $persons_array[$row[
"active_id"]] = array(
"name" => $this->lng->txt(
"deleted_user"));
4683 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4685 $persons_array[$row[
"active_id"]] = array(
"name" => $row[
"lastname"]);
4689 $persons_array[$row[
"active_id"]] = array(
"name" => trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]),
"login" => $row[
"login"]);
4694 return $persons_array;
4707 $result = $ilDB->queryF(
"SELECT COUNT(active_id) total FROM tst_active WHERE test_fi = %s AND submitted = %s",
4708 array(
'integer',
'integer'),
4712 return $row[
"total"];
4727 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, " .
4728 "tst_test_rnd_qst.pass, qpl_questions.points " .
4729 "FROM tst_test_rnd_qst, qpl_questions " .
4730 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
4731 "AND tst_test_rnd_qst.active_fi = %s ORDER BY tst_test_rnd_qst.sequence",
4738 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4739 "qpl_questions.points " .
4740 "FROM tst_test_question, tst_active, qpl_questions " .
4741 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4742 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi",
4752 array_push($qtest,
$row);
4770 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, " .
4771 "qpl_questions.points " .
4772 "FROM tst_test_rnd_qst, qpl_questions " .
4773 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
4774 "AND tst_test_rnd_qst.active_fi = %s AND tst_test_rnd_qst.pass = %s " .
4775 "ORDER BY tst_test_rnd_qst.sequence",
4776 array(
'integer',
'integer'),
4777 array($active_id,
$pass)
4782 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4783 "qpl_questions.points " .
4784 "FROM tst_test_question, tst_active, qpl_questions " .
4785 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4786 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi",
4796 array_push($qpass,
$row);
4805 include_once
"./Modules/Test/classes/class.ilTestEvaluationPassData.php";
4806 include_once
"./Modules/Test/classes/class.ilTestEvaluationUserData.php";
4807 include_once
"./Modules/Test/classes/class.ilTestEvaluationData.php";
4809 $result = $ilDB->queryF(
"SELECT tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
4810 "qpl_questions.points maxpoints " .
4811 "FROM tst_test_result, qpl_questions, tst_active " .
4812 "WHERE tst_active.active_id = tst_test_result.active_fi " .
4813 "AND qpl_questions.question_id = tst_test_result.question_fi " .
4814 "AND tst_active.test_fi = %s " .
4815 "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
4824 $data->getParticipant(
$row[
"active_fi"])->getPass(
$row[
"pass"])->addAnsweredQuestion(
$row[
"original_id"] ?
$row[
"original_id"] :
$row[
"question_fi"], $row[
"maxpoints"], $row[
"points"]);
4827 foreach (array_keys(
$data->getParticipants()) as $active_id)
4831 for ($testpass = 0; $testpass <=
$data->getParticipant($active_id)->getLastPass(); $testpass++)
4834 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, qpl_questions.original_id, " .
4835 "tst_test_rnd_qst.pass, qpl_questions.points, qpl_questions.title " .
4836 "FROM tst_test_rnd_qst, qpl_questions " .
4837 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
4838 "AND tst_test_rnd_qst.pass = %s " .
4839 "AND tst_test_rnd_qst.active_fi = %s ORDER BY tst_test_rnd_qst.sequence",
4840 array(
'integer',
'integer'),
4841 array($testpass, $active_id)
4847 $tpass = array_key_exists(
"pass",
$row) ?
$row[
"pass"] : 0;
4848 $data->getParticipant($active_id)->addQuestion(
$row[
"original_id"] ?
$row[
"original_id"] :
$row[
"question_fi"], $row[
"question_fi"], $row[
"points"], $row[
"sequence"], $tpass);
4849 $data->addQuestionTitle($row[
"original_id"] ? $row[
"original_id"] : $row[
"question_fi"], $row[
"title"]);
4856 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4857 "qpl_questions.points, qpl_questions.title, qpl_questions.original_id " .
4858 "FROM tst_test_question, tst_active, qpl_questions " .
4859 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4860 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi ORDER BY tst_test_question.sequence",
4866 $questionsbysequence = array();
4869 $questionsbysequence[
$row[
"sequence"]] =
$row;
4871 $seqresult = $ilDB->queryF(
"SELECT * FROM tst_sequence WHERE active_fi = %s",
4875 while ($seqrow = $ilDB->fetchAssoc($seqresult))
4877 $questionsequence = unserialize($seqrow[
"sequence"]);
4878 foreach ($questionsequence as $sidx => $seq)
4880 $qsid = $questionsbysequence[$seq][
"original_id"] ? $questionsbysequence[$seq][
"original_id"] : $questionsbysequence[$seq][
"question_fi"];
4881 $data->getParticipant($active_id)->addQuestion($qsid, $questionsbysequence[$seq][
"question_fi"], $questionsbysequence[$seq][
"points"], $sidx + 1, $seqrow[
"pass"]);
4882 $data->addQuestionTitle($qsid, $questionsbysequence[$seq][
"title"]);
4889 if ($this->ects_output)
4893 foreach (array_keys(
$data->getParticipants()) as $active_id)
4895 $percentage =
$data->getParticipant($active_id)->getReachedPointsInPercent();
4896 $mark = $this->mark_schema->getMatchingMark($percentage);
4897 if (is_object($mark))
4899 $data->getParticipant($active_id)->setMark($mark->getShortName());
4900 $data->getParticipant($active_id)->setMarkOfficial($mark->getOfficialName());
4901 $data->getParticipant($active_id)->setPassed($mark->getPassed());
4903 if ($this->ects_output)
4905 $ects_mark = $this->
getECTSGrade($passed_array,
$data->getParticipant($active_id)->getReached(),
$data->getParticipant($active_id)->getMaxPoints());
4906 $data->getParticipant($active_id)->setECTSMark($ects_mark);
4909 $data->getParticipant($active_id)->setFirstVisit($visitingTime[
"firstvisit"]);
4910 $data->getParticipant($active_id)->setLastVisit($visitingTime[
"lastvisit"]);
4921 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.pass, COUNT(tst_test_rnd_qst.question_fi) qcount, " .
4922 "SUM(qpl_questions.points) qsum FROM tst_test_rnd_qst, qpl_questions " .
4923 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id AND " .
4924 "tst_test_rnd_qst.active_fi = %s and pass = %s GROUP BY tst_test_rnd_qst.active_fi, " .
4925 "tst_test_rnd_qst.pass",
4926 array(
'integer',
'integer'),
4927 array($active_id,
$pass)
4932 $result = $ilDB->queryF(
"SELECT COUNT(tst_test_question.question_fi) qcount, " .
4933 "SUM(qpl_questions.points) qsum FROM tst_test_question, qpl_questions, tst_active " .
4934 "WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = tst_active.test_fi AND " .
4935 "tst_active.active_id = %s GROUP BY tst_test_question.test_fi",
4943 return array(
"count" =>
$row[
"qcount"],
"points" =>
$row[
"qsum"]);
4947 return array(
"count" => 0,
"points" => 0);
4953 include_once
"./Modules/Test/classes/class.ilTestEvaluationData.php";
4954 include_once
"./Modules/Test/classes/class.ilTestEvaluationPassData.php";
4955 include_once
"./Modules/Test/classes/class.ilTestEvaluationUserData.php";
4957 if ($withStatistics)
4959 $data->calculateStatistics();
4961 $data->setFilter($filterby, $filtertext);
4986 $result = $ilDB->queryF(
"SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
4987 "tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
4988 "qpl_questions.points maxpoints " .
4989 "FROM tst_test_result, qpl_questions, tst_active " .
4990 "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
4991 "WHERE tst_active.active_id = tst_test_result.active_fi " .
4992 "AND qpl_questions.question_id = tst_test_result.question_fi " .
4993 "AND tst_active.test_fi = %s " .
4994 "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
4998 $overview = array();
5001 if (!array_key_exists(
$row[
"active_fi"], $overview))
5003 $overview[
$row[
"active_fi"]] = array();
5004 $overview[$row[
"active_fi"]][
"firstname"] = $row[
"firstname"];
5005 $overview[$row[
"active_fi"]][
"lastname"] = $row[
"lastname"];
5006 $overview[$row[
"active_fi"]][
"title"] = $row[
"title"];
5007 $overview[$row[
"active_fi"]][
"login"] = $row[
"login"];
5008 $overview[$row[
"active_fi"]][
"usr_id"] = $row[
"usr_id"];
5009 $overview[$row[
"active_fi"]][
"started"] = $row[
"started"];
5010 $overview[$row[
"active_fi"]][
"finished"] = $row[
"finished"];
5012 if (!array_key_exists(
$row[
"pass"], $overview[
$row[
"active_fi"]]))
5014 $overview[$row[
"active_fi"]][$row[
"pass"]] = array();
5015 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] = 0;
5016 $overview[$row[
"active_fi"]][$row[
"pass"]][
"maxpoints"] = $row[
"maxpoints"];
5018 array_push($overview[$row[
"active_fi"]][$row[
"pass"]], $row);
5019 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] += $row[
"points"];
5035 $result = $ilDB->queryF(
"SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
5036 "tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
5037 "qpl_questions.points maxpoints " .
5038 "FROM tst_test_result, qpl_questions, tst_active " .
5039 "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
5040 "WHERE tst_active.active_id = tst_test_result.active_fi " .
5041 "AND qpl_questions.question_id = tst_test_result.question_fi " .
5042 "AND tst_active.test_fi = %s AND tst_active.active_id = %s" .
5043 "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
5044 array(
'integer',
'integer'),
5047 $overview = array();
5050 if (!array_key_exists(
$row[
"active_fi"], $overview))
5052 $overview[
$row[
"active_fi"]] = array();
5053 $overview[$row[
"active_fi"]][
"firstname"] = $row[
"firstname"];
5054 $overview[$row[
"active_fi"]][
"lastname"] = $row[
"lastname"];
5055 $overview[$row[
"active_fi"]][
"title"] = $row[
"title"];
5056 $overview[$row[
"active_fi"]][
"login"] = $row[
"login"];
5057 $overview[$row[
"active_fi"]][
"usr_id"] = $row[
"usr_id"];
5058 $overview[$row[
"active_fi"]][
"started"] = $row[
"started"];
5059 $overview[$row[
"active_fi"]][
"finished"] = $row[
"finished"];
5061 if (!array_key_exists(
$row[
"pass"], $overview[
$row[
"active_fi"]]))
5063 $overview[$row[
"active_fi"]][$row[
"pass"]] = array();
5064 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] = 0;
5065 $overview[$row[
"active_fi"]][$row[
"pass"]][
"maxpoints"] = $row[
"maxpoints"];
5067 array_push($overview[$row[
"active_fi"]][$row[
"pass"]], $row);
5068 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] += $row[
"points"];
5087 if (strlen($firstname.$lastname.$title) == 0)
5089 $name = $this->lng->txt(
"deleted_user");
5093 if ($user_id == ANONYMOUS_USER_ID)
5099 $name = trim($lastname .
", " . $firstname .
" " .
$title);
5103 $name = $this->lng->txt(
"anonymous");
5125 if (strlen($firstname.$lastname.$title) == 0)
5127 $name = $lng->txt(
"deleted_user");
5131 if ($user_id == ANONYMOUS_USER_ID)
5137 $name = trim($lastname .
", " . $firstname .
" " .
$title);
5141 $name = $lng->txt(
"anonymous");
5157 $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",
5164 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->started, $matches);
5165 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5166 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->finished, $matches);
5167 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5168 $times[
$row->active_fi] += ($epoch_2 - $epoch_1);
5172 foreach ($times as
$key => $value)
5174 $max_time += $value;
5179 $average_time = round($max_time / $counter);
5185 return $average_time;
5194 function &
getAvailableQuestionpools($use_object_id =
false, $equal_points =
false, $could_be_offline =
false, $show_path = FALSE, $with_questioncount = FALSE, $permission =
"read")
5196 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5208 $time_in_seconds = 0;
5209 foreach ($this->questions as $question_id)
5212 $est_time = $question->getEstimatedWorkingTime();
5213 $time_in_seconds += $est_time[
"h"] * 3600 + $est_time[
"m"] * 60 + $est_time[
"s"];
5215 $hours = (int)($time_in_seconds / 3600) ;
5216 $time_in_seconds = $time_in_seconds - ($hours * 3600);
5217 $minutes = (int)($time_in_seconds / 60);
5218 $time_in_seconds = $time_in_seconds - ($minutes * 60);
5219 $result = array(
"hh" => $hours,
"mm" => $minutes,
"ss" => $time_in_seconds);
5235 foreach ($qpls as $arr) array_push($qplids, $arr[
'qpl']);
5236 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_cpy WHERE tst_fi = %s AND ' . $ilDB->in(
'qpl_fi', $qplids,
false,
'integer'),
5243 while (
$row = $ilDB->fetchAssoc(
$result)) array_push($ids,
$row[
'qst_fi']);
5244 $nr = ($nr > count($ids)) ? count($ids) : $nr;
5245 if ($nr == 0)
return array();
5246 $rand_keys = array_rand($ids, $nr);
5247 $selection = array();
5248 if (is_array($rand_keys))
5250 foreach ($rand_keys as
$key)
5252 $selection[$ids[
$key]] = $ids[
$key];
5257 $selection[$ids[$rand_keys]] = $ids[$rand_keys];
5287 $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",
5291 $original_ids = array();
5292 $paramtypes = array();
5293 $paramvalues = array();
5296 array_push($original_ids,
$row[
'original_id']);
5301 if (($questionpool == 0) && (!is_array($qpls)))
5303 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5305 if (count($available_pools))
5307 $available =
" AND " . $ilDB->in(
'obj_fi', $available_pools,
false,
'integer');
5315 $constraint_qpls =
"";
5316 $result_array = array();
5317 if ($questionpool == 0)
5319 if (is_array($qpls))
5321 if (count($qpls) > 0)
5323 $constraint_qpls =
" AND " . $ilDB->in(
'obj_fi', $qpls,
false,
'integer');
5328 $original_clause =
"";
5329 if (count($original_ids))
5331 $original_clause =
" AND " . $ilDB->in(
'question_id', $original_ids,
true,
'integer');
5334 if ($questionpool == 0)
5336 $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",
5337 array(
'integer',
'text'),
5343 $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",
5344 array(
'integer',
'integer',
'text'),
5345 array($questionpool, 0,
"1")
5348 $found_ids = array();
5351 array_push($found_ids,
$row[
'question_id']);
5353 $nr_of_questions = ($nr_of_questions > count($found_ids)) ? count($found_ids) : $nr_of_questions;
5354 if ($nr_of_questions == 0)
return array();
5355 $rand_keys = array_rand($found_ids, $nr_of_questions);
5357 if (is_array($rand_keys))
5359 foreach ($rand_keys as
$key)
5366 $result[$found_ids[$rand_keys]] = $found_ids[$rand_keys];
5379 return CLIENT_WEB_DIR .
"/assessment/" . $this->
getId() .
"/images/";
5390 include_once
"./Services/Utilities/classes/class.ilUtil.php";
5405 if ((!$question_type) and ($question_id > 0))
5409 if (!strlen($question_type))
return null;
5410 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
5412 $question_type_gui = $question_type .
"GUI";
5413 $question =
new $question_type_gui();
5414 if ($question_id > 0)
5416 $question->object->loadFromDb($question_id);
5430 if (strcmp($question_id,
"") != 0)
5432 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
5447 $this->questions = array_values($this->questions);
5448 $array_pos = array_search($target_index, $this->questions);
5449 if ($insert_mode == 0)
5451 $part1 = array_slice($this->questions, 0, $array_pos);
5452 $part2 = array_slice($this->questions, $array_pos);
5454 else if ($insert_mode == 1)
5456 $part1 = array_slice($this->questions, 0, $array_pos + 1);
5457 $part2 = array_slice($this->questions, $array_pos + 1);
5459 foreach ($move_questions as $question_id)
5461 if (!(array_search($question_id, $part1) === FALSE))
5463 unset($part1[array_search($question_id, $part1)]);
5465 if (!(array_search($question_id, $part2) === FALSE))
5467 unset($part2[array_search($question_id, $part2)]);
5470 $part1 = array_values($part1);
5471 $part2 = array_values($part2);
5472 $new_array = array_values(array_merge($part1, $move_questions, $part2));
5473 $this->questions = array();
5475 foreach ($new_array as $question_id)
5477 $this->questions[$counter] = $question_id;
5495 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartingTime(), $matches))
5497 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5499 if ($now < $epoch_time)
5520 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndingTime(), $matches))
5522 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5524 if ($now > $epoch_time)
5544 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5547 if (count($available_pools))
5549 $available =
" AND " . $ilDB->in(
'qpl_questions.obj_fi', $available_pools,
false,
'integer');
5557 $available .=
" AND qpl_questions.complete = " . $ilDB->quote(
"1",
'text');
5561 if (is_array($arrFilter))
5563 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
5565 $where .=
" AND " . $ilDB->like(
'qpl_questions.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
5567 if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description']))
5569 $where .=
" AND " . $ilDB->like(
'qpl_questions.description',
'text',
"%%" . $arrFilter[
'description'] .
"%%");
5571 if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author']))
5573 $where .=
" AND " . $ilDB->like(
'qpl_questions.author',
'text',
"%%" . $arrFilter[
'author'] .
"%%");
5575 if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type']))
5577 $where .=
" AND qpl_qst_type.type_tag = " . $ilDB->quote($arrFilter[
'type'],
'text');
5579 if (array_key_exists(
'qpl', $arrFilter) && strlen($arrFilter[
'qpl']))
5581 $where .=
" AND " . $ilDB->like(
'object_data.title',
'text',
"%%" . $arrFilter[
'qpl'] .
"%%");
5586 $original_clause =
" qpl_questions.original_id IS NULL";
5587 if (count($original_ids))
5589 $original_clause =
" qpl_questions.original_id IS NULL AND " . $ilDB->in(
'qpl_questions.question_id', $original_ids,
true,
'integer');
5592 $query_result = $ilDB->query(
5593 "SELECT qpl_questions.*, qpl_questions.tstamp, qpl_qst_type.type_tag, qpl_qst_type.plugin, object_data.title qpl " .
5594 "FROM qpl_questions, qpl_qst_type, object_data WHERE $original_clause $available AND " .
5595 "object_data.obj_id = qpl_questions.obj_fi AND qpl_questions.tstamp > 0 AND " .
5596 "qpl_questions.question_type_fi = qpl_qst_type.question_type_id$where");
5599 if ($query_result->numRows())
5601 while (
$row = $ilDB->fetchAssoc($query_result))
5603 $row[
'ttype'] = $types[
$row[
'type_tag']];
5608 array_push($rows, $row);
5613 array_push($rows, $row);
5625 global $ilPluginAdmin;
5627 $lng->loadLanguageModule(
"assessment");
5628 $result = $ilDB->query(
"SELECT * FROM qpl_qst_type");
5632 if (
$row[
"plugin"] == 0)
5634 $types[
$row[
'type_tag']] = $lng->txt($row[
"type_tag"]);
5638 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
5639 foreach ($pl_names as $pl_name)
5642 if (strcmp($pl->getQuestionType(),
$row[
"type_tag"]) == 0)
5644 $types[
$row[
'type_tag']] = $pl->getQuestionTypeTranslation();
5664 $this->
setTitle($assessment->getTitle());
5666 foreach ($assessment->objectives as $objectives)
5668 foreach ($objectives->materials as $material)
5673 if ($assessment->getPresentationMaterial())
5678 foreach ($assessment->assessmentcontrol as $assessmentcontrol)
5680 switch ($assessmentcontrol->getSolutionswitch())
5691 foreach ($assessment->qtimetadata as
$metadata)
5693 switch ($metadata[
"label"])
5697 $type = $metadata[
"entry"];
5718 case "sequence_settings":
5728 $this->
setKiosk($metadata[
"entry"]);
5730 case "showfinalstatement":
5742 case "hide_previous_results":
5743 if ($metadata[
"entry"] == 0)
5752 case "use_previous_answers":
5755 case "answer_feedback":
5758 case "hide_title_points":
5761 case "title_output":
5767 case "random_question_count":
5770 case "results_presentation":
5773 case "reset_processing_time":
5776 case "instant_verification":
5779 case "answer_feedback_points":
5791 case "fixed_participants":
5794 case "score_reporting":
5797 case "shuffle_questions":
5800 case "count_system":
5806 case "mailnotification":
5809 case "score_cutting":
5815 case "allowedUsers":
5818 case "allowedUsersTimeGap":
5821 case "pass_scoring":
5824 case "show_summary":
5827 case "reporting_date":
5828 $iso8601period = $metadata[
"entry"];
5829 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
5831 $this->
setReportingDate(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
5834 case "processing_time":
5837 case "starting_time":
5838 $iso8601period = $metadata[
"entry"];
5839 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
5841 $this->
setStartingTime(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
5845 $iso8601period = $metadata[
"entry"];
5846 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
5848 $this->
setEndingTime(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
5852 if (preg_match(
"/mark_step_\d+/", $metadata[
"label"]))
5854 $xmlmark = $metadata[
"entry"];
5855 preg_match(
"/<short>(.*?)<\/short>/", $xmlmark, $matches);
5856 $mark_short = $matches[1];
5857 preg_match(
"/<official>(.*?)<\/official>/", $xmlmark, $matches);
5858 $mark_official = $matches[1];
5859 preg_match(
"/<percentage>(.*?)<\/percentage>/", $xmlmark, $matches);
5860 $mark_percentage = $matches[1];
5861 preg_match(
"/<passed>(.*?)<\/passed>/", $xmlmark, $matches);
5862 $mark_passed = $matches[1];
5863 $this->mark_schema->addMarkStep($mark_short, $mark_official, $mark_percentage, $mark_passed);
5867 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
5869 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
5870 include_once
"./Services/RTE/classes/class.ilRTE.php";
5871 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5872 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
5875 if (file_exists($importfile))
5885 $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
5900 include_once(
"./classes/class.ilXmlWriter.php");
5904 $a_xml_writer->xmlSetDtdDef(
"<!DOCTYPE questestinterop SYSTEM \"ims_qtiasiv1p2p1.dtd\">");
5905 $a_xml_writer->xmlStartTag(
"questestinterop");
5908 "ident" =>
"il_".IL_INST_ID.
"_tst_".$this->getTestId(),
5911 $a_xml_writer->xmlStartTag(
"assessment", $attrs);
5913 $a_xml_writer->xmlElement(
"qticomment", NULL, $this->
getDescription());
5916 if ($this->enable_processing_time)
5918 preg_match(
"/(\d+):(\d+):(\d+)/", $this->processing_time, $matches);
5919 $a_xml_writer->xmlElement(
"duration", NULL, sprintf(
"P0Y0M0DT%dH%dM%dS", $matches[1], $matches[2], $matches[3]));
5923 $a_xml_writer->xmlStartTag(
"qtimetadata");
5924 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5925 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ILIAS_VERSION");
5926 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->ilias->getSetting(
"ilias_version"));
5927 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5930 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5931 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"anonymity");
5932 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getAnonymity()));
5933 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5936 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5937 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"random_test");
5938 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
isRandomTest()));
5939 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5942 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5943 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"sequence_settings");
5945 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5948 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5949 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"author");
5950 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getAuthor());
5951 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5954 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5955 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"reset_processing_time");
5957 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5960 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5961 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"count_system");
5962 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getCountSystem());
5963 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5966 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5967 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mc_scoring");
5968 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getMCScoring());
5969 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5972 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5973 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"score_cutting");
5974 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getScoreCutting());
5975 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5978 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5979 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"password");
5980 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getPassword());
5981 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5984 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5985 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"allowedUsers");
5986 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getAllowedUsers());
5987 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5990 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5991 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"allowedUsersTimeGap");
5993 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5996 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5997 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"pass_scoring");
5998 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getPassScoring());
5999 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6004 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6005 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"reporting_date");
6006 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->reporting_date, $matches);
6007 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
6008 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6011 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6012 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"nr_of_tries");
6013 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getNrOfTries()));
6014 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6017 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6018 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"kiosk");
6019 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getKiosk()));
6020 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6023 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6024 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"use_previous_answers");
6026 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6029 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6030 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"title_output");
6031 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getTitleOutput()));
6032 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6035 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6036 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"random_question_count");
6038 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6041 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6042 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"results_presentation");
6044 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6047 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6048 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"show_summary");
6050 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6053 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6054 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"score_reporting");
6055 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getScoreReporting()));
6056 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6059 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6060 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"instant_verification");
6062 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6065 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6066 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"answer_feedback");
6067 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getAnswerFeedback()));
6068 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6071 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6072 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"answer_feedback_points");
6074 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6077 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6078 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"show_cancel");
6079 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShowCancel()));
6080 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6083 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6084 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"show_marker");
6085 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShowMarker()));
6086 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6089 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6090 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"fixed_participants");
6092 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6095 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6096 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"showfinalstatement");
6097 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getShowFinalStatement()) ?
"1" :
"0")));
6098 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6101 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6102 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"showinfo");
6103 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getShowInfo()) ?
"1" :
"0")));
6104 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6107 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6108 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mailnotification");
6110 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6113 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6114 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"forcejs");
6115 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getForceJS()) ?
"1" :
"0")));
6116 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6119 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6120 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"customstyle");
6121 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getCustomStyle());
6122 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6125 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6126 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"shuffle_questions");
6127 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShuffleQuestions()));
6128 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6131 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6132 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"processing_time");
6134 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6139 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6140 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"starting_time");
6141 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->starting_time, $matches);
6142 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
6143 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6148 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6149 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ending_time");
6150 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->ending_time, $matches);
6151 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
6152 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6154 foreach ($this->mark_schema->mark_steps as $index => $mark)
6157 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6158 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mark_step_$index");
6159 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"<short>%s</short><official>%s</official><percentage>%.2f</percentage><passed>%d</passed>", $mark->getShortName(), $mark->getOfficialName(), $mark->getMinimumLevel(), $mark->getPassed()));
6160 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6162 $a_xml_writer->xmlEndTag(
"qtimetadata");
6165 $a_xml_writer->xmlStartTag(
"objectives");
6167 $a_xml_writer->xmlEndTag(
"objectives");
6173 "solutionswitch" =>
"Yes"
6180 $a_xml_writer->xmlElement(
"assessmentcontrol", $attrs, NULL);
6185 $a_xml_writer->xmlStartTag(
"presentation_material");
6186 $a_xml_writer->xmlStartTag(
"flow_mat");
6188 $a_xml_writer->xmlEndTag(
"flow_mat");
6189 $a_xml_writer->xmlEndTag(
"presentation_material");
6195 $a_xml_writer->xmlElement(
"section", $attrs, NULL);
6196 $a_xml_writer->xmlEndTag(
"assessment");
6197 $a_xml_writer->xmlEndTag(
"questestinterop");
6199 $xml = $a_xml_writer->xmlDumpMem(FALSE);
6201 foreach ($this->questions as $question_id)
6204 $qti_question = $question->toXML(
false);
6205 $qti_question = preg_replace(
"/<questestinterop>/",
"", $qti_question);
6206 $qti_question = preg_replace(
"/<\/questestinterop>/",
"", $qti_question);
6207 if (strpos($xml,
"</section>") !==
false)
6209 $xml = str_replace(
"</section>",
"$qti_question</section>", $xml);
6213 $xml = str_replace(
"<section ident=\"1\"/>",
"<section ident=\"1\">\n$qti_question</section>", $xml);
6229 $this->mob_ids = array();
6230 $this->file_ids = array();
6233 $attrs[
"Type"] =
"Test";
6234 $a_xml_writer->xmlStartTag(
"ContentObject", $attrs);
6240 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Page Objects");
6241 $ilBench->start(
"ContentObjectExport",
"exportPageObjects");
6243 $ilBench->stop(
"ContentObjectExport",
"exportPageObjects");
6244 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Page Objects");
6247 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Media Objects");
6248 $ilBench->start(
"ContentObjectExport",
"exportMediaObjects");
6250 $ilBench->stop(
"ContentObjectExport",
"exportMediaObjects");
6251 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Media Objects");
6254 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export File Items");
6255 $ilBench->start(
"ContentObjectExport",
"exportFileItems");
6257 $ilBench->stop(
"ContentObjectExport",
"exportFileItems");
6258 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export File Items");
6260 $a_xml_writer->xmlEndTag(
"ContentObject");
6271 include_once
"./Services/MetaData/classes/class.ilMD2XML.php";
6273 $md2xml->setExportMode(
true);
6274 $md2xml->startExport();
6275 $a_xml_writer->appendXML($md2xml->getXML());
6285 if ($a_tag ==
"Identifier" && $a_param ==
"Entry")
6287 include_once
"./Services/Utilities/classes/class.ilUtil.php";
6305 include_once
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
6307 foreach ($this->questions as $question_id)
6309 $ilBench->start(
"ContentObjectExport",
"exportPageObject");
6310 $expLog->write(date(
"[y-m-d H:i:s] ").
"Page Object ".$question_id);
6313 $a_xml_writer->xmlStartTag(
"PageObject", $attrs);
6317 $ilBench->start(
"ContentObjectExport",
"exportPageObject_XML");
6319 $page_object->buildDom();
6320 $page_object->insertInstIntoIDs($a_inst);
6321 $mob_ids = $page_object->collectMediaObjects(
false);
6322 $file_ids = $page_object->collectFileItems();
6323 $xml = $page_object->getXMLFromDom(
false,
false,
false,
"",
true);
6324 $xml = str_replace(
"&",
"&", $xml);
6325 $a_xml_writer->appendXML($xml);
6326 $page_object->freeDom();
6327 unset ($page_object);
6329 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_XML");
6332 $ilBench->start(
"ContentObjectExport",
"exportPageObject_CollectMedia");
6334 foreach($mob_ids as $mob_id)
6336 $this->mob_ids[$mob_id] = $mob_id;
6338 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_CollectMedia");
6341 $ilBench->start(
"ContentObjectExport",
"exportPageObject_CollectFileItems");
6343 foreach($file_ids as $file_id)
6345 $this->file_ids[$file_id] = $file_id;
6347 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_CollectFileItems");
6349 $a_xml_writer->xmlEndTag(
"PageObject");
6352 $ilBench->stop(
"ContentObjectExport",
"exportPageObject");
6366 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
6368 foreach ($this->mob_ids as $mob_id)
6370 $expLog->write(date(
"[y-m-d H:i:s] ").
"Media Object ".$mob_id);
6374 $media_obj->exportXML($a_xml_writer, $a_inst);
6375 $media_obj->exportFiles($a_target_dir);
6387 include_once
"./Modules/File/classes/class.ilObjFile.php";
6389 foreach ($this->file_ids as $file_id)
6391 $expLog->write(date(
"[y-m-d H:i:s] ").
"File Item ".$file_id);
6392 $file_obj =
new ilObjFile($file_id,
false);
6393 $file_obj->export($a_target_dir);
6404 if (!is_array($this->import_mapping))
6410 return $this->import_mapping;
6425 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);
6436 function _getECTSGrade($points_passed, $reached_points, $max_points, $a, $b, $c,
$d, $e, $fx)
6438 include_once
"./classes/class.ilStatistics.php";
6441 $passed_statistics->setData($points_passed);
6442 $ects_percentiles = array
6444 "A" => $passed_statistics->quantile($a),
6445 "B" => $passed_statistics->quantile($b),
6446 "C" => $passed_statistics->quantile($c),
6447 "D" => $passed_statistics->quantile(
$d),
6448 "E" => $passed_statistics->quantile($e)
6450 if (count($points_passed) && ($reached_points >= $ects_percentiles[
"A"]))
6454 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"B"]))
6458 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"C"]))
6462 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"D"]))
6466 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"E"]))
6470 else if (strcmp($fx,
"") != 0)
6472 if ($max_points > 0)
6474 $percentage = ($reached_points / $max_points) * 100.0;
6475 if ($percentage < 0) $percentage = 0.0;
6481 if ($percentage >= $fx)
6498 return $this->mark_schema->checkMarks();
6530 $md_life =& $md->getLifecycle();
6533 if (strlen($a_author) == 0)
6536 $a_author = $ilUser->getFullname();
6539 $md_life =& $md->addLifecycle();
6541 $con =& $md_life->addContribute();
6542 $con->setRole(
"Author");
6544 $ent =& $con->addEntity();
6545 $ent->setEntity($a_author);
6571 include_once
"./Services/MetaData/classes/class.ilMD.php";
6573 $md_life =& $md->getLifecycle();
6576 $ids =& $md_life->getContributeIds();
6577 foreach ($ids as
$id)
6579 $md_cont =& $md_life->getContribute($id);
6580 if (strcmp($md_cont->getRole(),
"Author") == 0)
6582 $entids =& $md_cont->getEntityIds();
6583 foreach ($entids as $entid)
6585 $md_ent =& $md_cont->getEntity($entid);
6586 array_push(
$author, $md_ent->getEntity());
6604 include_once
"./Services/MetaData/classes/class.ilMD.php";
6605 $md =&
new ilMD($obj_id, 0,
"tst");
6606 $md_life =& $md->getLifecycle();
6609 $ids =& $md_life->getContributeIds();
6610 foreach ($ids as
$id)
6612 $md_cont =& $md_life->getContribute($id);
6613 if (strcmp($md_cont->getRole(),
"Author") == 0)
6615 $entids =& $md_cont->getEntityIds();
6616 foreach ($entids as $entid)
6618 $md_ent =& $md_cont->getEntity($entid);
6619 array_push(
$author, $md_ent->getEntity());
6638 $result_array = array();
6648 $result_array[$obj_id] = $titles[
$ref_id];
6656 return $result_array;
6671 $result = $ilDB->queryF(
"SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY sequence, test_random_id",
6679 $next_id = $ilDB->nextId(
'tst_test_random');
6680 $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)",
6681 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
6682 array($next_id, $new_id,
$row[
"questionpool_fi"],
$row[
"num_of_q"], time(),
$row[
'sequence'])
6748 $newObj->saveToDb();
6751 include_once
"./Services/Certificate/classes/class.ilCertificate.php";
6752 include_once
"./Modules/Test/classes/class.ilTestCertificateAdapter.php";
6755 $cert->cloneCertificate($newcert);
6759 $newObj->saveRandomQuestionCount($newObj->getRandomQuestionCount());
6764 include_once(
"./Services/CopyWizard/classes/class.ilCopyWizardOptions.php");
6768 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
6769 foreach ($this->questions as
$key => $question_id)
6772 $newObj->questions[
$key] = $question->duplicate();
6775 $question->saveToDb($original_id);
6779 $cwo->appendMapping($this->
getRefId().
'_'.$question_id,$newObj->getRefId().
'_'.$newObj->questions[
$key]);
6780 $ilLog->write(__METHOD__.
': Added mapping '.$this->getRefId().
'_'.$question_id.
' <-> ' .
6781 $newObj->getRefId().
'_'.$newObj->questions[
$key]);
6784 $newObj->saveToDb();
6805 foreach ($qpls as
$data)
6807 $maxcount += $data[
"contains"];
6809 if ($num > $maxcount) $num = $maxcount;
6814 foreach ($qpls as
$data)
6816 $add = ($data[
"count"] <= $data[
"contains"]) ? $data[
"count"] : $data[
"contains"];
6823 $num = count($this->questions);
6840 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
6850 if (
$test[
"random_test"] == 1)
6854 $result = $ilDB->queryF(
"SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY sequence, test_random_id",
6862 $countresult = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND qpl_questions.tstamp > 0 AND original_id IS NULL",
6864 $row[
"questionpool_fi"]
6866 $contains = $countresult->numRows();
6867 $qpls[$counter] = array(
6868 "index" => $counter,
6869 "count" =>
$row[
"num_of_q"],
6870 "qpl" =>
$row[
"questionpool_fi"],
6871 "contains" => $contains
6876 if (
$test[
"random_question_count"] > 0)
6878 $num =
$test[
"random_question_count"];
6880 foreach ($qpls as
$data)
6882 $maxcount += $data[
"contains"];
6884 if ($num > $maxcount) $num = $maxcount;
6889 foreach ($qpls as
$data)
6891 $add = ($data[
"count"] <= $data[
"contains"]) ? $data[
"count"] : $data[
"contains"];
6898 $result = $ilDB->queryF(
"SELECT test_question_id FROM tst_test_question WHERE test_fi = %s",
6918 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
6922 $this->questions = array();
6936 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
6940 $this->questions = array();
6956 if (strcmp($question_id,
"") != 0)
6958 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
6961 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
6976 $result = $ilDB->queryF(
"SELECT obj_fi FROM tst_tests WHERE test_id = %s",
6983 $object_id =
$row[
"obj_fi"];
6999 $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",
7006 $object_id =
$row[
"obj_fi"];
7022 $result = $ilDB->queryF(
"SELECT test_id FROM tst_tests WHERE obj_fi = %s",
7047 if (($active_id) && ($question_id))
7051 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
7054 $result = $ilDB->queryF(
"SELECT value1 FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
7055 array(
'integer',
'integer',
'integer'),
7056 array($active_id, $question_id,
$pass)
7081 $result = $ilDB->queryF(
"SELECT question_text FROM qpl_questions WHERE question_id = %s",
7104 $result_array = array();
7108 if (is_numeric($user_id))
7110 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, %s login, %s lastname, %s firstname, tst_invited_user.clientip, " .
7111 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7112 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7113 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
7115 array(
'text',
'text',
'text',
'integer',
'integer'),
7116 array(
"", $this->lng->txt(
"unknown"),
"", $this->
getTestId(), $user_id)
7121 $result = $ilDB->queryF(
"SELECT tst_active.active_id, usr_id, %s login, %s lastname, %s firstname, tst_invited_user.clientip, " .
7122 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7123 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7124 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
7126 array(
'text',
'text',
'text',
'integer'),
7127 array(
"", $this->lng->txt(
"unknown"),
"", $this->
getTestId())
7133 if (is_numeric($user_id))
7135 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
7136 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7137 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7138 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
7140 array(
'integer',
'integer'),
7146 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
7147 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7148 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7149 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
7156 $result_array = array();
7159 $result_array[
$row[
'usr_id']]=
$row;
7161 return $result_array;
7176 $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 ".
7177 "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),
7178 array(
'text',
'text',
'text',
'integer'),
7179 array(
"", $this->lng->txt(
"unknown"),
"", $this->
getTestId())
7184 $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 ".
7185 "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),
7195 foreach (
$data as $index => $participant)
7197 if (strlen(trim($participant[
"firstname"].$participant[
"lastname"])) == 0)
7199 $data[$index][
"lastname"] = $this->lng->txt(
"deleted_user");
7209 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
7211 if (count($scoring) == 0)
return array();
7214 $filtered_participants = array();
7215 foreach ($participants as $active_id => $participant)
7217 $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",
7227 if ($participant->active) $filtered_participants[$active_id] = $participant;
7230 if (!$participant->active) $filtered_participants[$active_id] = $participant;
7233 $filtered_participants[$active_id] = $participant;
7248 $assessmentSetting =
new ilSetting(
"assessment");
7249 $manscoring_done = $assessmentSetting->get(
"manscoring_done_" . $active_id);
7250 if ($manscoring_done) $filtered_participants[$active_id] = $participant;
7262 $assessmentSetting =
new ilSetting(
"assessment");
7263 $manscoring_done = $assessmentSetting->get(
"manscoring_done_" . $active_id);
7264 if (!$manscoring_done) $filtered_participants[$active_id] = $participant;
7272 if (
$row[
"manual"]) $found++;
7274 if (($found > 0) && ($found < $count)) $filtered_participants[$active_id] = $participant;
7277 $filtered_participants[$active_id] = $participant;
7282 return $filtered_participants;
7296 if (!is_array($ids) || count($ids) ==0)
return array();
7300 $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",
7301 array(
'text',
'text',
'text'),
7302 array(
"", $this->lng->txt(
"unknown"),
"")
7307 $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");
7310 $result_array = array();
7313 $result_array[
$row[
"usr_id"]]=
$row;
7315 return $result_array;
7320 if (!is_array($ids) || count($ids) ==0)
return array();
7332 if (!is_array($ids) || count($ids) ==0)
return array();
7334 foreach ($ids as $obj_id)
7350 include_once
"./Modules/Group/classes/class.ilObjGroup.php";
7352 $members = $group->getGroupMemberIds();
7353 include_once
'./Services/User/classes/class.ilObjUser.php';
7354 foreach ($members as $user_id)
7369 $members = $rbacreview->assignedUsers($role_id,
"usr_id");
7370 include_once
'./Services/User/classes/class.ilObjUser.php';
7371 foreach ($members as $user_id)
7389 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
7390 array(
'integer',
'integer'),
7405 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
7406 array(
'integer',
'integer'),
7409 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_invited_user (test_fi, user_fi, clientip, tstamp) VALUES (%s, %s, %s, %s)",
7410 array(
'integer',
'integer',
'text',
'integer'),
7411 array($this->
getTestId(), $user_id, (strlen($client_ip)) ? $client_ip : NULL, time())
7420 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_invited_user SET clientip = %s, tstamp = %s WHERE test_fi=%s and user_fi=%s",
7421 array(
'text',
'integer',
'integer',
'integer'),
7422 array((strlen($client_ip)) ? $client_ip : NULL, time(), $this->
getTestId(), $user_id)
7434 if (is_numeric($question_fi))
7436 $result = $ilDB->queryF(
"SELECT question_fi, solved FROM tst_qst_solved WHERE active_fi = %s AND question_fi=%s",
7437 array(
'integer',
'integer'),
7438 array($active_id, $question_fi)
7443 $result = $ilDB->queryF(
"SELECT question_fi, solved FROM tst_qst_solved WHERE active_fi = %s",
7448 $result_array = array();
7451 $result_array[
$row[
"question_fi"]]=
$row;
7453 return $result_array;
7465 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s AND question_fi = %s",
7466 array(
'integer',
'integer'),
7467 array($active_id, $question_id)
7469 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_qst_solved (solved, question_fi, active_fi) VALUES (%s, %s, %s)",
7470 array(
'integer',
'integer',
'integer'),
7471 array($value, $question_id, $active_id)
7483 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s, tstamp = %s WHERE test_fi = %s AND user_fi = %s",
7484 array(
'integer',
'timestamp',
'integer',
'integer',
'integer'),
7485 array(1, date(
'Y-m-d H:i:s'), time(), $this->
getTestId(), $user_id)
7487 $this->testSession = NULL;
7497 $result = $ilDB->queryF(
"SELECT submitted FROM tst_active WHERE active_id=%s AND submitted=%s",
7498 array(
'integer',
'integer'),
7499 array($active_id, 1)
7501 return $result->numRows() == 1;
7512 if (!is_numeric($user_id))
7513 $user_id = $ilUser->getId();
7515 $result = $ilDB->queryF(
"SELECT submitted FROM tst_active WHERE test_fi=%s AND user_fi=%s AND submitted=%s",
7516 array(
'integer',
'integer',
'integer'),
7519 return $result->numRows() == 1;
7553 "user_id" => $this->lng->txt(
"user_id"),
7554 "matriculation" => $this->lng->txt(
"matriculation"),
7555 "lastname" => $this->lng->txt(
"lastname"),
7556 "firstname" => $this->lng->txt(
"firstname"),
7557 "login" =>$this->lng->txt(
"login"),
7558 "reached_points" => $this->lng->txt(
"tst_reached_points"),
7559 "max_points" => $this->lng->txt(
"tst_maximum_points"),
7560 "percent_value" => $this->lng->txt(
"tst_percent_solved"),
7561 "mark" => $this->lng->txt(
"tst_mark"),
7562 "ects" => $this->lng->txt(
"ects_grade")
7565 if (count($participants))
7567 if ($this->ects_output)
7571 foreach ($participants as $active_id => $user_rec)
7574 $reached_points = 0;
7576 foreach ($this->questions as $value)
7579 if (is_object($question))
7581 $max_points += $question->getMaximumPoints();
7582 $reached_points += $question->getReachedPoints($active_id);
7585 if ($max_points > 0)
7587 $percentvalue = $reached_points / $max_points;
7588 if ($percentvalue < 0) $percentvalue = 0.0;
7594 $mark_obj = $this->mark_schema->getMatchingMark($percentvalue * 100);
7598 $mark = $mark_obj->getOfficialName();
7599 $ects_mark = $this->
getECTSGrade($passed_array, $reached_points, $max_points);
7603 $user_rec[
'firstname'] =
"";
7604 $user_rec[
'lastname'] = $this->lng->txt(
"unknown");
7607 "user_id"=>$user_rec[
'usr_id'],
7608 "matriculation" => $user_rec[
'matriculation'],
7609 "lastname" => $user_rec[
'lastname'],
7610 "firstname" => $user_rec[
'firstname'],
7611 "login"=>$user_rec[
'login'],
7612 "reached_points" => $reached_points,
7613 "max_points" => $max_points,
7614 "percent_value" => $percentvalue,
7616 "ects" => $ects_mark
7636 $resultarray = array();
7637 foreach (
$row as $rowindex => $entry)
7644 if (strpos($entry,
"\"") !== FALSE)
7646 $entry = str_replace(
"\"",
"\"\"", $entry);
7654 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
7657 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
7661 $resultarray[$rowindex] = utf8_decode($entry);
7664 return $resultarray;
7678 $result = $ilDB->queryF(
"SELECT tries FROM tst_active WHERE active_id = %s",
7685 return $row[
"tries"];
7705 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s",
7712 $max =
$row[
"maxpass"];
7733 $result = $ilDB->queryF(
"SELECT * FROM tst_pass_result WHERE active_fi = %s",
7743 if (
$row[
"points"] > $bestpoints)
7746 $bestpoints =
$row[
"points"];
7749 if (is_array($bestrow))
7751 return $bestrow[
"pass"];
7774 $counted_pass = NULL;
7783 return $counted_pass;
7801 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
7803 foreach ($this->questions as $value)
7807 $workedthrough += 1;
7810 return $workedthrough;
7826 $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",
7827 array(
'integer',
'integer'),
7828 array($active_id,
$pass)
7833 return $row[
"tstamp"];
7851 "executable" =>
true,
7852 "errormessage" =>
""
7856 $result[
"executable"] =
false;
7862 $result[
"executable"] =
false;
7891 $result[
"executable"] =
false;
7892 $result[
"errormessage"] = $this->lng->txt(
"detail_max_processing_time_reached");
7902 $result[
"executable"] =
false;
7903 $result[
"errormessage"] = $this->lng->txt(
"maximum_nr_of_tries_reached");
7909 $result[
"executable"] = FALSE;
7910 $result[
"errormessage"] = $this->lng->txt(
"maximum_nr_of_tries_reached");
7931 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getReportingDate(), $matches))
7933 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
7935 if ($now < $epoch_time)
7951 $notimeleft = FALSE;
7976 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getReportingDate(), $matches))
7978 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
7980 if ($now < $epoch_time)
8005 if ($active_id < 1)
return FALSE;
8007 $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",
8008 array(
'integer',
'integer'),
8009 array($active_id,
$pass)
8014 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches))
8016 return mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
8061 $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",
8065 $removableQuestions = array();
8066 while (
$row = $ilDB->fetchAssoc($query_result))
8068 array_push($removableQuestions,
$row);
8070 return $removableQuestions;
8081 return ($this->shuffle_questions) ? 1 : 0;
8092 $this->shuffle_questions = ($a_shuffle) ? 1 : 0;
8109 return ($this->show_summary) ? $this->show_summary : 0;
8126 $this->show_summary = $a_value;
8137 if (($this->show_summary & 1) > 0)
8157 $this->show_summary = 1;
8161 $this->show_summary = 0;
8173 if (($this->show_summary & 2) > 0)
8193 $this->show_summary = $this->show_summary | 2;
8199 $this->show_summary = $this->show_summary ^ 2;
8212 if (($this->show_summary & 4) > 0)
8232 $this->show_summary = $this->show_summary | 4;
8238 $this->show_summary = $this->show_summary ^ 4;
8251 if (($this->show_summary & 8) > 0)
8271 $this->show_summary = $this->show_summary | 8;
8277 $this->show_summary = $this->show_summary ^ 8;
8290 return ($this->results_presentation) ? $this->results_presentation : 0;
8301 if (($this->results_presentation & 1) > 0)
8319 if (($this->results_presentation & 2) > 0)
8337 if (($this->results_presentation & 4) > 0)
8355 if (($this->results_presentation & 8) > 0)
8373 if (($this->results_presentation & 16) > 0)
8391 if (($this->results_presentation & 32) > 0)
8407 if (($this->results_presentation & 64) > 0)
8425 $this->results_presentation = $a_results_presentation;
8440 $this->results_presentation = $this->results_presentation | 1;
8446 $this->results_presentation = $this->results_presentation ^ 1;
8461 $this->results_presentation = $this->results_presentation | 2;
8467 $this->results_presentation = $this->results_presentation ^ 2;
8493 $this->results_presentation = $this->results_presentation | 4;
8499 $this->results_presentation = $this->results_presentation ^ 4;
8514 $this->results_presentation = $this->results_presentation | 8;
8520 $this->results_presentation = $this->results_presentation ^ 8;
8535 $this->results_presentation = $this->results_presentation | 16;
8541 $this->results_presentation = $this->results_presentation ^ 16;
8556 $this->results_presentation = $this->results_presentation | 32;
8562 $this->results_presentation = $this->results_presentation ^ 32;
8577 $this->results_presentation = $this->results_presentation | 64;
8583 $this->results_presentation = $this->results_presentation ^ 64;
8596 $codestring =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
8599 for ($i = 1; $i <=5; $i++)
8601 $index = mt_rand(0, strlen($codestring)-1);
8602 $code .= substr($codestring, $index, 1);
8616 $result = $ilDB->queryF(
"SELECT anonymous_id FROM tst_active WHERE test_fi = %s AND anonymous_id = %s",
8617 array(
'integer',
'text'),
8620 return (
$result->numRows() > 0) ?
true :
false;
8626 $result = $ilDB->queryF(
"SELECT user_fi FROM tst_active WHERE active_id = %s",
8633 return $row[
"user_fi"];
8644 if (!is_array(
$_SESSION[
"tst_access_code"]))
8650 return $_SESSION[
"tst_access_code"][
"$id"];
8657 if (!is_array(
$_SESSION[
"tst_access_code"]))
8661 $_SESSION[
"tst_access_code"][
"$id"] = $access_code;
8667 unset(
$_SESSION[
"tst_access_code"][
"$id"]);
8672 return ($this->allowedUsers) ? $this->allowedUsers : 0;
8677 $this->allowedUsers = $a_allowed_users;
8682 return ($this->allowedUsersTimeGap) ? $this->allowedUsersTimeGap : 0;
8687 $this->allowedUsersTimeGap = $a_allowed_users_time_gap;
8696 if (($nr_of_users > 0) && ($time_gap > 0))
8699 $time_border = $now - $time_gap;
8700 $str_time_border = strftime(
"%Y%m%d%H%M%S", $time_border);
8701 $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",
8702 array(
'integer',
'integer'),
8705 if (
$result->numRows() >= $nr_of_users)
8707 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
8726 $result = $ilDB->queryF(
"SELECT finished FROM tst_times WHERE active_fi = %s ORDER BY finished DESC",
8733 return $row[
"finished"];
8747 if (preg_match(
"/<[^>]*?>/", $a_text))
8767 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
8769 $material = $a_material->getMaterial($i);
8770 if (strcmp($material[
"type"],
"mattext") == 0)
8772 $result .= $material[
"material"]->getContent();
8774 if (strcmp($material[
"type"],
"matimage") == 0)
8776 $matimage = $material[
"material"];
8777 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
8780 if (!is_array(
$_SESSION[
"import_mob_xhtml"]))
$_SESSION[
"import_mob_xhtml"] = array();
8781 array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(),
"uri" => $matimage->getUri()));
8786 $ilLog->write(print_r(
$_SESSION[
"import_mob_xhtml"],
true));
8800 include_once
"./Services/RTE/classes/class.ilRTE.php";
8801 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
8803 $a_xml_writer->xmlStartTag(
"material");
8805 "texttype" =>
"text/plain"
8807 if ($this->
isHTML($a_material))
8809 $attrs[
"texttype"] =
"text/xhtml";
8814 foreach (
$mobs as $mob)
8816 $moblabel =
"il_" . IL_INST_ID .
"_mob_" . $mob;
8817 if (strpos($a_material,
"mm_$mob") !== FALSE)
8823 "label" => $moblabel,
8824 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
8827 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
8830 $a_xml_writer->xmlEndTag(
"material");
8841 include_once
"./Services/Utilities/classes/class.ilUtil.php";
8855 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET certificate_visibility = %s, tstamp = %s WHERE test_id = %s",
8856 array(
'text',
'integer',
'integer'),
8857 array($a_value, time(), $this->
getTestId())
8869 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
8880 $this->certificate_visibility = $a_value;
8891 return ($this->anonymity) ? 1 : 0;
8905 $this->anonymity = 1;
8908 $this->anonymity = 0;
8921 return ($this->show_cancel) ? 1 : 0;
8935 $this->show_cancel = 1;
8938 $this->show_cancel = 0;
8951 return ($this->show_marker) ? 1 : 0;
8965 $this->show_marker = 1;
8968 $this->show_marker = 0;
8981 return ($this->fixed_participants) ? 1 : 0;
8995 $this->fixed_participants = 1;
8998 $this->fixed_participants = 0;
9014 $result = $ilDB->queryF(
"SELECT anonymity FROM tst_tests WHERE obj_fi = %s",
9020 return $row[
'anonymity'];
9036 $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",
9042 return $row[
'random_test'];
9059 return $this->lng->txt(
"unknown") . $suffix;
9063 include_once
'./Services/User/classes/class.ilObjUser.php';
9065 if (strlen($uname[
"firstname"].$uname[
"lastname"]) == 0) $uname[
"firstname"] = $this->lng->txt(
"deleted_user");
9068 return trim($uname[
"lastname"] .
", " . $uname[
"firstname"]) . $suffix;
9072 return trim($uname[
"firstname"] .
" " . $uname[
"lastname"]) . $suffix;
9088 return $this->lng->txt(
"tst_start_test");
9090 $active_pass = $this->
_getPass($active_id);
9094 if ($active_pass == 0)
9096 return $this->lng->txt(
"tst_start_test");
9100 return $this->lng->txt(
"tst_start_new_test_pass");
9105 return $this->lng->txt(
"tst_resume_test");
9122 $result = $ilDB->queryF(
"SELECT * FROM tst_test_defaults WHERE user_fi = %s ORDER BY $sortby $sortorder",
9124 array($ilUser->getId())
9126 $defaults = array();
9129 $defaults[
$row[
"test_defaults_id"]] =
$row;
9145 $result = $ilDB->queryF(
"SELECT * FROM tst_test_defaults WHERE test_defaults_id = %s",
9147 array($test_defaults_id)
9169 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_defaults WHERE test_defaults_id = %s",
9171 array($test_default_id)
9185 $testsettings = array(
9222 $next_id = $ilDB->nextId(
'tst_test_defaults');
9223 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_defaults (test_defaults_id, name, user_fi, defaults, marks, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
9224 array(
'integer',
'text',
'integer',
'text',
'text',
'integer'),
9225 array($next_id, $a_name, $ilUser->getId(), serialize($testsettings), serialize($this->mark_schema), time())
9244 $testsettings = unserialize($defaults[
"defaults"]);
9245 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
9246 $this->mark_schema = unserialize($defaults[
"marks"]);
9271 $this->
setKiosk($testsettings[
"Kiosk"]);
9274 $this->
setECTSFX($testsettings[
"ECTSFX"]);
9297 if (extension_loaded(
"tidy"))
9301 "output-xml" =>
true,
9302 "numeric-entities" =>
true
9306 $tidy->cleanRepair();
9307 $print_output = tidy_get_output(
$tidy);
9308 $print_output = preg_replace(
"/^.*?(<html)/",
"\\1", $print_output);
9312 $print_output = str_replace(
" ",
" ", $print_output);
9313 $print_output = str_replace(
"⊗",
"X", $print_output);
9315 $xsl = file_get_contents(
"./Modules/Test/xml/question2fo.xsl");
9316 $args = array(
'/_xml' => $print_output,
'/_xsl' => $xsl );
9333 $content = preg_replace(
"/href=\".*?\"/",
"", $content);
9334 $printbody =
new ilTemplate(
"tpl.il_as_tst_print_body.html", TRUE, TRUE,
"Modules/Test");
9336 $printbody->setVariable(
"ADM_CONTENT", $content);
9337 $printbody->setCurrentBlock(
"css_file");
9339 $printbody->parseCurrentBlock();
9340 $printbody->setCurrentBlock(
"css_file");
9342 $printbody->parseCurrentBlock();
9343 $printoutput = $printbody->get();
9344 $html = str_replace(
"href=\"./",
"href=\"" . ILIAS_HTTP_PATH .
"/", $printoutput);
9345 $html = preg_replace(
"/<div id=\"dontprint\">.*?<\\/div>/ims",
"", $html);
9346 if (extension_loaded(
"tidy"))
9350 "output-xml" =>
true,
9351 "numeric-entities" =>
true
9355 $tidy->cleanRepair();
9356 $html = tidy_get_output(
$tidy);
9357 $html = preg_replace(
"/^.*?(<html)/",
"\\1", $html);
9361 $html = str_replace(
" ",
" ", $html);
9362 $html = str_replace(
"⊗",
"X", $html);
9377 include_once
"./Services/Utilities/classes/class.ilUtil.php";
9379 $fp = fopen($fo_file,
"w"); fwrite($fp, $fo); fclose($fp);
9381 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
9391 $ilLog->write(__METHOD__.
': '.$e->getMessage());
9396 $ilLog->write(__METHOD__.
': '.$e->getMessage());
9423 $result = $ilDB->queryF(
"SELECT feedback FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s",
9424 array(
'integer',
'integer',
'integer'),
9425 array($active_id, $question_id,
$pass)
9430 include_once(
"./Services/RTE/classes/class.ilRTE.php");
9450 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s",
9451 array(
'integer',
'integer',
'integer'),
9452 array($active_id, $question_id,
$pass)
9455 if (strlen($feedback))
9457 $next_id = $ilDB->nextId(
'tst_manual_fb');
9458 $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)",
9459 array(
'integer',
'integer',
'integer',
'integer',
'text',
'integer'),
9462 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
9465 global
$lng, $ilUser;
9466 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
9468 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
9475 $ilias->raiseError(
$result->getMessage());
9493 if (strcmp(
$_GET[
"tst_javascript"],
"0") == 0)
return FALSE;
9495 $assessmentSetting =
new ilSetting(
"assessment");
9496 return ($ilUser->getPref(
"tst_javascript") === FALSE) ? $assessmentSetting->get(
"use_javascript") : $ilUser->getPref(
"tst_javascript");
9509 include_once
"./Modules/Test/classes/class.ilTestSession.php";
9527 $this->test_id = $a_id;
9539 if (is_object($this->testSession) && ($this->testSession->getActiveId() > 0))
return $this->testSession;
9543 include_once
"./Modules/Test/classes/class.ilTestSession.php";
9566 if (is_object($this->testSession) && ($this->testSession->getActiveId() > 0))
return $this->testSession;
9572 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
9574 if (!$this->testSequence->hasSequence())
9576 $this->testSequence->createNewSequence($this->
getQuestionCount(), $shuffle);
9577 $this->testSequence->saveToDb();
9583 if (is_object($this->testSequence) && ($this->testSequence->getActiveId() > 0))
return $this->testSequence;
9585 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
9586 if (($active_id > 0) && (strlen(
$pass)))
9602 foreach (
$result as $sequence => $question)
9604 if (is_numeric($sequence))
9606 if ($question[
"reached"] == $question[
"max"])
9627 if (count($participants))
9629 foreach ($participants as $active_id => $user_rec)
9632 $reached_points = 0;
9634 foreach ($this->questions as $value)
9637 if (is_object($question))
9639 $max_points += $question->getMaximumPoints();
9640 $reached_points += $question->getReachedPoints($active_id);
9641 if ($max_points > 0)
9643 $percentvalue = $reached_points / $max_points;
9644 if ($percentvalue < 0) $percentvalue = 0.0;
9652 $user_rec[
'firstname'] =
"";
9653 $user_rec[
'lastname'] = $this->lng->txt(
"unknown");
9656 "user_id"=>$user_rec[
'usr_id'],
9657 "matriculation" => $user_rec[
'matriculation'],
9658 "lastname" => $user_rec[
'lastname'],
9659 "firstname" => $user_rec[
'firstname'],
9660 "login"=>$user_rec[
'login'],
9661 "question_id" => $question->getId(),
9662 "question_title" => $question->getTitle(),
9663 "reached_points" => $reached_points,
9664 "max_points" => $max_points
9681 $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",
9685 $rec = $ilDB->fetchAssoc(
$result);
9686 return $rec[
"obj_id"];
9697 global $ilPluginAdmin;
9698 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE,
"TestQuestionPool",
"qst", $a_pname))
9715 $assessmentSetting =
new ilSetting(
"assessment");
9716 $assessmentSetting->set(
"evalFields_" . $this->
getId(), serialize($fields));
9726 $assessmentSetting =
new ilSetting(
"assessment");
9727 $found = $assessmentSetting->get(
"evalFields_" . $this->
getId());
9729 if (strlen($found)) $fields = unserialize($found);
9730 if (is_array($fields))
return $fields;
else return array();
9737 $result = $ilDB->queryF(
"SELECT passed FROM tst_result_cache WHERE active_fi = %s",
9744 return $row[
'passed'];
9749 $result_array =& $this->
getTestResult($active_id, $counted_pass);
9750 return $result_array[
"test"][
"passed"];
9763 include_once
"./Services/Certificate/classes/class.ilCertificate.php";
9764 include_once
"./Modules/Test/classes/class.ilTestCertificateAdapter.php";
9766 if ($cert->isComplete())
9813 $result = $ilDB->queryF(
"SELECT tst_test_result.active_fi, tst_test_result.question_fi, tst_test_result.pass FROM tst_test_result, tst_active, qpl_questions WHERE tst_active.active_id = tst_test_result.active_fi AND tst_active.test_fi = %s AND tst_test_result.question_fi = qpl_questions.question_id AND qpl_questions.original_id = %s",
9814 array(
'integer',
'integer'),
9817 $foundusers = array();
9820 if (!array_key_exists(
$row[
"active_fi"], $foundusers))
9822 $foundusers[
$row[
"active_fi"]] = array();
9824 array_push($foundusers[
$row[
"active_fi"]], array(
"pass" => $row[
"pass"],
"qid" => $row[
"question_fi"]));
9838 include_once
'./Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
9857 $foundParticipants =&
$data->getParticipants();
9858 $results = array(
"overview" => array(),
"questions" => array());
9859 if (count($foundParticipants))
9861 $results[
"overview"][$this->lng->txt(
"tst_eval_total_persons")] = count($foundParticipants);
9863 $results[
"overview"][$this->lng->txt(
"tst_eval_total_finished")] = $total_finished;
9865 $diff_seconds = $average_time;
9866 $diff_hours = floor($diff_seconds/3600);
9867 $diff_seconds -= $diff_hours * 3600;
9868 $diff_minutes = floor($diff_seconds/60);
9869 $diff_seconds -= $diff_minutes * 60;
9870 $results[
"overview"][$this->lng->txt(
"tst_eval_total_finished_average_time")] = sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
9872 $total_passed_reached = 0;
9873 $total_passed_max = 0;
9874 $total_passed_time = 0;
9875 foreach ($foundParticipants as $userdata)
9877 if ($userdata->getPassed())
9880 $total_passed_reached += $userdata->getReached();
9881 $total_passed_max += $userdata->getMaxpoints();
9882 $total_passed_time += $userdata->getTimeOfWork();
9885 $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
9886 $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
9887 $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
9888 $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed")] = $total_passed;
9889 $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);
9890 $average_time = $average_passed_time;
9891 $diff_seconds = $average_time;
9892 $diff_hours = floor($diff_seconds/3600);
9893 $diff_seconds -= $diff_hours * 3600;
9894 $diff_minutes = floor($diff_seconds/60);
9895 $diff_seconds -= $diff_minutes * 60;
9896 $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed_average_time")] = sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
9899 foreach (
$data->getQuestionTitles() as $question_id => $question_title)
9904 foreach ($foundParticipants as $userdata)
9906 for ($i = 0; $i <= $userdata->getLastPass(); $i++)
9908 if (is_object($userdata->getPass($i)))
9910 $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
9911 if (is_array($question))
9914 $reached += $question[
"reached"];
9915 $max += $question[
"points"];
9920 $percent = $max ? $reached/$max * 100.0 : 0;
9922 $results[
"questions"][$question_id] = array(
9924 sprintf(
"%.2f", $answered ? $reached / $answered : 0) .
" " . strtolower($this->lng->txt(
"of")) .
" " . sprintf(
"%.2f", $answered ? $max / $answered : 0),
9925 sprintf(
"%.2f", $percent) .
"%",
9927 sprintf(
"%.2f", $answered ? $reached / $answered : 0),
9928 sprintf(
"%.2f", $answered ? $max / $answered : 0),
9940 include_once(
"./Modules/Test/classes/class.ilTestExport.php");
9942 return $test_exp->buildExportFile();
9960 $this->mailnotification = $a_notification;
9965 include_once
"./Services/Mail/classes/class.ilMail.php";
9966 $mail =
new ilMail(ANONYMOUS_USER_ID);
9969 $message =
new ilTemplate(
"tpl.il_as_tst_finish_notification_simple.html", TRUE, TRUE,
"Modules/Test");
9970 $message->setVariable(
'TEXT_TEST_TITLE', $this->lng->txt(
'title'));
9971 $message->setVariable(
'VALUE_TEST_TITLE', $this->
getTitle());
9972 $message->setVariable(
'TEXT_USER_NAME', $this->lng->txt(
'username'));
9973 $message->setVariable(
'VALUE_USER_NAME', $usr_data);
9974 $message->setVariable(
'TEXT_FINISH_TIME', $this->lng->txt(
'tst_finished'));
9978 $res = $mail->sendMail(
9982 sprintf($this->lng->txt(
'tst_user_finished_test'), $this->
getTitle()),
9991 include_once
"./Services/Mail/classes/class.ilMail.php";
9992 $mail =
new ilMail(ANONYMOUS_USER_ID);
9995 $message =
new ilTemplate(
"tpl.il_as_tst_finish_notification_simple.html", TRUE, TRUE,
"Modules/Test");
9996 $message->setVariable(
'TEXT_TEST_TITLE', $this->lng->txt(
'title'));
9997 $message->setVariable(
'VALUE_TEST_TITLE', $this->
getTitle());
9998 $message->setVariable(
'TEXT_USER_NAME', $this->lng->txt(
'username'));
9999 $message->setVariable(
'VALUE_USER_NAME', $usr_data);
10000 $message->setVariable(
'TEXT_FINISH_TIME', $this->lng->txt(
'tst_finished'));
10004 include_once
"./Modules/Test/classes/class.ilTestExport.php";
10006 $file = $exportObj->exportToExcel($deliver = FALSE,
'active_id', $active_id, $passedonly = FALSE);
10007 include_once
"./classes/class.ilFileDataMail.php";
10009 $fd->copyAttachmentFile(
$file,
"result_" . $active_id .
".xls");
10010 $file_names[] =
"result_" . $active_id .
".xls";
10015 sprintf($this->lng->txt(
'tst_user_finished_test'), $this->
getTitle()),
10017 count($file_names) ? $file_names : array(),
10020 if(count($file_names))
10022 $fd->unlinkFiles($file_names);
10033 $query =
"SELECT usr_id FROM usr_data";
10037 $activequery = sprintf(
"SELECT user_fi FROM tst_active WHERE test_fi = %s AND user_fi = %s",
10038 $ilDB->quote($this->getTestId()),
10039 $ilDB->quote(
$data[
'usr_id'])
10041 $activeresult = $ilDB->query($activequery);
10042 if ($activeresult->numRows() == 0)
10044 $user_id =
$data[
'usr_id'];
10045 if ($user_id != 13)
10047 include_once
"./Modules/Test/classes/class.ilTestSession.php";
10054 $nr_of_passes = rand(1, $passes);
10058 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
10065 for ($seq = 1; $seq <= count($this->questions); $seq++)
10067 $question_id =
$testSequence->getQuestionForSequence($seq);
10071 if (
$pass < $nr_of_passes - 1)
10083 if ($number == 0)
return;
10093 $result = $ilDB->queryF(
"SELECT * FROM tst_result_cache WHERE active_fi = %s",
10099 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
10101 $result = $ilDB->queryF(
"SELECT * FROM tst_result_cache WHERE active_fi = %s",