5 include_once
"./classes/class.ilObject.php";
6 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
416 function ilObjTest($a_id = 0,$a_call_by_reference =
true)
420 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
423 $this->author = $ilUser->fullname;
424 $this->introduction =
"";
425 $this->questions = array();
428 $this->instant_verification = 0;
429 $this->answer_feedback_points = 0;
430 $this->reporting_date =
"";
431 $this->nr_of_tries = 0;
433 $this->use_previous_answers = 1;
434 $this->title_output = 0;
435 $this->starting_time =
"";
436 $this->ending_time =
"";
437 $this->processing_time =
"00:00:00";
438 $this->enable_processing_time =
"0";
439 $this->reset_processing_time = 0;
440 $this->ects_output = 0;
441 $this->ects_fx = NULL;
442 $this->random_test = 0;
443 $this->shuffle_questions = FALSE;
444 $this->mailnottype = 0;
445 $this->exportsettings = 0;
446 $this->show_summary = 8;
447 $this->random_question_count =
"";
452 $this->answer_feedback = 0;
453 $this->password =
"";
454 $this->certificate_visibility = 0;
455 $this->allowedUsers =
"";
456 $this->_showfinalstatement = FALSE;
457 $this->_finalstatement =
"";
458 $this->_showinfo = TRUE;
459 $this->_forcejs = FALSE;
460 $this->_customStyle =
"";
461 $this->allowedUsersTimeGap =
"";
462 $this->anonymity = 0;
463 $this->show_cancel = 1;
464 $this->show_marker = 0;
465 $this->fixed_participants = 0;
470 $this->testSession = FALSE;
471 $this->testSequence = FALSE;
472 $this->mailnotification = 0;
473 $this->poolUsage = 0;
475 $lng->loadLanguageModule(
"assessment");
476 $this->mark_schema->createSimpleSchema($lng->txt(
"failed_short"), $lng->txt(
"failed_official"), 0, 0, $lng->txt(
"passed_short"), $lng->txt(
"passed_official"), 50, 1);
477 $this->ects_grades = array(
484 $this->express_mode =
false;
485 $this->template_id =
'';
486 $this->
ilObject($a_id, $a_call_by_reference);
512 if (!parent::update())
542 function read($a_force_db =
false)
558 if (!parent::delete())
585 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s",
589 $active_array = array();
592 array_push($active_array,
$row[
"active_id"]);
595 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
600 if (count($active_array))
602 foreach ($active_array as $active_id)
604 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_times WHERE active_fi = %s",
609 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
616 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_mark WHERE test_fi = %s",
621 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s",
630 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_tests WHERE test_id = %s",
635 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
650 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
662 include_once
"./Services/Utilities/classes/class.ilUtil.php";
664 $directory = $tst_data_dir.
"/tst_".$this->
getId();
665 if (is_dir($directory))
667 include_once
"./Services/Utilities/classes/class.ilUtil.php";
670 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
676 foreach(
$mobs as $mob)
715 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
755 if ($a_node_id==
$_GET[
"ref_id"])
757 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
758 $parent_type = $parent_obj->getType();
759 if ($parent_type == $this->
getType())
761 $a_node_id = (int) $tree->getParentId($a_node_id);
765 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
775 include_once
"./Services/Utilities/classes/class.ilUtil.php";
778 if (!is_writable($tst_data_dir))
780 $this->ilias->raiseError(
"Test Data Directory (".$tst_data_dir
781 .
") not writeable.",$this->ilias->error_obj->MESSAGE);
785 $tst_dir = $tst_data_dir.
"/tst_".$this->
getId();
787 if (!@is_dir($tst_dir))
789 $this->ilias->raiseError(
"Creation of Test Directory failed.",$this->ilias->error_obj->MESSAGE);
792 $export_dir = $tst_dir.
"/export";
794 if (!@is_dir($export_dir))
796 $this->ilias->raiseError(
"Creation of Export Directory failed.",$this->ilias->error_obj->MESSAGE);
807 include_once
"./Services/Utilities/classes/class.ilUtil.php";
821 if (!@is_dir(
$dir) or
834 while ($entry =
$dir->read())
836 if ($entry !=
"." and
839 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(tst(__results)?_)*[0-9]+\.[a-z]{1,3}\$", $entry))
860 if (strlen($a_import_dir))
862 $_SESSION[
"tst_import_dir"] = $a_import_dir;
897 include_once
"./Services/Utilities/classes/class.ilUtil.php";
901 if (!is_writable($tst_data_dir))
903 $this->ilias->raiseError(
"Test Data Directory (".$tst_data_dir
904 .
") not writeable.",$this->ilias->error_obj->FATAL);
908 $tst_dir = $tst_data_dir.
"/tst_import";
910 if (!@is_dir($tst_dir))
912 $ilias->raiseError(
"Creation of test import directory failed.",
$ilias->error_obj->FATAL);
927 $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",
934 if (strcmp(
$row[
'foundtypes'],
'assSingleChoice') == 0)
952 $result = $ilDB->queryF(
"SELECT DISTINCT(qpl_qst_type.type_tag) foundtypes FROM qpl_questions, tst_test_result, qpl_qst_type, tst_active WHERE tst_test_result.question_fi = qpl_questions.question_id AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND tst_test_result.active_fi = tst_active.active_id AND tst_active.test_fi = %s",
959 if (strcmp(
$row[
'foundtypes'],
'assSingleChoice') == 0)
983 $result = $ilDB->queryF(
"SELECT DISTINCT(qpl_qst_sc.shuffle) foundshuffles FROM qpl_questions, qpl_qst_sc, tst_test_result, qpl_qst_type, tst_active WHERE tst_test_result.question_fi = qpl_questions.question_id AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND tst_test_result.active_fi = tst_active.active_id AND qpl_questions.question_id = qpl_qst_sc.question_fi AND tst_active.test_fi = %s AND qpl_qst_type.type_tag = %s",
984 array(
'integer',
'text'),
985 array($this->
getTestId(),
'assSingleChoice')
990 return (
$row[
'foundshuffles'] == 0);
1003 if ((count($this->mark_schema->mark_steps)) and (count($this->questions)))
1017 foreach ($arr as $array)
1019 $count += $array[
"count"];
1040 $test->loadFromDb();
1041 return $test->isComplete();
1052 if ($this->test_id > 0)
1054 $fx_support = preg_replace(
"/,/",
".", $fx_support);
1055 if (preg_match(
"/\d+/", $fx_support))
1057 $fx_support = $fx_support;
1063 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET ects_output = %s, ects_a = %s, ects_b = %s, ects_c = %s, ects_d = %s, ects_e = %s, ects_fx = %s WHERE test_id = %s",
1064 array(
'text',
'float',
'float',
'float',
'float',
'float',
'float',
'integer'),
1068 $this->ects_fx = $fx_support;
1086 if ($this->test_id > 0)
1088 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET complete = %s WHERE test_id = %s",
1089 array(
'text',
'integer'),
1090 array($complete, $this->test_id)
1115 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1116 $completecontent =
"";
1119 $completecontent .= $content;
1138 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1139 if ($this->test_id == -1)
1142 $next_id = $ilDB->nextId(
'tst_tests');
1143 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_tests (test_id, obj_fi, author, introduction, " .
1144 "finalstatement, showinfo, forcejs, customstyle, showfinalstatement, sequence_settings, " .
1145 "score_reporting, instant_verification, answer_feedback_points, answer_feedback, anonymity, show_cancel, show_marker, " .
1146 "fixed_participants, nr_of_tries, kiosk, use_previous_answers, title_output, processing_time, enable_processing_time, " .
1147 "reset_processing_time, reporting_date, starting_time, ending_time, complete, ects_output, ects_a, ects_b, ects_c, ects_d, " .
1148 "ects_e, ects_fx, random_test, random_question_count, count_system, mc_scoring, score_cutting, pass_scoring, " .
1149 "shuffle_questions, results_presentation, show_summary, password, allowedusers, mailnottype, exportsettings, " .
1150 "alloweduserstimegap, certificate_visibility, mailnotification, created, tstamp, enabled_view_mode, template_id, pool_usage, online_status) " .
1151 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, " .
1152 "%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
1154 'integer',
'integer',
'text',
'text',
1155 'text',
'integer',
'integer',
'text',
'integer',
'integer',
1156 'integer',
'text',
'text',
'text',
'text',
'text',
'integer',
1157 'text',
'integer',
'integer',
'text',
'text',
'text',
'text',
1158 'integer',
'text',
'text',
'text',
'text',
'text',
'float',
'float',
'float',
'float',
1159 'float',
'float',
'text',
'integer',
'text',
'text',
'text',
'text',
1160 'text',
'integer',
'integer',
'text',
'integer',
'integer',
'integer',
1161 'integer',
'text',
'integer',
'integer',
'integer',
'text',
'text',
'integer',
'integer'
1194 strlen($this->ects_grades[
"A"]) ? $this->ects_grades[
"A"] : NULL,
1195 strlen($this->ects_grades[
"B"]) ? $this->ects_grades[
"B"] : NULL,
1196 strlen($this->ects_grades[
"C"]) ? $this->ects_grades[
"C"] : NULL,
1197 strlen($this->ects_grades[
"D"]) ? $this->ects_grades[
"D"] : NULL,
1198 strlen($this->ects_grades[
"E"]) ? $this->ects_grades[
"E"] : NULL,
1224 $this->test_id = $next_id;
1237 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
1239 array($this->test_id)
1243 $oldrow = $ilDB->fetchAssoc(
$result);
1247 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET author = %s, introduction = %s, " .
1248 "finalstatement = %s, showinfo = %s, forcejs = %s, customstyle = %s, showfinalstatement = %s, sequence_settings = %s, " .
1249 "score_reporting = %s, instant_verification = %s, answer_feedback_points = %s, answer_feedback = %s, anonymity = %s, show_cancel = %s, show_marker = %s, " .
1250 "fixed_participants = %s, nr_of_tries = %s, kiosk = %s, use_previous_answers = %s, title_output = %s, processing_time = %s, enable_processing_time = %s, " .
1251 "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, " .
1252 "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, " .
1253 "shuffle_questions = %s, results_presentation = %s, show_summary = %s, password = %s, allowedusers = %s, mailnottype = %s, exportsettings = %s, " .
1254 "alloweduserstimegap = %s, certificate_visibility = %s, mailnotification = %s, tstamp = %s, enabled_view_mode = %s, template_id = %s, pool_usage = %s, online_status = %s WHERE test_id = %s",
1257 'text',
'integer',
'integer',
'text',
'integer',
'integer',
1258 'integer',
'text',
'text',
'text',
'text',
'text',
'integer',
1259 'text',
'integer',
'integer',
'text',
'text',
'text',
'text',
1260 'integer',
'text',
'text',
'text',
'text',
'text',
'float',
'float',
'float',
'float',
1261 'float',
'float',
'text',
'integer',
'text',
'text',
'text',
'text',
1262 'text',
'integer',
'integer',
'text',
'integer',
'integer',
'integer',
1263 'integer',
'text',
'integer',
'integer',
'text',
'text',
'integer',
'integer',
'integer'
1294 strlen($this->ects_grades[
"A"]) ? $this->ects_grades[
"A"] : NULL,
1295 strlen($this->ects_grades[
"B"]) ? $this->ects_grades[
"B"] : NULL,
1296 strlen($this->ects_grades[
"C"]) ? $this->ects_grades[
"C"] : NULL,
1297 strlen($this->ects_grades[
"D"]) ? $this->ects_grades[
"D"] : NULL,
1298 strlen($this->ects_grades[
"E"]) ? $this->ects_grades[
"E"] : NULL,
1325 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1328 $logresult = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
1333 if ($logresult->numRows() == 1)
1335 $newrow = $ilDB->fetchAssoc($logresult);
1337 $changed_fields = array();
1338 foreach ($oldrow as $key => $value)
1340 if (strcmp($oldrow[$key], $newrow[$key]) != 0)
1342 array_push($changed_fields,
"$key: " . $oldrow[$key] .
" => " . $newrow[$key]);
1345 $changes = join($changed_fields,
", ");
1346 if (count($changed_fields) > 0)
1357 $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND tries >= %s AND submitted = %s",
1358 array(
'integer',
'integer',
'integer'),
1361 while (
$row = $ilDB->fetchAssoc($aresult))
1363 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
1364 array(
'integer',
'timestamp',
'integer'),
1365 array(1, date(
'Y-m-d H:i:s'),
$row[
"active_id"])
1370 $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND tries < %s AND submitted = %s",
1371 array(
'integer',
'integer',
'integer'),
1374 while (
$row = $ilDB->fetchAssoc($aresult))
1376 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
1377 array(
'integer',
'timestamp',
'integer'),
1378 array(0, NULL,
$row[
"active_id"])
1385 $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND submitted = %s",
1386 array(
'integer',
'integer'),
1389 while (
$row = $ilDB->fetchAssoc($aresult))
1391 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
1392 array(
'integer',
'timestamp',
'integer'),
1393 array(0, NULL,
$row[
"active_id"])
1403 if (!$properties_only)
1408 $ilias->raiseError(
$result->getMessage());
1416 $this->mark_schema->saveToDb($this->test_id);
1431 $oldquestions = array();
1432 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
1435 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence",
1443 array_push($oldquestions,
$row[
"question_fi"]);
1449 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
1454 foreach ($this->questions as $key => $value)
1456 $next_id = $ilDB->nextId(
'tst_test_question');
1457 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
1458 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
1459 array($next_id, $this->
getTestId(), $value, $key, time())
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",
1469 $newquestions = array();
1474 array_push($newquestions,
$row[
"question_fi"]);
1477 foreach ($oldquestions as $index => $question_id)
1479 if (strcmp($newquestions[$index], $question_id) != 0)
1481 $pos = array_search($question_id, $newquestions);
1492 foreach ($newquestions as $index => $question_id)
1494 if (array_search($question_id, $oldquestions) === FALSE)
1508 $result = $ilDB->queryF(
'SELECT copy_id FROM tst_rnd_cpy WHERE tst_fi = %s',
1512 return $result->numRows() > 0;
1527 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
1528 array(
'integer',
'integer'),
1529 array($active_id,
$pass)
1531 if (
$result->numRows() < $maxcount)
1533 $duplicate_id = $question_id;
1537 if ($duplicate_id === FALSE)
1542 $next_id = $ilDB->nextId(
'tst_test_rnd_qst');
1543 $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)",
1544 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
1545 array($next_id,$active_id, $duplicate_id,
$result->numRows()+1,
$pass, time())
1563 $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",
1564 array(
'integer',
'integer'),
1565 array($question_id, $active_id)
1571 return $row[
"question_id"];
1588 $result = $ilDB->queryF(
"SELECT test_result_id FROM tst_test_result WHERE active_fi = %s AND pass = %s",
1589 array(
'integer',
'integer'),
1590 array($active_id,
$pass)
1606 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
1607 array(
'integer',
'integer'),
1608 array($active_id,
$pass)
1610 return (
$result->numRows() > 0) ?
true :
false;
1632 if (
false &&
$pass > 0)
1647 $ilias->raiseError(sprintf($this->lng->txt(
"error_random_question_generation"), $ilUser->getId(), $this->
getTestId()), $ilErr->FATAL);
1655 $allquestions = array();
1656 foreach ($rndquestions as $question_id)
1658 array_push($allquestions, $question_id);
1662 srand ((
float)microtime()*1000000);
1663 shuffle($allquestions);
1667 foreach ($qpls as
$data)
1669 $maxcount += $data[
"contains"];
1671 if ($num > $maxcount) $num = $maxcount;
1672 foreach ($allquestions as $question_id)
1680 $allquestions = array();
1682 foreach ($qpls as $key => $value)
1684 if ($value[
"count"] > 0)
1687 foreach ($rndquestions as $question_id)
1689 array_push($allquestions, $question_id);
1692 $add = ($value[
"count"] <= $value[
"contains"]) ? $value[
"count"] : $value[
"contains"];
1697 srand ((
float)microtime()*1000000);
1698 shuffle($allquestions);
1700 foreach ($allquestions as $question_id)
1717 if (strlen($total_questions))
1721 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET random_question_count = %s, tstamp = %s WHERE test_id = %s",
1722 array(
'integer',
'integer',
'integer'),
1725 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1745 $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",
1753 $qpls[$counter] = array(
1754 "index" => $counter,
1755 "count" =>
$row[
"num_of_q"],
1756 "qpl" =>
$row[
"questionpool_fi"],
1757 "contains" =>
$row[
"questioncount"]
1772 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1774 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
1786 foreach ($this->random_questionpool_data as $idx =>
$data)
1791 $next_id = $ilDB->nextId(
'tst_test_random');
1792 $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)",
1793 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
1813 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_cpy WHERE tst_fi = %s',
1820 $question->delete(
$row[
'qst_fi']);
1823 $affectedRows = $ilDB->manipulateF(
'DELETE FROM tst_rnd_cpy WHERE tst_fi = %s',
1828 $affectedRows = $ilDB->manipulateF(
'DELETE FROM tst_rnd_qpl_title WHERE tst_fi = %s',
1842 $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',
1849 if (is_array($pools[
$row[
'qpl_fi']]))
1851 $pools[$row[
'qpl_fi']][
'count']++;
1855 $pools[$row[
'qpl_fi']][
'count'] = 1;
1857 $pools[$row[
'qpl_fi']][
'num_of_q'] = $row[
'num_of_q'];
1859 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_qpl_title WHERE tst_fi = %s',
1866 $pools[
$row[
'qpl_fi']][
'title'] = $row[
'qpl_title'];
1872 $result = $ilDB->queryF(
'SELECT tst_test_random.* FROM tst_test_random WHERE tst_test_random.test_fi = %s ORDER BY sequence, test_random_id',
1879 $pools[
$row[
'questionpool_fi']][
'count'] = $row[
'num_of_q'];
1880 $pools[$row[
'questionpool_fi']][
'num_of_q'] = $row[
'num_of_q'];
1882 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_qpl_title WHERE tst_fi = %s',
1889 $pools[
$row[
'qpl_fi']][
'title'] = $row[
'qpl_title'];
1901 $result = $ilDB->queryF(
'SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND complete = %s AND original_id IS NULL',
1902 array(
'integer',
'text'),
1903 array($questionpool_id, 1)
1905 $saved_titles = array();
1909 $duplicate_id = $question->duplicate(
true, null, null, null, $this->
getId());
1910 if ($duplicate_id > 0)
1912 $next_id = $ilDB->nextId(
'tst_rnd_cpy');
1913 $ilDB->manipulateF(
'INSERT INTO tst_rnd_cpy (copy_id, tst_fi, qst_fi, qpl_fi) VALUES (%s, %s, %s, %s)',
1914 array(
'integer',
'integer',
'integer',
'integer'),
1915 array($next_id, $this->
getTestId(), $duplicate_id, $questionpool_id)
1917 if (!array_key_exists($questionpool_id, $saved_titles))
1919 $next_id = $ilDB->nextId(
'tst_rnd_qpl_title');
1920 $ilDB->manipulateF(
'INSERT INTO tst_rnd_qpl_title (title_id, tst_fi, qpl_fi, qpl_title) VALUES (%s, %s, %s, %s)',
1921 array(
'integer',
'integer',
'integer',
'text'),
1924 $saved_titles[$questionpool_id] = 1;
1932 include_once
"./Modules/Test/classes/class.ilRandomTestData.php";
1933 if (array_key_exists($position, $this->random_questionpool_data))
1935 $newitems = array();
1936 for ($i = 0; $i < $position; $i++)
1938 array_push($newitems, $this->random_questionpool_data[$i]);
1941 for ($i = $position; $i < count($this->random_questionpool_data); $i++)
1943 array_push($newitems, $this->random_questionpool_data[$i]);
1945 $this->random_questionpool_data = $newitems;
1949 array_push($this->random_questionpool_data,
new ilRandomTestData($count, $qpl));
1955 if (array_key_exists($position, $this->random_questionpool_data))
1957 unset($this->random_questionpool_data[$position]);
1963 $this->random_questionpool_data = $a_data;
1981 $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",
1985 include_once
"./Modules/Test/classes/class.ilRandomTestData.php";
2007 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE obj_fi = %s",
2009 array($this->
getId())
2020 include_once(
"./Services/RTE/classes/class.ilRTE.php");
2052 "A" =>
$data->ects_a,
2053 "B" =>
$data->ects_b,
2054 "C" =>
$data->ects_c,
2055 "D" =>
$data->ects_d,
2056 "E" =>
$data->ects_e
2062 $this->mark_schema->flush();
2063 $this->mark_schema->loadFromDb($this->
getTestId());
2094 $this->questions = array();
2095 if (strcmp($active_id,
"") == 0)
2105 $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",
2106 array(
'integer',
'integer'),
2107 array($active_id,
$pass)
2115 $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",
2123 $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",
2125 array($this->test_id)
2131 $this->questions[$index++] =
$data[
"question_fi"];
2156 $this->_finalstatement = $a_statement;
2168 $this->_showinfo = ($a_info) ? 1 : 0;
2180 $this->_forcejs = ($a_js) ? 1 : 0;
2192 $this->_customStyle = $a_customStyle;
2204 return (strlen($this->_customStyle)) ? $this->_customStyle : NULL;
2217 $css_path = str_replace(
"ta.css",
"customstyles", $css_path) .
"/";
2218 $customstyles = array();
2219 if (is_dir($css_path))
2222 include_once
"./Services/Utilities/classes/class.ilFileUtils.php";
2228 if (strpos($filename,
".css"))
2230 array_push($customstyles, $filename);
2235 return $customstyles;
2250 $custom = str_replace(
"ta.css",
"customstyles/" . $this->
getCustomStyle(), $default);
2251 if (file_exists($custom))
2254 $custom = str_replace(
"ta.css",
"customstyles/" . $this->
getCustomStyle(), $custom);
2277 $this->_showfinalstatement = ($show) ? 1 : 0;
2290 return ($this->random_test) ? 1 : 0;
2303 $query =
"SELECT random_test FROM tst_tests ".
2304 "WHERE obj_fi = ".$ilDB->quote($a_obj_id,
'integer');
2308 return $row->random_test ?
true :
false;
2322 return ($this->random_question_count) ? $this->random_question_count : 0;
2333 return (strlen($this->introduction)) ? $this->introduction : NULL;
2344 return (strlen($this->_finalstatement)) ? $this->_finalstatement : NULL;
2356 return ($this->_showinfo) ? 1 : 0;
2368 return ($this->_forcejs) ? 1 : 0;
2380 return ($this->_showfinalstatement) ? 1 : 0;
2404 return ($this->ects_output) ? 1 : 0;
2416 $this->ects_output = $a_ects_output ? 1 : 0;
2428 return (strlen($this->ects_fx)) ? $this->ects_fx : NULL;
2440 $this->ects_fx = $a_ects_fx;
2464 if (is_array($a_ects_grades))
2466 $this->ects_grades = $a_ects_grades;
2503 switch ($instant_feedback)
2506 $this->instant_verification = 1;
2509 $this->instant_verification = 0;
2526 $this->answer_feedback = 1;
2529 $this->answer_feedback = 0;
2546 $this->answer_feedback_points = 1;
2549 $this->answer_feedback_points = 0;
2563 $this->random_test = $a_random_test;
2575 $this->random_question_count = $a_random_question_count;
2589 $this->reporting_date =
"";
2590 $this->ects_output = 0;
2607 return ($this->sequence_settings) ? $this->sequence_settings : 0;
2619 return ($this->score_reporting) ? $this->score_reporting : 0;
2631 return ($this->instant_verification) ? $this->instant_verification : 0;
2643 return ($this->answer_feedback) ? $this->answer_feedback : 0;
2655 return ($this->answer_feedback_points) ? $this->answer_feedback_points : 0;
2667 return ($this->count_system) ? $this->count_system : 0;
2680 $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",
2687 return $row[
"count_system"];
2701 return ($this->mc_scoring) ? $this->mc_scoring : 0;
2713 return ($this->score_cutting) ? $this->score_cutting : 0;
2725 return (strlen($this->password)) ? $this->password : NULL;
2737 return ($this->pass_scoring) ? $this->pass_scoring : 0;
2750 $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",
2757 return $row[
"pass_scoring"];
2772 $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",
2779 return $row[
"mc_scoring"];
2794 $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",
2801 return $row[
"score_cutting"];
2815 return (strlen($this->reporting_date)) ? $this->reporting_date : NULL;
2827 return ($this->nr_of_tries) ? $this->nr_of_tries : 0;
2839 return ($this->_kiosk) ? $this->_kiosk : 0;
2852 $this->_kiosk = $kiosk;
2864 if (($this->_kiosk & 1) > 0)
2885 $this->_kiosk = $this->_kiosk | 1;
2891 $this->_kiosk = $this->_kiosk ^ 1;
2905 if (($this->_kiosk & 2) > 0)
2925 $this->_kiosk = $this->_kiosk | 2;
2931 $this->_kiosk = $this->_kiosk ^ 2;
2945 if (($this->_kiosk & 4) > 0)
2965 $this->_kiosk = $this->_kiosk | 4;
2971 $this->_kiosk = $this->_kiosk ^ 4;
2985 return ($this->use_previous_answers) ? $this->use_previous_answers : 0;
2997 return ($this->title_output) ? $this->title_output : 0;
3012 $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",
3019 return $row[
"title_output"];
3040 $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",
3052 if ($user_active_user_setting)
3054 $res = $ilUser->getPref(
"tst_use_previous_answers");
3073 return (strlen($this->processing_time)) ? $this->processing_time : NULL;
3084 if (strlen($this->processing_time))
3086 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/is", $this->processing_time, $matches))
3088 if ((
int)$matches[1]+(
int)$matches[2]+(
int)$matches[3] == 0)
3095 'hh' => $matches[1],
3096 'mm' => $matches[2],
3097 'ss' => $matches[3],
3114 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $this->
getProcessingTime(), $matches))
3116 return ($matches[1] * 3600) + ($matches[2] * 60) + $matches[3];
3133 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndingTime(), $matches))
3135 $ending = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
3137 return $ending - $now;
3154 return ($this->enable_processing_time) ? $this->enable_processing_time : 0;
3166 return ($this->reset_processing_time) ? $this->reset_processing_time : 0;
3178 return (strlen($this->starting_time)) ? $this->starting_time : NULL;
3190 return (strlen($this->ending_time)) ? $this->ending_time : NULL;
3216 $this->use_previous_answers = 1;
3220 $this->use_previous_answers = 0;
3236 $this->title_output = 1;
3239 $this->title_output = 2;
3242 $this->title_output = 0;
3269 $this->enable_processing_time =
"1";
3271 $this->enable_processing_time =
"0";
3286 $this->reset_processing_time = 1;
3290 $this->reset_processing_time = 0;
3327 $this->count_system = $a_count_system;
3339 $this->password = $a_password;
3351 $this->score_cutting = $a_score_cutting;
3363 $this->mc_scoring = $a_mc_scoring;
3375 switch ($a_pass_scoring)
3396 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3401 $question->delete($question_id);
3421 $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",
3422 array(
'integer',
'integer'),
3425 $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",
3426 array(
'integer',
'integer'),
3429 $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",
3430 array(
'integer',
'integer'),
3433 $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)",
3440 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE tst_solutions.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3444 $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)",
3448 $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)",
3452 $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)",
3456 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3462 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE tst_sequence.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
3469 $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)",
3476 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
3482 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE keyword = %s",
3484 array(
"tst_password_".$this->
getTestId())
3489 if (@is_dir(CLIENT_WEB_DIR .
"/assessment/tst_" . $this->
getTestId()))
3500 foreach ($active_ids as $active_id)
3502 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s",
3506 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s",
3510 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE active_fi = %s",
3514 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE active_fi = %s",
3521 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_rnd_qst WHERE active_fi = %s",
3527 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3535 foreach ($active_ids as $active_id)
3539 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE active_id = %s",
3544 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
3552 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
3553 array(
'integer',
'text'),
3560 if (@is_dir(CLIENT_WEB_DIR .
"/assessment/tst_" . $this->
getTestId() .
"/$active_id"))
3574 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s",
3578 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s",
3582 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE active_fi = %s",
3586 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE active_fi = %s",
3593 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_rnd_qst WHERE active_fi = %s",
3599 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3605 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
3611 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE active_id = %s",
3619 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
3620 array(
'integer',
'text'),
3621 array($user_id,
"tst_password_".$this->
getTestId())
3627 if (@is_dir(CLIENT_WEB_DIR .
"/assessment/tst_" . $this->
getTestId() .
"/$active_id"))
3645 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s",
3646 array(
'integer',
'integer'),
3650 if (
$data->sequence > 1)
3653 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s",
3654 array(
'integer',
'integer'),
3657 $data_previous = $ilDB->fetchObject(
$result);
3659 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3660 array(
'integer',
'integer'),
3661 array(
$data->sequence, $data_previous->test_question_id)
3664 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3665 array(
'integer',
'integer'),
3666 array(
$data->sequence - 1,
$data->test_question_id)
3668 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3689 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s",
3690 array(
'integer',
'integer'),
3694 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s",
3695 array(
'integer',
'integer'),
3701 $data_next = $ilDB->fetchObject(
$result);
3703 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3704 array(
'integer',
'integer'),
3705 array(
$data->sequence, $data_next->test_question_id)
3708 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
3709 array(
'integer',
'integer'),
3710 array(
$data->sequence + 1,
$data->test_question_id)
3712 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3732 $duplicate_id = $question->duplicate(
true, null, null, null, $this->
getId());
3734 return $duplicate_id;
3746 #var_dump($question_id);
3748 $duplicate_id = $question_id;
3753 $result = $ilDB->queryF(
"SELECT MAX(sequence) seq FROM tst_test_question WHERE test_fi=%s",
3762 $sequence =
$data->seq + 1;
3765 $next_id = $ilDB->nextId(
'tst_test_question');
3766 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
3767 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
3768 array($next_id, $this->
getTestId(), $duplicate_id, $sequence, time())
3770 if ($affectedRows == 1)
3772 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
3779 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
3785 return $duplicate_id;
3801 $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",
3807 array_push($titles,
$row[
"title"]);
3826 $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",
3832 $titles[
$row[
'question_id']] = $row[
"title"];
3850 return $this->lng->txt(
"ass_question");
3870 $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",
3889 $existing_questions = array();
3894 $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",
3895 array(
'integer',
'integer'),
3896 array($active_id,
$pass)
3901 $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",
3908 array_push($existing_questions,
$data->original_id);
3910 return $existing_questions;
3924 if ($question_id < 1)
return -1;
3925 $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",
3932 return $data->type_tag;
3950 $next_id = $ilDB->nextId(
'tst_times');
3951 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_times (times_id, active_fi, started, finished, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
3952 array(
'integer',
'integer',
'timestamp',
'timestamp',
'integer',
'integer'),
3953 array($next_id, $active_id, strftime(
"%Y-%m-%d %H:%M:%S"), strftime(
"%Y-%m-%d %H:%M:%S"),
$pass, time())
3968 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_times SET finished = %s, tstamp = %s WHERE times_id = %s",
3969 array(
'timestamp',
'integer',
'integer'),
3970 array(strftime(
"%Y-%m-%d %H:%M:%S"), time(), $times_id)
3987 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_solutions WHERE active_fi = %s AND pass = %s GROUP BY question_fi",
3988 array(
'integer',
'integer'),
3989 array($active_id, 0)
3994 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_solutions WHERE active_fi = %s AND pass = %s GROUP BY question_fi",
3995 array(
'integer',
'integer'),
3996 array($active_id,
$pass)
3999 $result_array = array();
4002 array_push($result_array,
$row[
"question_fi"]);
4004 return $result_array;
4018 return ((($currentpass > 0) && ($num == 0)) || $this->
isTestFinished($active_id)) ?
true :
false;
4032 $result_array = array();
4037 if (count($this->questions) == 0)
return $result_array;
4042 $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'),
4043 array(
'integer',
'integer'),
4044 array($active_id,
$pass)
4049 if (count($this->questions) == 0)
return $result_array;
4050 $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'));
4054 $result_array[
$row[
"question_id"]] =
$row;
4056 return $result_array;
4072 if (!$user_id) $user_id = $ilUser->getId();
4075 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
4076 array(
'integer',
'integer',
'text'),
4080 else if (strlen($anonymous_id))
4082 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
4083 array(
'integer',
'integer',
'text'),
4084 array($user_id, $this->test_id, $anonymous_id)
4089 if (
$_SESSION[
"AccountId"] == ANONYMOUS_USER_ID)
4093 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s",
4094 array(
'integer',
'integer'),
4095 array($user_id, $this->test_id)
4101 return $row[
"active_id"];
4123 $user_id = $ilUser->id;
4129 $result = $ilDB->queryF(
"SELECT tst_active.active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s",
4130 array(
'integer',
'integer'),
4136 return $row[
"active_id"];
4152 $keys = array_keys($array);
4155 foreach ($keys as $key)
4178 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
4180 $sequence = array();
4181 if ($ordered_sequence)
4189 $arrResults = array();
4190 $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",
4191 array(
'integer',
'integer'),
4192 array($active_id,
$pass)
4194 while (
$row = $ilDB->fetchAssoc($solutionresult))
4196 $arrResults[
$row[
'question_fi']] =
$row;
4199 require_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
4200 $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'));
4202 $unordered = array();
4206 $percentvalue = (
$row[
'points']) ? $arrResults[
$row[
'question_id']][
'reached'] /
$row[
'points'] : 0;
4207 if ($percentvalue < 0) $percentvalue = 0.0;
4211 "max" => round(
$row[
'points'], 2),
4212 "reached" => round($arrResults[
$row[
'question_id']][
'reached'],2),
4213 "percent" => sprintf(
"%2.2f ", ($percentvalue) * 100) .
"%",
4215 "type" => $row[
"type_tag"],
4216 "qid" => $row[
'question_id'],
4217 "original_id" => $row[
"original_id"],
4218 "workedthrough" => ($arrResults[$row[
'question_id']][
'workedthru']) ? 1 : 0
4220 $unordered[$row[
'question_id']] =
$data;
4227 foreach ($sequence as $qid)
4231 $pass_max += round($unordered[$qid][
'max'], 2);
4232 $pass_reached += round($unordered[$qid][
'reached'], 2);
4236 $unordered[$qid][
'nr'] = $key;
4237 array_push($found, $unordered[$qid]);
4245 if (
$results[
'reached_points'] < 0)
4249 if ($pass_reached < 0) $pass_reached = 0;
4251 $found[
'pass'][
'total_max_points'] = $pass_max;
4252 $found[
'pass'][
'total_reached_points'] = $pass_reached;
4253 $found[
'pass'][
'percent'] = ($pass_max > 0) ? $pass_reached / $pass_max : 0;
4254 $found[
"test"][
"total_max_points"] =
$results[
'max_points'];
4255 $found[
"test"][
"total_reached_points"] =
$results[
'reached_points'];
4256 $found[
"test"][
"result_pass"] =
$results[
'pass'];
4257 if ((!$total_reached_points) or (!$total_max_points))
4263 $percentage = ($total_reached_points / $total_max_points) * 100.0;
4264 if ($percentage < 0) $percentage = 0.0;
4266 $found[
"test"][
"passed"] =
$results[
'passed'];
4280 $result = $ilDB->queryF(
"SELECT COUNT(active_id) total FROM tst_active WHERE test_fi = %s",
4285 return $row[
"total"];
4298 $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",
4299 array(
'integer',
'integer'),
4305 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4306 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4307 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4308 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4309 $time += ($epoch_2 - $epoch_1);
4336 $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",
4344 if (!array_key_exists(
$row[
"active_fi"], $times))
4346 $times[
$row[
"active_fi"]] = 0;
4348 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4349 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4350 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4351 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4352 $times[
$row[
"active_fi"]] += ($epoch_2 - $epoch_1);
4367 $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",
4368 array(
'integer',
'integer'),
4374 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4375 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4376 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4377 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4378 $time += ($epoch_2 - $epoch_1);
4393 $result = $ilDB->queryF(
"SELECT * FROM tst_times WHERE active_fi = %s AND pass = %s ORDER BY started",
4394 array(
'integer',
'integer'),
4395 array($active_id,
$pass)
4400 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4401 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4402 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4403 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4404 $time += ($epoch_2 - $epoch_1);
4433 $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",
4434 array(
'integer',
'integer'),
4441 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
4442 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4443 if ($firstvisit == 0 || $epoch_1 < $firstvisit) $firstvisit = $epoch_1;
4444 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
4445 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4446 if ($epoch_2 > $lastvisit) $lastvisit = $epoch_2;
4448 return array(
"firstvisit" => $firstvisit,
"lastvisit" => $lastvisit);
4463 $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",
4472 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->started, $matches);
4473 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4474 if (!$first_visit) {
4475 $first_visit = $epoch_1;
4477 if ($epoch_1 < $first_visit) {
4478 $first_visit = $epoch_1;
4480 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->finished, $matches);
4481 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
4483 $last_visit = $epoch_2;
4485 if ($epoch_2 > $last_visit) {
4486 $last_visit = $epoch_2;
4488 $times[
$row->active_fi] += ($epoch_2 - $epoch_1);
4491 foreach ($times as $key => $value) {
4492 $max_time += $value;
4494 if ((!$test_result[
"test"][
"total_reached_points"]) or (!$test_result[
"test"][
"total_max_points"]))
4500 $percentage = ($test_result[
"test"][
"total_reached_points"] / $test_result[
"test"][
"total_max_points"]) * 100.0;
4501 if ($percentage < 0) $percentage = 0.0;
4503 $mark_obj = $this->mark_schema->getMatchingMark($percentage);
4504 $first_date = getdate($first_visit);
4505 $last_date = getdate($last_visit);
4506 $qworkedthrough = 0;
4507 foreach ($test_result as $key => $value)
4509 if (preg_match(
"/\d+/", $key))
4511 $qworkedthrough += $value[
"workedthrough"];
4514 if (!$qworkedthrough)
4520 $atimeofwork = $max_time / $qworkedthrough;
4526 $result_mark = $mark_obj->getShortName();
4527 if ($mark_obj->getPassed())
4536 $percent_worked_through = 0;
4537 if (count($this->questions))
4539 $percent_worked_through = $qworkedthrough / count($this->questions);
4541 $result_array = array(
4542 "qworkedthrough" => $qworkedthrough,
4543 "qmax" => count($this->questions),
4544 "pworkedthrough" => $percent_worked_through,
4545 "timeofwork" => $max_time,
4546 "atimeofwork" => $atimeofwork,
4547 "firstvisit" => $first_date,
4548 "lastvisit" => $last_date,
4549 "resultspoints" => $test_result[
"test"][
"total_reached_points"],
4550 "maxpoints" => $test_result[
"test"][
"total_max_points"],
4551 "resultsmarks" => $result_mark,
4552 "passed" => $passed,
4553 "distancemedian" =>
"0"
4555 foreach ($test_result as $key => $value)
4557 if (preg_match(
"/\d+/", $key))
4559 $result_array[$key] = $value;
4562 return $result_array;
4574 $totalpoints_array = array();
4576 foreach ($all_users as $active_id => $user_name)
4579 $reached = $test_result[
"test"][
"total_reached_points"];
4580 $total = $test_result[
"test"][
"total_max_points"];
4582 $mark = $this->mark_schema->getMatchingMark($percentage*100.0);
4585 if ($mark->getPassed())
4587 array_push($totalpoints_array, $test_result[
"test"][
"total_reached_points"]);
4591 return $totalpoints_array;
4603 $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",
4607 $persons_array = array();
4610 $name = $this->lng->txt(
"unknown");
4611 $fullname = $this->lng->txt(
"unknown");
4615 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
4617 $name = $this->lng->txt(
"deleted_user");
4618 $fullname = $this->lng->txt(
"deleted_user");
4619 $login = $this->lng->txt(
"unknown");
4623 $login = $row[
"login"];
4624 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4626 $name = $this->lng->txt(
"unknown");
4627 $fullname = $this->lng->txt(
"unknown");
4631 $name = trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]);
4632 $fullname = trim($row[
"title"] .
" " . $row[
"firstname"] .
" " . $row[
"lastname"]);
4636 $persons_array[
$row[
"active_id"]] = array(
4638 "fullname" => $fullname,
4642 return $persons_array;
4654 $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),
4658 $persons_array = array();
4663 $persons_array[
$row[
"active_id"]] = $this->lng->txt(
"unknown");
4667 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
4669 $persons_array[$row[
"active_id"]] = $this->lng->txt(
"deleted_user");
4673 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4675 $persons_array[$row[
"active_id"]] = $row[
"lastname"];
4679 $persons_array[$row[
"active_id"]] = trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]);
4684 return $persons_array;
4696 $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),
4700 $persons_array = array();
4705 $persons_array[
$row[
"active_id"]] = array(
"name" => $this->lng->txt(
"unknown"));
4709 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
4711 $persons_array[$row[
"active_id"]] = array(
"name" => $this->lng->txt(
"deleted_user"));
4715 if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
4717 $persons_array[$row[
"active_id"]] = array(
"name" => $row[
"lastname"]);
4721 $persons_array[$row[
"active_id"]] = array(
"name" => trim($row[
"lastname"] .
", " . $row[
"firstname"] .
" " . $row[
"title"]),
"login" => $row[
"login"]);
4726 return $persons_array;
4739 $result = $ilDB->queryF(
"SELECT COUNT(active_id) total FROM tst_active WHERE test_fi = %s AND submitted = %s",
4740 array(
'integer',
'integer'),
4744 return $row[
"total"];
4759 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, " .
4760 "tst_test_rnd_qst.pass, qpl_questions.points " .
4761 "FROM tst_test_rnd_qst, qpl_questions " .
4762 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
4763 "AND tst_test_rnd_qst.active_fi = %s ORDER BY tst_test_rnd_qst.sequence",
4770 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4771 "qpl_questions.points " .
4772 "FROM tst_test_question, tst_active, qpl_questions " .
4773 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4774 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi",
4784 array_push($qtest,
$row);
4802 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, " .
4803 "qpl_questions.points " .
4804 "FROM tst_test_rnd_qst, qpl_questions " .
4805 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
4806 "AND tst_test_rnd_qst.active_fi = %s AND tst_test_rnd_qst.pass = %s " .
4807 "ORDER BY tst_test_rnd_qst.sequence",
4808 array(
'integer',
'integer'),
4809 array($active_id,
$pass)
4814 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4815 "qpl_questions.points " .
4816 "FROM tst_test_question, tst_active, qpl_questions " .
4817 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4818 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi",
4828 array_push($qpass,
$row);
4837 include_once
"./Modules/Test/classes/class.ilTestEvaluationPassData.php";
4838 include_once
"./Modules/Test/classes/class.ilTestEvaluationUserData.php";
4839 include_once
"./Modules/Test/classes/class.ilTestEvaluationData.php";
4841 $result = $ilDB->queryF(
"SELECT tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
4842 "qpl_questions.points maxpoints " .
4843 "FROM tst_test_result, qpl_questions, tst_active " .
4844 "WHERE tst_active.active_id = tst_test_result.active_fi " .
4845 "AND qpl_questions.question_id = tst_test_result.question_fi " .
4846 "AND tst_active.test_fi = %s " .
4847 "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
4856 $data->getParticipant(
$row[
"active_fi"])->getPass(
$row[
"pass"])->addAnsweredQuestion(
$row[
"question_fi"],
$row[
"maxpoints"],
$row[
"points"]);
4859 foreach (array_keys(
$data->getParticipants()) as $active_id)
4863 for ($testpass = 0; $testpass <=
$data->getParticipant($active_id)->getLastPass(); $testpass++)
4866 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, qpl_questions.original_id, " .
4867 "tst_test_rnd_qst.pass, qpl_questions.points, qpl_questions.title " .
4868 "FROM tst_test_rnd_qst, qpl_questions " .
4869 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
4870 "AND tst_test_rnd_qst.pass = %s " .
4871 "AND tst_test_rnd_qst.active_fi = %s ORDER BY tst_test_rnd_qst.sequence",
4872 array(
'integer',
'integer'),
4873 array($testpass, $active_id)
4879 $tpass = array_key_exists(
"pass",
$row) ?
$row[
"pass"] : 0;
4880 $data->getParticipant($active_id)->addQuestion(
$row[
"original_id"],
$row[
"question_fi"],
$row[
"points"],
$row[
"sequence"], $tpass);
4881 $data->addQuestionTitle(
$row[
"question_fi"],
$row[
"title"]);
4888 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
4889 "qpl_questions.points, qpl_questions.title, qpl_questions.original_id " .
4890 "FROM tst_test_question, tst_active, qpl_questions " .
4891 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
4892 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi ORDER BY tst_test_question.sequence",
4898 $questionsbysequence = array();
4901 $questionsbysequence[
$row[
"sequence"]] =
$row;
4903 $seqresult = $ilDB->queryF(
"SELECT * FROM tst_sequence WHERE active_fi = %s",
4907 while ($seqrow = $ilDB->fetchAssoc($seqresult))
4909 $questionsequence = unserialize($seqrow[
"sequence"]);
4910 foreach ($questionsequence as $sidx => $seq)
4912 $data->getParticipant($active_id)->addQuestion($questionsbysequence[$seq][
"original_id"], $questionsbysequence[$seq][
"question_fi"], $questionsbysequence[$seq][
"points"], $sidx + 1, $seqrow[
"pass"]);
4913 $data->addQuestionTitle($questionsbysequence[$seq][
"question_fi"], $questionsbysequence[$seq][
"title"]);
4920 if ($this->ects_output)
4924 foreach (array_keys(
$data->getParticipants()) as $active_id)
4926 $percentage =
$data->getParticipant($active_id)->getReachedPointsInPercent();
4927 $mark = $this->mark_schema->getMatchingMark($percentage);
4928 if (is_object($mark))
4930 $data->getParticipant($active_id)->setMark($mark->getShortName());
4931 $data->getParticipant($active_id)->setMarkOfficial($mark->getOfficialName());
4932 $data->getParticipant($active_id)->setPassed($mark->getPassed());
4934 if ($this->ects_output)
4936 $ects_mark = $this->
getECTSGrade($passed_array,
$data->getParticipant($active_id)->getReached(),
$data->getParticipant($active_id)->getMaxPoints());
4937 $data->getParticipant($active_id)->setECTSMark($ects_mark);
4940 $data->getParticipant($active_id)->setFirstVisit($visitingTime[
"firstvisit"]);
4941 $data->getParticipant($active_id)->setLastVisit($visitingTime[
"lastvisit"]);
4952 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.pass, COUNT(tst_test_rnd_qst.question_fi) qcount, " .
4953 "SUM(qpl_questions.points) qsum FROM tst_test_rnd_qst, qpl_questions " .
4954 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id AND " .
4955 "tst_test_rnd_qst.active_fi = %s and pass = %s GROUP BY tst_test_rnd_qst.active_fi, " .
4956 "tst_test_rnd_qst.pass",
4957 array(
'integer',
'integer'),
4958 array($active_id,
$pass)
4963 $result = $ilDB->queryF(
"SELECT COUNT(tst_test_question.question_fi) qcount, " .
4964 "SUM(qpl_questions.points) qsum FROM tst_test_question, qpl_questions, tst_active " .
4965 "WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = tst_active.test_fi AND " .
4966 "tst_active.active_id = %s GROUP BY tst_test_question.test_fi",
4974 return array(
"count" =>
$row[
"qcount"],
"points" =>
$row[
"qsum"]);
4978 return array(
"count" => 0,
"points" => 0);
4984 include_once
"./Modules/Test/classes/class.ilTestEvaluationData.php";
4985 include_once
"./Modules/Test/classes/class.ilTestEvaluationPassData.php";
4986 include_once
"./Modules/Test/classes/class.ilTestEvaluationUserData.php";
4988 if ($withStatistics)
4990 $data->calculateStatistics();
4992 $data->setFilter($filterby, $filtertext);
5017 $result = $ilDB->queryF(
"SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
5018 "tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
5019 "qpl_questions.points maxpoints " .
5020 "FROM tst_test_result, qpl_questions, tst_active " .
5021 "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
5022 "WHERE tst_active.active_id = tst_test_result.active_fi " .
5023 "AND qpl_questions.question_id = tst_test_result.question_fi " .
5024 "AND tst_active.test_fi = %s " .
5025 "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
5029 $overview = array();
5032 if (!array_key_exists(
$row[
"active_fi"], $overview))
5034 $overview[
$row[
"active_fi"]] = array();
5035 $overview[$row[
"active_fi"]][
"firstname"] = $row[
"firstname"];
5036 $overview[$row[
"active_fi"]][
"lastname"] = $row[
"lastname"];
5037 $overview[$row[
"active_fi"]][
"title"] = $row[
"title"];
5038 $overview[$row[
"active_fi"]][
"login"] = $row[
"login"];
5039 $overview[$row[
"active_fi"]][
"usr_id"] = $row[
"usr_id"];
5040 $overview[$row[
"active_fi"]][
"started"] = $row[
"started"];
5041 $overview[$row[
"active_fi"]][
"finished"] = $row[
"finished"];
5043 if (!array_key_exists(
$row[
"pass"], $overview[
$row[
"active_fi"]]))
5045 $overview[$row[
"active_fi"]][$row[
"pass"]] = array();
5046 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] = 0;
5047 $overview[$row[
"active_fi"]][$row[
"pass"]][
"maxpoints"] = $row[
"maxpoints"];
5049 array_push($overview[$row[
"active_fi"]][$row[
"pass"]], $row);
5050 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] += $row[
"points"];
5066 $result = $ilDB->queryF(
"SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
5067 "tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
5068 "qpl_questions.points maxpoints " .
5069 "FROM tst_test_result, qpl_questions, tst_active " .
5070 "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
5071 "WHERE tst_active.active_id = tst_test_result.active_fi " .
5072 "AND qpl_questions.question_id = tst_test_result.question_fi " .
5073 "AND tst_active.test_fi = %s AND tst_active.active_id = %s" .
5074 "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
5075 array(
'integer',
'integer'),
5078 $overview = array();
5081 if (!array_key_exists(
$row[
"active_fi"], $overview))
5083 $overview[
$row[
"active_fi"]] = array();
5084 $overview[$row[
"active_fi"]][
"firstname"] = $row[
"firstname"];
5085 $overview[$row[
"active_fi"]][
"lastname"] = $row[
"lastname"];
5086 $overview[$row[
"active_fi"]][
"title"] = $row[
"title"];
5087 $overview[$row[
"active_fi"]][
"login"] = $row[
"login"];
5088 $overview[$row[
"active_fi"]][
"usr_id"] = $row[
"usr_id"];
5089 $overview[$row[
"active_fi"]][
"started"] = $row[
"started"];
5090 $overview[$row[
"active_fi"]][
"finished"] = $row[
"finished"];
5092 if (!array_key_exists(
$row[
"pass"], $overview[
$row[
"active_fi"]]))
5094 $overview[$row[
"active_fi"]][$row[
"pass"]] = array();
5095 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] = 0;
5096 $overview[$row[
"active_fi"]][$row[
"pass"]][
"maxpoints"] = $row[
"maxpoints"];
5098 array_push($overview[$row[
"active_fi"]][$row[
"pass"]], $row);
5099 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] += $row[
"points"];
5118 if (strlen($firstname.$lastname.$title) == 0)
5120 $name = $this->lng->txt(
"deleted_user");
5124 if ($user_id == ANONYMOUS_USER_ID)
5130 $name = trim($lastname .
", " . $firstname .
" " .
$title);
5134 $name = $this->lng->txt(
"anonymous");
5156 if (strlen($firstname.$lastname.$title) == 0)
5158 $name = $lng->txt(
"deleted_user");
5162 if ($user_id == ANONYMOUS_USER_ID)
5168 $name = trim($lastname .
", " . $firstname .
" " .
$title);
5172 $name = $lng->txt(
"anonymous");
5188 $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",
5195 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->started, $matches);
5196 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5197 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row->finished, $matches);
5198 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5199 $times[
$row->active_fi] += ($epoch_2 - $epoch_1);
5203 foreach ($times as $key => $value)
5205 $max_time += $value;
5210 $average_time = round($max_time / $counter);
5216 return $average_time;
5225 function &
getAvailableQuestionpools($use_object_id =
false, $equal_points =
false, $could_be_offline =
false, $show_path = FALSE, $with_questioncount = FALSE, $permission =
"read")
5227 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5239 $time_in_seconds = 0;
5240 foreach ($this->questions as $question_id)
5243 $est_time = $question->getEstimatedWorkingTime();
5244 $time_in_seconds += $est_time[
"h"] * 3600 + $est_time[
"m"] * 60 + $est_time[
"s"];
5246 $hours = (int)($time_in_seconds / 3600) ;
5247 $time_in_seconds = $time_in_seconds - ($hours * 3600);
5248 $minutes = (int)($time_in_seconds / 60);
5249 $time_in_seconds = $time_in_seconds - ($minutes * 60);
5250 $result = array(
"hh" => $hours,
"mm" => $minutes,
"ss" => $time_in_seconds);
5266 foreach ($qpls as $arr) array_push($qplids, $arr[
'qpl']);
5267 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_cpy WHERE tst_fi = %s AND ' . $ilDB->in(
'qpl_fi', $qplids,
false,
'integer'),
5274 while (
$row = $ilDB->fetchAssoc(
$result)) array_push($ids,
$row[
'qst_fi']);
5275 $nr = ($nr > count($ids)) ? count($ids) : $nr;
5276 if ($nr == 0)
return array();
5277 $rand_keys = array_rand($ids, $nr);
5278 $selection = array();
5279 if (is_array($rand_keys))
5281 foreach ($rand_keys as $key)
5283 $selection[$ids[$key]] = $ids[$key];
5288 $selection[$ids[$rand_keys]] = $ids[$rand_keys];
5318 $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",
5322 $original_ids = array();
5323 $paramtypes = array();
5324 $paramvalues = array();
5327 array_push($original_ids,
$row[
'original_id']);
5332 if (($questionpool == 0) && (!is_array($qpls)))
5334 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5336 if (count($available_pools))
5338 $available =
" AND " . $ilDB->in(
'obj_fi', $available_pools,
false,
'integer');
5346 $constraint_qpls =
"";
5347 $result_array = array();
5348 if ($questionpool == 0)
5350 if (is_array($qpls))
5352 if (count($qpls) > 0)
5354 $constraint_qpls =
" AND " . $ilDB->in(
'obj_fi', $qpls,
false,
'integer');
5359 $original_clause =
"";
5360 if (count($original_ids))
5362 $original_clause =
" AND " . $ilDB->in(
'question_id', $original_ids,
true,
'integer');
5365 if ($questionpool == 0)
5367 $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",
5368 array(
'integer',
'text'),
5374 $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",
5375 array(
'integer',
'integer',
'text'),
5376 array($questionpool, 0,
"1")
5379 $found_ids = array();
5382 array_push($found_ids,
$row[
'question_id']);
5384 $nr_of_questions = ($nr_of_questions > count($found_ids)) ? count($found_ids) : $nr_of_questions;
5385 if ($nr_of_questions == 0)
return array();
5386 $rand_keys = array_rand($found_ids, $nr_of_questions);
5388 if (is_array($rand_keys))
5390 foreach ($rand_keys as $key)
5392 $result[$found_ids[$key]] = $found_ids[$key];
5397 $result[$found_ids[$rand_keys]] = $found_ids[$rand_keys];
5410 return CLIENT_WEB_DIR .
"/assessment/" . $this->
getId() .
"/images/";
5421 include_once
"./Services/Utilities/classes/class.ilUtil.php";
5436 if ((!$question_type) and ($question_id > 0))
5440 if (!strlen($question_type))
return null;
5441 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
5443 $question_type_gui = $question_type .
"GUI";
5444 $question =
new $question_type_gui();
5445 if ($question_id > 0)
5447 $question->object->loadFromDb($question_id);
5461 if (strcmp($question_id,
"") != 0)
5463 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
5478 $this->questions = array_values($this->questions);
5479 $array_pos = array_search($target_index, $this->questions);
5480 if ($insert_mode == 0)
5482 $part1 = array_slice($this->questions, 0, $array_pos);
5483 $part2 = array_slice($this->questions, $array_pos);
5485 else if ($insert_mode == 1)
5487 $part1 = array_slice($this->questions, 0, $array_pos + 1);
5488 $part2 = array_slice($this->questions, $array_pos + 1);
5490 foreach ($move_questions as $question_id)
5492 if (!(array_search($question_id, $part1) === FALSE))
5494 unset($part1[array_search($question_id, $part1)]);
5496 if (!(array_search($question_id, $part2) === FALSE))
5498 unset($part2[array_search($question_id, $part2)]);
5501 $part1 = array_values($part1);
5502 $part2 = array_values($part2);
5503 $new_array = array_values(array_merge($part1, $move_questions, $part2));
5504 $this->questions = array();
5506 foreach ($new_array as $question_id)
5508 $this->questions[$counter] = $question_id;
5526 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartingTime(), $matches))
5528 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5530 if ($now < $epoch_time)
5551 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndingTime(), $matches))
5553 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
5555 if ($now > $epoch_time)
5575 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5578 if (count($available_pools))
5580 $available =
" AND " . $ilDB->in(
'qpl_questions.obj_fi', $available_pools,
false,
'integer');
5588 $available .=
" AND qpl_questions.complete = " . $ilDB->quote(
"1",
'text');
5592 if (is_array($arrFilter))
5594 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
5596 $where .=
" AND " . $ilDB->like(
'qpl_questions.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
5598 if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description']))
5600 $where .=
" AND " . $ilDB->like(
'qpl_questions.description',
'text',
"%%" . $arrFilter[
'description'] .
"%%");
5602 if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author']))
5604 $where .=
" AND " . $ilDB->like(
'qpl_questions.author',
'text',
"%%" . $arrFilter[
'author'] .
"%%");
5606 if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type']))
5608 $where .=
" AND qpl_qst_type.type_tag = " . $ilDB->quote($arrFilter[
'type'],
'text');
5610 if (array_key_exists(
'qpl', $arrFilter) && strlen($arrFilter[
'qpl']))
5612 $where .=
" AND " . $ilDB->like(
'object_data.title',
'text',
"%%" . $arrFilter[
'qpl'] .
"%%");
5617 $original_clause =
" qpl_questions.original_id IS NULL";
5618 if (count($original_ids))
5620 $original_clause =
" qpl_questions.original_id IS NULL AND " . $ilDB->in(
'qpl_questions.question_id', $original_ids,
true,
'integer');
5623 $query_result = $ilDB->query(
5624 "SELECT qpl_questions.*, qpl_questions.tstamp, qpl_qst_type.type_tag, qpl_qst_type.plugin, object_data.title qpl " .
5625 "FROM qpl_questions, qpl_qst_type, object_data WHERE $original_clause $available AND " .
5626 "object_data.obj_id = qpl_questions.obj_fi AND qpl_questions.tstamp > 0 AND " .
5627 "qpl_questions.question_type_fi = qpl_qst_type.question_type_id$where");
5630 if ($query_result->numRows())
5632 while (
$row = $ilDB->fetchAssoc($query_result))
5634 $row[
'ttype'] = $types[
$row[
'type_tag']];
5639 array_push($rows, $row);
5644 array_push($rows, $row);
5656 global $ilPluginAdmin;
5658 $lng->loadLanguageModule(
"assessment");
5659 $result = $ilDB->query(
"SELECT * FROM qpl_qst_type");
5663 if (
$row[
"plugin"] == 0)
5665 $types[
$row[
'type_tag']] = $lng->txt($row[
"type_tag"]);
5669 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE,
"TestQuestionPool",
"qst");
5670 foreach ($pl_names as $pl_name)
5673 if (strcmp($pl->getQuestionType(),
$row[
"type_tag"]) == 0)
5675 $types[
$row[
'type_tag']] = $pl->getQuestionTypeTranslation();
5695 $this->
setTitle($assessment->getTitle());
5697 foreach ($assessment->objectives as $objectives)
5699 foreach ($objectives->materials as $material)
5704 if ($assessment->getPresentationMaterial())
5709 foreach ($assessment->assessmentcontrol as $assessmentcontrol)
5711 switch ($assessmentcontrol->getSolutionswitch())
5722 foreach ($assessment->qtimetadata as
$metadata)
5724 switch ($metadata[
"label"])
5728 $type = $metadata[
"entry"];
5749 case "sequence_settings":
5759 $this->
setKiosk($metadata[
"entry"]);
5761 case "showfinalstatement":
5773 case "hide_previous_results":
5774 if ($metadata[
"entry"] == 0)
5783 case "use_previous_answers":
5786 case "answer_feedback":
5789 case "hide_title_points":
5792 case "title_output":
5798 case "random_question_count":
5801 case "results_presentation":
5804 case "reset_processing_time":
5807 case "instant_verification":
5810 case "answer_feedback_points":
5822 case "fixed_participants":
5825 case "score_reporting":
5828 case "shuffle_questions":
5831 case "count_system":
5837 case "mailnotification":
5843 case "exportsettings":
5846 case "score_cutting":
5852 case "allowedUsers":
5855 case "allowedUsersTimeGap":
5858 case "pass_scoring":
5861 case "show_summary":
5864 case "reporting_date":
5865 $iso8601period = $metadata[
"entry"];
5866 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
5868 $this->
setReportingDate(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
5871 case "processing_time":
5874 case "starting_time":
5875 $iso8601period = $metadata[
"entry"];
5876 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
5878 $this->
setStartingTime(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
5882 $iso8601period = $metadata[
"entry"];
5883 if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
5885 $this->
setEndingTime(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
5889 if (preg_match(
"/mark_step_\d+/", $metadata[
"label"]))
5891 $xmlmark = $metadata[
"entry"];
5892 preg_match(
"/<short>(.*?)<\/short>/", $xmlmark, $matches);
5893 $mark_short = $matches[1];
5894 preg_match(
"/<official>(.*?)<\/official>/", $xmlmark, $matches);
5895 $mark_official = $matches[1];
5896 preg_match(
"/<percentage>(.*?)<\/percentage>/", $xmlmark, $matches);
5897 $mark_percentage = $matches[1];
5898 preg_match(
"/<passed>(.*?)<\/passed>/", $xmlmark, $matches);
5899 $mark_passed = $matches[1];
5900 $this->mark_schema->addMarkStep($mark_short, $mark_official, $mark_percentage, $mark_passed);
5904 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
5906 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
5907 include_once
"./Services/RTE/classes/class.ilRTE.php";
5908 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
5909 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
5912 if (file_exists($importfile))
5922 $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
5937 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
5941 $a_xml_writer->xmlSetDtdDef(
"<!DOCTYPE questestinterop SYSTEM \"ims_qtiasiv1p2p1.dtd\">");
5942 $a_xml_writer->xmlStartTag(
"questestinterop");
5945 "ident" =>
"il_".IL_INST_ID.
"_tst_".$this->getTestId(),
5948 $a_xml_writer->xmlStartTag(
"assessment", $attrs);
5950 $a_xml_writer->xmlElement(
"qticomment", NULL, $this->
getDescription());
5953 if ($this->enable_processing_time)
5955 preg_match(
"/(\d+):(\d+):(\d+)/", $this->processing_time, $matches);
5956 $a_xml_writer->xmlElement(
"duration", NULL, sprintf(
"P0Y0M0DT%dH%dM%dS", $matches[1], $matches[2], $matches[3]));
5960 $a_xml_writer->xmlStartTag(
"qtimetadata");
5961 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5962 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ILIAS_VERSION");
5963 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->ilias->getSetting(
"ilias_version"));
5964 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5967 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5968 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"anonymity");
5969 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getAnonymity()));
5970 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5973 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5974 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"random_test");
5975 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
isRandomTest()));
5976 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5979 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5980 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"sequence_settings");
5982 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5985 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5986 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"author");
5987 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getAuthor());
5988 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5991 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5992 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"reset_processing_time");
5994 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
5997 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
5998 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"count_system");
5999 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getCountSystem());
6000 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6003 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6004 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mc_scoring");
6005 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getMCScoring());
6006 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6009 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6010 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"score_cutting");
6011 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getScoreCutting());
6012 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6015 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6016 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"password");
6017 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getPassword());
6018 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6021 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6022 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"allowedUsers");
6023 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getAllowedUsers());
6024 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6027 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6028 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"allowedUsersTimeGap");
6030 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6033 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6034 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"pass_scoring");
6035 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getPassScoring());
6036 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6041 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6042 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"reporting_date");
6043 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->reporting_date, $matches);
6044 $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]));
6045 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6048 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6049 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"nr_of_tries");
6050 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getNrOfTries()));
6051 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6054 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6055 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"kiosk");
6056 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getKiosk()));
6057 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6060 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6061 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"use_previous_answers");
6063 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6066 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6067 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"title_output");
6068 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getTitleOutput()));
6069 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6072 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6073 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"random_question_count");
6075 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6078 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6079 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"results_presentation");
6081 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6084 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6085 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"show_summary");
6087 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6090 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6091 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"score_reporting");
6092 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getScoreReporting()));
6093 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6096 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6097 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"instant_verification");
6099 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6102 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6103 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"answer_feedback");
6104 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getAnswerFeedback()));
6105 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6108 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6109 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"answer_feedback_points");
6111 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6114 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6115 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"show_cancel");
6116 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShowCancel()));
6117 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6120 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6121 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"show_marker");
6122 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShowMarker()));
6123 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6126 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6127 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"fixed_participants");
6129 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6132 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6133 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"showfinalstatement");
6134 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getShowFinalStatement()) ?
"1" :
"0")));
6135 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6138 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6139 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"showinfo");
6140 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getShowInfo()) ?
"1" :
"0")));
6141 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6144 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6145 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mailnotification");
6147 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6150 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6151 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mailnottype");
6153 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6156 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6157 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"exportsettings");
6159 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6162 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6163 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"forcejs");
6164 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getForceJS()) ?
"1" :
"0")));
6165 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6168 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6169 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"customstyle");
6170 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getCustomStyle());
6171 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6174 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6175 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"shuffle_questions");
6176 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShuffleQuestions()));
6177 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6180 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6181 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"processing_time");
6183 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6188 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6189 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"starting_time");
6190 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->starting_time, $matches);
6191 $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]));
6192 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6197 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6198 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"ending_time");
6199 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->ending_time, $matches);
6200 $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]));
6201 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6203 foreach ($this->mark_schema->mark_steps as $index => $mark)
6206 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
6207 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"mark_step_$index");
6208 $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()));
6209 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
6211 $a_xml_writer->xmlEndTag(
"qtimetadata");
6214 $a_xml_writer->xmlStartTag(
"objectives");
6216 $a_xml_writer->xmlEndTag(
"objectives");
6222 "solutionswitch" =>
"Yes"
6229 $a_xml_writer->xmlElement(
"assessmentcontrol", $attrs, NULL);
6234 $a_xml_writer->xmlStartTag(
"presentation_material");
6235 $a_xml_writer->xmlStartTag(
"flow_mat");
6237 $a_xml_writer->xmlEndTag(
"flow_mat");
6238 $a_xml_writer->xmlEndTag(
"presentation_material");
6244 $a_xml_writer->xmlElement(
"section", $attrs, NULL);
6245 $a_xml_writer->xmlEndTag(
"assessment");
6246 $a_xml_writer->xmlEndTag(
"questestinterop");
6248 $xml = $a_xml_writer->xmlDumpMem(FALSE);
6250 foreach ($this->questions as $question_id)
6253 $qti_question = $question->toXML(
false);
6254 $qti_question = preg_replace(
"/<questestinterop>/",
"", $qti_question);
6255 $qti_question = preg_replace(
"/<\/questestinterop>/",
"", $qti_question);
6256 if (strpos($xml,
"</section>") !==
false)
6258 $xml = str_replace(
"</section>",
"$qti_question</section>", $xml);
6262 $xml = str_replace(
"<section ident=\"1\"/>",
"<section ident=\"1\">\n$qti_question</section>", $xml);
6278 $this->mob_ids = array();
6279 $this->file_ids = array();
6282 $attrs[
"Type"] =
"Test";
6283 $a_xml_writer->xmlStartTag(
"ContentObject", $attrs);
6289 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Page Objects");
6290 $ilBench->start(
"ContentObjectExport",
"exportPageObjects");
6292 $ilBench->stop(
"ContentObjectExport",
"exportPageObjects");
6293 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Page Objects");
6296 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Media Objects");
6297 $ilBench->start(
"ContentObjectExport",
"exportMediaObjects");
6299 $ilBench->stop(
"ContentObjectExport",
"exportMediaObjects");
6300 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Media Objects");
6303 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export File Items");
6304 $ilBench->start(
"ContentObjectExport",
"exportFileItems");
6306 $ilBench->stop(
"ContentObjectExport",
"exportFileItems");
6307 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export File Items");
6309 $a_xml_writer->xmlEndTag(
"ContentObject");
6320 include_once
"./Services/MetaData/classes/class.ilMD2XML.php";
6322 $md2xml->setExportMode(
true);
6323 $md2xml->startExport();
6324 $a_xml_writer->appendXML($md2xml->getXML());
6334 if ($a_tag ==
"Identifier" && $a_param ==
"Entry")
6336 include_once
"./Services/Utilities/classes/class.ilUtil.php";
6354 include_once
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
6356 foreach ($this->questions as $question_id)
6358 $ilBench->start(
"ContentObjectExport",
"exportPageObject");
6359 $expLog->write(date(
"[y-m-d H:i:s] ").
"Page Object ".$question_id);
6362 $a_xml_writer->xmlStartTag(
"PageObject", $attrs);
6366 $ilBench->start(
"ContentObjectExport",
"exportPageObject_XML");
6368 $page_object->buildDom();
6369 $page_object->insertInstIntoIDs($a_inst);
6370 $mob_ids = $page_object->collectMediaObjects(
false);
6371 $file_ids = $page_object->collectFileItems();
6372 $xml = $page_object->getXMLFromDom(
false,
false,
false,
"",
true);
6373 $xml = str_replace(
"&",
"&", $xml);
6374 $a_xml_writer->appendXML($xml);
6375 $page_object->freeDom();
6376 unset ($page_object);
6378 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_XML");
6381 $ilBench->start(
"ContentObjectExport",
"exportPageObject_CollectMedia");
6383 foreach($mob_ids as $mob_id)
6385 $this->mob_ids[$mob_id] = $mob_id;
6387 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_CollectMedia");
6390 $ilBench->start(
"ContentObjectExport",
"exportPageObject_CollectFileItems");
6392 foreach($file_ids as $file_id)
6394 $this->file_ids[$file_id] = $file_id;
6396 $ilBench->stop(
"ContentObjectExport",
"exportPageObject_CollectFileItems");
6398 $a_xml_writer->xmlEndTag(
"PageObject");
6401 $ilBench->stop(
"ContentObjectExport",
"exportPageObject");
6415 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
6417 foreach ($this->mob_ids as $mob_id)
6419 $expLog->write(date(
"[y-m-d H:i:s] ").
"Media Object ".$mob_id);
6423 $media_obj->exportXML($a_xml_writer, $a_inst);
6424 $media_obj->exportFiles($a_target_dir);
6436 include_once
"./Modules/File/classes/class.ilObjFile.php";
6438 foreach ($this->file_ids as $file_id)
6440 $expLog->write(date(
"[y-m-d H:i:s] ").
"File Item ".$file_id);
6441 $file_obj =
new ilObjFile($file_id,
false);
6442 $file_obj->export($a_target_dir);
6453 if (!is_array($this->import_mapping))
6459 return $this->import_mapping;
6474 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);
6485 function _getECTSGrade($points_passed, $reached_points, $max_points, $a, $b, $c,
$d, $e, $fx)
6487 include_once
"./classes/class.ilStatistics.php";
6490 $passed_statistics->setData($points_passed);
6491 $ects_percentiles = array
6493 "A" => $passed_statistics->quantile($a),
6494 "B" => $passed_statistics->quantile($b),
6495 "C" => $passed_statistics->quantile($c),
6496 "D" => $passed_statistics->quantile(
$d),
6497 "E" => $passed_statistics->quantile($e)
6499 if (count($points_passed) && ($reached_points >= $ects_percentiles[
"A"]))
6503 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"B"]))
6507 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"C"]))
6511 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"D"]))
6515 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"E"]))
6519 else if (strcmp($fx,
"") != 0)
6521 if ($max_points > 0)
6523 $percentage = ($reached_points / $max_points) * 100.0;
6524 if ($percentage < 0) $percentage = 0.0;
6530 if ($percentage >= $fx)
6547 return $this->mark_schema->checkMarks();
6579 $md_life =& $md->getLifecycle();
6582 if (strlen($a_author) == 0)
6585 $a_author = $ilUser->getFullname();
6588 $md_life =& $md->addLifecycle();
6590 $con =& $md_life->addContribute();
6591 $con->setRole(
"Author");
6593 $ent =& $con->addEntity();
6594 $ent->setEntity($a_author);
6620 include_once
"./Services/MetaData/classes/class.ilMD.php";
6622 $md_life =& $md->getLifecycle();
6625 $ids =& $md_life->getContributeIds();
6626 foreach ($ids as
$id)
6628 $md_cont =& $md_life->getContribute($id);
6629 if (strcmp($md_cont->getRole(),
"Author") == 0)
6631 $entids =& $md_cont->getEntityIds();
6632 foreach ($entids as $entid)
6634 $md_ent =& $md_cont->getEntity($entid);
6635 array_push(
$author, $md_ent->getEntity());
6653 include_once
"./Services/MetaData/classes/class.ilMD.php";
6654 $md =&
new ilMD($obj_id, 0,
"tst");
6655 $md_life =& $md->getLifecycle();
6658 $ids =& $md_life->getContributeIds();
6659 foreach ($ids as
$id)
6661 $md_cont =& $md_life->getContribute($id);
6662 if (strcmp($md_cont->getRole(),
"Author") == 0)
6664 $entids =& $md_cont->getEntityIds();
6665 foreach ($entids as $entid)
6667 $md_ent =& $md_cont->getEntity($entid);
6668 array_push(
$author, $md_ent->getEntity());
6687 $result_array = array();
6697 $result_array[$obj_id] = $titles[
$ref_id];
6705 return $result_array;
6720 $result = $ilDB->queryF(
"SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY sequence, test_random_id",
6728 $next_id = $ilDB->nextId(
'tst_test_random');
6729 $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)",
6730 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
6731 array($next_id, $new_id,
$row[
"questionpool_fi"],
$row[
"num_of_q"], time(),
$row[
'sequence'])
6773 $newObj->setKiosk($this->
getKiosk());
6803 $newObj->saveToDb();
6806 include_once
"./Services/Certificate/classes/class.ilCertificate.php";
6807 include_once
"./Modules/Test/classes/class.ilTestCertificateAdapter.php";
6810 $cert->cloneCertificate($newcert);
6814 $newObj->saveRandomQuestionCount($newObj->getRandomQuestionCount());
6819 include_once(
"./Services/CopyWizard/classes/class.ilCopyWizardOptions.php");
6823 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
6824 foreach ($this->questions as $key => $question_id)
6827 $newObj->questions[$key] = $question->duplicate(
true, null, null, null, $newObj->getId());
6830 $question->saveToDb($original_id);
6834 $cwo->appendMapping($this->
getRefId().
'_'.$question_id,$newObj->getRefId().
'_'.$newObj->questions[$key]);
6835 $ilLog->write(__METHOD__.
': Added mapping '.$this->getRefId().
'_'.$question_id.
' <-> ' .
6836 $newObj->getRefId().
'_'.$newObj->questions[$key]);
6839 $newObj->saveToDb();
6860 foreach ($qpls as
$data)
6862 $maxcount += $data[
"contains"];
6864 if ($num > $maxcount) $num = $maxcount;
6869 foreach ($qpls as
$data)
6871 $add = ($data[
"count"] <= $data[
"contains"]) ? $data[
"count"] : $data[
"contains"];
6878 $num = count($this->questions);
6895 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
6905 if (
$test[
"random_test"] == 1)
6909 $result = $ilDB->queryF(
"SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY sequence, test_random_id",
6917 $countresult = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND qpl_questions.tstamp > 0 AND original_id IS NULL",
6919 $row[
"questionpool_fi"]
6921 $contains = $countresult->numRows();
6922 $qpls[$counter] = array(
6923 "index" => $counter,
6924 "count" =>
$row[
"num_of_q"],
6925 "qpl" =>
$row[
"questionpool_fi"],
6926 "contains" => $contains
6931 if (
$test[
"random_question_count"] > 0)
6933 $num =
$test[
"random_question_count"];
6935 foreach ($qpls as
$data)
6937 $maxcount += $data[
"contains"];
6939 if ($num > $maxcount) $num = $maxcount;
6944 foreach ($qpls as
$data)
6946 $add = ($data[
"count"] <= $data[
"contains"]) ? $data[
"count"] : $data[
"contains"];
6953 $result = $ilDB->queryF(
"SELECT test_question_id FROM tst_test_question WHERE test_fi = %s",
6973 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
6977 $this->questions = array();
6991 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
6995 $this->questions = array();
7011 if (strcmp($question_id,
"") != 0)
7013 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
7016 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
7031 $result = $ilDB->queryF(
"SELECT obj_fi FROM tst_tests WHERE test_id = %s",
7038 $object_id =
$row[
"obj_fi"];
7054 $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",
7061 $object_id =
$row[
"obj_fi"];
7077 $result = $ilDB->queryF(
"SELECT test_id FROM tst_tests WHERE obj_fi = %s",
7102 if (($active_id) && ($question_id))
7106 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
7109 $result = $ilDB->queryF(
"SELECT value1 FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
7110 array(
'integer',
'integer',
'integer'),
7111 array($active_id, $question_id,
$pass)
7136 $result = $ilDB->queryF(
"SELECT question_text FROM qpl_questions WHERE question_id = %s",
7159 $result_array = array();
7163 if (is_numeric($user_id))
7165 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, %s login, %s lastname, %s firstname, tst_invited_user.clientip, " .
7166 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7167 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7168 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
7170 array(
'text',
'text',
'text',
'integer',
'integer'),
7171 array(
"", $this->lng->txt(
"unknown"),
"", $this->
getTestId(), $user_id)
7176 $result = $ilDB->queryF(
"SELECT tst_active.active_id, usr_id, %s login, %s lastname, %s firstname, tst_invited_user.clientip, " .
7177 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7178 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7179 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
7181 array(
'text',
'text',
'text',
'integer'),
7182 array(
"", $this->lng->txt(
"unknown"),
"", $this->
getTestId())
7188 if (is_numeric($user_id))
7190 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
7191 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7192 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7193 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
7195 array(
'integer',
'integer'),
7201 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
7202 "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
7203 "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
7204 "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
7211 $result_array = array();
7214 $result_array[
$row[
'usr_id']]=
$row;
7216 return $result_array;
7231 $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 ".
7232 "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),
7233 array(
'text',
'text',
'text',
'integer'),
7234 array(
"", $this->lng->txt(
"unknown"),
"", $this->
getTestId())
7239 $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 ".
7240 "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),
7250 foreach (
$data as $index => $participant)
7252 if (strlen(trim($participant[
"firstname"].$participant[
"lastname"])) == 0)
7254 $data[$index][
"lastname"] = $this->lng->txt(
"deleted_user");
7264 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
7266 if (count($scoring) == 0)
return array();
7269 $filtered_participants = array();
7270 foreach ($participants as $active_id => $participant)
7272 $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",
7282 if ($participant->active) $filtered_participants[$active_id] = $participant;
7285 if (!$participant->active) $filtered_participants[$active_id] = $participant;
7288 $filtered_participants[$active_id] = $participant;
7303 $assessmentSetting =
new ilSetting(
"assessment");
7304 $manscoring_done = $assessmentSetting->get(
"manscoring_done_" . $active_id);
7305 if ($manscoring_done) $filtered_participants[$active_id] = $participant;
7317 $assessmentSetting =
new ilSetting(
"assessment");
7318 $manscoring_done = $assessmentSetting->get(
"manscoring_done_" . $active_id);
7319 if (!$manscoring_done) $filtered_participants[$active_id] = $participant;
7327 if (
$row[
"manual"]) $found++;
7329 if (($found > 0) && ($found < $count)) $filtered_participants[$active_id] = $participant;
7332 $filtered_participants[$active_id] = $participant;
7337 return $filtered_participants;
7351 if (!is_array($ids) || count($ids) ==0)
return array();
7355 $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",
7356 array(
'text',
'text',
'text'),
7357 array(
"", $this->lng->txt(
"unknown"),
"")
7362 $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");
7365 $result_array = array();
7368 $result_array[
$row[
"usr_id"]]=
$row;
7370 return $result_array;
7375 if (!is_array($ids) || count($ids) ==0)
return array();
7387 if (!is_array($ids) || count($ids) ==0)
return array();
7389 foreach ($ids as $obj_id)
7405 include_once
"./Modules/Group/classes/class.ilObjGroup.php";
7407 $members = $group->getGroupMemberIds();
7408 include_once
'./Services/User/classes/class.ilObjUser.php';
7409 foreach ($members as $user_id)
7424 $members = $rbacreview->assignedUsers($role_id,
"usr_id");
7425 include_once
'./Services/User/classes/class.ilObjUser.php';
7426 foreach ($members as $user_id)
7444 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
7445 array(
'integer',
'integer'),
7460 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
7461 array(
'integer',
'integer'),
7464 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_invited_user (test_fi, user_fi, clientip, tstamp) VALUES (%s, %s, %s, %s)",
7465 array(
'integer',
'integer',
'text',
'integer'),
7466 array($this->
getTestId(), $user_id, (strlen($client_ip)) ? $client_ip : NULL, time())
7475 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_invited_user SET clientip = %s, tstamp = %s WHERE test_fi=%s and user_fi=%s",
7476 array(
'text',
'integer',
'integer',
'integer'),
7477 array((strlen($client_ip)) ? $client_ip : NULL, time(), $this->
getTestId(), $user_id)
7489 if (is_numeric($question_fi))
7491 $result = $ilDB->queryF(
"SELECT question_fi, solved FROM tst_qst_solved WHERE active_fi = %s AND question_fi=%s",
7492 array(
'integer',
'integer'),
7493 array($active_id, $question_fi)
7498 $result = $ilDB->queryF(
"SELECT question_fi, solved FROM tst_qst_solved WHERE active_fi = %s",
7503 $result_array = array();
7506 $result_array[
$row[
"question_fi"]]=
$row;
7508 return $result_array;
7520 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s AND question_fi = %s",
7521 array(
'integer',
'integer'),
7522 array($active_id, $question_id)
7524 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_qst_solved (solved, question_fi, active_fi) VALUES (%s, %s, %s)",
7525 array(
'integer',
'integer',
'integer'),
7526 array($value, $question_id, $active_id)
7538 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s, tstamp = %s WHERE test_fi = %s AND user_fi = %s",
7539 array(
'integer',
'timestamp',
'integer',
'integer',
'integer'),
7540 array(1, date(
'Y-m-d H:i:s'), time(), $this->
getTestId(), $user_id)
7542 $this->testSession = NULL;
7552 $result = $ilDB->queryF(
"SELECT submitted FROM tst_active WHERE active_id=%s AND submitted=%s",
7553 array(
'integer',
'integer'),
7554 array($active_id, 1)
7556 return $result->numRows() == 1;
7567 if (!is_numeric($user_id))
7568 $user_id = $ilUser->getId();
7570 $result = $ilDB->queryF(
"SELECT submitted FROM tst_active WHERE test_fi=%s AND user_fi=%s AND submitted=%s",
7571 array(
'integer',
'integer',
'integer'),
7574 return $result->numRows() == 1;
7608 "user_id" => $this->lng->txt(
"user_id"),
7609 "matriculation" => $this->lng->txt(
"matriculation"),
7610 "lastname" => $this->lng->txt(
"lastname"),
7611 "firstname" => $this->lng->txt(
"firstname"),
7612 "login" =>$this->lng->txt(
"login"),
7613 "reached_points" => $this->lng->txt(
"tst_reached_points"),
7614 "max_points" => $this->lng->txt(
"tst_maximum_points"),
7615 "percent_value" => $this->lng->txt(
"tst_percent_solved"),
7616 "mark" => $this->lng->txt(
"tst_mark"),
7617 "ects" => $this->lng->txt(
"ects_grade")
7620 if (count($participants))
7622 if ($this->ects_output)
7626 foreach ($participants as $active_id => $user_rec)
7629 $reached_points = 0;
7631 foreach ($this->questions as $value)
7634 if (is_object($question))
7636 $max_points += $question->getMaximumPoints();
7637 $reached_points += $question->getReachedPoints($active_id);
7640 if ($max_points > 0)
7642 $percentvalue = $reached_points / $max_points;
7643 if ($percentvalue < 0) $percentvalue = 0.0;
7649 $mark_obj = $this->mark_schema->getMatchingMark($percentvalue * 100);
7653 $mark = $mark_obj->getOfficialName();
7654 $ects_mark = $this->
getECTSGrade($passed_array, $reached_points, $max_points);
7658 $user_rec[
'firstname'] =
"";
7659 $user_rec[
'lastname'] = $this->lng->txt(
"unknown");
7662 "user_id"=>$user_rec[
'usr_id'],
7663 "matriculation" => $user_rec[
'matriculation'],
7664 "lastname" => $user_rec[
'lastname'],
7665 "firstname" => $user_rec[
'firstname'],
7666 "login"=>$user_rec[
'login'],
7667 "reached_points" => $reached_points,
7668 "max_points" => $max_points,
7669 "percent_value" => $percentvalue,
7671 "ects" => $ects_mark
7691 $resultarray = array();
7692 foreach (
$row as $rowindex => $entry)
7699 if (strpos($entry,
"\"") !== FALSE)
7701 $entry = str_replace(
"\"",
"\"\"", $entry);
7709 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
7712 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
7716 $resultarray[$rowindex] = utf8_decode($entry);
7719 return $resultarray;
7733 $result = $ilDB->queryF(
"SELECT tries FROM tst_active WHERE active_id = %s",
7740 return $row[
"tries"];
7760 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s",
7767 $max =
$row[
"maxpass"];
7790 $result = $ilDB->queryF(
"SELECT * FROM tst_pass_result WHERE active_fi = %s",
7800 if(
$row[
"maxpoints"] > 0)
7802 $factor =
$row[
"points"] /
$row[
"maxpoints"];
7809 if($factor > $bestfactor)
7812 $bestfactor = $factor;
7815 if (is_array($bestrow))
7817 return $bestrow[
"pass"];
7840 $counted_pass = NULL;
7849 return $counted_pass;
7867 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
7869 foreach ($this->questions as $value)
7873 $workedthrough += 1;
7876 return $workedthrough;
7892 $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",
7893 array(
'integer',
'integer'),
7894 array($active_id,
$pass)
7899 return $row[
"tstamp"];
7917 "executable" =>
true,
7918 "errormessage" =>
""
7922 $result[
"executable"] =
false;
7928 $result[
"executable"] =
false;
7957 $result[
"executable"] =
false;
7958 $result[
"errormessage"] = $this->lng->txt(
"detail_max_processing_time_reached");
7968 $result[
"executable"] =
false;
7969 $result[
"errormessage"] = $this->lng->txt(
"maximum_nr_of_tries_reached");
7988 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getReportingDate(), $matches))
7990 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
7992 if ($now < $epoch_time)
8008 $notimeleft = FALSE;
8033 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getReportingDate(), $matches))
8035 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
8037 if ($now < $epoch_time)
8062 if ($active_id < 1)
return FALSE;
8064 $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",
8065 array(
'integer',
'integer'),
8066 array($active_id,
$pass)
8071 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches))
8073 return mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
8121 questtypes.type_tag,
8123 origquest.obj_fi orig_obj_fi
8125 FROM qpl_questions questions
8127 INNER JOIN qpl_qst_type questtypes
8128 ON questtypes.question_type_id = questions.question_type_fi
8130 INNER JOIN tst_test_question tstquest
8131 ON tstquest.question_fi = questions.question_id
8133 LEFT JOIN qpl_questions origquest
8134 ON origquest.question_id = questions.original_id
8136 WHERE tstquest.test_fi = %s
8138 ORDER BY tstquest.sequence
8141 $query_result = $ilDB->queryF(
8144 $removableQuestions = array();
8145 while (
$row = $ilDB->fetchAssoc($query_result))
8147 array_push($removableQuestions,
$row);
8149 return $removableQuestions;
8160 return ($this->shuffle_questions) ? 1 : 0;
8171 $this->shuffle_questions = ($a_shuffle) ? 1 : 0;
8188 return ($this->show_summary) ? $this->show_summary : 0;
8205 $this->show_summary = $a_value;
8216 if (($this->show_summary & 1) > 0)
8236 $this->show_summary = 1;
8240 $this->show_summary = 0;
8252 if (($this->show_summary & 2) > 0)
8272 $this->show_summary = $this->show_summary | 2;
8278 $this->show_summary = $this->show_summary ^ 2;
8291 if (($this->show_summary & 4) > 0)
8311 $this->show_summary = $this->show_summary | 4;
8317 $this->show_summary = $this->show_summary ^ 4;
8330 if (($this->show_summary & 8) > 0)
8350 $this->show_summary = $this->show_summary | 8;
8356 $this->show_summary = $this->show_summary ^ 8;
8369 return ($this->results_presentation) ? $this->results_presentation : 0;
8380 if (($this->results_presentation & 1) > 0)
8398 if (($this->results_presentation & 2) > 0)
8416 if (($this->results_presentation & 4) > 0)
8434 if (($this->results_presentation & 8) > 0)
8452 if (($this->results_presentation & 16) > 0)
8470 if (($this->results_presentation & 32) > 0)
8486 if (($this->results_presentation & 64) > 0)
8504 $this->results_presentation = $a_results_presentation;
8519 $this->results_presentation = $this->results_presentation | 1;
8525 $this->results_presentation = $this->results_presentation ^ 1;
8540 $this->results_presentation = $this->results_presentation | 2;
8546 $this->results_presentation = $this->results_presentation ^ 2;
8572 $this->results_presentation = $this->results_presentation | 4;
8578 $this->results_presentation = $this->results_presentation ^ 4;
8593 $this->results_presentation = $this->results_presentation | 8;
8599 $this->results_presentation = $this->results_presentation ^ 8;
8614 $this->results_presentation = $this->results_presentation | 16;
8620 $this->results_presentation = $this->results_presentation ^ 16;
8635 $this->results_presentation = $this->results_presentation | 32;
8641 $this->results_presentation = $this->results_presentation ^ 32;
8656 $this->results_presentation = $this->results_presentation | 64;
8662 $this->results_presentation = $this->results_presentation ^ 64;
8675 $codestring =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
8678 for ($i = 1; $i <=5; $i++)
8680 $index = mt_rand(0, strlen($codestring)-1);
8681 $code .= substr($codestring, $index, 1);
8695 $result = $ilDB->queryF(
"SELECT anonymous_id FROM tst_active WHERE test_fi = %s AND anonymous_id = %s",
8696 array(
'integer',
'text'),
8699 return (
$result->numRows() > 0) ?
true :
false;
8705 $result = $ilDB->queryF(
"SELECT user_fi FROM tst_active WHERE active_id = %s",
8712 return $row[
"user_fi"];
8723 if (!is_array(
$_SESSION[
"tst_access_code"]))
8729 return $_SESSION[
"tst_access_code"][
"$id"];
8736 if (!is_array(
$_SESSION[
"tst_access_code"]))
8740 $_SESSION[
"tst_access_code"][
"$id"] = $access_code;
8746 unset(
$_SESSION[
"tst_access_code"][
"$id"]);
8751 return ($this->allowedUsers) ? $this->allowedUsers : 0;
8756 $this->allowedUsers = $a_allowed_users;
8761 return ($this->allowedUsersTimeGap) ? $this->allowedUsersTimeGap : 0;
8766 $this->allowedUsersTimeGap = $a_allowed_users_time_gap;
8775 if (($nr_of_users > 0) && ($time_gap > 0))
8778 $time_border = $now - $time_gap;
8779 $str_time_border = strftime(
"%Y%m%d%H%M%S", $time_border);
8780 $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",
8781 array(
'integer',
'integer'),
8784 if (
$result->numRows() >= $nr_of_users)
8786 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
8805 $result = $ilDB->queryF(
"SELECT finished FROM tst_times WHERE active_fi = %s ORDER BY finished DESC",
8812 return $row[
"finished"];
8826 if (preg_match(
"/<[^>]*?>/", $a_text))
8846 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
8848 $material = $a_material->getMaterial($i);
8849 if (strcmp($material[
"type"],
"mattext") == 0)
8851 $result .= $material[
"material"]->getContent();
8853 if (strcmp($material[
"type"],
"matimage") == 0)
8855 $matimage = $material[
"material"];
8856 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
8859 if (!is_array(
$_SESSION[
"import_mob_xhtml"]))
$_SESSION[
"import_mob_xhtml"] = array();
8860 array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(),
"uri" => $matimage->getUri()));
8865 $ilLog->write(print_r(
$_SESSION[
"import_mob_xhtml"],
true));
8879 include_once
"./Services/RTE/classes/class.ilRTE.php";
8880 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
8882 $a_xml_writer->xmlStartTag(
"material");
8884 "texttype" =>
"text/plain"
8886 if ($this->
isHTML($a_material))
8888 $attrs[
"texttype"] =
"text/xhtml";
8893 foreach (
$mobs as $mob)
8895 $moblabel =
"il_" . IL_INST_ID .
"_mob_" . $mob;
8896 if (strpos($a_material,
"mm_$mob") !== FALSE)
8902 "label" => $moblabel,
8903 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
8906 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
8909 $a_xml_writer->xmlEndTag(
"material");
8920 include_once
"./Services/Utilities/classes/class.ilUtil.php";
8934 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET certificate_visibility = %s, tstamp = %s WHERE test_id = %s",
8935 array(
'text',
'integer',
'integer'),
8936 array($a_value, time(), $this->
getTestId())
8948 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
8959 $this->certificate_visibility = $a_value;
8970 return ($this->anonymity) ? 1 : 0;
8984 $this->anonymity = 1;
8987 $this->anonymity = 0;
9000 return ($this->show_cancel) ? 1 : 0;
9014 $this->show_cancel = 1;
9017 $this->show_cancel = 0;
9030 return ($this->show_marker) ? 1 : 0;
9044 $this->show_marker = 1;
9047 $this->show_marker = 0;
9060 return ($this->fixed_participants) ? 1 : 0;
9074 $this->fixed_participants = 1;
9077 $this->fixed_participants = 0;
9093 $result = $ilDB->queryF(
"SELECT anonymity FROM tst_tests WHERE obj_fi = %s",
9099 return $row[
'anonymity'];
9115 $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",
9121 return $row[
'random_test'];
9138 return $this->lng->txt(
"unknown") . $suffix;
9142 include_once
'./Services/User/classes/class.ilObjUser.php';
9144 if (strlen($uname[
"firstname"].$uname[
"lastname"]) == 0) $uname[
"firstname"] = $this->lng->txt(
"deleted_user");
9147 return trim($uname[
"lastname"] .
", " . $uname[
"firstname"]) . $suffix;
9151 return trim($uname[
"firstname"] .
" " . $uname[
"lastname"]) . $suffix;
9167 return $this->lng->txt(
"tst_start_test");
9169 $active_pass = $this->
_getPass($active_id);
9173 if ($active_pass == 0)
9175 return $this->lng->txt(
"tst_start_test");
9179 return $this->lng->txt(
"tst_start_new_test_pass");
9184 return $this->lng->txt(
"tst_resume_test");
9201 $result = $ilDB->queryF(
"SELECT * FROM tst_test_defaults WHERE user_fi = %s ORDER BY $sortby $sortorder",
9203 array($ilUser->getId())
9205 $defaults = array();
9208 $defaults[
$row[
"test_defaults_id"]] =
$row;
9224 $result = $ilDB->queryF(
"SELECT * FROM tst_test_defaults WHERE test_defaults_id = %s",
9226 array($test_defaults_id)
9248 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_defaults WHERE test_defaults_id = %s",
9250 array($test_default_id)
9264 $testsettings = array(
9304 $next_id = $ilDB->nextId(
'tst_test_defaults');
9305 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_defaults (test_defaults_id, name, user_fi, defaults, marks, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
9306 array(
'integer',
'text',
'integer',
'text',
'text',
'integer'),
9307 array($next_id, $a_name, $ilUser->getId(), serialize($testsettings), serialize($this->mark_schema), time())
9326 $testsettings = unserialize($defaults[
"defaults"]);
9327 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
9328 $this->mark_schema = unserialize($defaults[
"marks"]);
9354 $this->
setKiosk($testsettings[
"Kiosk"]);
9357 $this->
setECTSFX($testsettings[
"ECTSFX"]);
9382 if (extension_loaded(
"tidy"))
9386 "output-xml" =>
true,
9387 "numeric-entities" =>
true
9391 $tidy->cleanRepair();
9392 $print_output = tidy_get_output(
$tidy);
9393 $print_output = preg_replace(
"/^.*?(<html)/",
"\\1", $print_output);
9397 $print_output = str_replace(
" ",
" ", $print_output);
9398 $print_output = str_replace(
"⊗",
"X", $print_output);
9400 $xsl = file_get_contents(
"./Modules/Test/xml/question2fo.xsl");
9401 $args = array(
'/_xml' => $print_output,
'/_xsl' => $xsl );
9404 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, $params);
9418 $content = preg_replace(
"/href=\".*?\"/",
"", $content);
9419 $printbody =
new ilTemplate(
"tpl.il_as_tst_print_body.html", TRUE, TRUE,
"Modules/Test");
9421 $printbody->setVariable(
"ADM_CONTENT", $content);
9422 $printbody->setCurrentBlock(
"css_file");
9424 $printbody->parseCurrentBlock();
9425 $printbody->setCurrentBlock(
"css_file");
9427 $printbody->parseCurrentBlock();
9428 $printoutput = $printbody->get();
9429 $html = str_replace(
"href=\"./",
"href=\"" . ILIAS_HTTP_PATH .
"/", $printoutput);
9430 $html = preg_replace(
"/<div id=\"dontprint\">.*?<\\/div>/ims",
"", $html);
9431 if (extension_loaded(
"tidy"))
9435 "output-xml" =>
true,
9436 "numeric-entities" =>
true
9440 $tidy->cleanRepair();
9441 $html = tidy_get_output(
$tidy);
9442 $html = preg_replace(
"/^.*?(<html)/",
"\\1", $html);
9446 $html = str_replace(
" ",
" ", $html);
9447 $html = str_replace(
"⊗",
"X", $html);
9449 $html = preg_replace(
"/src=\".\\//ims",
"src=\"" . ILIAS_HTTP_PATH .
"/", $html);
9463 include_once
"./Services/Utilities/classes/class.ilUtil.php";
9465 $fp = fopen($fo_file,
"w"); fwrite($fp, $fo); fclose($fp);
9467 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
9477 $ilLog->write(__METHOD__.
': '.$e->getMessage());
9482 $ilLog->write(__METHOD__.
': '.$e->getMessage());
9509 $result = $ilDB->queryF(
"SELECT feedback FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s",
9510 array(
'integer',
'integer',
'integer'),
9511 array($active_id, $question_id,
$pass)
9516 include_once(
"./Services/RTE/classes/class.ilRTE.php");
9532 function saveManualFeedback($active_id, $question_id,
$pass, $feedback)
9536 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s",
9537 array(
'integer',
'integer',
'integer'),
9538 array($active_id, $question_id,
$pass)
9541 if (strlen($feedback))
9543 $next_id = $ilDB->nextId(
'tst_manual_fb');
9545 $result = $ilDB->insert(
'tst_manual_fb', array(
9546 'manual_feedback_id' => array(
'integer', $next_id ),
9547 'active_fi' => array(
'integer', $active_id ),
9548 'question_fi' => array(
'integer', $question_id ),
9549 'pass' => array(
'integer',
$pass),
9551 'tstamp' => array(
'integer', time() ),
9555 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
9558 global
$lng, $ilUser;
9559 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
9561 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
9568 $ilias->raiseError(
$result->getMessage());
9586 if (strcmp(
$_GET[
"tst_javascript"],
"0") == 0)
return FALSE;
9588 $assessmentSetting =
new ilSetting(
"assessment");
9589 return ($ilUser->getPref(
"tst_javascript") === FALSE) ? $assessmentSetting->get(
"use_javascript") : $ilUser->getPref(
"tst_javascript");
9602 include_once
"./Modules/Test/classes/class.ilTestSession.php";
9621 $this->test_id = $a_id;
9633 if (is_object($this->testSession) && ($this->testSession->getActiveId() > 0))
return $this->testSession;
9637 include_once
"./Modules/Test/classes/class.ilTestSession.php";
9662 if (is_object($this->testSession) && ($this->testSession->getActiveId() > 0))
return $this->testSession;
9668 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
9670 if (!$this->testSequence->hasSequence())
9672 $this->testSequence->createNewSequence($this->
getQuestionCount(), $shuffle);
9673 $this->testSequence->saveToDb();
9679 if (is_object($this->testSequence) && ($this->testSequence->getActiveId() > 0))
return $this->testSequence;
9681 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
9682 if (($active_id > 0) && (strlen(
$pass)))
9698 foreach (
$result as $sequence => $question)
9700 if (is_numeric($sequence))
9702 if ($question[
"reached"] == $question[
"max"])
9723 if (count($participants))
9725 foreach ($participants as $active_id => $user_rec)
9728 $reached_points = 0;
9730 foreach ($this->questions as $value)
9733 if (is_object($question))
9735 $max_points += $question->getMaximumPoints();
9736 $reached_points += $question->getReachedPoints($active_id);
9737 if ($max_points > 0)
9739 $percentvalue = $reached_points / $max_points;
9740 if ($percentvalue < 0) $percentvalue = 0.0;
9748 $user_rec[
'firstname'] =
"";
9749 $user_rec[
'lastname'] = $this->lng->txt(
"unknown");
9752 "user_id"=>$user_rec[
'usr_id'],
9753 "matriculation" => $user_rec[
'matriculation'],
9754 "lastname" => $user_rec[
'lastname'],
9755 "firstname" => $user_rec[
'firstname'],
9756 "login"=>$user_rec[
'login'],
9757 "question_id" => $question->getId(),
9758 "question_title" => $question->getTitle(),
9759 "reached_points" => $reached_points,
9760 "max_points" => $max_points
9777 $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",
9781 $rec = $ilDB->fetchAssoc(
$result);
9782 return $rec[
"obj_id"];
9793 global $ilPluginAdmin;
9794 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE,
"TestQuestionPool",
"qst", $a_pname))
9808 $result = $ilDB->queryF(
"SELECT passed FROM tst_result_cache WHERE active_fi = %s",
9815 return $row[
'passed'];
9820 $result_array =& $this->
getTestResult($active_id, $counted_pass);
9821 return $result_array[
"test"][
"passed"];
9834 include_once
"./Services/Certificate/classes/class.ilCertificate.php";
9835 include_once
"./Modules/Test/classes/class.ilTestCertificateAdapter.php";
9837 if ($cert->isComplete())
9884 $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.question_id = %s",
9885 array(
'integer',
'integer'),
9888 $foundusers = array();
9891 if (!array_key_exists(
$row[
"active_fi"], $foundusers))
9893 $foundusers[
$row[
"active_fi"]] = array();
9895 array_push($foundusers[
$row[
"active_fi"]], array(
"pass" => $row[
"pass"],
"qid" => $row[
"question_fi"]));
9909 include_once
'./Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
9928 $foundParticipants =&
$data->getParticipants();
9929 $results = array(
"overview" => array(),
"questions" => array());
9930 if (count($foundParticipants))
9932 $results[
"overview"][$this->lng->txt(
"tst_eval_total_persons")] = count($foundParticipants);
9934 $results[
"overview"][$this->lng->txt(
"tst_eval_total_finished")] = $total_finished;
9936 $diff_seconds = $average_time;
9937 $diff_hours = floor($diff_seconds/3600);
9938 $diff_seconds -= $diff_hours * 3600;
9939 $diff_minutes = floor($diff_seconds/60);
9940 $diff_seconds -= $diff_minutes * 60;
9941 $results[
"overview"][$this->lng->txt(
"tst_eval_total_finished_average_time")] = sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
9943 $total_passed_reached = 0;
9944 $total_passed_max = 0;
9945 $total_passed_time = 0;
9946 foreach ($foundParticipants as $userdata)
9948 if ($userdata->getPassed())
9951 $total_passed_reached += $userdata->getReached();
9952 $total_passed_max += $userdata->getMaxpoints();
9953 $total_passed_time += $userdata->getTimeOfWork();
9956 $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
9957 $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
9958 $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
9959 $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed")] = $total_passed;
9960 $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);
9961 $average_time = $average_passed_time;
9962 $diff_seconds = $average_time;
9963 $diff_hours = floor($diff_seconds/3600);
9964 $diff_seconds -= $diff_hours * 3600;
9965 $diff_minutes = floor($diff_seconds/60);
9966 $diff_seconds -= $diff_minutes * 60;
9967 $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed_average_time")] = sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
9970 foreach (
$data->getQuestionTitles() as $question_id => $question_title)
9975 foreach ($foundParticipants as $userdata)
9977 for ($i = 0; $i <= $userdata->getLastPass(); $i++)
9979 if (is_object($userdata->getPass($i)))
9981 $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
9982 if (is_array($question))
9985 $reached += $question[
"reached"];
9986 $max += $question[
"points"];
9991 $percent = $max ? $reached/$max * 100.0 : 0;
9993 $results[
"questions"][$question_id] = array(
9995 sprintf(
"%.2f", $answered ? $reached / $answered : 0) .
" " . strtolower($this->lng->txt(
"of")) .
" " . sprintf(
"%.2f", $answered ? $max / $answered : 0),
9996 sprintf(
"%.2f", $percent) .
"%",
9998 sprintf(
"%.2f", $answered ? $reached / $answered : 0),
9999 sprintf(
"%.2f", $answered ? $max / $answered : 0),
10011 include_once(
"./Modules/Test/classes/class.ilTestExport.php");
10013 return $test_exp->buildExportFile();
10031 $this->mailnotification = $a_notification;
10036 include_once
"./Services/Mail/classes/class.ilMail.php";
10037 $mail =
new ilMail(ANONYMOUS_USER_ID);
10040 $message =
new ilTemplate(
"tpl.il_as_tst_finish_notification_simple.html", TRUE, TRUE,
"Modules/Test");
10041 $message->setVariable(
'TEXT_TEST_TITLE', $this->lng->txt(
'title'));
10042 $message->setVariable(
'VALUE_TEST_TITLE', $this->
getTitle());
10043 $message->setVariable(
'TEXT_USER_NAME', $this->lng->txt(
'username'));
10044 $message->setVariable(
'VALUE_USER_NAME', $usr_data);
10045 $message->setVariable(
'TEXT_FINISH_TIME', $this->lng->txt(
'tst_finished'));
10049 $res = $mail->sendMail(
10053 sprintf($this->lng->txt(
'tst_user_finished_test'), $this->
getTitle()),
10058 global
$ilLog; $ilLog->write(
"sending mail: " .
$res);
10068 include_once
"./Modules/Test/classes/class.ilObjTestGUI.php";
10069 include_once
"./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
10071 return $table_gui->getSelectedColumns();
10076 include_once
"./Services/Mail/classes/class.ilMail.php";
10077 $mail =
new ilMail(ANONYMOUS_USER_ID);
10080 $message =
new ilTemplate(
"tpl.il_as_tst_finish_notification_simple.html", TRUE, TRUE,
"Modules/Test");
10081 $message->setVariable(
'TEXT_TEST_TITLE', $this->lng->txt(
'title'));
10082 $message->setVariable(
'VALUE_TEST_TITLE', $this->
getTitle());
10083 $message->setVariable(
'TEXT_USER_NAME', $this->lng->txt(
'username'));
10084 $message->setVariable(
'VALUE_USER_NAME', $usr_data);
10085 $message->setVariable(
'TEXT_FINISH_TIME', $this->lng->txt(
'tst_finished'));
10089 include_once
"./Modules/Test/classes/class.ilTestExport.php";
10091 $file = $exportObj->exportToExcel($deliver = FALSE,
'active_id', $active_id, $passedonly = FALSE);
10092 include_once
"./classes/class.ilFileDataMail.php";
10094 $fd->copyAttachmentFile(
$file,
"result_" . $active_id .
".xls");
10095 $file_names[] =
"result_" . $active_id .
".xls";
10100 sprintf($this->lng->txt(
'tst_user_finished_test'), $this->
getTitle()),
10102 count($file_names) ? $file_names : array(),
10105 if(count($file_names))
10107 $fd->unlinkFiles($file_names);
10118 $query =
"SELECT usr_id FROM usr_data";
10122 $activequery = sprintf(
"SELECT user_fi FROM tst_active WHERE test_fi = %s AND user_fi = %s",
10123 $ilDB->quote($this->getTestId()),
10124 $ilDB->quote(
$data[
'usr_id'])
10126 $activeresult = $ilDB->query($activequery);
10127 if ($activeresult->numRows() == 0)
10129 $user_id =
$data[
'usr_id'];
10130 if ($user_id != 13)
10132 include_once
"./Modules/Test/classes/class.ilTestSession.php";
10140 $nr_of_passes = rand(1, $passes);
10144 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
10151 for ($seq = 1; $seq <= count($this->questions); $seq++)
10153 $question_id =
$testSequence->getQuestionForSequence($seq);
10157 if (
$pass < $nr_of_passes - 1)
10169 if ($number == 0)
return;
10179 $result = $ilDB->queryF(
"SELECT * FROM tst_result_cache WHERE active_fi = %s",
10185 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
10187 $result = $ilDB->queryF(
"SELECT * FROM tst_result_cache WHERE active_fi = %s",
10199 if ($this->mailnottype == 1)
10213 $this->mailnottype = 1;
10217 $this->mailnottype = 0;
10223 if ($this->exportsettings)
10237 $this->exportsettings = $a_settings;
10241 $this->exportsettings = 0;
10247 if (($this->exportsettings & 1) > 0)
10261 $this->exportsettings = $this->exportsettings | 1;
10267 $this->exportsettings = $this->exportsettings ^ 1;
10273 return $this->enabled_view_mode;
10277 $this->enabled_view_mode = $mode;
10289 $new_array = array();
10292 $query =
'SELECT question_fi FROM tst_test_question WHERE test_fi = %s';
10293 $types = array(
'integer');
10296 $new_question_id += 1;
10300 $res = $ilDB->queryF(
$query, $types, $values);
10301 while(
$row = $ilDB->fetchAssoc(
$res)) {
10303 $qid =
$row[
'question_fi'];
10305 if ($qid == $new_question_id) {
10308 else if ($qid == $previous_question_id) {
10309 $new_array[$position++] = $qid;
10310 $new_array[$position++] = $new_question_id;
10314 $new_array[$position++] = $qid;
10318 $update_query =
'UPDATE tst_test_question SET sequence = %s WHERE test_fi = %s AND question_fi = %s';
10319 $update_types = array(
'integer',
'integer',
'integer');
10321 foreach($new_array as $position => $qid) {
10322 $ilDB->manipulateF(
10335 $this->
setAnswerFeedback((is_array($options) && in_array(
'instant_feedback_answer', $options)) ? 1 : 0);
10336 $this->
setAnswerFeedbackPoints((is_array($options) && in_array(
'instant_feedback_points', $options)) ? 1 : 0);
10342 'pass_details' =>
'setShowPassDetails',
10343 'solution_details' =>
'setShowSolutionDetails',
10344 'solution_printview' =>
'setShowSolutionPrintview',
10345 'solution_feedback' =>
'setShowSolutionFeedback',
10346 'solution_answers_only' =>
'setShowSolutionAnswersOnly',
10347 'solution_signature' =>
'setShowSolutionSignature',
10348 'solution_suggested' =>
'setShowSolutionSuggested',
10350 foreach($setter as $key => $setter) {
10351 if (in_array($key, $options)) {
10365 $this->poolUsage = (boolean)$usage;
10369 $positions = asort($order);
10375 foreach($order as $key => $position) {
10376 $id = substr($key, strpos($key,
'_') + 1);
10377 $ilDB->manipulateF(
10378 'UPDATE tst_test_question SET sequence = %s WHERE question_fi=%s',
10379 array(
'integer',
'integer'),
10390 if ($question_before) {
10391 $query =
'SELECT sequence, test_fi FROM tst_test_question WHERE question_fi = %s';
10392 $types = array(
'integer');
10393 $values = array($question_before);
10394 $rset = $ilDB->queryF(
$query, $types, $values);
10397 if (!$question_before || ($rset && !(
$row = $ilDB->fetchAssoc($rset)))) {
10404 $update =
'UPDATE tst_test_question SET sequence = sequence + 1 WHERE sequence > %s AND test_fi = %s';
10405 $types = array(
'integer',
'integer');
10406 $values = array(
$row[
'sequence'],
$row[
'test_fi']);
10407 $ilDB->manipulateF($update, $types, $values);
10409 $update =
'UPDATE tst_test_question SET sequence = %s WHERE question_fi = %s';
10410 $types = array(
'integer',
'integer');
10411 $values = array(
$row[
'sequence'] + 1, $question_to_move);
10412 $ilDB->manipulateF($update, $types, $values);
10419 $query =
'SELECT count(question_id) cnt FROM qpl_questions'.
10420 ' INNER JOIN object_data on obj_fi = obj_id'.
10421 ' WHERE type <> '.$ilDB->quote(
'qpl',
'text').
10422 ' AND '.$ilDB->in(
'question_id', array_keys(
$questions),
false,
'integer');
10424 $rset = $ilDB->query(
$query);
10426 if (
$row = $ilDB->fetchAssoc($rset)) {
10427 return $row[
'cnt'] > 0;
10442 $result = $ilDB->queryF(
"SELECT test_fi,MAX(pass) AS pass FROM tst_active".
10443 " JOIN tst_pass_result ON (tst_pass_result.active_fi = tst_active.active_id)".
10444 " WHERE user_fi=%s".
10445 " GROUP BY test_fi",
10446 array(
'integer',
'integer'),
10447 array($a_user_id, 1)
10453 $all[$obj_id] = (bool)
$row[
"pass"];
10469 $this->online = (bool)$a_online;