4 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
5 require_once
'Modules/TestQuestionPool/classes/class.assQuestion.php';
57 $this->test_obj = &$a_test_obj;
62 $this->mode = $a_mode;
68 $this->export_dir = $this->test_obj->getExportDirectory();
70 switch ($this->mode) {
72 $this->subdir = $date .
"__" . $this->inst_id .
"__" .
73 "tst__results_" . $this->test_obj->getId();
76 $this->subdir = $date .
"__" . $this->inst_id .
"__" .
77 "test__aggregated__results_" . $this->test_obj->getId();
80 $this->subdir = $date .
"__" . $this->inst_id .
"__" .
81 "tst" .
"_" . $this->test_obj->getId();
82 $this->filename = $this->subdir .
".xml";
83 $this->resultsfile = $date .
"__" . $this->inst_id .
"__" .
84 "results" .
"_" . $this->test_obj->getId() .
".xml";
85 $this->qti_filename = $date .
"__" . $this->inst_id .
"__" .
86 "qti" .
"_" . $this->test_obj->getId() .
".xml";
89 $this->filename = $this->subdir .
"." . $this->
getExtension();
105 $this->resultExportingEnabledForTestExport = $resultExprtingEnabledForTestExport;
133 return $this->test_obj->buildStatisticsAccessFilteredParticipantList();
138 switch ($this->mode) {
160 switch ($this->mode) {
180 $expDir = $this->test_obj->getExportDirectory();
183 $this->test_obj->createExportDirectory();
184 include_once
"./Services/Utilities/classes/class.ilUtil.php";
187 include_once
'./Services/Logging/classes/class.ilLog.php';
188 $expLog =
new ilLog($expDir,
"export.log");
190 $expLog->setLogFormat(
"");
191 $expLog->write(date(
"[y-m-d H:i:s] ") .
"Start Export Of Results");
194 $file = fopen($this->export_dir .
"/" . $this->filename,
"w");
195 fwrite($file,
$data);
199 @copy($excelfile, $this->export_dir .
"/" . str_replace($this->
getExtension(),
"xlsx", $this->filename));
202 $expLog->write(date(
"[y-m-d H:i:s] ") .
"Finished Export of Results");
214 $data = $this->test_obj->getAggregatedResultsData();
216 require_once
'Modules/TestQuestionPool/classes/class.ilAssExcelFormatHelper.php';
218 $worksheet->addSheet($this->lng->txt(
'tst_results_aggregated'));
222 $worksheet->setCell($row, $col++, $this->lng->txt(
'result'));
223 $worksheet->setCell($row, $col++, $this->lng->txt(
'value'));
225 $worksheet->setBold(
'A' . $row .
':' . $worksheet->getColumnCoord($col - 1) . $row);
228 foreach (
$data[
'overview'] as $key => $value) {
230 $worksheet->setCell($row, $col++, $key);
231 $worksheet->setCell($row, $col++, $value);
238 $worksheet->setCell($row, $col++, $this->lng->txt(
'question_id'));
239 $worksheet->setCell($row, $col++, $this->lng->txt(
'question_title'));
240 $worksheet->setCell($row, $col++, $this->lng->txt(
'average_reached_points'));
241 $worksheet->setCell($row, $col++, $this->lng->txt(
'points'));
242 $worksheet->setCell($row, $col++, $this->lng->txt(
'percentage'));
243 $worksheet->setCell($row, $col++, $this->lng->txt(
'number_of_answers'));
245 $worksheet->setBold(
'A' . $row .
':' . $worksheet->getColumnCoord($col - 1) . $row);
248 foreach (
$data[
'questions'] as $key => $value) {
250 $worksheet->setCell($row, $col++, $key);
251 $worksheet->setCell($row, $col++, $value[0]);
252 $worksheet->setCell($row, $col++, $value[4]);
253 $worksheet->setCell($row, $col++, $value[5]);
254 $worksheet->setCell($row, $col++, $value[6]);
255 $worksheet->setCell($row, $col++, $value[3]);
260 $worksheet->sendToClient(
265 $worksheet->writeToFile($excelfile);
266 return $excelfile .
'.xlsx';
277 $data = $this->test_obj->getAggregatedResultsData();
279 array_push(
$rows, array(
280 $this->lng->txt(
"result"),
281 $this->lng->txt(
"value")
283 foreach (
$data[
"overview"] as $key => $value) {
284 array_push(
$rows, array(
289 array_push(
$rows, array(
290 $this->lng->txt(
"question_id"),
291 $this->lng->txt(
"question_title"),
292 $this->lng->txt(
"average_reached_points"),
293 $this->lng->txt(
"points"),
294 $this->lng->txt(
"percentage"),
295 $this->lng->txt(
"number_of_answers")
297 foreach (
$data[
"questions"] as $key => $value) {
298 array_push(
$rows, array(
309 foreach (
$rows as $evalrow) {
310 $csvrow = &$this->test_obj->processCSVRow($evalrow,
true, $separator);
311 $csv .= join($separator, $csvrow) .
"\n";
331 public function exportToExcel($deliver =
true, $filterby =
"", $filtertext =
"", $passedonly =
false)
335 if (strcmp($this->mode,
"aggregated") == 0) {
339 require_once
'Modules/TestQuestionPool/classes/class.ilAssExcelFormatHelper.php';
342 $worksheet->addSheet($this->lng->txt(
'tst_results'));
344 $additionalFields = $this->test_obj->getEvaluationAdditionalFields();
349 if ($this->test_obj->getAnonymity()) {
350 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'counter'));
352 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'name'));
353 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'login'));
356 if (count($additionalFields)) {
357 foreach ($additionalFields as $fieldname) {
358 if (strcmp($fieldname,
"exam_id") == 0) {
359 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'exam_id_label'));
362 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt($fieldname));
366 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_resultspoints'));
367 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'maximum_points'));
368 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_resultsmarks'));
370 if ($this->test_obj->getECTSOutput()) {
371 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'ects_grade'));
374 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_qworkedthrough'));
375 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_qmax'));
376 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_pworkedthrough'));
377 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_timeofwork'));
378 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_atimeofwork'));
379 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_firstvisit'));
380 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_lastvisit'));
381 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_mark_median'));
382 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_rank_participant'));
383 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_rank_median'));
384 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_total_participants'));
385 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_median'));
386 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_tbl_col_started_passes'));
387 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_tbl_col_finished_passes'));
388 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'scored_pass'));
389 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'pass'));
391 $worksheet->setBold(
'A' . $row .
':' . $worksheet->getColumnCoord($col - 1) . $row);
394 $data = $this->test_obj->getCompleteEvaluationData(
true, $filterby, $filtertext);
395 $firstrowwritten =
false;
396 foreach (
$data->getParticipants() as $active_id => $userdata) {
397 if ($passedonly &&
$data->getParticipant($active_id)->getPassed() ==
false) {
405 if ($this->test_obj->isRandomTest() && $firstrowwritten) {
409 if ($this->test_obj->getAnonymity()) {
410 $worksheet->setCell($row, $col++, $counter);
412 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getName());
413 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getLogin());
416 if (count($additionalFields)) {
418 foreach ($additionalFields as $fieldname) {
419 if (strcmp($fieldname,
'gender') == 0) {
420 $worksheet->setCell($row, $col++, strlen($userfields[$fieldname]) ? $this->lng->txt(
'gender_' . $userfields[$fieldname]) :
'');
421 } elseif (strcmp($fieldname,
"exam_id") == 0) {
422 $worksheet->setCell($row, $col++, $userdata->getExamIdFromScoredPass());
424 $worksheet->setCell($row, $col++, $userfields[$fieldname]);
429 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getReached());
430 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getMaxpoints());
431 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getMark());
433 if ($this->test_obj->getECTSOutput()) {
434 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getECTSMark());
437 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getQuestionsWorkedThrough());
438 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getNumberOfQuestions());
439 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() .
'%');
441 $time =
$data->getParticipant($active_id)->getTimeOfWork();
442 $time_seconds = $time;
443 $time_hours = floor($time_seconds / 3600);
444 $time_seconds -= $time_hours * 3600;
445 $time_minutes = floor($time_seconds / 60);
446 $time_seconds -= $time_minutes * 60;
447 $worksheet->setCell($row, $col++, sprintf(
"%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
448 $time =
$data->getParticipant($active_id)->getQuestionsWorkedThrough() ?
$data->getParticipant($active_id)->getTimeOfWork() /
$data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
449 $time_seconds = $time;
450 $time_hours = floor($time_seconds / 3600);
451 $time_seconds -= $time_hours * 3600;
452 $time_minutes = floor($time_seconds / 60);
453 $time_seconds -= $time_minutes * 60;
454 $worksheet->setCell($row, $col++, sprintf(
"%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
458 $median =
$data->getStatistics()->getStatistics()->median();
459 $pct =
$data->getParticipant($active_id)->getMaxpoints() ? $median /
$data->getParticipant($active_id)->getMaxpoints() * 100.0 : 0;
460 $mark = $this->test_obj->mark_schema->getMatchingMark($pct);
461 $mark_short_name =
"";
463 if (is_object($mark)) {
464 $mark_short_name = $mark->getShortName();
467 $worksheet->setCell($row, $col++, $mark_short_name);
468 $worksheet->setCell($row, $col++,
$data->getStatistics()->getStatistics()->rank(
$data->getParticipant($active_id)->getReached()));
469 $worksheet->setCell($row, $col++,
$data->getStatistics()->getStatistics()->rank_median());
470 $worksheet->setCell($row, $col++,
$data->getStatistics()->getStatistics()->count());
471 $worksheet->setCell($row, $col++, $median);
472 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getPassCount());
473 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getFinishedPasses());
475 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getBestPass() + 1);
477 $worksheet->setCell($row, $col++,
$data->getParticipant($active_id)->getLastPass() + 1);
485 if ($finishdate > 0) {
488 if ($this->test_obj->isRandomTest()) {
492 $worksheet->setCell($row, $col++,
$pass + 1);
493 if (is_object(
$data->getParticipant($active_id)) && is_array(
$data->getParticipant($active_id)->getQuestions(
$pass))) {
494 $evaluated_questions =
$data->getParticipant($active_id)->getQuestions(
$pass);
497 foreach ($questions as $question) {
498 $question_data =
$data->getParticipant($active_id)->getPass(
$pass)->getAnsweredQuestionByQuestionId($question[
"id"]);
499 $worksheet->setCell($row, $col, $question_data[
"reached"]);
500 if ($this->test_obj->isRandomTest()) {
503 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col) . ($row - 1), preg_replace(
"/<.*?>/",
"",
$data->getQuestionTitle($question[
"id"])));
505 if (
$pass == 0 && !$firstrowwritten) {
506 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col) . 1,
$data->getQuestionTitle($question[
"id"]));
511 $firstrowwritten =
true;
518 if ($this->test_obj->getExportSettingsSingleChoiceShort() && !$this->test_obj->isRandomTest() && $this->test_obj->hasSingleChoiceQuestions()) {
520 $titles = $this->test_obj->getQuestionTitlesAndIndexes();
521 $positions = array();
524 foreach ($titles as $id => $title) {
525 $positions[$id] = $pos;
529 $usernames = array();
530 $participantcount = count(
$data->getParticipants());
531 $allusersheet =
false;
534 $worksheet->addSheet($this->lng->txt(
'eval_all_users'));
537 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'name'));
538 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'login'));
539 if (count($additionalFields)) {
540 foreach ($additionalFields as $fieldname) {
541 if (strcmp($fieldname,
"matriculation") == 0) {
542 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'matriculation'));
544 if (strcmp($fieldname,
"exam_id") == 0) {
545 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'exam_id_label'));
549 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'test'));
550 foreach ($titles as $title) {
551 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $title);
553 $worksheet->setBold(
'A' . $row .
':' . $worksheet->getColumnCoord($col - 1) . $row);
556 foreach (
$data->getParticipants() as $active_id => $userdata) {
557 $username = (!is_null($userdata) && $userdata->getName()) ? $userdata->getName() :
"ID $active_id";
558 if (array_key_exists($username, $usernames)) {
559 $usernames[$username]++;
560 $username .=
" ($usernames[$username])";
562 $usernames[$username] = 1;
565 $worksheet->setCell($row, $col++, $username);
566 $worksheet->setCell($row, $col++, $userdata->getLogin());
567 if (count($additionalFields)) {
569 foreach ($additionalFields as $fieldname) {
570 if (strcmp($fieldname,
"matriculation") == 0) {
571 if (strlen($userfields[$fieldname])) {
572 $worksheet->setCell($row, $col++, $userfields[$fieldname]);
577 if (strcmp($fieldname,
"exam_id") == 0) {
578 if (strlen($userfields[$fieldname])) {
579 $worksheet->setCell($row, $col++, $userdata->getExamIdFromScoredPass());
586 $worksheet->setCell($row, $col++, $this->test_obj->getTitle());
587 $pass = $userdata->getScoredPass();
588 if (is_object($userdata) && is_array($userdata->getQuestions(
$pass))) {
589 foreach ($userdata->getQuestions(
$pass) as $question) {
591 if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(),
'assSingleChoice') == 0) {
592 $solution = $objQuestion->getSolutionValues($active_id,
$pass);
593 $pos = $positions[$question[
"id"]];
594 $selectedanswer =
"x";
595 foreach ($objQuestion->getAnswers() as $id => $answer) {
596 if (strlen($solution[0][
"value1"]) && $id == $solution[0][
"value1"]) {
597 $selectedanswer = $answer->getAnswertext();
600 $worksheet->setCell($row, $col + $pos, $selectedanswer);
607 if ($this->test_obj->isSingleChoiceTestWithoutShuffle()) {
611 $usernames = array();
612 $allusersheet =
false;
615 $worksheet->addSheet($this->lng->txt(
'eval_all_users') .
' (2)');
618 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'name'));
619 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'login'));
620 if (count($additionalFields)) {
621 foreach ($additionalFields as $fieldname) {
622 if (strcmp($fieldname,
"matriculation") == 0) {
623 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'matriculation'));
625 if (strcmp($fieldname,
"exam_id") == 0) {
626 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'exam_id_label'));
630 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'test'));
631 foreach ($titles as $title) {
632 $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $title);
634 $worksheet->setBold(
'A' . $row .
':' . $worksheet->getColumnCoord($col - 1) . $row);
637 foreach (
$data->getParticipants() as $active_id => $userdata) {
638 $username = (!is_null($userdata) && $userdata->getName()) ? $userdata->getName() :
"ID $active_id";
639 if (array_key_exists($username, $usernames)) {
640 $usernames[$username]++;
641 $username .=
" ($usernames[$username])";
643 $usernames[$username] = 1;
646 $worksheet->setCell($row, $col++, $username);
647 $worksheet->setCell($row, $col++, $userdata->getLogin());
648 if (count($additionalFields)) {
650 foreach ($additionalFields as $fieldname) {
651 if (strcmp($fieldname,
"matriculation") == 0) {
652 if (strlen($userfields[$fieldname])) {
653 $worksheet->setCell($row, $col++, $userfields[$fieldname]);
658 if (strcmp($fieldname,
"exam_id") == 0) {
659 if (strlen($userfields[$fieldname])) {
660 $worksheet->setCell($row, $col++, $userdata->getExamIdFromScoredPass());
667 $worksheet->setCell($row, $col++, $this->test_obj->getTitle());
668 $pass = $userdata->getScoredPass();
669 if (is_object($userdata) && is_array($userdata->getQuestions(
$pass))) {
670 foreach ($userdata->getQuestions(
$pass) as $question) {
672 if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(),
'assSingleChoice') == 0) {
673 $solution = $objQuestion->getSolutionValues($active_id,
$pass);
674 $pos = $positions[$question[
"aid"]];
675 $selectedanswer = chr(65 + $solution[0][
"value1"]);
676 $worksheet->setCell($row, $col + $pos, $selectedanswer);
685 $usernames = array();
686 $participantcount = count(
$data->getParticipants());
687 $allusersheet =
false;
689 foreach (
$data->getParticipants() as $active_id => $userdata) {
690 $username = (!is_null($userdata) && $userdata->getName())
691 ? $userdata->getName()
693 $username = mb_substr($username, 0, 26);
695 $username_to_lower = strtolower($username);
696 if (array_key_exists($username_to_lower, $usernames)) {
697 $usernames[$username_to_lower]++;
698 $username .=
" (" . $usernames[$username_to_lower] .
")";
700 $usernames[$username_to_lower] = 0;
703 if ($participantcount > 250) {
704 if (!$allusersheet || ($pages - 1) < floor($row / 64000)) {
705 $worksheet->addSheet($this->lng->txt(
"eval_all_users") . (($pages > 0) ?
" (" . ($pages + 1) .
")" :
""));
706 $allusersheet =
true;
711 $resultsheet = $worksheet->addSheet($username);
714 $pass = $userdata->getScoredPass();
715 $row = ($allusersheet) ? $row : 1;
716 $worksheet->setCell($row, 0, sprintf($this->lng->txt(
"tst_result_user_name_pass"),
$pass + 1, $userdata->getName()));
717 $worksheet->setBold($worksheet->getColumnCoord(0) . $row);
719 if (is_object($userdata) && is_array($userdata->getQuestions(
$pass))) {
720 foreach ($userdata->getQuestions(
$pass) as $question) {
721 require_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
723 if (is_object($question)) {
724 $row = $question->setExportDetailsXLS($worksheet, $row, $active_id,
$pass);
732 $testname = $this->test_obj->getTitle();
733 switch ($this->mode) {
735 $testname .=
'_results';
739 $worksheet->sendToClient($testname);
742 $worksheet->writeToFile($excelfile);
743 return $excelfile .
'.xlsx';
758 public function exportToCSV($deliver =
true, $filterby =
"", $filtertext =
"", $passedonly =
false)
760 $this->test_obj->setAccessFilteredParticipantList(
761 $this->test_obj->buildStatisticsAccessFilteredParticipantList()
764 if (strcmp($this->mode,
"aggregated") == 0) {
771 if ($this->test_obj->getAnonymity()) {
772 array_push($datarow, $this->lng->txt(
"counter"));
775 array_push($datarow, $this->lng->txt(
"name"));
777 array_push($datarow, $this->lng->txt(
"login"));
780 $additionalFields = $this->test_obj->getEvaluationAdditionalFields();
781 if (count($additionalFields)) {
782 foreach ($additionalFields as $fieldname) {
783 if (strcmp($fieldname,
"exam_id") == 0) {
784 array_push($datarow, $this->lng->txt(
'exam_id_label'));
788 array_push($datarow, $this->lng->txt($fieldname));
792 array_push($datarow, $this->lng->txt(
"tst_stat_result_resultspoints"));
794 array_push($datarow, $this->lng->txt(
"maximum_points"));
796 array_push($datarow, $this->lng->txt(
"tst_stat_result_resultsmarks"));
798 if ($this->test_obj->getECTSOutput()) {
799 array_push($datarow, $this->lng->txt(
"ects_grade"));
802 array_push($datarow, $this->lng->txt(
"tst_stat_result_qworkedthrough"));
804 array_push($datarow, $this->lng->txt(
"tst_stat_result_qmax"));
806 array_push($datarow, $this->lng->txt(
"tst_stat_result_pworkedthrough"));
808 array_push($datarow, $this->lng->txt(
"tst_stat_result_timeofwork"));
810 array_push($datarow, $this->lng->txt(
"tst_stat_result_atimeofwork"));
812 array_push($datarow, $this->lng->txt(
"tst_stat_result_firstvisit"));
814 array_push($datarow, $this->lng->txt(
"tst_stat_result_lastvisit"));
817 array_push($datarow, $this->lng->txt(
"tst_stat_result_mark_median"));
819 array_push($datarow, $this->lng->txt(
"tst_stat_result_rank_participant"));
821 array_push($datarow, $this->lng->txt(
"tst_stat_result_rank_median"));
823 array_push($datarow, $this->lng->txt(
"tst_stat_result_total_participants"));
825 array_push($datarow, $this->lng->txt(
"tst_stat_result_median"));
827 array_push($datarow, $this->lng->txt(
"tst_tbl_col_started_passes"));
829 array_push($datarow, $this->lng->txt(
"tst_tbl_col_finished_passes"));
832 array_push($datarow, $this->lng->txt(
"scored_pass"));
835 array_push($datarow, $this->lng->txt(
"pass"));
838 $data = &$this->test_obj->getCompleteEvaluationData(
true, $filterby, $filtertext);
839 $headerrow = $datarow;
841 foreach (
$data->getParticipants() as $active_id => $userdata) {
842 $datarow = $headerrow;
845 if (
$data->getParticipant($active_id)->getPassed() ==
false) {
851 if ($this->test_obj->getAnonymity()) {
852 array_push($datarow2, $counter);
854 array_push($datarow2,
$data->getParticipant($active_id)->getName());
855 array_push($datarow2,
$data->getParticipant($active_id)->getLogin());
857 if (count($additionalFields)) {
859 foreach ($additionalFields as $fieldname) {
860 if (strcmp($fieldname,
"gender") == 0) {
861 array_push($datarow2, strlen($userfields[$fieldname]) ? $this->lng->txt(
'gender_' . $userfields[$fieldname]) :
'');
862 } elseif (strcmp($fieldname,
"exam_id") == 0) {
863 array_push($datarow2, $userdata->getExamIdFromScoredPass());
865 array_push($datarow2, $userfields[$fieldname]);
869 array_push($datarow2,
$data->getParticipant($active_id)->getReached());
870 array_push($datarow2,
$data->getParticipant($active_id)->getMaxpoints());
871 array_push($datarow2,
$data->getParticipant($active_id)->getMark());
872 if ($this->test_obj->getECTSOutput()) {
873 array_push($datarow2,
$data->getParticipant($active_id)->getECTSMark());
875 array_push($datarow2,
$data->getParticipant($active_id)->getQuestionsWorkedThrough());
876 array_push($datarow2,
$data->getParticipant($active_id)->getNumberOfQuestions());
877 array_push($datarow2,
$data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() / 100.0);
878 $time =
$data->getParticipant($active_id)->getTimeOfWork();
879 $time_seconds = $time;
880 $time_hours = floor($time_seconds / 3600);
881 $time_seconds -= $time_hours * 3600;
882 $time_minutes = floor($time_seconds / 60);
883 $time_seconds -= $time_minutes * 60;
884 array_push($datarow2, sprintf(
"%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
885 $time =
$data->getParticipant($active_id)->getQuestionsWorkedThrough() ?
$data->getParticipant($active_id)->getTimeOfWork() /
$data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
886 $time_seconds = $time;
887 $time_hours = floor($time_seconds / 3600);
888 $time_seconds -= $time_hours * 3600;
889 $time_minutes = floor($time_seconds / 60);
890 $time_seconds -= $time_minutes * 60;
891 array_push($datarow2, sprintf(
"%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
893 $fv =
$data->getParticipant($active_id)->getFirstVisit();
894 $lv =
$data->getParticipant($active_id)->getLastVisit();
895 foreach (array($fv, $lv) as $ts) {
898 array_push($datarow2, $visit);
900 array_push($datarow2,
"");
904 $median =
$data->getStatistics()->getStatistics()->median();
905 $pct =
$data->getParticipant($active_id)->getMaxpoints() ? $median /
$data->getParticipant($active_id)->getMaxpoints() * 100.0 : 0;
906 $mark = $this->test_obj->mark_schema->getMatchingMark($pct);
907 $mark_short_name =
"";
908 if (is_object($mark)) {
909 $mark_short_name = $mark->getShortName();
911 array_push($datarow2, $mark_short_name);
912 array_push($datarow2,
$data->getStatistics()->getStatistics()->rank(
$data->getParticipant($active_id)->getReached()));
913 array_push($datarow2,
$data->getStatistics()->getStatistics()->rank_median());
914 array_push($datarow2,
$data->getStatistics()->getStatistics()->count());
915 array_push($datarow2, $median);
917 array_push($datarow2,
$data->getParticipant($active_id)->getPassCount());
918 array_push($datarow2,
$data->getParticipant($active_id)->getFinishedPasses());
920 array_push($datarow2,
$data->getParticipant($active_id)->getBestPass() + 1);
922 array_push($datarow2,
$data->getParticipant($active_id)->getLastPass() + 1);
926 if ($finishdate > 0) {
928 for (
$i = 1;
$i < $col - 1;
$i++) {
929 array_push($datarow2,
"");
930 array_push($datarow,
"");
932 array_push($datarow,
"");
934 array_push($datarow2,
$pass + 1);
935 if (is_object(
$data->getParticipant($active_id)) && is_array($evaluated_questions =
$data->getParticipant($active_id)->getQuestions(
$pass))) {
937 foreach ($questions as $question) {
938 $question_data =
$data->getParticipant($active_id)->getPass(
$pass)->getAnsweredQuestionByQuestionId($question[
"id"]);
939 array_push($datarow2, $question_data[
"reached"]);
940 array_push($datarow, preg_replace(
"/<.*?>/",
"",
$data->getQuestionTitle($question[
"id"])));
943 if ($this->test_obj->isRandomTest() ||
944 $counter == 1 &&
$pass == 0) {
945 array_push(
$rows, $datarow);
948 array_push(
$rows, $datarow2);
957 foreach (
$rows as $evalrow) {
958 $csvrow = &$this->test_obj->processCSVRow($evalrow,
true, $separator);
959 $csv .= join($separator, $csvrow) .
"\n";
972 $key = $this->test_obj->isRandomTest() ?
'qid' :
'sequence';
975 function (
$a,
$b) use ($key) {
976 if (isset(
$a[$key],
$b[$key]) &&
$a[$key] >
$b[$key]) {
997 $ilBench->start(
"TestExport",
"buildExportFile");
1001 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
1005 $this->xml->
xmlSetDtdDef(
"<!DOCTYPE Test SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co.dtd\">");
1008 $this->xml->xmlSetGenCmt(
"Export of ILIAS Test " .
1009 $this->test_obj->getId() .
" of installation " . $this->inst .
".");
1012 $this->xml->xmlHeader();
1014 $this->xml->xmlStartTag(
"ContentObject", array(
'Type' =>
'Test'));
1017 $this->test_obj->createExportDirectory();
1018 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1020 ilUtil::makeDir($this->export_dir .
"/" . $this->subdir .
"/objects");
1023 $expDir = $this->test_obj->getExportDirectory();
1024 include_once
"./Services/Logging/classes/class.ilLog.php";
1025 $expLog =
new ilLog($expDir,
"export.log");
1027 $expLog->setLogFormat(
"");
1028 $expLog->write(date(
"[y-m-d H:i:s] ") .
"Start Export");
1031 $qti_file = fopen($this->export_dir .
"/" . $this->subdir .
"/" . $this->qti_filename,
"w");
1036 $ilBench->start(
"TestExport",
"buildExportFile_getXML");
1037 $this->test_obj->exportPagesXML(
1040 $this->export_dir .
"/" . $this->subdir,
1043 $ilBench->stop(
"TestExport",
"buildExportFile_getXML");
1051 $this->xml->xmlEndTag(
"ContentObject");
1061 $ilBench->start(
"TestExport",
"buildExportFile_dumpToFile");
1062 $this->xml->xmlDumpFile($this->export_dir .
"/" . $this->subdir .
"/" . $this->filename,
false);
1063 $ilBench->stop(
"TestExport",
"buildExportFile_dumpToFile");
1067 include_once
"./Modules/Test/classes/class.ilTestResultsToXML.php";
1068 $resultwriter =
new ilTestResultsToXML($this->test_obj->getTestId(), $this->test_obj->getAnonymity());
1070 $ilBench->start(
"TestExport",
"buildExportFile_results");
1071 $resultwriter->xmlDumpFile($this->export_dir .
"/" . $this->subdir .
"/" . $this->resultsfile,
false);
1072 $ilBench->stop(
"TestExport",
"buildExportFile_results");
1076 $ilBench->start(
"QuestionpoolExport",
"buildExportFile_saveAdditionalMobs");
1078 $ilBench->stop(
"QuestionpoolExport",
"buildExportFile_saveAdditionalMobs");
1081 $ilBench->start(
"TestExport",
"buildExportFile_zipFile");
1083 $this->export_dir .
"/" . $this->subdir,
1084 $this->export_dir .
"/" . $this->subdir .
".zip" 1086 $ilBench->stop(
"TestExport",
"buildExportFile_zipFile");
1091 $expLog->write(date(
"[y-m-d H:i:s] ") .
"Finished Export");
1092 $ilBench->stop(
"TestExport",
"buildExportFile");
1094 return $this->export_dir .
"/" . $this->subdir .
".zip";
1101 $tstQtiXml = $this->test_obj->toXML();
1104 if (strpos($tstQtiXml,
"</section>") !==
false) {
1105 $qtiXml = str_replace(
"</section>",
"$qstQtiXml</section>", $tstQtiXml);
1107 $qtiXml = str_replace(
"<section ident=\"1\"/>",
"<section ident=\"1\">\n$qstQtiXml</section>", $tstQtiXml);
1117 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1119 $xml = $questionOBJ->toXML(
false);
1122 $xml = preg_replace(
"/<questestinterop>/",
"",
$xml);
1123 $xml = preg_replace(
"/<\/questestinterop>/",
"",
$xml);
1130 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1133 foreach (
$mobs as $mob) {
1136 $mob_obj->exportFiles($a_export_dir);
1142 foreach (
$mobs as $mob) {
1145 $mob_obj->exportFiles($a_export_dir);
1158 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentExporter.php';
1160 $skillQuestionAssignmentExporter->setXmlWriter($a_xml_writer);
1161 $skillQuestionAssignmentExporter->setQuestionIds($questions);
1162 $skillQuestionAssignmentExporter->setAssignmentList($assignmentList);
1163 $skillQuestionAssignmentExporter->export();
1169 $ilDB = $DIC[
'ilDB'];
1171 require_once
'Modules/Test/classes/class.ilTestSkillLevelThresholdList.php';
1173 $thresholdList->setTestId($this->test_obj->getTestId());
1174 $thresholdList->loadFromDb();
1176 require_once
'Modules/Test/classes/class.ilTestSkillLevelThresholdExporter.php';
1178 $skillLevelThresholdExporter->setXmlWriter($a_xml_writer);
1179 $skillLevelThresholdExporter->setAssignmentList($assignmentList);
1180 $skillLevelThresholdExporter->setThresholdList($thresholdList);
1181 $skillLevelThresholdExporter->export();
1190 $ilDB = $DIC[
'ilDB'];
1192 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentList.php';
1194 $assignmentList->setParentObjId($this->test_obj->getId());
1195 $assignmentList->loadFromDb();
1196 $assignmentList->loadAdditionalSkillData();
1198 return $assignmentList;
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
setIncludeRandomTestQuestionsEnabled($includeRandomTestQuestionsEnabled)
buildQuestionSkillAssignmentList()
exportToCSV($deliver=true, $filterby="", $filtertext="", $passedonly=false)
Exports the evaluation data to the CSV file format.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
aggregatedResultsToExcel($deliver=true)
Exports the aggregated results to the Microsoft Excel file format.
$forcedAccessFilteredParticipantList
getQuestionQtiXml($questionId)
static lookupPassResultsUpdateTimestamp($active_id, $pass)
populateQuestionSkillAssignmentsXml(ilXmlWriter $a_xml_writer, ilAssQuestionSkillAssignmentList $assignmentList, $questions)
$resultExportingEnabledForTestExport
buildExportFileXML()
build xml export file
orderQuestions(array $questions)
Test results to XML class.
isResultExportingEnabledForTestExport()
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
__construct(&$a_test_obj, $a_mode="xml")
Constructor.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
buildExportFile()
build export file (complete zip file)
setForcedAccessFilteredParticipantList(ilTestParticipantList $forcedAccessFilteredParticipantList)
getAccessFilteredParticipantList()
exportXHTMLMediaObjects($a_export_dir)
redirection script todo: (a better solution should control the processing via a xml file) ...
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static _instantiateQuestion($question_id)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
setResultExportingEnabledForTestExport($resultExprtingEnabledForTestExport)
populateSkillLevelThresholdsXml(ilXmlWriter $a_xml_writer, ilAssQuestionSkillAssignmentList $assignmentList)
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
aggregatedResultsToCSV($deliver=true)
Exports the aggregated results to CSV.
exportToExcel($deliver=true, $filterby="", $filtertext="", $passedonly=false)
Exports the evaluation data to the Microsoft Excel file format.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
static _lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
getForcedAccessFilteredParticipantList()
buildExportResultFile()
build xml export file
populateQuestionSetConfigXml(ilXmlWriter $xmlWriter)