5 include_once
"./classes/class.ilObject.php";
6 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
411 function ilObjTest($a_id = 0,$a_call_by_reference =
true)
415 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
418 $this->author = $ilUser->fullname;
419 $this->introduction =
"";
420 $this->questions = array();
423 $this->instant_verification = 0;
424 $this->answer_feedback_points = 0;
425 $this->reporting_date =
"";
426 $this->nr_of_tries = 0;
428 $this->use_previous_answers = 1;
429 $this->title_output = 0;
430 $this->starting_time =
"";
431 $this->ending_time =
"";
432 $this->processing_time =
"00:00:00";
433 $this->enable_processing_time =
"0";
434 $this->reset_processing_time = 0;
435 $this->ects_output = 0;
436 $this->ects_fx = NULL;
437 $this->random_test = 0;
438 $this->shuffle_questions = FALSE;
439 $this->mailnottype = 0;
440 $this->exportsettings = 0;
441 $this->show_summary = 8;
442 $this->random_question_count =
"";
447 $this->answer_feedback = 0;
448 $this->password =
"";
449 $this->certificate_visibility = 0;
450 $this->allowedUsers =
"";
451 $this->_showfinalstatement = FALSE;
452 $this->_finalstatement =
"";
453 $this->_showinfo = TRUE;
454 $this->_forcejs = FALSE;
455 $this->_customStyle =
"";
456 $this->allowedUsersTimeGap =
"";
457 $this->anonymity = 0;
458 $this->show_cancel = 1;
459 $this->show_marker = 0;
460 $this->fixed_participants = 0;
465 $this->testSession = FALSE;
466 $this->testSequence = FALSE;
467 $this->mailnotification = 0;
469 $lng->loadLanguageModule(
"assessment");
470 $this->mark_schema->createSimpleSchema($lng->txt(
"failed_short"), $lng->txt(
"failed_official"), 0, 0, $lng->txt(
"passed_short"), $lng->txt(
"passed_official"), 50, 1);
471 $this->ects_grades = array(
478 $this->
ilObject($a_id, $a_call_by_reference);
504 if (!parent::update())
531 function read($a_force_db =
false)
547 if (!parent::delete())
574 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s",
578 $active_array = array();
581 array_push($active_array,
$row[
"active_id"]);
584 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
589 if (count($active_array))
591 foreach ($active_array as $active_id)
593 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_times WHERE active_fi = %s",
598 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
605 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_mark WHERE test_fi = %s",
610 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s",
619 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_tests WHERE test_id = %s",
624 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
639 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
651 include_once
"./Services/Utilities/classes/class.ilUtil.php";
653 $directory = $tst_data_dir.
"/tst_".$this->
getId();
654 if (is_dir($directory))
656 include_once
"./Services/Utilities/classes/class.ilUtil.php";
659 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
665 foreach(
$mobs as $mob)
704 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
744 if ($a_node_id==
$_GET[
"ref_id"])
746 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
747 $parent_type = $parent_obj->getType();
748 if ($parent_type == $this->
getType())
750 $a_node_id = (int) $tree->getParentId($a_node_id);
754 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
764 include_once
"./Services/Utilities/classes/class.ilUtil.php";
767 if (!is_writable($tst_data_dir))
769 $this->ilias->raiseError(
"Test Data Directory (".$tst_data_dir
770 .
") not writeable.",$this->ilias->error_obj->MESSAGE);
774 $tst_dir = $tst_data_dir.
"/tst_".$this->
getId();
776 if (!@is_dir($tst_dir))
778 $this->ilias->raiseError(
"Creation of Test Directory failed.",$this->ilias->error_obj->MESSAGE);
781 $export_dir = $tst_dir.
"/export";
783 if (!@is_dir($export_dir))
785 $this->ilias->raiseError(
"Creation of Export Directory failed.",$this->ilias->error_obj->MESSAGE);
796 include_once
"./Services/Utilities/classes/class.ilUtil.php";
810 if (!@is_dir(
$dir) or
823 while ($entry =
$dir->read())
825 if ($entry !=
"." and
828 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(test(__results)?__)*[0-9]+\.[a-z]{1,3}\$", $entry))
854 include_once
"./Services/Utilities/classes/class.ilUtil.php";
858 if (!is_writable($tst_data_dir))
860 $ilias->raiseError(
"Test data directory (".$tst_data_dir
861 .
") not writeable.",$ilias->error_obj->FATAL);
865 $tst_dir = $tst_data_dir.
"/tst_import";
867 if (!@is_dir($tst_dir))
869 $ilias->raiseError(
"Creation of test import directory failed.",$ilias->error_obj->FATAL);
881 include_once
"./Services/Utilities/classes/class.ilUtil.php";
900 include_once
"./Services/Utilities/classes/class.ilUtil.php";
904 if (!is_writable($tst_data_dir))
906 $this->ilias->raiseError(
"Test Data Directory (".$tst_data_dir
907 .
") not writeable.",$this->ilias->error_obj->FATAL);
911 $tst_dir = $tst_data_dir.
"/tst_import";
913 if (!@is_dir($tst_dir))
915 $ilias->raiseError(
"Creation of test import directory failed.",
$ilias->error_obj->FATAL);
927 if(strlen($this->import_dir))
932 include_once
"./Services/Utilities/classes/class.ilUtil.php";
951 $this->import_dir = $a_import_dir;
965 $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",
972 if (strcmp(
$row[
'foundtypes'],
'assSingleChoice') == 0)
990 $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",
997 if (strcmp(
$row[
'foundtypes'],
'assSingleChoice') == 0)
1021 $result = $ilDB->queryF(
"SELECT DISTINCT(qpl_qst_sc.shuffle) foundshuffles FROM qpl_questions, qpl_qst_sc, tst_test_result, qpl_qst_type, tst_active WHERE tst_test_result.question_fi = qpl_questions.question_id AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND tst_test_result.active_fi = tst_active.active_id AND qpl_questions.question_id = qpl_qst_sc.question_fi AND tst_active.test_fi = %s AND qpl_qst_type.type_tag = %s",
1022 array(
'integer',
'text'),
1023 array($this->
getTestId(),
'assSingleChoice')
1028 return (
$row[
'foundshuffles'] == 0);
1041 if ((count($this->mark_schema->mark_steps)) and (count($this->questions)))
1055 foreach ($arr as $array)
1057 $count += $array[
"count"];
1078 $test->loadFromDb();
1079 return $test->isComplete();
1090 if ($this->test_id > 0)
1092 $fx_support = preg_replace(
"/,/",
".", $fx_support);
1093 if (preg_match(
"/\d+/", $fx_support))
1095 $fx_support = $fx_support;
1101 $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",
1102 array(
'text',
'float',
'float',
'float',
'float',
'float',
'float',
'integer'),
1106 $this->ects_fx = $fx_support;
1124 if ($this->test_id > 0)
1126 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET complete = %s WHERE test_id = %s",
1127 array(
'text',
'integer'),
1128 array($complete, $this->test_id)
1153 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1154 $completecontent =
"";
1157 $completecontent .= $content;
1176 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1177 if ($this->test_id == -1)
1180 $next_id = $ilDB->nextId(
'tst_tests');
1181 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_tests (test_id, obj_fi, author, introduction, " .
1182 "finalstatement, showinfo, forcejs, customstyle, showfinalstatement, sequence_settings, " .
1183 "score_reporting, instant_verification, answer_feedback_points, answer_feedback, anonymity, show_cancel, show_marker, " .
1184 "fixed_participants, nr_of_tries, kiosk, use_previous_answers, title_output, processing_time, enable_processing_time, " .
1185 "reset_processing_time, reporting_date, starting_time, ending_time, complete, ects_output, ects_a, ects_b, ects_c, ects_d, " .
1186 "ects_e, ects_fx, random_test, random_question_count, count_system, mc_scoring, score_cutting, pass_scoring, " .
1187 "shuffle_questions, results_presentation, show_summary, password, allowedusers, mailnottype, exportsettings, " .
1188 "alloweduserstimegap, certificate_visibility, mailnotification, created, tstamp) " .
1189 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, " .
1190 "%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
1192 'integer',
'integer',
'text',
'text',
1193 'text',
'integer',
'integer',
'text',
'integer',
'integer',
1194 'integer',
'text',
'text',
'text',
'text',
'text',
'integer',
1195 'text',
'integer',
'integer',
'text',
'text',
'text',
'text',
1196 'integer',
'text',
'text',
'text',
'text',
'text',
'float',
'float',
'float',
'float',
1197 'float',
'float',
'text',
'integer',
'text',
'text',
'text',
'text',
1198 'text',
'integer',
'integer',
'text',
'integer',
'integer',
'integer',
1199 'integer',
'text',
'integer',
'integer',
'integer'
1232 strlen($this->ects_grades[
"A"]) ? $this->ects_grades[
"A"] : NULL,
1233 strlen($this->ects_grades[
"B"]) ? $this->ects_grades[
"B"] : NULL,
1234 strlen($this->ects_grades[
"C"]) ? $this->ects_grades[
"C"] : NULL,
1235 strlen($this->ects_grades[
"D"]) ? $this->ects_grades[
"D"] : NULL,
1236 strlen($this->ects_grades[
"E"]) ? $this->ects_grades[
"E"] : NULL,
1258 $this->test_id = $next_id;
1271 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
1273 array($this->test_id)
1277 $oldrow = $ilDB->fetchAssoc(
$result);
1281 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET author = %s, introduction = %s, " .
1282 "finalstatement = %s, showinfo = %s, forcejs = %s, customstyle = %s, showfinalstatement = %s, sequence_settings = %s, " .
1283 "score_reporting = %s, instant_verification = %s, answer_feedback_points = %s, answer_feedback = %s, anonymity = %s, show_cancel = %s, show_marker = %s, " .
1284 "fixed_participants = %s, nr_of_tries = %s, kiosk = %s, use_previous_answers = %s, title_output = %s, processing_time = %s, enable_processing_time = %s, " .
1285 "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, " .
1286 "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, " .
1287 "shuffle_questions = %s, results_presentation = %s, show_summary = %s, password = %s, allowedusers = %s, mailnottype = %s, exportsettings = %s, " .
1288 "alloweduserstimegap = %s, certificate_visibility = %s, mailnotification = %s, tstamp = %s WHERE test_id = %s",
1291 'text',
'integer',
'integer',
'text',
'integer',
'integer',
1292 'integer',
'text',
'text',
'text',
'text',
'text',
'integer',
1293 'text',
'integer',
'integer',
'text',
'text',
'text',
'text',
1294 'integer',
'text',
'text',
'text',
'text',
'text',
'float',
'float',
'float',
'float',
1295 'float',
'float',
'text',
'integer',
'text',
'text',
'text',
'text',
1296 'text',
'integer',
'integer',
'text',
'integer',
'integer',
'integer',
1297 'integer',
'text',
'integer',
'integer',
'integer'
1328 strlen($this->ects_grades[
"A"]) ? $this->ects_grades[
"A"] : NULL,
1329 strlen($this->ects_grades[
"B"]) ? $this->ects_grades[
"B"] : NULL,
1330 strlen($this->ects_grades[
"C"]) ? $this->ects_grades[
"C"] : NULL,
1331 strlen($this->ects_grades[
"D"]) ? $this->ects_grades[
"D"] : NULL,
1332 strlen($this->ects_grades[
"E"]) ? $this->ects_grades[
"E"] : NULL,
1355 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1358 $logresult = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
1363 if ($logresult->numRows() == 1)
1365 $newrow = $ilDB->fetchAssoc($logresult);
1367 $changed_fields = array();
1368 foreach ($oldrow as $key => $value)
1370 if (strcmp($oldrow[$key], $newrow[$key]) != 0)
1372 array_push($changed_fields,
"$key: " . $oldrow[$key] .
" => " . $newrow[$key]);
1375 $changes = join($changed_fields,
", ");
1376 if (count($changed_fields) > 0)
1387 $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND tries >= %s AND submitted = %s",
1388 array(
'integer',
'integer',
'integer'),
1391 while (
$row = $ilDB->fetchAssoc($aresult))
1393 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
1394 array(
'integer',
'timestamp',
'integer'),
1395 array(1, date(
'Y-m-d H:i:s'),
$row[
"active_id"])
1400 $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND tries < %s AND submitted = %s",
1401 array(
'integer',
'integer',
'integer'),
1404 while (
$row = $ilDB->fetchAssoc($aresult))
1406 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
1407 array(
'integer',
'timestamp',
'integer'),
1408 array(0, NULL,
$row[
"active_id"])
1415 $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND submitted = %s",
1416 array(
'integer',
'integer'),
1419 while (
$row = $ilDB->fetchAssoc($aresult))
1421 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
1422 array(
'integer',
'timestamp',
'integer'),
1423 array(0, NULL,
$row[
"active_id"])
1433 if (!$properties_only)
1438 $ilias->raiseError(
$result->getMessage());
1446 $this->mark_schema->saveToDb($this->test_id);
1461 $oldquestions = array();
1462 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
1465 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence",
1473 array_push($oldquestions,
$row[
"question_fi"]);
1479 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
1484 foreach ($this->questions as $key => $value)
1486 $next_id = $ilDB->nextId(
'tst_test_question');
1487 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
1488 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
1489 array($next_id, $this->
getTestId(), $value, $key, time())
1492 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1495 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence",
1499 $newquestions = array();
1504 array_push($newquestions,
$row[
"question_fi"]);
1507 foreach ($oldquestions as $index => $question_id)
1509 if (strcmp($newquestions[$index], $question_id) != 0)
1511 $pos = array_search($question_id, $newquestions);
1522 foreach ($newquestions as $index => $question_id)
1524 if (array_search($question_id, $oldquestions) === FALSE)
1538 $result = $ilDB->queryF(
'SELECT copy_id FROM tst_rnd_cpy WHERE tst_fi = %s',
1542 return $result->numRows() > 0;
1557 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
1558 array(
'integer',
'integer'),
1559 array($active_id,
$pass)
1561 if (
$result->numRows() < $maxcount)
1563 $duplicate_id = $question_id;
1567 if ($duplicate_id === FALSE)
1572 $next_id = $ilDB->nextId(
'tst_test_rnd_qst');
1573 $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)",
1574 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
1575 array($next_id,$active_id, $duplicate_id,
$result->numRows()+1,
$pass, time())
1593 $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",
1594 array(
'integer',
'integer'),
1595 array($question_id, $active_id)
1601 return $row[
"question_id"];
1618 $result = $ilDB->queryF(
"SELECT test_result_id FROM tst_test_result WHERE active_fi = %s AND pass = %s",
1619 array(
'integer',
'integer'),
1620 array($active_id,
$pass)
1636 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
1637 array(
'integer',
'integer'),
1638 array($active_id,
$pass)
1640 return (
$result->numRows() > 0) ?
true :
false;
1677 $ilias->raiseError(sprintf($this->lng->txt(
"error_random_question_generation"), $ilUser->getId(), $this->
getTestId()), $ilErr->FATAL);
1685 $allquestions = array();
1686 foreach ($rndquestions as $question_id)
1688 array_push($allquestions, $question_id);
1692 srand ((
float)microtime()*1000000);
1693 shuffle($allquestions);
1697 foreach ($qpls as
$data)
1699 $maxcount += $data[
"contains"];
1701 if ($num > $maxcount) $num = $maxcount;
1702 foreach ($allquestions as $question_id)
1710 $allquestions = array();
1712 foreach ($qpls as $key => $value)
1714 if ($value[
"count"] > 0)
1717 foreach ($rndquestions as $question_id)
1719 array_push($allquestions, $question_id);
1722 $add = ($value[
"count"] <= $value[
"contains"]) ? $value[
"count"] : $value[
"contains"];
1727 srand ((
float)microtime()*1000000);
1728 shuffle($allquestions);
1730 foreach ($allquestions as $question_id)
1747 if (strlen($total_questions))
1751 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET random_question_count = %s, tstamp = %s WHERE test_id = %s",
1752 array(
'integer',
'integer',
'integer'),
1755 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1775 $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",
1783 $qpls[$counter] = array(
1784 "index" => $counter,
1785 "count" =>
$row[
"num_of_q"],
1786 "qpl" =>
$row[
"questionpool_fi"],
1787 "contains" =>
$row[
"questioncount"]
1802 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1804 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
1816 foreach ($this->random_questionpool_data as $idx =>
$data)
1821 $next_id = $ilDB->nextId(
'tst_test_random');
1822 $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)",
1823 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
1843 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_cpy WHERE tst_fi = %s',
1850 $question->delete(
$row[
'qst_fi']);
1853 $affectedRows = $ilDB->manipulateF(
'DELETE FROM tst_rnd_cpy WHERE tst_fi = %s',
1858 $affectedRows = $ilDB->manipulateF(
'DELETE FROM tst_rnd_qpl_title WHERE tst_fi = %s',
1872 $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',
1879 if (is_array($pools[
$row[
'qpl_fi']]))
1881 $pools[$row[
'qpl_fi']][
'count']++;
1885 $pools[$row[
'qpl_fi']][
'count'] = 1;
1887 $pools[$row[
'qpl_fi']][
'num_of_q'] = $row[
'num_of_q'];
1889 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_qpl_title WHERE tst_fi = %s',
1896 $pools[
$row[
'qpl_fi']][
'title'] = $row[
'qpl_title'];
1902 $result = $ilDB->queryF(
'SELECT tst_test_random.* FROM tst_test_random WHERE tst_test_random.test_fi = %s ORDER BY sequence, test_random_id',
1909 $pools[
$row[
'questionpool_fi']][
'count'] = $row[
'num_of_q'];
1910 $pools[$row[
'questionpool_fi']][
'num_of_q'] = $row[
'num_of_q'];
1912 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_qpl_title WHERE tst_fi = %s',
1919 $pools[
$row[
'qpl_fi']][
'title'] = $row[
'qpl_title'];
1931 $result = $ilDB->queryF(
'SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND complete = %s AND original_id IS NULL',
1932 array(
'integer',
'text'),
1933 array($questionpool_id, 1)
1935 $saved_titles = array();
1939 $duplicate_id = $question->duplicate(
true);
1940 if ($duplicate_id > 0)
1942 $next_id = $ilDB->nextId(
'tst_rnd_cpy');
1943 $ilDB->manipulateF(
'INSERT INTO tst_rnd_cpy (copy_id, tst_fi, qst_fi, qpl_fi) VALUES (%s, %s, %s, %s)',
1944 array(
'integer',
'integer',
'integer',
'integer'),
1945 array($next_id, $this->
getTestId(), $duplicate_id, $questionpool_id)
1947 if (!array_key_exists($questionpool_id, $saved_titles))
1949 $next_id = $ilDB->nextId(
'tst_rnd_qpl_title');
1950 $ilDB->manipulateF(
'INSERT INTO tst_rnd_qpl_title (title_id, tst_fi, qpl_fi, qpl_title) VALUES (%s, %s, %s, %s)',
1951 array(
'integer',
'integer',
'integer',
'text'),
1954 $saved_titles[$questionpool_id] = 1;
1962 include_once
"./Modules/Test/classes/class.ilRandomTestData.php";
1963 if (array_key_exists($position, $this->random_questionpool_data))
1965 $newitems = array();
1966 for ($i = 0; $i < $position; $i++)
1968 array_push($newitems, $this->random_questionpool_data[$i]);
1971 for ($i = $position; $i < count($this->random_questionpool_data); $i++)
1973 array_push($newitems, $this->random_questionpool_data[$i]);
1975 $this->random_questionpool_data = $newitems;
1979 array_push($this->random_questionpool_data,
new ilRandomTestData($count, $qpl));
1985 if (array_key_exists($position, $this->random_questionpool_data))
1987 unset($this->random_questionpool_data[$position]);
1993 $this->random_questionpool_data = $a_data;
2011 $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",
2015 include_once
"./Modules/Test/classes/class.ilRandomTestData.php";
2037 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE obj_fi = %s",
2039 array($this->
getId())
2050 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2082 "A" =>
$data->ects_a,
2083 "B" =>
$data->ects_b,
2084 "C" =>
$data->ects_c,
2085 "D" =>
$data->ects_d,
2086 "E" =>
$data->ects_e
2092 $this->mark_schema->flush();
2093 $this->mark_schema->loadFromDb($this->
getTestId());
2120 $this->questions = array();
2121 if (strcmp($active_id,
"") == 0)
2131 $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",
2132 array(
'integer',
'integer'),
2133 array($active_id,
$pass)
2141 $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",
2149 $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",
2151 array($this->test_id)
2157 $this->questions[$index++] =
$data[
"question_fi"];
2182 $this->_finalstatement = $a_statement;
2194 $this->_showinfo = ($a_info) ? 1 : 0;
2206 $this->_forcejs = ($a_js) ? 1 : 0;
2218 $this->_customStyle = $a_customStyle;
2230 return (strlen($this->_customStyle)) ? $this->_customStyle : NULL;
2243 $css_path = str_replace(
"ta.css",
"customstyles", $css_path) .
"/";
2244 $customstyles = array();
2245 if (is_dir($css_path))
2248 include_once
"./Services/Utilities/classes/class.ilFileUtils.php";
2254 if (strpos($filename,
".css"))
2256 array_push($customstyles, $filename);
2261 return $customstyles;
2276 $custom = str_replace(
"ta.css",
"customstyles/" . $this->
getCustomStyle(), $default);
2277 if (file_exists($custom))
2280 $custom = str_replace(
"ta.css",
"customstyles/" . $this->
getCustomStyle(), $custom);
2303 $this->_showfinalstatement = ($show) ? 1 : 0;
2316 return ($this->random_test) ? 1 : 0;
2329 $query =
"SELECT random_test FROM tst_tests ".
2330 "WHERE obj_fi = ".$ilDB->quote($a_obj_id,
'integer');
2334 return $row->random_test ?
true :
false;
2348 return ($this->random_question_count) ? $this->random_question_count : 0;
2359 return (strlen($this->introduction)) ? $this->introduction : NULL;
2370 return (strlen($this->_finalstatement)) ? $this->_finalstatement : NULL;
2382 return ($this->_showinfo) ? 1 : 0;
2394 return ($this->_forcejs) ? 1 : 0;
2406 return ($this->_showfinalstatement) ? 1 : 0;
2430 return ($this->ects_output) ? 1 : 0;
2442 $this->ects_output = $a_ects_output ? 1 : 0;
2454 return (strlen($this->ects_fx)) ? $this->ects_fx : NULL;
2466 $this->ects_fx = $a_ects_fx;
2490 if (is_array($a_ects_grades))
2492 $this->ects_grades = $a_ects_grades;
2529 switch ($instant_feedback)
2532 $this->instant_verification = 1;
2535 $this->instant_verification = 0;
2552 $this->answer_feedback = 1;
2555 $this->answer_feedback = 0;
2572 $this->answer_feedback_points = 1;
2575 $this->answer_feedback_points = 0;
2589 $this->random_test = $a_random_test;
2601 $this->random_question_count = $a_random_question_count;
2615 $this->reporting_date =
"";
2616 $this->ects_output = 0;
2633 return ($this->sequence_settings) ? $this->sequence_settings : 0;
2645 return ($this->score_reporting) ? $this->score_reporting : 0;
2657 return ($this->instant_verification) ? $this->instant_verification : 0;
2669 return ($this->answer_feedback) ? $this->answer_feedback : 0;
2681 return ($this->answer_feedback_points) ? $this->answer_feedback_points : 0;
2693 return ($this->count_system) ? $this->count_system : 0;
2706 $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",
2713 return $row[
"count_system"];
2727 return ($this->mc_scoring) ? $this->mc_scoring : 0;
2739 return ($this->score_cutting) ? $this->score_cutting : 0;
2751 return (strlen($this->password)) ? $this->password : NULL;
2763 return ($this->pass_scoring) ? $this->pass_scoring : 0;
2776 $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",
2783 return $row[
"pass_scoring"];
2798 $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",
2805 return $row[
"mc_scoring"];
2820 $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",
2827 return $row[
"score_cutting"];
2841 return (strlen($this->reporting_date)) ? $this->reporting_date : NULL;
2853 return ($this->nr_of_tries) ? $this->nr_of_tries : 0;
2865 return ($this->_kiosk) ? $this->_kiosk : 0;
2878 $this->_kiosk = $kiosk;
2890 if (($this->_kiosk & 1) > 0)
2911 $this->_kiosk = $this->_kiosk | 1;
2917 $this->_kiosk = $this->_kiosk ^ 1;
2931 if (($this->_kiosk & 2) > 0)
2951 $this->_kiosk = $this->_kiosk | 2;
2957 $this->_kiosk = $this->_kiosk ^ 2;
2971 if (($this->_kiosk & 4) > 0)
2991 $this->_kiosk = $this->_kiosk | 4;
2997 $this->_kiosk = $this->_kiosk ^ 4;
3011 return ($this->use_previous_answers) ? $this->use_previous_answers : 0;
3023 return ($this->title_output) ? $this->title_output : 0;
3038 $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",
3045 return $row[
"title_output"];
3066 $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",
3078 if ($user_active_user_setting)
3080 $res = $ilUser->getPref(
"tst_use_previous_answers");
3099 return (strlen($this->processing_time)) ? $this->processing_time : NULL;
3110 if (strlen($this->processing_time))
3112 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/is", $this->processing_time, $matches))
3114 if ((
int)$matches[1]+(
int)$matches[2]+(
int)$matches[3] == 0)
3121 'hh' => $matches[1],
3122 'mm' => $matches[2],
3123 'ss' => $matches[3],
3140 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $this->
getProcessingTime(), $matches))
3142 return ($matches[1] * 3600) + ($matches[2] * 60) + $matches[3];
3159 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndingTime(), $matches))
3161 $ending = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
3163 return $ending - $now;
3180 return ($this->enable_processing_time) ? $this->enable_processing_time : 0;
3192 return ($this->reset_processing_time) ? $this->reset_processing_time : 0;
3204 return (strlen($this->starting_time)) ? $this->starting_time : NULL;
3216 return (strlen($this->ending_time)) ? $this->ending_time : NULL;
3242 $this->use_previous_answers = 1;
3246 $this->use_previous_answers = 0;
3262 $this->title_output = 1;
3265 $this->title_output = 2;
3268 $this->title_output = 0;
3295 $this->enable_processing_time =
"1";
3297 $this->enable_processing_time =
"0";
3312 $this->reset_processing_time = 1;
3316 $this->reset_processing_time = 0;
3353 $this->count_system = $a_count_system;
3365 $this->password = $a_password;
3377 $this->score_cutting = $a_score_cutting;
3389 $this->mc_scoring = $a_mc_scoring;
3401 switch ($a_pass_scoring)
3422 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3427 $question->delete($question_id);
3446 $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",
3447 array(
'integer',
'integer'),
3450 $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",
3451 array(
'integer',
'integer'),
3454 $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",
3455 array(
'integer',
'integer'),
3458 $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)",
3465 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE tst_solutions.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3469 $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)",
3473 $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)",
3477 $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)",
3481 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3487 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE tst_sequence.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3494 $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)",
3501 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
3507 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE keyword = %s",
3509 array(
"tst_password_".$this->
getTestId())
3514 if (@is_dir(CLIENT_WEB_DIR .
"/assessment/tst_" . $this->
getTestId()))
3525 foreach ($active_ids as $active_id)
3527 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s",
3531 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s",
3535 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE active_fi = %s",
3539 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE active_fi = %s",
3546 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_rnd_qst WHERE active_fi = %s",
3552 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3560 foreach ($active_ids as $active_id)
3564 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE active_id = %s",
3569 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
3577 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
3578 array(
'integer',
'text'),
3585 if (@is_dir(CLIENT_WEB_DIR .
"/assessment/tst_" . $this->
getTestId() .
"/$active_id"))
3599 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s",
3603 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s",
3607 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE active_fi = %s",
3611 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE active_fi = %s",
3618 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_rnd_qst WHERE active_fi = %s",
3624 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3630 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
3636 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE active_id = %s",
3644 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
3645 array(
'integer',
'text'),
3646 array($user_id,
"tst_password_".$this->
getTestId())
3652 if (@is_dir(CLIENT_WEB_DIR .
"/assessment/tst_" . $this->
getTestId() .
"/$active_id"))
3670 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s",
3671 array(
'integer',
'integer'),
3675 if (
$data->sequence > 1)
3678 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s",
3679 array(
'integer',
'integer'),
3682 $data_previous = $ilDB->fetchObject(
$result);
3684 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3685 array(
'integer',
'integer'),
3686 array(
$data->sequence, $data_previous->test_question_id)
3689 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3690 array(
'integer',
'integer'),
3691 array(
$data->sequence - 1,
$data->test_question_id)
3693 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3714 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s",
3715 array(
'integer',
'integer'),
3719 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s",
3720 array(
'integer',
'integer'),
3726 $data_next = $ilDB->fetchObject(
$result);
3728 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3729 array(
'integer',
'integer'),
3730 array(
$data->sequence, $data_next->test_question_id)
3733 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3734 array(
'integer',
'integer'),
3735 array(
$data->sequence + 1,
$data->test_question_id)
3737 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3757 $duplicate_id = $question->duplicate(
true);
3759 return $duplicate_id;
3775 $result = $ilDB->queryF(
"SELECT MAX(sequence) seq FROM tst_test_question WHERE test_fi=%s",
3784 $sequence =
$data->seq + 1;
3787 $next_id = $ilDB->nextId(
'tst_test_question');
3788 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
3789 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
3790 array($next_id, $this->
getTestId(), $duplicate_id, $sequence, time())
3792 if ($affectedRows == 1)
3794 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3801 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
3822 $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",
3828 array_push($titles,
$row[
"title"]);
3847 $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",
3853 $titles[
$row[
'question_id']] = $row[
"title"];
3871 return $this->lng->txt(
"ass_question");
3891 $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",
3910 $existing_questions = array();
3915 $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",
3916 array(
'integer',
'integer'),
3917 array($active_id,
$pass)
3922 $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",
3929 array_push($existing_questions,
$data->original_id);
3931 return $existing_questions;
3945 if ($question_id < 1)
return -1;
3946 $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",
3953 return $data->type_tag;
3971 $next_id = $ilDB->nextId(
'tst_times');
3972 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_times (times_id, active_fi, started, finished, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
3973 array(
'integer',
'integer',
'timestamp',
'timestamp',
'integer',
'integer'),
3974 array($next_id, $active_id, strftime(
"%Y-%m-%d %H:%M:%S"), strftime(
"%Y-%m-%d %H:%M:%S"),
$pass, time())
3989 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_times SET finished = %s, tstamp = %s WHERE times_id = %s",
3990 array(
'timestamp',
'integer',
'integer'),
3991 array(strftime(
"%Y-%m-%d %H:%M:%S"), time(), $times_id)
4008 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_solutions WHERE active_fi = %s AND pass = %s GROUP BY question_fi",
4009 array(
'integer',
'integer'),
4010 array($active_id, 0)
4015 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_solutions WHERE active_fi = %s AND pass = %s GROUP BY question_fi",
4016 array(
'integer',
'integer'),
4017 array($active_id,
$pass)
4020 $result_array = array();
4023 array_push($result_array,
$row[
"question_fi"]);
4025 return $result_array;
4039 return ((($currentpass > 0) && ($num == 0)) || $this->
isTestFinished($active_id)) ?
true :
false;
4053 $result_array = array();
4058 if (count($this->questions) == 0)
return $result_array;
4063 $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'),
4064 array(
'integer',
'integer'),
4065 array($active_id,
$pass)
4070 if (count($this->questions) == 0)
return $result_array;
4071 $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'));
4075 $result_array[
$row[
"question_id"]] =
$row;
4077 return $result_array;
4093 if (!$user_id) $user_id = $ilUser->getId();
4096 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
4097 array(
'integer',
'integer',
'text'),
4101 else if (strlen($anonymous_id))
4103 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
4104 array(
'integer',
'integer',
'text'),
4105 array($user_id, $this->test_id, $anonymous_id)
4110 if (
$_SESSION[
"AccountId"] == ANONYMOUS_USER_ID)
4114 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s",
4115 array(
'integer',
'integer'),
4116 array($user_id, $this->test_id)
4122 return $row[
"active_id"];
4144 $user_id = $ilUser->id;
4150 $result = $ilDB->queryF(
"SELECT tst_active.active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s",
4151 array(
'integer',
'integer'),
4157 return $row[
"active_id"];
4173 $keys = array_keys($array);
4176 foreach ($keys as $key)
4199 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
4201 $sequence = array();
4202 if ($ordered_sequence)
4210 $arrResults = array();
4211 $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",
4212 array(
'integer',
'integer'),
4213 array($active_id,
$pass)
4215 while (
$row = $ilDB->fetchAssoc($solutionresult))
4217 $arrResults[
$row[
'question_fi']] =
$row;
4220 require_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
4221 $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'));
4223 $unordered = array();
4227 $percentvalue = (
$row[
'points']) ? $arrResults[
$row[
'question_id']][
'reached'] /
$row[
'points'] : 0;
4228 if ($percentvalue < 0) $percentvalue = 0.0;
4232 "max" => round(
$row[
'points'], 2),
4233 "reached" => round($arrResults[
$row[
'question_id']][
'reached'],2),
4234 "percent" => sprintf(
"%2.2f ", ($percentvalue) * 100) .
"%",
4236 "type" => $row[
"type_tag"],
4237 "qid" => $row[
'question_id'],
4238 "original_id" => $row[
"original_id"],
4239 "workedthrough" => ($arrResults[$row[
'question_id']][
'workedthru']) ? 1 : 0
4241 $unordered[$row[
'question_id']] =
$data;
4248 foreach ($sequence as $qid)
4252 $pass_max += round($unordered[$qid][
'max'], 2);
4253 $pass_reached += round($unordered[$qid][
'reached'], 2);
4257 $unordered[$qid][
'nr'] = $key;
4258 array_push($found, $unordered[$qid]);
4266 if (
$results[
'reached_points'] < 0)
4270 if ($pass_reached < 0) $pass_reached = 0;
4272 $found[
'pass'][
'total_max_points'] = $pass_max;
4273 $found[
'pass'][
'total_reached_points'] = $pass_reached;
4274 $found[
'pass'][
'percent'] = ($pass_max > 0) ? $pass_reached / $pass_max : 0;
4275 $found[
"test"][
"total_max_points"] =
$results[
'max_points'];
4276 $found[
"test"][
"total_reached_points"] =
$results[
'reached_points'];
4277 $found[
"test"][
"result_pass"] =
$results[
'pass'];
4278 if ((!$total_reached_points) or (!$total_max_points))
4284 $percentage = ($total_reached_points / $total_max_points) * 100.0;
4285 if ($percentage < 0) $percentage = 0.0;
4287 $found[
"test"][
"passed"] =
$results[
'passed'];
4301 $result = $ilDB->queryF(
"SELECT COUNT(active_id) total FROM tst_active WHERE test_fi = %s",
4306 return $row[
"total"];
4319 $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",
4320 array(
'integer',
'integer'),
4326 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4327 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4328 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4329 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4330 $time += ($epoch_2 - $epoch_1);
4357 $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",
4365 if (!array_key_exists(
$row[
"active_fi"], $times))
4367 $times[
$row[
"active_fi"]] = 0;
4369 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4370 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4371 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4372 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4373 $times[
$row[
"active_fi"]] += ($epoch_2 - $epoch_1);
4388 $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",
4389 array(
'integer',
'integer'),
4395 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4396 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4397 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4398 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4399 $time += ($epoch_2 - $epoch_1);
4414 $result = $ilDB->queryF(
"SELECT * FROM tst_times WHERE active_fi = %s AND pass = %s ORDER BY started",
4415 array(
'integer',
'integer'),
4416 array($active_id,
$pass)
4421 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4422 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4423 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4424 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4425 $time += ($epoch_2 - $epoch_1);
4454 $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",
4455 array(
'integer',
'integer'),
4462 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4463 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4464 if ($firstvisit == 0 || $epoch_1 < $firstvisit) $firstvisit = $epoch_1;
4465 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4466 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4467 if ($epoch_2 > $lastvisit) $lastvisit = $epoch_2;
4469 return array(
"firstvisit" => $firstvisit,
"lastvisit" => $lastvisit);
4484 $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",
4493 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->started, $matches);
4494 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4495 if (!$first_visit) {
4496 $first_visit = $epoch_1;
4498 if ($epoch_1 < $first_visit) {
4499 $first_visit = $epoch_1;
4501 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->finished, $matches);
4502 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4504 $last_visit = $epoch_2;
4506 if ($epoch_2 > $last_visit) {
4507 $last_visit = $epoch_2;
4509 $times[
$row->active_fi] += ($epoch_2 - $epoch_1);
4512 foreach ($times as $key => $value) {
4513 $max_time += $value;
4515 if ((!$test_result[
"test"][
"total_reached_points"]) or (!$test_result[
"test"][
"total_max_points"]))
4521 $percentage = ($test_result[
"test"][
"total_reached_points"] / $test_result[
"test"][
"total_max_points"]) * 100.0;
4522 if ($percentage < 0) $percentage = 0.0;
4524 $mark_obj = $this->mark_schema->getMatchingMark($percentage);
4525 $first_date = getdate($first_visit);
4526 $last_date = getdate($last_visit);
4527 $qworkedthrough = 0;
4528 foreach ($test_result as $key => $value)
4530 if (preg_match(
"/\d+/", $key))
4532 $qworkedthrough += $value[
"workedthrough"];
4535 if (!$qworkedthrough)
4541 $atimeofwork = $max_time / $qworkedthrough;
4547 $result_mark = $mark_obj->getShortName();
4548 if ($mark_obj->getPassed())
4557 $percent_worked_through = 0;
4558 if (count($this->questions))
4560 $percent_worked_through = $qworkedthrough / count($this->questions);
4562 $result_array = array(
4563 "qworkedthrough" => $qworkedthrough,
4564 "qmax" => count($this->questions),
4565 "pworkedthrough" => $percent_worked_through,
4566 "timeofwork" => $max_time,
4567 "atimeofwork" => $atimeofwork,
4568 "firstvisit" => $first_date,
4569 "lastvisit" => $last_date,
4570 "resultspoints" => $test_result[
"test"][
"total_reached_points"],
4571 "maxpoints" => $test_result[
"test"][
"total_max_points"],
4572 "resultsmarks" => $result_mark,
4573 "passed" => $passed,
4574 "distancemedian" =>
"0"
4576 foreach ($test_result as $key => $value)
4578 if (preg_match(
"/\d+/", $key))
4580 $result_array[$key] = $value;
4583 return $result_array;
4595 $totalpoints_array = array();
4597 foreach ($all_users as $active_id => $user_name)
4600 $reached = $test_result[
"test"][
"total_reached_points"];
4601 $total = $test_result[
"test"][
"total_max_points"];
4603 $mark = $this->mark_schema->getMatchingMark($percentage*100.0);
4606 if ($mark->getPassed())
4608 array_push($totalpoints_array, $test_result[
"test"][
"total_reached_points"]);
4612 return $totalpoints_array;
4624 $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",
4628 $persons_array = array();
4631 $name = $this->lng->txt(
"unknown");
4632 $fullname = $this->lng->txt(
"unknown");
4636 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
4638 $name = $this->lng->txt(
"deleted_user");
4639 $fullname = $this->lng->txt(
"deleted_user");
4640 $login = $this->lng->txt(
"unknown");
4644 $login = $row[
"login"];
4645 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4647 $name = $this->lng->txt(
"unknown");
4648 $fullname = $this->lng->txt(
"unknown");
4652 $name = trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]);
4653 $fullname = trim($row[
"title"] .
" " . $row[
"firstname"] .
" " . $row[
"lastname"]);
4657 $persons_array[
$row[
"active_id"]] = array(
4659 "fullname" => $fullname,
4663 return $persons_array;
4675 $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),
4679 $persons_array = array();
4684 $persons_array[
$row[
"active_id"]] = $this->lng->txt(
"unknown");
4688 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
4690 $persons_array[$row[
"active_id"]] = $this->lng->txt(
"deleted_user");
4694 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4696 $persons_array[$row[
"active_id"]] = $row[
"lastname"];
4700 $persons_array[$row[
"active_id"]] = trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]);
4705 return $persons_array;
4717 $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),
4721 $persons_array = array();
4726 $persons_array[
$row[
"active_id"]] = array(
"name" => $this->lng->txt(
"unknown"));
4730 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
4732 $persons_array[$row[
"active_id"]] = array(
"name" => $this->lng->txt(
"deleted_user"));
4736 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4738 $persons_array[$row[
"active_id"]] = array(
"name" => $row[
"lastname"]);
4742 $persons_array[$row[
"active_id"]] = array(
"name" => trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]),
"login" => $row[
"login"]);
4747 return $persons_array;
4760 $result = $ilDB->queryF(
"SELECT COUNT(active_id) total FROM tst_active WHERE test_fi = %s AND submitted = %s",
4761 array(
'integer',
'integer'),
4765 return $row[
"total"];
4780 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, " .
4781 "tst_test_rnd_qst.pass, qpl_questions.points " .
4782 "FROM tst_test_rnd_qst, qpl_questions " .
4783 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
4784 "AND tst_test_rnd_qst.active_fi = %s ORDER BY tst_test_rnd_qst.sequence",
4791 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4792 "qpl_questions.points " .
4793 "FROM tst_test_question, tst_active, qpl_questions " .
4794 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4795 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi",
4805 array_push($qtest,
$row);
4823 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, " .
4824 "qpl_questions.points " .
4825 "FROM tst_test_rnd_qst, qpl_questions " .
4826 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
4827 "AND tst_test_rnd_qst.active_fi = %s AND tst_test_rnd_qst.pass = %s " .
4828 "ORDER BY tst_test_rnd_qst.sequence",
4829 array(
'integer',
'integer'),
4830 array($active_id,
$pass)
4835 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4836 "qpl_questions.points " .
4837 "FROM tst_test_question, tst_active, qpl_questions " .
4838 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4839 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi",
4849 array_push($qpass,
$row);
4858 include_once
"./Modules/Test/classes/class.ilTestEvaluationPassData.php";
4859 include_once
"./Modules/Test/classes/class.ilTestEvaluationUserData.php";
4860 include_once
"./Modules/Test/classes/class.ilTestEvaluationData.php";
4862 $result = $ilDB->queryF(
"SELECT tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
4863 "qpl_questions.points maxpoints " .
4864 "FROM tst_test_result, qpl_questions, tst_active " .
4865 "WHERE tst_active.active_id = tst_test_result.active_fi " .
4866 "AND qpl_questions.question_id = tst_test_result.question_fi " .
4867 "AND tst_active.test_fi = %s " .
4868 "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
4877 $data->getParticipant(
$row[
"active_fi"])->getPass(
$row[
"pass"])->addAnsweredQuestion(
$row[
"original_id"] ?
$row[
"original_id"] :
$row[
"question_fi"], $row[
"maxpoints"], $row[
"points"]);
4880 foreach (array_keys(
$data->getParticipants()) as $active_id)
4884 for ($testpass = 0; $testpass <=
$data->getParticipant($active_id)->getLastPass(); $testpass++)
4887 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, qpl_questions.original_id, " .
4888 "tst_test_rnd_qst.pass, qpl_questions.points, qpl_questions.title " .
4889 "FROM tst_test_rnd_qst, qpl_questions " .
4890 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
4891 "AND tst_test_rnd_qst.pass = %s " .
4892 "AND tst_test_rnd_qst.active_fi = %s ORDER BY tst_test_rnd_qst.sequence",
4893 array(
'integer',
'integer'),
4894 array($testpass, $active_id)
4900 $tpass = array_key_exists(
"pass",
$row) ?
$row[
"pass"] : 0;
4901 $data->getParticipant($active_id)->addQuestion(
$row[
"original_id"] ?
$row[
"original_id"] :
$row[
"question_fi"], $row[
"question_fi"], $row[
"points"], $row[
"sequence"], $tpass);
4902 $data->addQuestionTitle($row[
"original_id"] ? $row[
"original_id"] : $row[
"question_fi"], $row[
"title"]);
4909 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4910 "qpl_questions.points, qpl_questions.title, qpl_questions.original_id " .
4911 "FROM tst_test_question, tst_active, qpl_questions " .
4912 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4913 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi ORDER BY tst_test_question.sequence",
4919 $questionsbysequence = array();
4922 $questionsbysequence[
$row[
"sequence"]] =
$row;
4924 $seqresult = $ilDB->queryF(
"SELECT * FROM tst_sequence WHERE active_fi = %s",
4928 while ($seqrow = $ilDB->fetchAssoc($seqresult))
4930 $questionsequence = unserialize($seqrow[
"sequence"]);
4931 foreach ($questionsequence as $sidx => $seq)
4933 $qsid = $questionsbysequence[$seq][
"original_id"] ? $questionsbysequence[$seq][
"original_id"] : $questionsbysequence[$seq][
"question_fi"];
4934 $data->getParticipant($active_id)->addQuestion($qsid, $questionsbysequence[$seq][
"question_fi"], $questionsbysequence[$seq][
"points"], $sidx + 1, $seqrow[
"pass"]);
4935 $data->addQuestionTitle($qsid, $questionsbysequence[$seq][
"title"]);
4942 if ($this->ects_output)
4946 foreach (array_keys(
$data->getParticipants()) as $active_id)
4948 $percentage =
$data->getParticipant($active_id)->getReachedPointsInPercent();
4949 $mark = $this->mark_schema->getMatchingMark($percentage);
4950 if (is_object($mark))
4952 $data->getParticipant($active_id)->setMark($mark->getShortName());
4953 $data->getParticipant($active_id)->setMarkOfficial($mark->getOfficialName());
4954 $data->getParticipant($active_id)->setPassed($mark->getPassed());
4956 if ($this->ects_output)
4958 $ects_mark = $this->
getECTSGrade($passed_array,
$data->getParticipant($active_id)->getReached(),
$data->getParticipant($active_id)->getMaxPoints());
4959 $data->getParticipant($active_id)->setECTSMark($ects_mark);
4962 $data->getParticipant($active_id)->setFirstVisit($visitingTime[
"firstvisit"]);
4963 $data->getParticipant($active_id)->setLastVisit($visitingTime[
"lastvisit"]);
4974 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.pass, COUNT(tst_test_rnd_qst.question_fi) qcount, " .
4975 "SUM(qpl_questions.points) qsum FROM tst_test_rnd_qst, qpl_questions " .
4976 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id AND " .
4977 "tst_test_rnd_qst.active_fi = %s and pass = %s GROUP BY tst_test_rnd_qst.active_fi, " .
4978 "tst_test_rnd_qst.pass",
4979 array(
'integer',
'integer'),
4980 array($active_id,
$pass)
4985 $result = $ilDB->queryF(
"SELECT COUNT(tst_test_question.question_fi) qcount, " .
4986 "SUM(qpl_questions.points) qsum FROM tst_test_question, qpl_questions, tst_active " .
4987 "WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = tst_active.test_fi AND " .
4988 "tst_active.active_id = %s GROUP BY tst_test_question.test_fi",
4996 return array(
"count" =>
$row[
"qcount"],
"points" =>
$row[
"qsum"]);
5000 return array(
"count" => 0,
"points" => 0);
5006 include_once
"./Modules/Test/classes/class.ilTestEvaluationData.php";
5007 include_once
"./Modules/Test/classes/class.ilTestEvaluationPassData.php";
5008 include_once
"./Modules/Test/classes/class.ilTestEvaluationUserData.php";
5010 if ($withStatistics)
5012 $data->calculateStatistics();
5014 $data->setFilter($filterby, $filtertext);
5039 $result = $ilDB->queryF(
"SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
5040 "tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
5041 "qpl_questions.points maxpoints " .
5042 "FROM tst_test_result, qpl_questions, tst_active " .
5043 "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
5044 "WHERE tst_active.active_id = tst_test_result.active_fi " .
5045 "AND qpl_questions.question_id = tst_test_result.question_fi " .
5046 "AND tst_active.test_fi = %s " .
5047 "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
5051 $overview = array();
5054 if (!array_key_exists(
$row[
"active_fi"], $overview))
5056 $overview[
$row[
"active_fi"]] = array();
5057 $overview[$row[
"active_fi"]][
"firstname"] = $row[
"firstname"];
5058 $overview[$row[
"active_fi"]][
"lastname"] = $row[
"lastname"];
5059 $overview[$row[
"active_fi"]][
"title"] = $row[
"title"];
5060 $overview[$row[
"active_fi"]][
"login"] = $row[
"login"];
5061 $overview[$row[
"active_fi"]][
"usr_id"] = $row[
"usr_id"];
5062 $overview[$row[
"active_fi"]][
"started"] = $row[
"started"];
5063 $overview[$row[
"active_fi"]][
"finished"] = $row[
"finished"];
5065 if (!array_key_exists(
$row[
"pass"], $overview[
$row[
"active_fi"]]))
5067 $overview[$row[
"active_fi"]][$row[
"pass"]] = array();
5068 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] = 0;
5069 $overview[$row[
"active_fi"]][$row[
"pass"]][
"maxpoints"] = $row[
"maxpoints"];
5071 array_push($overview[$row[
"active_fi"]][$row[
"pass"]], $row);
5072 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] += $row[
"points"];
5088 $result = $ilDB->queryF(
"SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
5089 "tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
5090 "qpl_questions.points maxpoints " .
5091 "FROM tst_test_result, qpl_questions, tst_active " .
5092 "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
5093 "WHERE tst_active.active_id = tst_test_result.active_fi " .
5094 "AND qpl_questions.question_id = tst_test_result.question_fi " .
5095 "AND tst_active.test_fi = %s AND tst_active.active_id = %s" .
5096 "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
5097 array(
'integer',
'integer'),
5100 $overview = array();
5103 if (!array_key_exists(
$row[
"active_fi"], $overview))
5105 $overview[
$row[
"active_fi"]] = array();
5106 $overview[$row[
"active_fi"]][
"firstname"] = $row[
"firstname"];
5107 $overview[$row[
"active_fi"]][
"lastname"] = $row[
"lastname"];
5108 $overview[$row[
"active_fi"]][
"title"] = $row[
"title"];
5109 $overview[$row[
"active_fi"]][
"login"] = $row[
"login"];
5110 $overview[$row[
"active_fi"]][
"usr_id"] = $row[
"usr_id"];
5111 $overview[$row[
"active_fi"]][
"started"] = $row[
"started"];
5112 $overview[$row[
"active_fi"]][
"finished"] = $row[
"finished"];
5114 if (!array_key_exists(
$row[
"pass"], $overview[
$row[
"active_fi"]]))
5116 $overview[$row[
"active_fi"]][$row[
"pass"]] = array();
5117 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] = 0;
5118 $overview[$row[
"active_fi"]][$row[
"pass"]][
"maxpoints"] = $row[
"maxpoints"];
5120 array_push($overview[$row[
"active_fi"]][$row[
"pass"]], $row);
5121 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] += $row[
"points"];
5140 if (strlen($firstname.$lastname.$title) == 0)
5142 $name = $this->lng->txt(
"deleted_user");
5146 if ($user_id == ANONYMOUS_USER_ID)
5152 $name = trim($lastname .
", " . $firstname .
" " .
$title);
5156 $name = $this->lng->txt(
"anonymous");
5178 if (strlen($firstname.$lastname.$title) == 0)
5180 $name = $lng->txt(
"deleted_user");
5184 if ($user_id == ANONYMOUS_USER_ID)
5190 $name = trim($lastname .
", " . $firstname .
" " .
$title);
5194 $name = $lng->txt(
"anonymous");
5210 $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",
5217 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->started, $matches);
5218 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5219 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->finished, $matches);
5220 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5221 $times[
$row->active_fi] += ($epoch_2 - $epoch_1);
5225 foreach ($times as $key => $value)
5227 $max_time += $value;
5232 $average_time = round($max_time / $counter);
5238 return $average_time;
5247 function &
getAvailableQuestionpools($use_object_id =
false, $equal_points =
false, $could_be_offline =
false, $show_path = FALSE, $with_questioncount = FALSE, $permission =
"read")
5249 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5261 $time_in_seconds = 0;
5262 foreach ($this->questions as $question_id)
5265 $est_time = $question->getEstimatedWorkingTime();
5266 $time_in_seconds += $est_time[
"h"] * 3600 + $est_time[
"m"] * 60 + $est_time[
"s"];
5268 $hours = (int)($time_in_seconds / 3600) ;
5269 $time_in_seconds = $time_in_seconds - ($hours * 3600);
5270 $minutes = (int)($time_in_seconds / 60);
5271 $time_in_seconds = $time_in_seconds - ($minutes * 60);
5272 $result = array(
"hh" => $hours,
"mm" => $minutes,
"ss" => $time_in_seconds);
5288 foreach ($qpls as $arr) array_push($qplids, $arr[
'qpl']);
5289 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_cpy WHERE tst_fi = %s AND ' . $ilDB->in(
'qpl_fi', $qplids,
false,
'integer'),
5296 while (
$row = $ilDB->fetchAssoc(
$result)) array_push($ids,
$row[
'qst_fi']);
5297 $nr = ($nr > count($ids)) ? count($ids) : $nr;
5298 if ($nr == 0)
return array();
5299 $rand_keys = array_rand($ids, $nr);
5300 $selection = array();
5301 if (is_array($rand_keys))
5303 foreach ($rand_keys as $key)
5305 $selection[$ids[$key]] = $ids[$key];
5310 $selection[$ids[$rand_keys]] = $ids[$rand_keys];
5340 $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",
5344 $original_ids = array();
5345 $paramtypes = array();
5346 $paramvalues = array();
5349 array_push($original_ids,
$row[
'original_id']);
5354 if (($questionpool == 0) && (!is_array($qpls)))
5356 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5358 if (count($available_pools))
5360 $available =
" AND " . $ilDB->in(
'obj_fi', $available_pools,
false,
'integer');
5368 $constraint_qpls =
"";
5369 $result_array = array();
5370 if ($questionpool == 0)
5372 if (is_array($qpls))
5374 if (count($qpls) > 0)
5376 $constraint_qpls =
" AND " . $ilDB->in(
'obj_fi', $qpls,
false,
'integer');
5381 $original_clause =
"";
5382 if (count($original_ids))
5384 $original_clause =
" AND " . $ilDB->in(
'question_id', $original_ids,
true,
'integer');
5387 if ($questionpool == 0)
5389 $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",
5390 array(
'integer',
'text'),
5396 $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",
5397 array(
'integer',
'integer',
'text'),
5398 array($questionpool, 0,
"1")
5401 $found_ids = array();
5404 array_push($found_ids,
$row[
'question_id']);
5406 $nr_of_questions = ($nr_of_questions > count($found_ids)) ? count($found_ids) : $nr_of_questions;
5407 if ($nr_of_questions == 0)
return array();
5408 $rand_keys = array_rand($found_ids, $nr_of_questions);
5410 if (is_array($rand_keys))
5412 foreach ($rand_keys as $key)
5414 $result[$found_ids[$key]] = $found_ids[$key];
5419 $result[$found_ids[$rand_keys]] = $found_ids[$rand_keys];
5432 return CLIENT_WEB_DIR .
"/assessment/" . $this->
getId() .
"/images/";
5443 include_once
"./Services/Utilities/classes/class.ilUtil.php";
5458 if ((!$question_type) and ($question_id > 0))
5462 if (!strlen($question_type))
return null;
5463 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
5465 $question_type_gui = $question_type .
"GUI";
5466 $question =
new $question_type_gui();
5467 if ($question_id > 0)
5469 $question->object->loadFromDb($question_id);
5483 if (strcmp($question_id,
"") != 0)
5485 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
5500 $this->questions = array_values($this->questions);
5501 $array_pos = array_search($target_index, $this->questions);
5502 if ($insert_mode == 0)
5504 $part1 = array_slice($this->questions, 0, $array_pos);
5505 $part2 = array_slice($this->questions, $array_pos);
5507 else if ($insert_mode == 1)
5509 $part1 = array_slice($this->questions, 0, $array_pos + 1);
5510 $part2 = array_slice($this->questions, $array_pos + 1);
5512 foreach ($move_questions as $question_id)
5514 if (!(array_search($question_id, $part1) === FALSE))
5516 unset($part1[array_search($question_id, $part1)]);
5518 if (!(array_search($question_id, $part2) === FALSE))
5520 unset($part2[array_search($question_id, $part2)]);
5523 $part1 = array_values($part1);
5524 $part2 = array_values($part2);
5525 $new_array = array_values(array_merge($part1, $move_questions, $part2));
5526 $this->questions = array();
5528 foreach ($new_array as $question_id)
5530 $this->questions[$counter] = $question_id;
5548 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartingTime(), $matches))
5550 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5552 if ($now < $epoch_time)
5573 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndingTime(), $matches))
5575 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5577 if ($now > $epoch_time)
5597 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5600 if (count($available_pools))
5602 $available =
" AND " . $ilDB->in(
'qpl_questions.obj_fi', $available_pools,
false,
'integer');
5610 $available .=
" AND qpl_questions.complete = " . $ilDB->quote(
"1",
'text');
5614 if (is_array($arrFilter))
5616 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
5618 $where .=
" AND " . $ilDB->like(
'qpl_questions.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
5620 if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description']))
5622 $where .=
" AND " . $ilDB->like(
'qpl_questions.description',
'text',
"%%" . $arrFilter[
'description'] .
"%%");
5624 if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author']))
5626 $where .=
" AND " . $ilDB->like(
'qpl_questions.author',
'text',
"%%" . $arrFilter[
'author'] .
"%%");
5628 if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type']))
5630 $where .=
" AND qpl_qst_type.type_tag = " . $ilDB->quote($arrFilter[
'type'],
'text');
5632 if (array_key_exists(
'qpl', $arrFilter) && strlen($arrFilter[
'qpl']))
5634 $where .=
" AND " . $ilDB->like(
'object_data.title',
'text',
"%%" . $arrFilter[
'qpl'] .
"%%");
5639 $original_clause =
" qpl_questions.original_id IS NULL";
5640 if (count($original_ids))
5642 $original_clause =
" qpl_questions.original_id IS NULL AND " . $ilDB->in(
'qpl_questions.question_id', $original_ids,
true,
'integer');
5645 $query_result = $ilDB->query(
5646 "SELECT qpl_questions.*, qpl_questions.tstamp, qpl_qst_type.type_tag, qpl_qst_type.plugin, object_data.title qpl " .
5647 "FROM qpl_questions, qpl_qst_type, object_data WHERE $original_clause $available AND " .
5648 "object_data.obj_id = qpl_questions.obj_fi AND qpl_questions.tstamp > 0 AND " .
5649 "qpl_questions.question_type_fi = qpl_qst_type.question_type_id$where");
5652 if ($query_result->numRows())
5654 while (
$row = $ilDB->fetchAssoc($query_result))
5656 $row[
'ttype'] = $types[
$row[
'type_tag']];
5661 array_push($rows, $row);
5666 array_push($rows, $row);
5678 global $ilPluginAdmin;
5680 $lng->loadLanguageModule(
"assessment");
5681 $result = $ilDB->query(
"SELECT * FROM qpl_qst_type");
5685 if (
$row[
"plugin"] == 0)
5687 $types[
$row[
'type_tag']] = $lng->txt($row[
"type_tag"]);
5691 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
5692 foreach ($pl_names as $pl_name)
5695 if (strcmp($pl->getQuestionType(),
$row[
"type_tag"]) == 0)
5697 $types[
$row[
'type_tag']] = $pl->getQuestionTypeTranslation();
5717 $this->
setTitle($assessment->getTitle());
5719 foreach ($assessment->objectives as $objectives)
5721 foreach ($objectives->materials as $material)
5726 if ($assessment->getPresentationMaterial())
5731 foreach ($assessment->assessmentcontrol as $assessmentcontrol)
5733 switch ($assessmentcontrol->getSolutionswitch())
5744 foreach ($assessment->qtimetadata as
$metadata)
5746 switch ($metadata[
"label"])
5750 $type = $metadata[
"entry"];
5771 case "sequence_settings":
5781 $this->
setKiosk($metadata[
"entry"]);
5783 case "showfinalstatement":
5795 case "hide_previous_results":
5796 if ($metadata[
"entry"] == 0)
5805 case "use_previous_answers":
5808 case "answer_feedback":
5811 case "hide_title_points":
5814 case "title_output":
5820 case "random_question_count":
5823 case "results_presentation":
5826 case "reset_processing_time":
5829 case "instant_verification":
5832 case "answer_feedback_points":
5844 case "fixed_participants":
5847 case "score_reporting":
5850 case "shuffle_questions":
5853 case "count_system":
5859 case "mailnotification":
5865 case "exportsettings":
5868 case "score_cutting":
5874 case "allowedUsers":
5877 case "allowedUsersTimeGap":
5880 case "pass_scoring":
5883 case "show_summary":
5886 case "reporting_date":
5887 $iso8601period = $metadata[
"entry"];
5888 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
5890 $this->
setReportingDate(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
5893 case "processing_time":
5896 case "starting_time":
5897 $iso8601period = $metadata[
"entry"];
5898 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
5900 $this->
setStartingTime(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
5904 $iso8601period = $metadata[
"entry"];
5905 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
5907 $this->
setEndingTime(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
5911 if (preg_match(
"/mark_step_\d+/", $metadata[
"label"]))
5913 $xmlmark = $metadata[
"entry"];
5914 preg_match(
"/<short>(.*?)<\/short>/", $xmlmark, $matches);
5915 $mark_short = $matches[1];
5916 preg_match(
"/<official>(.*?)<\/official>/", $xmlmark, $matches);
5917 $mark_official = $matches[1];
5918 preg_match(
"/<percentage>(.*?)<\/percentage>/", $xmlmark, $matches);
5919 $mark_percentage = $matches[1];
5920 preg_match(
"/<passed>(.*?)<\/passed>/", $xmlmark, $matches);
5921 $mark_passed = $matches[1];
5922 $this->mark_schema->addMarkStep($mark_short, $mark_official, $mark_percentage, $mark_passed);
5926 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
5928 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
5929 include_once
"./Services/RTE/classes/class.ilRTE.php";
5930 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5931 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
5934 if (file_exists($importfile))
5944 $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
5959 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
5963 $a_xml_writer->xmlSetDtdDef(
"<!DOCTYPE questestinterop SYSTEM \"ims_qtiasiv1p2p1.dtd\">");
5964 $a_xml_writer->xmlStartTag(
"questestinterop");
5967 "ident" =>
"il_".IL_INST_ID.
"_tst_".$this->getTestId(),
5970 $a_xml_writer->xmlStartTag(
"assessment", $attrs);
5972 $a_xml_writer->xmlElement(
"qticomment", NULL, $this->
getDescription());
5975 if ($this->enable_processing_time)
5977 preg_match(
"/(\d+):(\d+):(\d+)/", $this->processing_time, $matches);
5978 $a_xml_writer->xmlElement(
"duration", NULL, sprintf(
"P0Y0M0DT%dH%dM%dS", $matches[1], $matches[2], $matches[3]));
5982 $a_xml_writer->xmlStartTag(
"qtimetadata");
5983 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5984 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ILIAS_VERSION");
5985 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->ilias->getSetting(
"ilias_version"));
5986 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5989 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5990 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"anonymity");
5991 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getAnonymity()));
5992 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5995 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5996 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"random_test");
5997 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
isRandomTest()));
5998 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6001 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6002 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"sequence_settings");
6004 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6007 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6008 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"author");
6009 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getAuthor());
6010 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6013 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6014 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"reset_processing_time");
6016 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6019 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6020 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"count_system");
6021 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getCountSystem());
6022 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6025 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6026 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mc_scoring");
6027 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getMCScoring());
6028 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6031 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6032 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"score_cutting");
6033 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getScoreCutting());
6034 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6037 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6038 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"password");
6039 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getPassword());
6040 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6043 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6044 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"allowedUsers");
6045 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getAllowedUsers());
6046 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6049 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6050 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"allowedUsersTimeGap");
6052 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6055 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6056 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"pass_scoring");
6057 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getPassScoring());
6058 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6063 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6064 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"reporting_date");
6065 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->reporting_date, $matches);
6066 $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]));
6067 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6070 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6071 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"nr_of_tries");
6072 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getNrOfTries()));
6073 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6076 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6077 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"kiosk");
6078 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getKiosk()));
6079 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6082 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6083 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"use_previous_answers");
6085 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6088 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6089 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"title_output");
6090 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getTitleOutput()));
6091 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6094 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6095 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"random_question_count");
6097 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6100 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6101 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"results_presentation");
6103 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6106 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6107 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"show_summary");
6109 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6112 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6113 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"score_reporting");
6114 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getScoreReporting()));
6115 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6118 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6119 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"instant_verification");
6121 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6124 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6125 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"answer_feedback");
6126 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getAnswerFeedback()));
6127 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6130 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6131 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"answer_feedback_points");
6133 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6136 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6137 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"show_cancel");
6138 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShowCancel()));
6139 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6142 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6143 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"show_marker");
6144 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShowMarker()));
6145 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6148 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6149 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"fixed_participants");
6151 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6154 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6155 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"showfinalstatement");
6156 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getShowFinalStatement()) ?
"1" :
"0")));
6157 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6160 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6161 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"showinfo");
6162 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getShowInfo()) ?
"1" :
"0")));
6163 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6166 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6167 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mailnotification");
6169 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6172 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6173 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mailnottype");
6175 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6178 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6179 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"exportsettings");
6181 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6184 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6185 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"forcejs");
6186 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getForceJS()) ?
"1" :
"0")));
6187 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6190 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6191 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"customstyle");
6192 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getCustomStyle());
6193 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6196 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6197 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"shuffle_questions");
6198 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShuffleQuestions()));
6199 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6202 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6203 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"processing_time");
6205 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6210 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6211 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"starting_time");
6212 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->starting_time, $matches);
6213 $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]));
6214 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6219 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6220 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ending_time");
6221 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->ending_time, $matches);
6222 $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]));
6223 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6225 foreach ($this->mark_schema->mark_steps as $index => $mark)
6228 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6229 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mark_step_$index");
6230 $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()));
6231 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6233 $a_xml_writer->xmlEndTag(
"qtimetadata");
6236 $a_xml_writer->xmlStartTag(
"objectives");
6238 $a_xml_writer->xmlEndTag(
"objectives");
6244 "solutionswitch" =>
"Yes"
6251 $a_xml_writer->xmlElement(
"assessmentcontrol", $attrs, NULL);
6256 $a_xml_writer->xmlStartTag(
"presentation_material");
6257 $a_xml_writer->xmlStartTag(
"flow_mat");
6259 $a_xml_writer->xmlEndTag(
"flow_mat");
6260 $a_xml_writer->xmlEndTag(
"presentation_material");
6266 $a_xml_writer->xmlElement(
"section", $attrs, NULL);
6267 $a_xml_writer->xmlEndTag(
"assessment");
6268 $a_xml_writer->xmlEndTag(
"questestinterop");
6270 $xml = $a_xml_writer->xmlDumpMem(FALSE);
6272 foreach ($this->questions as $question_id)
6275 $qti_question = $question->toXML(
false);
6276 $qti_question = preg_replace(
"/<questestinterop>/",
"", $qti_question);
6277 $qti_question = preg_replace(
"/<\/questestinterop>/",
"", $qti_question);
6278 if (strpos($xml,
"</section>") !==
false)
6280 $xml = str_replace(
"</section>",
"$qti_question</section>", $xml);
6284 $xml = str_replace(
"<section ident=\"1\"/>",
"<section ident=\"1\">\n$qti_question</section>", $xml);
6300 $this->mob_ids = array();
6301 $this->file_ids = array();
6304 $attrs[
"Type"] =
"Test";
6305 $a_xml_writer->xmlStartTag(
"ContentObject", $attrs);
6311 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Page Objects");
6312 $ilBench->start(
"ContentObjectExport",
"exportPageObjects");
6314 $ilBench->stop(
"ContentObjectExport",
"exportPageObjects");
6315 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Page Objects");
6318 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Media Objects");
6319 $ilBench->start(
"ContentObjectExport",
"exportMediaObjects");
6321 $ilBench->stop(
"ContentObjectExport",
"exportMediaObjects");
6322 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Media Objects");
6325 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export File Items");
6326 $ilBench->start(
"ContentObjectExport",
"exportFileItems");
6328 $ilBench->stop(
"ContentObjectExport",
"exportFileItems");
6329 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export File Items");
6331 $a_xml_writer->xmlEndTag(
"ContentObject");
6342 include_once
"./Services/MetaData/classes/class.ilMD2XML.php";
6344 $md2xml->setExportMode(
true);
6345 $md2xml->startExport();
6346 $a_xml_writer->appendXML($md2xml->getXML());
6356 if ($a_tag ==
"Identifier" && $a_param ==
"Entry")
6358 include_once
"./Services/Utilities/classes/class.ilUtil.php";
6376 include_once
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
6378 foreach ($this->questions as $question_id)
6380 $ilBench->start(
"ContentObjectExport",
"exportPageObject");
6381 $expLog->write(date(
"[y-m-d H:i:s] ").
"Page Object ".$question_id);
6384 $a_xml_writer->xmlStartTag(
"PageObject", $attrs);
6388 $ilBench->start(
"ContentObjectExport",
"exportPageObject_XML");
6390 $page_object->buildDom();
6391 $page_object->insertInstIntoIDs($a_inst);
6392 $mob_ids = $page_object->collectMediaObjects(
false);
6393 $file_ids = $page_object->collectFileItems();
6394 $xml = $page_object->getXMLFromDom(
false,
false,
false,
"",
true);
6395 $xml = str_replace(
"&",
"&", $xml);
6396 $a_xml_writer->appendXML($xml);
6397 $page_object->freeDom();
6398 unset ($page_object);
6400 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_XML");
6403 $ilBench->start(
"ContentObjectExport",
"exportPageObject_CollectMedia");
6405 foreach($mob_ids as $mob_id)
6407 $this->mob_ids[$mob_id] = $mob_id;
6409 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_CollectMedia");
6412 $ilBench->start(
"ContentObjectExport",
"exportPageObject_CollectFileItems");
6414 foreach($file_ids as $file_id)
6416 $this->file_ids[$file_id] = $file_id;
6418 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_CollectFileItems");
6420 $a_xml_writer->xmlEndTag(
"PageObject");
6423 $ilBench->stop(
"ContentObjectExport",
"exportPageObject");
6437 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
6439 foreach ($this->mob_ids as $mob_id)
6441 $expLog->write(date(
"[y-m-d H:i:s] ").
"Media Object ".$mob_id);
6445 $media_obj->exportXML($a_xml_writer, $a_inst);
6446 $media_obj->exportFiles($a_target_dir);
6458 include_once
"./Modules/File/classes/class.ilObjFile.php";
6460 foreach ($this->file_ids as $file_id)
6462 $expLog->write(date(
"[y-m-d H:i:s] ").
"File Item ".$file_id);
6463 $file_obj =
new ilObjFile($file_id,
false);
6464 $file_obj->export($a_target_dir);
6475 if (!is_array($this->import_mapping))
6481 return $this->import_mapping;
6496 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);
6507 function _getECTSGrade($points_passed, $reached_points, $max_points, $a, $b, $c,
$d, $e, $fx)
6509 include_once
"./classes/class.ilStatistics.php";
6512 $passed_statistics->setData($points_passed);
6513 $ects_percentiles = array
6515 "A" => $passed_statistics->quantile($a),
6516 "B" => $passed_statistics->quantile($b),
6517 "C" => $passed_statistics->quantile($c),
6518 "D" => $passed_statistics->quantile(
$d),
6519 "E" => $passed_statistics->quantile($e)
6521 if (count($points_passed) && ($reached_points >= $ects_percentiles[
"A"]))
6525 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"B"]))
6529 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"C"]))
6533 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"D"]))
6537 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"E"]))
6541 else if (strcmp($fx,
"") != 0)
6543 if ($max_points > 0)
6545 $percentage = ($reached_points / $max_points) * 100.0;
6546 if ($percentage < 0) $percentage = 0.0;
6552 if ($percentage >= $fx)
6569 return $this->mark_schema->checkMarks();
6601 $md_life =& $md->getLifecycle();
6604 if (strlen($a_author) == 0)
6607 $a_author = $ilUser->getFullname();
6610 $md_life =& $md->addLifecycle();
6612 $con =& $md_life->addContribute();
6613 $con->setRole(
"Author");
6615 $ent =& $con->addEntity();
6616 $ent->setEntity($a_author);
6642 include_once
"./Services/MetaData/classes/class.ilMD.php";
6644 $md_life =& $md->getLifecycle();
6647 $ids =& $md_life->getContributeIds();
6648 foreach ($ids as
$id)
6650 $md_cont =& $md_life->getContribute($id);
6651 if (strcmp($md_cont->getRole(),
"Author") == 0)
6653 $entids =& $md_cont->getEntityIds();
6654 foreach ($entids as $entid)
6656 $md_ent =& $md_cont->getEntity($entid);
6657 array_push(
$author, $md_ent->getEntity());
6675 include_once
"./Services/MetaData/classes/class.ilMD.php";
6676 $md =&
new ilMD($obj_id, 0,
"tst");
6677 $md_life =& $md->getLifecycle();
6680 $ids =& $md_life->getContributeIds();
6681 foreach ($ids as
$id)
6683 $md_cont =& $md_life->getContribute($id);
6684 if (strcmp($md_cont->getRole(),
"Author") == 0)
6686 $entids =& $md_cont->getEntityIds();
6687 foreach ($entids as $entid)
6689 $md_ent =& $md_cont->getEntity($entid);
6690 array_push(
$author, $md_ent->getEntity());
6709 $result_array = array();
6719 $result_array[$obj_id] = $titles[
$ref_id];
6727 return $result_array;
6742 $result = $ilDB->queryF(
"SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY sequence, test_random_id",
6750 $next_id = $ilDB->nextId(
'tst_test_random');
6751 $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)",
6752 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
6753 array($next_id, $new_id,
$row[
"questionpool_fi"],
$row[
"num_of_q"], time(),
$row[
'sequence'])
6797 $newObj->setKiosk($this->
getKiosk());
6821 $newObj->saveToDb();
6824 include_once
"./Services/Certificate/classes/class.ilCertificate.php";
6825 include_once
"./Modules/Test/classes/class.ilTestCertificateAdapter.php";
6828 $cert->cloneCertificate($newcert);
6832 $newObj->saveRandomQuestionCount($newObj->getRandomQuestionCount());
6837 include_once(
"./Services/CopyWizard/classes/class.ilCopyWizardOptions.php");
6841 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
6842 foreach ($this->questions as $key => $question_id)
6845 $newObj->questions[$key] = $question->duplicate();
6848 $question->saveToDb($original_id);
6852 $cwo->appendMapping($this->
getRefId().
'_'.$question_id,$newObj->getRefId().
'_'.$newObj->questions[$key]);
6853 $ilLog->write(__METHOD__.
': Added mapping '.$this->getRefId().
'_'.$question_id.
' <-> ' .
6854 $newObj->getRefId().
'_'.$newObj->questions[$key]);
6857 $newObj->saveToDb();
6878 foreach ($qpls as
$data)
6880 $maxcount += $data[
"contains"];
6882 if ($num > $maxcount) $num = $maxcount;
6887 foreach ($qpls as
$data)
6889 $add = ($data[
"count"] <= $data[
"contains"]) ? $data[
"count"] : $data[
"contains"];
6896 $num = count($this->questions);
6913 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
6923 if (
$test[
"random_test"] == 1)
6927 $result = $ilDB->queryF(
"SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY sequence, test_random_id",
6935 $countresult = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND qpl_questions.tstamp > 0 AND original_id IS NULL",
6937 $row[
"questionpool_fi"]
6939 $contains = $countresult->numRows();
6940 $qpls[$counter] = array(
6941 "index" => $counter,
6942 "count" =>
$row[
"num_of_q"],
6943 "qpl" =>
$row[
"questionpool_fi"],
6944 "contains" => $contains
6949 if (
$test[
"random_question_count"] > 0)
6951 $num =
$test[
"random_question_count"];
6953 foreach ($qpls as
$data)
6955 $maxcount += $data[
"contains"];
6957 if ($num > $maxcount) $num = $maxcount;
6962 foreach ($qpls as
$data)
6964 $add = ($data[
"count"] <= $data[
"contains"]) ? $data[
"count"] : $data[
"contains"];
6971 $result = $ilDB->queryF(
"SELECT test_question_id FROM tst_test_question WHERE test_fi = %s",
6991 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
6995 $this->questions = array();
7009 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
7013 $this->questions = array();
7029 if (strcmp($question_id,
"") != 0)
7031 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
7034 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
7049 $result = $ilDB->queryF(
"SELECT obj_fi FROM tst_tests WHERE test_id = %s",
7056 $object_id =
$row[
"obj_fi"];
7072 $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",
7079 $object_id =
$row[
"obj_fi"];
7095 $result = $ilDB->queryF(
"SELECT test_id FROM tst_tests WHERE obj_fi = %s",
7120 if (($active_id) && ($question_id))
7124 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
7127 $result = $ilDB->queryF(
"SELECT value1 FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
7128 array(
'integer',
'integer',
'integer'),
7129 array($active_id, $question_id,
$pass)
7154 $result = $ilDB->queryF(
"SELECT question_text FROM qpl_questions WHERE question_id = %s",
7177 $result_array = array();
7181 if (is_numeric($user_id))
7183 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, %s login, %s lastname, %s firstname, tst_invited_user.clientip, " .
7184 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7185 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7186 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
7188 array(
'text',
'text',
'text',
'integer',
'integer'),
7189 array(
"", $this->lng->txt(
"unknown"),
"", $this->
getTestId(), $user_id)
7194 $result = $ilDB->queryF(
"SELECT tst_active.active_id, usr_id, %s login, %s lastname, %s firstname, tst_invited_user.clientip, " .
7195 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7196 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7197 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
7199 array(
'text',
'text',
'text',
'integer'),
7200 array(
"", $this->lng->txt(
"unknown"),
"", $this->
getTestId())
7206 if (is_numeric($user_id))
7208 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
7209 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7210 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7211 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
7213 array(
'integer',
'integer'),
7219 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
7220 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7221 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7222 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
7229 $result_array = array();
7232 $result_array[
$row[
'usr_id']]=
$row;
7234 return $result_array;
7249 $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 ".
7250 "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),
7251 array(
'text',
'text',
'text',
'integer'),
7252 array(
"", $this->lng->txt(
"unknown"),
"", $this->
getTestId())
7257 $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 ".
7258 "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),
7268 foreach (
$data as $index => $participant)
7270 if (strlen(trim($participant[
"firstname"].$participant[
"lastname"])) == 0)
7272 $data[$index][
"lastname"] = $this->lng->txt(
"deleted_user");
7282 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
7284 if (count($scoring) == 0)
return array();
7287 $filtered_participants = array();
7288 foreach ($participants as $active_id => $participant)
7290 $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",
7300 if ($participant->active) $filtered_participants[$active_id] = $participant;
7303 if (!$participant->active) $filtered_participants[$active_id] = $participant;
7306 $filtered_participants[$active_id] = $participant;
7321 $assessmentSetting =
new ilSetting(
"assessment");
7322 $manscoring_done = $assessmentSetting->get(
"manscoring_done_" . $active_id);
7323 if ($manscoring_done) $filtered_participants[$active_id] = $participant;
7335 $assessmentSetting =
new ilSetting(
"assessment");
7336 $manscoring_done = $assessmentSetting->get(
"manscoring_done_" . $active_id);
7337 if (!$manscoring_done) $filtered_participants[$active_id] = $participant;
7345 if (
$row[
"manual"]) $found++;
7347 if (($found > 0) && ($found < $count)) $filtered_participants[$active_id] = $participant;
7350 $filtered_participants[$active_id] = $participant;
7355 return $filtered_participants;
7369 if (!is_array($ids) || count($ids) ==0)
return array();
7373 $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",
7374 array(
'text',
'text',
'text'),
7375 array(
"", $this->lng->txt(
"unknown"),
"")
7380 $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");
7383 $result_array = array();
7386 $result_array[
$row[
"usr_id"]]=
$row;
7388 return $result_array;
7393 if (!is_array($ids) || count($ids) ==0)
return array();
7405 if (!is_array($ids) || count($ids) ==0)
return array();
7407 foreach ($ids as $obj_id)
7423 include_once
"./Modules/Group/classes/class.ilObjGroup.php";
7425 $members = $group->getGroupMemberIds();
7426 include_once
'./Services/User/classes/class.ilObjUser.php';
7427 foreach ($members as $user_id)
7442 $members = $rbacreview->assignedUsers($role_id,
"usr_id");
7443 include_once
'./Services/User/classes/class.ilObjUser.php';
7444 foreach ($members as $user_id)
7462 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
7463 array(
'integer',
'integer'),
7478 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
7479 array(
'integer',
'integer'),
7482 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_invited_user (test_fi, user_fi, clientip, tstamp) VALUES (%s, %s, %s, %s)",
7483 array(
'integer',
'integer',
'text',
'integer'),
7484 array($this->
getTestId(), $user_id, (strlen($client_ip)) ? $client_ip : NULL, time())
7493 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_invited_user SET clientip = %s, tstamp = %s WHERE test_fi=%s and user_fi=%s",
7494 array(
'text',
'integer',
'integer',
'integer'),
7495 array((strlen($client_ip)) ? $client_ip : NULL, time(), $this->
getTestId(), $user_id)
7507 if (is_numeric($question_fi))
7509 $result = $ilDB->queryF(
"SELECT question_fi, solved FROM tst_qst_solved WHERE active_fi = %s AND question_fi=%s",
7510 array(
'integer',
'integer'),
7511 array($active_id, $question_fi)
7516 $result = $ilDB->queryF(
"SELECT question_fi, solved FROM tst_qst_solved WHERE active_fi = %s",
7521 $result_array = array();
7524 $result_array[
$row[
"question_fi"]]=
$row;
7526 return $result_array;
7538 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s AND question_fi = %s",
7539 array(
'integer',
'integer'),
7540 array($active_id, $question_id)
7542 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_qst_solved (solved, question_fi, active_fi) VALUES (%s, %s, %s)",
7543 array(
'integer',
'integer',
'integer'),
7544 array($value, $question_id, $active_id)
7556 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s, tstamp = %s WHERE test_fi = %s AND user_fi = %s",
7557 array(
'integer',
'timestamp',
'integer',
'integer',
'integer'),
7558 array(1, date(
'Y-m-d H:i:s'), time(), $this->
getTestId(), $user_id)
7560 $this->testSession = NULL;
7570 $result = $ilDB->queryF(
"SELECT submitted FROM tst_active WHERE active_id=%s AND submitted=%s",
7571 array(
'integer',
'integer'),
7572 array($active_id, 1)
7574 return $result->numRows() == 1;
7585 if (!is_numeric($user_id))
7586 $user_id = $ilUser->getId();
7588 $result = $ilDB->queryF(
"SELECT submitted FROM tst_active WHERE test_fi=%s AND user_fi=%s AND submitted=%s",
7589 array(
'integer',
'integer',
'integer'),
7592 return $result->numRows() == 1;
7626 "user_id" => $this->lng->txt(
"user_id"),
7627 "matriculation" => $this->lng->txt(
"matriculation"),
7628 "lastname" => $this->lng->txt(
"lastname"),
7629 "firstname" => $this->lng->txt(
"firstname"),
7630 "login" =>$this->lng->txt(
"login"),
7631 "reached_points" => $this->lng->txt(
"tst_reached_points"),
7632 "max_points" => $this->lng->txt(
"tst_maximum_points"),
7633 "percent_value" => $this->lng->txt(
"tst_percent_solved"),
7634 "mark" => $this->lng->txt(
"tst_mark"),
7635 "ects" => $this->lng->txt(
"ects_grade")
7638 if (count($participants))
7640 if ($this->ects_output)
7644 foreach ($participants as $active_id => $user_rec)
7647 $reached_points = 0;
7649 foreach ($this->questions as $value)
7652 if (is_object($question))
7654 $max_points += $question->getMaximumPoints();
7655 $reached_points += $question->getReachedPoints($active_id);
7658 if ($max_points > 0)
7660 $percentvalue = $reached_points / $max_points;
7661 if ($percentvalue < 0) $percentvalue = 0.0;
7667 $mark_obj = $this->mark_schema->getMatchingMark($percentvalue * 100);
7671 $mark = $mark_obj->getOfficialName();
7672 $ects_mark = $this->
getECTSGrade($passed_array, $reached_points, $max_points);
7676 $user_rec[
'firstname'] =
"";
7677 $user_rec[
'lastname'] = $this->lng->txt(
"unknown");
7680 "user_id"=>$user_rec[
'usr_id'],
7681 "matriculation" => $user_rec[
'matriculation'],
7682 "lastname" => $user_rec[
'lastname'],
7683 "firstname" => $user_rec[
'firstname'],
7684 "login"=>$user_rec[
'login'],
7685 "reached_points" => $reached_points,
7686 "max_points" => $max_points,
7687 "percent_value" => $percentvalue,
7689 "ects" => $ects_mark
7709 $resultarray = array();
7710 foreach (
$row as $rowindex => $entry)
7717 if (strpos($entry,
"\"") !== FALSE)
7719 $entry = str_replace(
"\"",
"\"\"", $entry);
7727 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
7730 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
7734 $resultarray[$rowindex] = utf8_decode($entry);
7737 return $resultarray;
7751 $result = $ilDB->queryF(
"SELECT tries FROM tst_active WHERE active_id = %s",
7758 return $row[
"tries"];
7778 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s",
7785 $max =
$row[
"maxpass"];
7806 $result = $ilDB->queryF(
"SELECT * FROM tst_pass_result WHERE active_fi = %s",
7816 $factor =
$row[
"points"] /
$row[
"maxpoints"];
7818 if($factor > $bestfactor)
7821 $bestfactor = $factor;
7824 if (is_array($bestrow))
7826 return $bestrow[
"pass"];
7849 $counted_pass = NULL;
7858 return $counted_pass;
7876 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
7878 foreach ($this->questions as $value)
7882 $workedthrough += 1;
7885 return $workedthrough;
7901 $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",
7902 array(
'integer',
'integer'),
7903 array($active_id,
$pass)
7908 return $row[
"tstamp"];
7926 "executable" =>
true,
7927 "errormessage" =>
""
7931 $result[
"executable"] =
false;
7937 $result[
"executable"] =
false;
7966 $result[
"executable"] =
false;
7967 $result[
"errormessage"] = $this->lng->txt(
"detail_max_processing_time_reached");
7977 $result[
"executable"] =
false;
7978 $result[
"errormessage"] = $this->lng->txt(
"maximum_nr_of_tries_reached");
7984 $result[
"executable"] = FALSE;
7985 $result[
"errormessage"] = $this->lng->txt(
"maximum_nr_of_tries_reached");
8006 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getReportingDate(), $matches))
8008 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
8010 if ($now < $epoch_time)
8026 $notimeleft = FALSE;
8051 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getReportingDate(), $matches))
8053 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
8055 if ($now < $epoch_time)
8080 if ($active_id < 1)
return FALSE;
8082 $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",
8083 array(
'integer',
'integer'),
8084 array($active_id,
$pass)
8089 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches))
8091 return mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
8136 $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",
8140 $removableQuestions = array();
8141 while (
$row = $ilDB->fetchAssoc($query_result))
8143 array_push($removableQuestions,
$row);
8145 return $removableQuestions;
8156 return ($this->shuffle_questions) ? 1 : 0;
8167 $this->shuffle_questions = ($a_shuffle) ? 1 : 0;
8184 return ($this->show_summary) ? $this->show_summary : 0;
8201 $this->show_summary = $a_value;
8212 if (($this->show_summary & 1) > 0)
8232 $this->show_summary = 1;
8236 $this->show_summary = 0;
8248 if (($this->show_summary & 2) > 0)
8268 $this->show_summary = $this->show_summary | 2;
8274 $this->show_summary = $this->show_summary ^ 2;
8287 if (($this->show_summary & 4) > 0)
8307 $this->show_summary = $this->show_summary | 4;
8313 $this->show_summary = $this->show_summary ^ 4;
8326 if (($this->show_summary & 8) > 0)
8346 $this->show_summary = $this->show_summary | 8;
8352 $this->show_summary = $this->show_summary ^ 8;
8365 return ($this->results_presentation) ? $this->results_presentation : 0;
8376 if (($this->results_presentation & 1) > 0)
8394 if (($this->results_presentation & 2) > 0)
8412 if (($this->results_presentation & 4) > 0)
8430 if (($this->results_presentation & 8) > 0)
8448 if (($this->results_presentation & 16) > 0)
8466 if (($this->results_presentation & 32) > 0)
8482 if (($this->results_presentation & 64) > 0)
8500 $this->results_presentation = $a_results_presentation;
8515 $this->results_presentation = $this->results_presentation | 1;
8521 $this->results_presentation = $this->results_presentation ^ 1;
8536 $this->results_presentation = $this->results_presentation | 2;
8542 $this->results_presentation = $this->results_presentation ^ 2;
8568 $this->results_presentation = $this->results_presentation | 4;
8574 $this->results_presentation = $this->results_presentation ^ 4;
8589 $this->results_presentation = $this->results_presentation | 8;
8595 $this->results_presentation = $this->results_presentation ^ 8;
8610 $this->results_presentation = $this->results_presentation | 16;
8616 $this->results_presentation = $this->results_presentation ^ 16;
8631 $this->results_presentation = $this->results_presentation | 32;
8637 $this->results_presentation = $this->results_presentation ^ 32;
8652 $this->results_presentation = $this->results_presentation | 64;
8658 $this->results_presentation = $this->results_presentation ^ 64;
8671 $codestring =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
8674 for ($i = 1; $i <=5; $i++)
8676 $index = mt_rand(0, strlen($codestring)-1);
8677 $code .= substr($codestring, $index, 1);
8691 $result = $ilDB->queryF(
"SELECT anonymous_id FROM tst_active WHERE test_fi = %s AND anonymous_id = %s",
8692 array(
'integer',
'text'),
8695 return (
$result->numRows() > 0) ?
true :
false;
8701 $result = $ilDB->queryF(
"SELECT user_fi FROM tst_active WHERE active_id = %s",
8708 return $row[
"user_fi"];
8719 if (!is_array(
$_SESSION[
"tst_access_code"]))
8725 return $_SESSION[
"tst_access_code"][
"$id"];
8732 if (!is_array(
$_SESSION[
"tst_access_code"]))
8736 $_SESSION[
"tst_access_code"][
"$id"] = $access_code;
8742 unset(
$_SESSION[
"tst_access_code"][
"$id"]);
8747 return ($this->allowedUsers) ? $this->allowedUsers : 0;
8752 $this->allowedUsers = $a_allowed_users;
8757 return ($this->allowedUsersTimeGap) ? $this->allowedUsersTimeGap : 0;
8762 $this->allowedUsersTimeGap = $a_allowed_users_time_gap;
8771 if (($nr_of_users > 0) && ($time_gap > 0))
8774 $time_border = $now - $time_gap;
8775 $str_time_border = strftime(
"%Y%m%d%H%M%S", $time_border);
8776 $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",
8777 array(
'integer',
'integer'),
8780 if (
$result->numRows() >= $nr_of_users)
8782 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
8801 $result = $ilDB->queryF(
"SELECT finished FROM tst_times WHERE active_fi = %s ORDER BY finished DESC",
8808 return $row[
"finished"];
8822 if (preg_match(
"/<[^>]*?>/", $a_text))
8842 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
8844 $material = $a_material->getMaterial($i);
8845 if (strcmp($material[
"type"],
"mattext") == 0)
8847 $result .= $material[
"material"]->getContent();
8849 if (strcmp($material[
"type"],
"matimage") == 0)
8851 $matimage = $material[
"material"];
8852 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
8855 if (!is_array(
$_SESSION[
"import_mob_xhtml"]))
$_SESSION[
"import_mob_xhtml"] = array();
8856 array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(),
"uri" => $matimage->getUri()));
8861 $ilLog->write(print_r(
$_SESSION[
"import_mob_xhtml"],
true));
8875 include_once
"./Services/RTE/classes/class.ilRTE.php";
8876 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
8878 $a_xml_writer->xmlStartTag(
"material");
8880 "texttype" =>
"text/plain"
8882 if ($this->
isHTML($a_material))
8884 $attrs[
"texttype"] =
"text/xhtml";
8889 foreach (
$mobs as $mob)
8891 $moblabel =
"il_" . IL_INST_ID .
"_mob_" . $mob;
8892 if (strpos($a_material,
"mm_$mob") !== FALSE)
8898 "label" => $moblabel,
8899 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
8902 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
8905 $a_xml_writer->xmlEndTag(
"material");
8916 include_once
"./Services/Utilities/classes/class.ilUtil.php";
8930 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET certificate_visibility = %s, tstamp = %s WHERE test_id = %s",
8931 array(
'text',
'integer',
'integer'),
8932 array($a_value, time(), $this->
getTestId())
8944 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
8955 $this->certificate_visibility = $a_value;
8966 return ($this->anonymity) ? 1 : 0;
8980 $this->anonymity = 1;
8983 $this->anonymity = 0;
8996 return ($this->show_cancel) ? 1 : 0;
9010 $this->show_cancel = 1;
9013 $this->show_cancel = 0;
9026 return ($this->show_marker) ? 1 : 0;
9040 $this->show_marker = 1;
9043 $this->show_marker = 0;
9056 return ($this->fixed_participants) ? 1 : 0;
9070 $this->fixed_participants = 1;
9073 $this->fixed_participants = 0;
9089 $result = $ilDB->queryF(
"SELECT anonymity FROM tst_tests WHERE obj_fi = %s",
9095 return $row[
'anonymity'];
9111 $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",
9117 return $row[
'random_test'];
9134 return $this->lng->txt(
"unknown") . $suffix;
9138 include_once
'./Services/User/classes/class.ilObjUser.php';
9140 if (strlen($uname[
"firstname"].$uname[
"lastname"]) == 0) $uname[
"firstname"] = $this->lng->txt(
"deleted_user");
9143 return trim($uname[
"lastname"] .
", " . $uname[
"firstname"]) . $suffix;
9147 return trim($uname[
"firstname"] .
" " . $uname[
"lastname"]) . $suffix;
9163 return $this->lng->txt(
"tst_start_test");
9165 $active_pass = $this->
_getPass($active_id);
9169 if ($active_pass == 0)
9171 return $this->lng->txt(
"tst_start_test");
9175 return $this->lng->txt(
"tst_start_new_test_pass");
9180 return $this->lng->txt(
"tst_resume_test");
9197 $result = $ilDB->queryF(
"SELECT * FROM tst_test_defaults WHERE user_fi = %s ORDER BY $sortby $sortorder",
9199 array($ilUser->getId())
9201 $defaults = array();
9204 $defaults[
$row[
"test_defaults_id"]] =
$row;
9220 $result = $ilDB->queryF(
"SELECT * FROM tst_test_defaults WHERE test_defaults_id = %s",
9222 array($test_defaults_id)
9244 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_defaults WHERE test_defaults_id = %s",
9246 array($test_default_id)
9260 $testsettings = array(
9300 $next_id = $ilDB->nextId(
'tst_test_defaults');
9301 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_defaults (test_defaults_id, name, user_fi, defaults, marks, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
9302 array(
'integer',
'text',
'integer',
'text',
'text',
'integer'),
9303 array($next_id, $a_name, $ilUser->getId(), serialize($testsettings), serialize($this->mark_schema), time())
9322 $testsettings = unserialize($defaults[
"defaults"]);
9323 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
9324 $this->mark_schema = unserialize($defaults[
"marks"]);
9350 $this->
setKiosk($testsettings[
"Kiosk"]);
9353 $this->
setECTSFX($testsettings[
"ECTSFX"]);
9378 if (extension_loaded(
"tidy"))
9382 "output-xml" =>
true,
9383 "numeric-entities" =>
true
9387 $tidy->cleanRepair();
9388 $print_output = tidy_get_output(
$tidy);
9389 $print_output = preg_replace(
"/^.*?(<html)/",
"\\1", $print_output);
9393 $print_output = str_replace(
" ",
" ", $print_output);
9394 $print_output = str_replace(
"⊗",
"X", $print_output);
9396 $xsl = file_get_contents(
"./Modules/Test/xml/question2fo.xsl");
9397 $args = array(
'/_xml' => $print_output,
'/_xsl' => $xsl );
9400 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, $params);
9414 $content = preg_replace(
"/href=\".*?\"/",
"", $content);
9415 $printbody =
new ilTemplate(
"tpl.il_as_tst_print_body.html", TRUE, TRUE,
"Modules/Test");
9417 $printbody->setVariable(
"ADM_CONTENT", $content);
9418 $printbody->setCurrentBlock(
"css_file");
9420 $printbody->parseCurrentBlock();
9421 $printbody->setCurrentBlock(
"css_file");
9423 $printbody->parseCurrentBlock();
9424 $printoutput = $printbody->get();
9425 $html = str_replace(
"href=\"./",
"href=\"" . ILIAS_HTTP_PATH .
"/", $printoutput);
9426 $html = preg_replace(
"/<div id=\"dontprint\">.*?<\\/div>/ims",
"", $html);
9427 if (extension_loaded(
"tidy"))
9431 "output-xml" =>
true,
9432 "numeric-entities" =>
true
9436 $tidy->cleanRepair();
9437 $html = tidy_get_output(
$tidy);
9438 $html = preg_replace(
"/^.*?(<html)/",
"\\1", $html);
9442 $html = str_replace(
" ",
" ", $html);
9443 $html = str_replace(
"⊗",
"X", $html);
9461 include_once
"./Services/Utilities/classes/class.ilUtil.php";
9462 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
9472 $ilLog->write(__METHOD__.
': '.$e->getMessage());
9477 $ilLog->write(__METHOD__.
': '.$e->getMessage());
9504 $result = $ilDB->queryF(
"SELECT feedback FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s",
9505 array(
'integer',
'integer',
'integer'),
9506 array($active_id, $question_id,
$pass)
9511 include_once(
"./Services/RTE/classes/class.ilRTE.php");
9531 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s",
9532 array(
'integer',
'integer',
'integer'),
9533 array($active_id, $question_id,
$pass)
9536 if (strlen($feedback))
9538 $next_id = $ilDB->nextId(
'tst_manual_fb');
9539 $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)",
9540 array(
'integer',
'integer',
'integer',
'integer',
'text',
'integer'),
9543 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
9546 global
$lng, $ilUser;
9547 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
9549 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
9556 $ilias->raiseError(
$result->getMessage());
9574 if (strcmp(
$_GET[
"tst_javascript"],
"0") == 0)
return FALSE;
9576 $assessmentSetting =
new ilSetting(
"assessment");
9577 return ($ilUser->getPref(
"tst_javascript") === FALSE) ? $assessmentSetting->get(
"use_javascript") : $ilUser->getPref(
"tst_javascript");
9590 include_once
"./Modules/Test/classes/class.ilTestSession.php";
9609 $this->test_id = $a_id;
9621 if (is_object($this->testSession) && ($this->testSession->getActiveId() > 0))
return $this->testSession;
9625 include_once
"./Modules/Test/classes/class.ilTestSession.php";
9650 if (is_object($this->testSession) && ($this->testSession->getActiveId() > 0))
return $this->testSession;
9656 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
9658 if (!$this->testSequence->hasSequence())
9660 $this->testSequence->createNewSequence($this->
getQuestionCount(), $shuffle);
9661 $this->testSequence->saveToDb();
9667 if (is_object($this->testSequence) && ($this->testSequence->getActiveId() > 0))
return $this->testSequence;
9669 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
9670 if (($active_id > 0) && (strlen(
$pass)))
9686 foreach (
$result as $sequence => $question)
9688 if (is_numeric($sequence))
9690 if ($question[
"reached"] == $question[
"max"])
9711 if (count($participants))
9713 foreach ($participants as $active_id => $user_rec)
9716 $reached_points = 0;
9718 foreach ($this->questions as $value)
9721 if (is_object($question))
9723 $max_points += $question->getMaximumPoints();
9724 $reached_points += $question->getReachedPoints($active_id);
9725 if ($max_points > 0)
9727 $percentvalue = $reached_points / $max_points;
9728 if ($percentvalue < 0) $percentvalue = 0.0;
9736 $user_rec[
'firstname'] =
"";
9737 $user_rec[
'lastname'] = $this->lng->txt(
"unknown");
9740 "user_id"=>$user_rec[
'usr_id'],
9741 "matriculation" => $user_rec[
'matriculation'],
9742 "lastname" => $user_rec[
'lastname'],
9743 "firstname" => $user_rec[
'firstname'],
9744 "login"=>$user_rec[
'login'],
9745 "question_id" => $question->getId(),
9746 "question_title" => $question->getTitle(),
9747 "reached_points" => $reached_points,
9748 "max_points" => $max_points
9765 $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",
9769 $rec = $ilDB->fetchAssoc(
$result);
9770 return $rec[
"obj_id"];
9781 global $ilPluginAdmin;
9782 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE,
"TestQuestionPool",
"qst", $a_pname))
9796 $result = $ilDB->queryF(
"SELECT passed FROM tst_result_cache WHERE active_fi = %s",
9803 return $row[
'passed'];
9808 $result_array =& $this->
getTestResult($active_id, $counted_pass);
9809 return $result_array[
"test"][
"passed"];
9822 include_once
"./Services/Certificate/classes/class.ilCertificate.php";
9823 include_once
"./Modules/Test/classes/class.ilTestCertificateAdapter.php";
9825 if ($cert->isComplete())
9872 $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",
9873 array(
'integer',
'integer'),
9876 $foundusers = array();
9879 if (!array_key_exists(
$row[
"active_fi"], $foundusers))
9881 $foundusers[
$row[
"active_fi"]] = array();
9883 array_push($foundusers[
$row[
"active_fi"]], array(
"pass" => $row[
"pass"],
"qid" => $row[
"question_fi"]));
9897 include_once
'./Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
9916 $foundParticipants =&
$data->getParticipants();
9917 $results = array(
"overview" => array(),
"questions" => array());
9918 if (count($foundParticipants))
9920 $results[
"overview"][$this->lng->txt(
"tst_eval_total_persons")] = count($foundParticipants);
9922 $results[
"overview"][$this->lng->txt(
"tst_eval_total_finished")] = $total_finished;
9924 $diff_seconds = $average_time;
9925 $diff_hours = floor($diff_seconds/3600);
9926 $diff_seconds -= $diff_hours * 3600;
9927 $diff_minutes = floor($diff_seconds/60);
9928 $diff_seconds -= $diff_minutes * 60;
9929 $results[
"overview"][$this->lng->txt(
"tst_eval_total_finished_average_time")] = sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
9931 $total_passed_reached = 0;
9932 $total_passed_max = 0;
9933 $total_passed_time = 0;
9934 foreach ($foundParticipants as $userdata)
9936 if ($userdata->getPassed())
9939 $total_passed_reached += $userdata->getReached();
9940 $total_passed_max += $userdata->getMaxpoints();
9941 $total_passed_time += $userdata->getTimeOfWork();
9944 $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
9945 $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
9946 $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
9947 $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed")] = $total_passed;
9948 $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);
9949 $average_time = $average_passed_time;
9950 $diff_seconds = $average_time;
9951 $diff_hours = floor($diff_seconds/3600);
9952 $diff_seconds -= $diff_hours * 3600;
9953 $diff_minutes = floor($diff_seconds/60);
9954 $diff_seconds -= $diff_minutes * 60;
9955 $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed_average_time")] = sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
9958 foreach (
$data->getQuestionTitles() as $question_id => $question_title)
9963 foreach ($foundParticipants as $userdata)
9965 for ($i = 0; $i <= $userdata->getLastPass(); $i++)
9967 if (is_object($userdata->getPass($i)))
9969 $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
9970 if (is_array($question))
9973 $reached += $question[
"reached"];
9974 $max += $question[
"points"];
9979 $percent = $max ? $reached/$max * 100.0 : 0;
9981 $results[
"questions"][$question_id] = array(
9983 sprintf(
"%.2f", $answered ? $reached / $answered : 0) .
" " . strtolower($this->lng->txt(
"of")) .
" " . sprintf(
"%.2f", $answered ? $max / $answered : 0),
9984 sprintf(
"%.2f", $percent) .
"%",
9986 sprintf(
"%.2f", $answered ? $reached / $answered : 0),
9987 sprintf(
"%.2f", $answered ? $max / $answered : 0),
9999 include_once(
"./Modules/Test/classes/class.ilTestExport.php");
10001 return $test_exp->buildExportFile();
10019 $this->mailnotification = $a_notification;
10024 include_once
"./Services/Mail/classes/class.ilMail.php";
10025 $mail =
new ilMail(ANONYMOUS_USER_ID);
10028 $message =
new ilTemplate(
"tpl.il_as_tst_finish_notification_simple.html", TRUE, TRUE,
"Modules/Test");
10029 $message->setVariable(
'TEXT_TEST_TITLE', $this->lng->txt(
'title'));
10030 $message->setVariable(
'VALUE_TEST_TITLE', $this->
getTitle());
10031 $message->setVariable(
'TEXT_USER_NAME', $this->lng->txt(
'username'));
10032 $message->setVariable(
'VALUE_USER_NAME', $usr_data);
10033 $message->setVariable(
'TEXT_FINISH_TIME', $this->lng->txt(
'tst_finished'));
10037 $res = $mail->sendMail(
10041 sprintf($this->lng->txt(
'tst_user_finished_test'), $this->
getTitle()),
10046 global
$ilLog; $ilLog->write(
"sending mail: " .
$res);
10056 include_once
"./Modules/Test/classes/class.ilObjTestGUI.php";
10057 include_once
"./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
10059 return $table_gui->getSelectedColumns();
10064 include_once
"./Services/Mail/classes/class.ilMail.php";
10065 $mail =
new ilMail(ANONYMOUS_USER_ID);
10068 $message =
new ilTemplate(
"tpl.il_as_tst_finish_notification_simple.html", TRUE, TRUE,
"Modules/Test");
10069 $message->setVariable(
'TEXT_TEST_TITLE', $this->lng->txt(
'title'));
10070 $message->setVariable(
'VALUE_TEST_TITLE', $this->
getTitle());
10071 $message->setVariable(
'TEXT_USER_NAME', $this->lng->txt(
'username'));
10072 $message->setVariable(
'VALUE_USER_NAME', $usr_data);
10073 $message->setVariable(
'TEXT_FINISH_TIME', $this->lng->txt(
'tst_finished'));
10077 include_once
"./Modules/Test/classes/class.ilTestExport.php";
10079 $file = $exportObj->exportToExcel($deliver = FALSE,
'active_id', $active_id, $passedonly = FALSE);
10080 include_once
"./classes/class.ilFileDataMail.php";
10082 $fd->copyAttachmentFile(
$file,
"result_" . $active_id .
".xls");
10083 $file_names[] =
"result_" . $active_id .
".xls";
10088 sprintf($this->lng->txt(
'tst_user_finished_test'), $this->
getTitle()),
10090 count($file_names) ? $file_names : array(),
10093 if(count($file_names))
10095 $fd->unlinkFiles($file_names);
10106 $query =
"SELECT usr_id FROM usr_data";
10110 $activequery = sprintf(
"SELECT user_fi FROM tst_active WHERE test_fi = %s AND user_fi = %s",
10111 $ilDB->quote($this->getTestId()),
10112 $ilDB->quote(
$data[
'usr_id'])
10114 $activeresult = $ilDB->query($activequery);
10115 if ($activeresult->numRows() == 0)
10117 $user_id =
$data[
'usr_id'];
10118 if ($user_id != 13)
10120 include_once
"./Modules/Test/classes/class.ilTestSession.php";
10128 $nr_of_passes = rand(1, $passes);
10132 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
10139 for ($seq = 1; $seq <= count($this->questions); $seq++)
10141 $question_id =
$testSequence->getQuestionForSequence($seq);
10145 if (
$pass < $nr_of_passes - 1)
10157 if ($number == 0)
return;
10167 $result = $ilDB->queryF(
"SELECT * FROM tst_result_cache WHERE active_fi = %s",
10173 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
10175 $result = $ilDB->queryF(
"SELECT * FROM tst_result_cache WHERE active_fi = %s",
10187 if ($this->mailnottype == 1)
10201 $this->mailnottype = 1;
10205 $this->mailnottype = 0;
10211 if ($this->exportsettings)
10225 $this->exportsettings = $a_settings;
10229 $this->exportsettings = 0;
10235 if (($this->exportsettings & 1) > 0)
10249 $this->exportsettings = $this->exportsettings | 1;
10255 $this->exportsettings = $this->exportsettings ^ 1;