24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
25 include_once
"Services/Utilities/classes/class.ilFormat.php";
54 $this->test_obj =& $a_test_obj;
59 $this->mode = $a_mode;
62 $settings = $this->ilias->getAllSettings();
63 $this->inst_id = IL_INST_ID;
66 $this->export_dir = $this->test_obj->getExportDirectory();
70 $this->subdir = $date.
"__".$this->inst_id.
"__".
71 "tst__results_".$this->test_obj->getId();
74 $this->subdir = $date.
"__".$this->inst_id.
"__".
75 "test__aggregated__results_".$this->test_obj->getId();
78 $this->subdir = $date.
"__".$this->inst_id.
"__".
79 "tst".
"_".$this->test_obj->getId();
80 $this->filename = $this->subdir.
".xml";
81 $this->resultsfile = $date.
"__".$this->inst_id.
"__".
82 "results".
"_".$this->test_obj->getId().
".xml";
83 $this->qti_filename = $date.
"__".$this->inst_id.
"__".
84 "qti".
"_".$this->test_obj->getId().
".xml";
87 $this->filename = $this->subdir.
".".$this->
getExtension();
91 switch ($this->mode) {
133 $expDir = $this->test_obj->getExportDirectory();
136 $this->test_obj->createExportDirectory();
137 include_once
"./Services/Utilities/classes/class.ilUtil.php";
140 $expLog =
new ilLog($expDir,
"export.log");
142 $expLog->setLogFormat(
"");
143 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Of Results");
146 $file = fopen($this->export_dir.
"/".$this->filename,
"w");
151 @copy($excelfile, $this->export_dir .
"/" . str_replace($this->
getExtension(),
"xls", $this->filename));
154 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export of Results");
166 $data = $this->test_obj->getAggregatedResultsData();
167 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
170 $testname =
ilUtil::getASCIIFilename(preg_replace(
"/\s/",
"_", $this->test_obj->getTitle() .
'_aggregated')) .
".xls";
171 $workbook = $adapter->getWorkbook();
172 $workbook->setVersion(8);
174 $format_percent =& $workbook->addFormat();
175 $format_percent->setNumFormat(
"0.00%");
176 $format_title =& $workbook->addFormat();
177 $format_title->setBold();
178 $format_title->setColor(
'black');
179 $format_title->setPattern(1);
180 $format_title->setFgColor(
'silver');
181 include_once
"./Services/Excel/classes/class.ilExcelUtils.php";
188 foreach (
$data[
"overview"] as $key => $value)
203 foreach (
$data[
"questions"] as $key => $value)
232 $data = $this->test_obj->getAggregatedResultsData();
234 array_push($rows, array(
235 $this->lng->txt(
"result"),
236 $this->lng->txt(
"value")
238 foreach (
$data[
"overview"] as $key => $value)
240 array_push($rows, array(
245 array_push($rows, array(
246 $this->lng->txt(
"question_title"),
247 $this->lng->txt(
"average_reached_points"),
248 $this->lng->txt(
"points"),
249 $this->lng->txt(
"percentage"),
250 $this->lng->txt(
"number_of_answers")
252 foreach (
$data[
"questions"] as $key => $value)
254 array_push($rows, array(
264 foreach ($rows as $evalrow)
266 $csvrow =& $this->test_obj->processCSVRow($evalrow, TRUE,
$separator);
287 function exportToExcel($deliver = TRUE, $filterby =
"", $filtertext =
"", $passedonly = FALSE)
293 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
296 $testname = $this->test_obj->getTitle();
300 $testname .=
'_results';
304 $workbook = $adapter->getWorkbook();
305 $workbook->setVersion(8);
307 $format_bold =& $workbook->addFormat();
308 $format_bold->setBold();
309 $format_percent =& $workbook->addFormat();
310 $format_percent->setNumFormat(
"0.00%");
311 $format_datetime =& $workbook->addFormat();
312 $format_datetime->setNumFormat(
"DD/MM/YYYY hh:mm:ss");
313 $format_title =& $workbook->addFormat();
314 $format_title->setBold();
315 $format_title->setColor(
'black');
316 $format_title->setPattern(1);
317 $format_title->setFgColor(
'silver');
318 include_once
"./Services/Excel/classes/class.ilExcelUtils.php";
320 $additionalFields = $this->test_obj->getEvaluationAdditionalFields();
324 if ($this->test_obj->getAnonymity())
333 if (count($additionalFields))
335 foreach ($additionalFields as $fieldname)
343 if ($this->test_obj->ects_output)
364 include_once
"./Services/Excel/classes/class.ilExcelUtils.php";
366 $data =& $this->test_obj->getCompleteEvaluationData(TRUE, $filterby, $filtertext);
367 $firstrowwritten =
false;
368 foreach (
$data->getParticipants() as $active_id => $userdata)
373 if (
$data->getParticipant($active_id)->getPassed() == FALSE)
381 if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions())
386 if ($this->test_obj->getAnonymity())
395 if (count($additionalFields))
398 foreach ($additionalFields as $fieldname)
400 if (strcmp($fieldname,
"gender") == 0)
413 if ($this->test_obj->ects_output)
419 $worksheet->write(
$row, $col++,
$data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() / 100.0, $format_percent);
420 $time =
$data->getParticipant($active_id)->getTimeOfWork();
421 $time_seconds = $time;
422 $time_hours = floor($time_seconds/3600);
423 $time_seconds -= $time_hours * 3600;
424 $time_minutes = floor($time_seconds/60);
425 $time_seconds -= $time_minutes * 60;
427 $time =
$data->getParticipant($active_id)->getQuestionsWorkedThrough() ?
$data->getParticipant($active_id)->getTimeOfWork() /
$data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
428 $time_seconds = $time;
429 $time_hours = floor($time_seconds/3600);
430 $time_seconds -= $time_hours * 3600;
431 $time_minutes = floor($time_seconds/60);
432 $time_seconds -= $time_minutes * 60;
434 $fv = getdate(
$data->getParticipant($active_id)->getFirstVisit());
443 $worksheet->write(
$row, $col++, $firstvisit, $format_datetime);
444 $lv = getdate(
$data->getParticipant($active_id)->getLastVisit());
453 $worksheet->write(
$row, $col++, $lastvisit, $format_datetime);
455 $median =
$data->getStatistics()->getStatistics()->median();
456 $pct =
$data->getParticipant($active_id)->getMaxpoints() ? $median /
$data->getParticipant($active_id)->getMaxpoints() * 100.0 : 0;
457 $mark = $this->test_obj->mark_schema->getMatchingMark($pct);
458 $mark_short_name =
"";
459 if (is_object($mark))
461 $mark_short_name = $mark->getShortName();
470 $worksheet->write(
$row, $col++,
$data->getParticipant($active_id)->getBestPass() + 1);
474 $worksheet->write(
$row, $col++,
$data->getParticipant($active_id)->getLastPass() + 1);
480 $finishdate = $this->test_obj->getPassFinishDate($active_id,
$pass);
486 if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions())
492 if (is_object(
$data->getParticipant($active_id)) && is_array(
$data->getParticipant($active_id)->getQuestions(
$pass)))
494 foreach (
$data->getParticipant($active_id)->getQuestions(
$pass) as $question)
496 $question_data =
$data->getParticipant($active_id)->getPass(
$pass)->getAnsweredQuestionByQuestionId($question[
"id"]);
498 if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions())
504 if (
$pass == 0 && !$firstrowwritten)
511 $firstrowwritten =
true;
518 if ($this->test_obj->getExportSettingsSingleChoiceShort() && !$this->test_obj->isRandomTest() && $this->test_obj->hasSingleChoiceQuestions())
521 $titles =& $this->test_obj->getQuestionTitlesAndIndexes();
522 $positions = array();
525 foreach ($titles as $id =>
$title)
527 $positions[$id] = $pos;
530 $usernames = array();
531 $participantcount = count(
$data->getParticipants());
532 $allusersheet =
false;
534 $resultsheet =& $workbook->addWorksheet($this->lng->txt(
"eval_all_users"));
539 if (count($additionalFields))
541 foreach ($additionalFields as $fieldname)
543 if (strcmp($fieldname,
"matriculation") == 0)
550 foreach ($titles as
$title)
556 foreach (
$data->getParticipants() as $active_id => $userdata)
559 if (array_key_exists($username, $usernames))
561 $usernames[$username]++;
562 $username .=
" ($i)";
566 $usernames[$username] = 1;
569 $resultsheet->write(
$row, $col++, $username);
570 $resultsheet->write(
$row, $col++, $userdata->getLogin());
571 if (count($additionalFields))
574 foreach ($additionalFields as $fieldname)
576 if (strcmp($fieldname,
"matriculation") == 0)
578 if (strlen($userfields[$fieldname]))
590 $pass = $userdata->getScoredPass();
591 if (is_object($userdata) && is_array($userdata->getQuestions(
$pass)))
593 foreach ($userdata->getQuestions(
$pass) as $question)
595 $objQuestion =& $this->test_obj->_instanciateQuestion($question[
"aid"]);
596 if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(),
'assSingleChoice') == 0)
598 $solution = $objQuestion->getSolutionValues($active_id,
$pass);
599 $pos = $positions[$question[
"aid"]];
600 $selectedanswer =
"x";
601 foreach ($objQuestion->getAnswers() as $id => $answer)
603 if (strlen($solution[0][
"value1"]) && $id == $solution[0][
"value1"])
605 $selectedanswer = $answer->getAnswertext();
614 if ($this->test_obj->isSingleChoiceTestWithoutShuffle())
619 $usernames = array();
620 $allusersheet =
false;
622 $resultsheet =& $workbook->addWorksheet($this->lng->txt(
"eval_all_users") .
" (2)");
627 if (count($additionalFields))
629 foreach ($additionalFields as $fieldname)
631 if (strcmp($fieldname,
"matriculation") == 0)
638 foreach ($titles as $title)
644 foreach (
$data->getParticipants() as $active_id => $userdata)
647 if (array_key_exists($username, $usernames))
649 $usernames[$username]++;
650 $username .=
" ($i)";
654 $usernames[$username] = 1;
657 $resultsheet->write(
$row, $col++, $username);
658 $resultsheet->write(
$row, $col++, $userdata->getLogin());
659 if (count($additionalFields))
662 foreach ($additionalFields as $fieldname)
664 if (strcmp($fieldname,
"matriculation") == 0)
666 if (strlen($userfields[$fieldname]))
678 $pass = $userdata->getScoredPass();
679 if (is_object($userdata) && is_array($userdata->getQuestions(
$pass)))
681 foreach ($userdata->getQuestions(
$pass) as $question)
683 $objQuestion =& $this->test_obj->_instanciateQuestion($question[
"aid"]);
684 if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(),
'assSingleChoice') == 0)
686 $solution = $objQuestion->getSolutionValues($active_id,
$pass);
687 $pos = $positions[$question[
"aid"]];
688 $selectedanswer = chr(65+$solution[0][
"value1"]);
700 $usernames = array();
701 $participantcount = count(
$data->getParticipants());
702 $allusersheet =
false;
705 foreach (
$data->getParticipants() as $active_id => $userdata)
710 if (array_key_exists($username, $usernames))
712 $usernames[$username]++;
713 $username .=
" ($i)";
717 $usernames[$username] = 1;
719 if ($participantcount > 250) {
720 if (!$allusersheet || ($pages-1) < floor(
$row / 64000)) {
721 $resultsheet =& $workbook->addWorksheet($this->lng->txt(
"eval_all_users") . (($pages > 0) ?
" (".($pages+1).
")" :
""));
722 $allusersheet =
true;
727 $resultsheet =& $workbook->addWorksheet(utf8_decode($username));
729 if (method_exists($resultsheet,
"writeString"))
731 $pass = $userdata->getScoredPass();
735 if (is_object($userdata) && is_array($userdata->getQuestions(
$pass)))
737 foreach ($userdata->getQuestions(
$pass) as $question)
739 $question =& $this->test_obj->_instanciateQuestion($question[
"id"]);
740 if (is_object($question))
742 $row = $question->setExportDetailsXLS($resultsheet,
$row, $active_id,
$pass, $format_title, $format_bold);
770 function exportToCSV($deliver = TRUE, $filterby =
"", $filtertext =
"", $passedonly = FALSE)
779 if ($this->test_obj->getAnonymity())
781 array_push($datarow, $this->lng->txt(
"counter"));
786 array_push($datarow, $this->lng->txt(
"name"));
788 array_push($datarow, $this->lng->txt(
"login"));
791 $additionalFields = $this->test_obj->getEvaluationAdditionalFields();
792 if (count($additionalFields))
794 foreach ($additionalFields as $fieldname)
796 array_push($datarow, $this->lng->txt($fieldname));
800 array_push($datarow, $this->lng->txt(
"tst_stat_result_resultspoints"));
802 array_push($datarow, $this->lng->txt(
"maximum_points"));
804 array_push($datarow, $this->lng->txt(
"tst_stat_result_resultsmarks"));
806 if ($this->test_obj->ects_output)
808 array_push($datarow, $this->lng->txt(
"ects_grade"));
811 array_push($datarow, $this->lng->txt(
"tst_stat_result_qworkedthrough"));
813 array_push($datarow, $this->lng->txt(
"tst_stat_result_qmax"));
815 array_push($datarow, $this->lng->txt(
"tst_stat_result_pworkedthrough"));
817 array_push($datarow, $this->lng->txt(
"tst_stat_result_timeofwork"));
819 array_push($datarow, $this->lng->txt(
"tst_stat_result_atimeofwork"));
821 array_push($datarow, $this->lng->txt(
"tst_stat_result_firstvisit"));
823 array_push($datarow, $this->lng->txt(
"tst_stat_result_lastvisit"));
826 array_push($datarow, $this->lng->txt(
"tst_stat_result_mark_median"));
828 array_push($datarow, $this->lng->txt(
"tst_stat_result_rank_participant"));
830 array_push($datarow, $this->lng->txt(
"tst_stat_result_rank_median"));
832 array_push($datarow, $this->lng->txt(
"tst_stat_result_total_participants"));
834 array_push($datarow, $this->lng->txt(
"tst_stat_result_median"));
836 array_push($datarow, $this->lng->txt(
"scored_pass"));
839 array_push($datarow, $this->lng->txt(
"pass"));
842 $data =& $this->test_obj->getCompleteEvaluationData(TRUE, $filterby, $filtertext);
843 $headerrow = $datarow;
845 foreach (
$data->getParticipants() as $active_id => $userdata)
847 $datarow = $headerrow;
851 if (
$data->getParticipant($active_id)->getPassed() == FALSE)
859 if ($this->test_obj->getAnonymity())
861 array_push($datarow2, $counter);
865 array_push($datarow2,
$data->getParticipant($active_id)->getName());
866 array_push($datarow2,
$data->getParticipant($active_id)->getLogin());
868 if (count($additionalFields))
871 foreach ($additionalFields as $fieldname)
873 if (strcmp($fieldname,
"gender") == 0)
875 array_push($datarow2, $this->lng->txt(
"gender_" . $userfields[$fieldname]));
879 array_push($datarow2, $userfields[$fieldname]);
883 array_push($datarow2,
$data->getParticipant($active_id)->getReached());
884 array_push($datarow2,
$data->getParticipant($active_id)->getMaxpoints());
885 array_push($datarow2,
$data->getParticipant($active_id)->getMark());
886 if ($this->test_obj->ects_output)
888 array_push($datarow2,
$data->getParticipant($active_id)->getECTSMark());
890 array_push($datarow2,
$data->getParticipant($active_id)->getQuestionsWorkedThrough());
891 array_push($datarow2,
$data->getParticipant($active_id)->getNumberOfQuestions());
892 array_push($datarow2,
$data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() / 100.0);
893 $time =
$data->getParticipant($active_id)->getTimeOfWork();
894 $time_seconds = $time;
895 $time_hours = floor($time_seconds/3600);
896 $time_seconds -= $time_hours * 3600;
897 $time_minutes = floor($time_seconds/60);
898 $time_seconds -= $time_minutes * 60;
899 array_push($datarow2, sprintf(
"%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
900 $time =
$data->getParticipant($active_id)->getQuestionsWorkedThrough() ?
$data->getParticipant($active_id)->getTimeOfWork() /
$data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
901 $time_seconds = $time;
902 $time_hours = floor($time_seconds/3600);
903 $time_seconds -= $time_hours * 3600;
904 $time_minutes = floor($time_seconds/60);
905 $time_seconds -= $time_minutes * 60;
906 array_push($datarow2, sprintf(
"%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
908 $fv =
$data->getParticipant($active_id)->getFirstVisit();
909 $lv =
$data->getParticipant($active_id)->getLastVisit();
910 foreach(array($fv, $lv) as $ts)
915 array_push($datarow2, $visit);
919 array_push($datarow2,
"");
923 $median =
$data->getStatistics()->getStatistics()->median();
924 $pct =
$data->getParticipant($active_id)->getMaxpoints() ? $median /
$data->getParticipant($active_id)->getMaxpoints() * 100.0 : 0;
925 $mark = $this->test_obj->mark_schema->getMatchingMark($pct);
926 $mark_short_name =
"";
927 if (is_object($mark))
929 $mark_short_name = $mark->getShortName();
931 array_push($datarow2, $mark_short_name);
932 array_push($datarow2,
$data->getStatistics()->getStatistics()->rank(
$data->getParticipant($active_id)->getReached()));
933 array_push($datarow2,
$data->getStatistics()->getStatistics()->rank_median());
934 array_push($datarow2,
$data->getStatistics()->getStatistics()->count());
935 array_push($datarow2, $median);
938 array_push($datarow2,
$data->getParticipant($active_id)->getBestPass() + 1);
942 array_push($datarow2,
$data->getParticipant($active_id)->getLastPass() + 1);
946 $finishdate = $this->test_obj->getPassFinishDate($active_id,
$pass);
951 for ($i = 1; $i < $col-1; $i++)
953 array_push($datarow2,
"");
954 array_push($datarow,
"");
956 array_push($datarow,
"");
958 array_push($datarow2,
$pass+1);
959 if (is_object(
$data->getParticipant($active_id)) && is_array(
$data->getParticipant($active_id)->getQuestions(
$pass)))
961 foreach (
$data->getParticipant($active_id)->getQuestions(
$pass) as $question)
963 $question_data =
$data->getParticipant($active_id)->getPass(
$pass)->getAnsweredQuestionByQuestionId($question[
"id"]);
964 array_push($datarow2, $question_data[
"reached"]);
965 array_push($datarow, preg_replace(
"/<.*?>/",
"",
$data->getQuestionTitle($question[
"id"])));
968 if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions() || ($counter == 1 &&
$pass == 0))
970 array_push($rows, $datarow);
973 array_push($rows, $datarow2);
982 foreach ($rows as $evalrow)
984 $csvrow =& $this->test_obj->processCSVRow($evalrow, TRUE,
$separator);
1005 $ilBench->start(
"TestExport",
"buildExportFile");
1007 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
1011 $this->xml->
xmlSetDtdDef(
"<!DOCTYPE Test SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co.dtd\">");
1014 $this->xml->xmlSetGenCmt(
"Export of ILIAS Test ".
1015 $this->test_obj->getId().
" of installation ".$this->inst.
".");
1018 $this->xml->xmlHeader();
1021 $this->test_obj->createExportDirectory();
1022 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1027 $expDir = $this->test_obj->getExportDirectory();
1028 include_once
"./Services/Logging/classes/class.ilLog.php";
1029 $expLog =
new ilLog($expDir,
"export.log");
1031 $expLog->setLogFormat(
"");
1032 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export");
1035 $qti_file = fopen($this->export_dir.
"/".$this->subdir.
"/".$this->qti_filename,
"w");
1036 fwrite($qti_file, $this->test_obj->toXML());
1040 $ilBench->start(
"TestExport",
"buildExportFile_getXML");
1041 $this->test_obj->exportPagesXML($this->xml, $this->inst_id,
1042 $this->export_dir.
"/".$this->subdir, $expLog);
1043 $ilBench->stop(
"TestExport",
"buildExportFile_getXML");
1053 $ilBench->start(
"TestExport",
"buildExportFile_dumpToFile");
1054 $this->xml->xmlDumpFile($this->export_dir.
"/".$this->subdir.
"/".$this->filename
1056 $ilBench->stop(
"TestExport",
"buildExportFile_dumpToFile");
1058 if (@file_exists(
"./Modules/Test/classes/class.ilTestResultsToXML.php"))
1061 include_once
"./Modules/Test/classes/class.ilTestResultsToXML.php";
1062 $resultwriter =
new ilTestResultsToXML($this->test_obj->getTestId(), $this->test_obj->getAnonymity());
1063 $ilBench->start(
"TestExport",
"buildExportFile_results");
1064 $resultwriter->
xmlDumpFile($this->export_dir.
"/".$this->subdir.
"/".$this->resultsfile,
false);
1065 $ilBench->stop(
"TestExport",
"buildExportFile_results");
1069 $ilBench->start(
"QuestionpoolExport",
"buildExportFile_saveAdditionalMobs");
1071 $ilBench->stop(
"QuestionpoolExport",
"buildExportFile_saveAdditionalMobs");
1074 $ilBench->start(
"TestExport",
"buildExportFile_zipFile");
1076 $this->export_dir.
"/".$this->subdir.
".zip");
1077 $ilBench->stop(
"TestExport",
"buildExportFile_zipFile");
1080 $this->xml->_XmlWriter;
1082 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export");
1083 $ilBench->stop(
"TestExport",
"buildExportFile");
1085 return $this->export_dir.
"/".$this->subdir.
".zip";
1090 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1093 foreach (
$mobs as $mob)
1098 $mob_obj->exportFiles($a_export_dir);
1102 foreach ($this->test_obj->questions as $question_id)
1105 foreach (
$mobs as $mob)
1110 $mob_obj->exportFiles($a_export_dir);