4require_once 
'./Modules/Test/classes/inc.AssessmentConstants.php';
 
    5require_once 
'Modules/TestQuestionPool/classes/class.assQuestion.php';
 
   57        $this->test_obj = &$a_test_obj;
 
   62        $this->mode = $a_mode;
 
   65        $this->inst_id = IL_INST_ID;
 
   68        $this->export_dir = $this->test_obj->getExportDirectory();
 
   69        switch ($this->mode) {
 
   71                $this->subdir = $date . 
"__" . $this->inst_id . 
"__" .
 
   72                    "tst__results_" . $this->test_obj->getId();
 
   75                $this->subdir = $date . 
"__" . $this->inst_id . 
"__" .
 
   76                    "test__aggregated__results_" . $this->test_obj->getId();
 
   79                $this->subdir = $date . 
"__" . $this->inst_id . 
"__" .
 
   80                    "tst" . 
"_" . $this->test_obj->getId();
 
   81                $this->filename = $this->subdir . 
".xml";
 
   82                $this->resultsfile = $date . 
"__" . $this->inst_id . 
"__" .
 
   83                    "results" . 
"_" . $this->test_obj->getId() . 
".xml";
 
   84                $this->qti_filename = $date . 
"__" . $this->inst_id . 
"__" .
 
   85                    "qti" . 
"_" . $this->test_obj->getId() . 
".xml";
 
   88        $this->filename = $this->subdir . 
"." . $this->
getExtension();
 
  104        $this->resultExportingEnabledForTestExport = $resultExprtingEnabledForTestExport;
 
  132        return $this->test_obj->buildStatisticsAccessFilteredParticipantList();
 
  137        switch ($this->mode) {
 
  159        switch ($this->mode) {
 
  179        $expDir = $this->test_obj->getExportDirectory();
 
  182        $this->test_obj->createExportDirectory();
 
  183        include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  186        include_once 
'./Services/Logging/classes/class.ilLog.php';
 
  187        $expLog = 
new ilLog($expDir, 
"export.log");
 
  189        $expLog->setLogFormat(
"");
 
  190        $expLog->write(date(
"[y-m-d H:i:s] ") . 
"Start Export Of Results");
 
  193        $file = fopen($this->export_dir . 
"/" . $this->filename, 
"w");
 
  194        fwrite($file, 
$data);
 
  198        @copy($excelfile, $this->export_dir . 
"/" . str_replace($this->
getExtension(), 
"xlsx", $this->filename));
 
  201        $expLog->write(date(
"[y-m-d H:i:s] ") . 
"Finished Export of Results");
 
  213        $data = $this->test_obj->getAggregatedResultsData();
 
  215        require_once 
'Modules/TestQuestionPool/classes/class.ilAssExcelFormatHelper.php';
 
  217        $worksheet->addSheet($this->lng->txt(
'tst_results_aggregated'));
 
  221        $worksheet->setCell($row, $col++, $this->lng->txt(
'result'));
 
  222        $worksheet->setCell($row, $col++, $this->lng->txt(
'value'));
 
  224        $worksheet->setBold(
'A' . $row . 
':' . $worksheet->getColumnCoord($col - 1) . $row);
 
  227        foreach (
$data[
'overview'] as $key => $value) {
 
  229            $worksheet->setCell($row, $col++, $key);
 
  230            $worksheet->setCell($row, $col++, $value);
 
  237        $worksheet->setCell($row, $col++, $this->lng->txt(
'question_id'));
 
  238        $worksheet->setCell($row, $col++, $this->lng->txt(
'question_title'));
 
  239        $worksheet->setCell($row, $col++, $this->lng->txt(
'average_reached_points'));
 
  240        $worksheet->setCell($row, $col++, $this->lng->txt(
'points'));
 
  241        $worksheet->setCell($row, $col++, $this->lng->txt(
'percentage'));
 
  242        $worksheet->setCell($row, $col++, $this->lng->txt(
'number_of_answers'));
 
  244        $worksheet->setBold(
'A' . $row . 
':' . $worksheet->getColumnCoord($col - 1) . $row);
 
  247        foreach (
$data[
'questions'] as $key => $value) {
 
  249            $worksheet->setCell($row, $col++, $key);
 
  250            $worksheet->setCell($row, $col++, $value[0]);
 
  251            $worksheet->setCell($row, $col++, $value[4]);
 
  252            $worksheet->setCell($row, $col++, $value[5]);
 
  253            $worksheet->setCell($row, $col++, $value[6]);
 
  254            $worksheet->setCell($row, $col++, $value[3]);
 
  259            $worksheet->sendToClient(
 
  264            $worksheet->writeToFile($excelfile);
 
  265            return $excelfile . 
'.xlsx';
 
  276        $data = $this->test_obj->getAggregatedResultsData();
 
  278        array_push(
$rows, array(
 
  279            $this->lng->txt(
"result"),
 
  280            $this->lng->txt(
"value")
 
  282        foreach (
$data[
"overview"] as $key => $value) {
 
  283            array_push(
$rows, array(
 
  288        array_push(
$rows, array(
 
  289            $this->lng->txt(
"question_id"),
 
  290            $this->lng->txt(
"question_title"),
 
  291            $this->lng->txt(
"average_reached_points"),
 
  292            $this->lng->txt(
"points"),
 
  293            $this->lng->txt(
"percentage"),
 
  294            $this->lng->txt(
"number_of_answers")
 
  296        foreach (
$data[
"questions"] as $key => $value) {
 
  297            array_push(
$rows, array(
 
  308        foreach (
$rows as $evalrow) {
 
  309            $csvrow = &$this->test_obj->processCSVRow($evalrow, 
true, $separator);
 
  310            $csv .= join($separator, $csvrow) . 
"\n";
 
  330    public function exportToExcel($deliver = 
true, $filterby = 
"", $filtertext = 
"", $passedonly = 
false)
 
  334        if (strcmp($this->mode, 
"aggregated") == 0) {
 
  338        require_once 
'Modules/TestQuestionPool/classes/class.ilAssExcelFormatHelper.php';
 
  341        $worksheet->addSheet($this->lng->txt(
'tst_results'));
 
  343        $additionalFields = $this->test_obj->getEvaluationAdditionalFields();
 
  348        if ($this->test_obj->getAnonymity()) {
 
  349            $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'counter'));
 
  351            $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'name'));
 
  352            $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'login'));
 
  355        if (count($additionalFields)) {
 
  356            foreach ($additionalFields as $fieldname) {
 
  357                if (strcmp($fieldname, 
"exam_id") == 0) {
 
  358                    $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'exam_id_label'));
 
  361                $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt($fieldname));
 
  365        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_resultspoints'));
 
  366        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'maximum_points'));
 
  367        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_resultsmarks'));
 
  369        if ($this->test_obj->getECTSOutput()) {
 
  370            $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'ects_grade'));
 
  373        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_qworkedthrough'));
 
  374        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_qmax'));
 
  375        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_pworkedthrough'));
 
  376        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_timeofwork'));
 
  377        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_atimeofwork'));
 
  378        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_firstvisit'));
 
  379        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_lastvisit'));
 
  380        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_mark_median'));
 
  381        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_rank_participant'));
 
  382        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_rank_median'));
 
  383        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_total_participants'));
 
  384        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'tst_stat_result_median'));
 
  385        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'scored_pass'));
 
  386        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'pass'));
 
  388        $worksheet->setBold(
'A' . $row . 
':' . $worksheet->getColumnCoord($col - 1) . $row);
 
  391        $data = $this->test_obj->getCompleteEvaluationData(
true, $filterby, $filtertext);
 
  392        $firstrowwritten = 
false;
 
  393        foreach (
$data->getParticipants() as $active_id => $userdata) {
 
  394            if ($passedonly && 
$data->getParticipant($active_id)->getPassed() == 
false) {
 
  402            if ($this->test_obj->isRandomTest()) {
 
  406            if ($this->test_obj->getAnonymity()) {
 
  407                $worksheet->setCell($row, $col++, $counter);
 
  409                $worksheet->setCell($row, $col++, 
$data->getParticipant($active_id)->getName());
 
  410                $worksheet->setCell($row, $col++, 
$data->getParticipant($active_id)->getLogin());
 
  413            if (count($additionalFields)) {
 
  415                foreach ($additionalFields as $fieldname) {
 
  416                    if (strcmp($fieldname, 
'gender') == 0) {
 
  417                        $worksheet->setCell($row, $col++, $this->lng->txt(
'gender_' . $userfields[$fieldname]));
 
  418                    } elseif (strcmp($fieldname, 
"exam_id") == 0) {
 
  419                        $worksheet->setCell($row, $col++, $userdata->getExamIdFromScoredPass());
 
  421                        $worksheet->setCell($row, $col++, $userfields[$fieldname]);
 
  426            $worksheet->setCell($row, $col++, 
$data->getParticipant($active_id)->getReached());
 
  427            $worksheet->setCell($row, $col++, 
$data->getParticipant($active_id)->getMaxpoints());
 
  428            $worksheet->setCell($row, $col++, 
$data->getParticipant($active_id)->getMark());
 
  430            if ($this->test_obj->getECTSOutput()) {
 
  431                $worksheet->setCell($row, $col++, 
$data->getParticipant($active_id)->getECTSMark());
 
  434            $worksheet->setCell($row, $col++, 
$data->getParticipant($active_id)->getQuestionsWorkedThrough());
 
  435            $worksheet->setCell($row, $col++, 
$data->getParticipant($active_id)->getNumberOfQuestions());
 
  436            $worksheet->setCell($row, $col++, 
$data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() . 
'%');
 
  438            $time = 
$data->getParticipant($active_id)->getTimeOfWork();
 
  439            $time_seconds = $time;
 
  440            $time_hours = floor($time_seconds / 3600);
 
  441            $time_seconds -= $time_hours * 3600;
 
  442            $time_minutes = floor($time_seconds / 60);
 
  443            $time_seconds -= $time_minutes * 60;
 
  444            $worksheet->setCell($row, $col++, sprintf(
"%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
 
  445            $time = 
$data->getParticipant($active_id)->getQuestionsWorkedThrough() ? 
$data->getParticipant($active_id)->getTimeOfWork() / 
$data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
 
  446            $time_seconds = $time;
 
  447            $time_hours = floor($time_seconds / 3600);
 
  448            $time_seconds -= $time_hours * 3600;
 
  449            $time_minutes = floor($time_seconds / 60);
 
  450            $time_seconds -= $time_minutes * 60;
 
  451            $worksheet->setCell($row, $col++, sprintf(
"%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
 
  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 = 
"";
 
  460            if (is_object($mark)) {
 
  461                $mark_short_name = $mark->getShortName();
 
  464            $worksheet->setCell($row, $col++, $mark_short_name);
 
  465            $worksheet->setCell($row, $col++, 
$data->getStatistics()->getStatistics()->rank(
$data->getParticipant($active_id)->getReached()));
 
  466            $worksheet->setCell($row, $col++, 
$data->getStatistics()->getStatistics()->rank_median());
 
  467            $worksheet->setCell($row, $col++, 
$data->getStatistics()->getStatistics()->count());
 
  468            $worksheet->setCell($row, $col++, $median);
 
  471                $worksheet->setCell($row, $col++, 
$data->getParticipant($active_id)->getBestPass() + 1);
 
  473                $worksheet->setCell($row, $col++, 
$data->getParticipant($active_id)->getLastPass() + 1);
 
  481                if ($finishdate > 0) {
 
  484                        if ($this->test_obj->isRandomTest()) {
 
  488                    $worksheet->setCell($row, $col++, 
$pass + 1);
 
  489                    if (is_object(
$data->getParticipant($active_id)) && is_array(
$data->getParticipant($active_id)->getQuestions(
$pass))) {
 
  490                        $evaluatedQuestions = 
$data->getParticipant($active_id)->getQuestions(
$pass);
 
  492                        if ($this->test_obj->getShuffleQuestions()) {
 
  495                            $questions = array();
 
  496                            foreach ($this->test_obj->getQuestions() as $qId) {
 
  497                                foreach ($evaluatedQuestions as $evaledQst) {
 
  498                                    if ($evaledQst[
'id'] != $qId) {
 
  502                                    $questions[] = $evaledQst;
 
  506                            $questions = $evaluatedQuestions;
 
  509                        foreach ($questions as $question) {
 
  510                            $question_data = 
$data->getParticipant($active_id)->getPass(
$pass)->getAnsweredQuestionByQuestionId($question[
"id"]);
 
  511                            $worksheet->setCell($row, $col, $question_data[
"reached"]);
 
  512                            if ($this->test_obj->isRandomTest()) {
 
  515                                $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col) . ($row - 1), preg_replace(
"/<.*?>/", 
"", 
$data->getQuestionTitle($question[
"id"])));
 
  517                                if (
$pass == 0 && !$firstrowwritten) {
 
  518                                    $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col) . 1, 
$data->getQuestionTitle($question[
"id"]));
 
  523                        $firstrowwritten = 
true;
 
  530        if ($this->test_obj->getExportSettingsSingleChoiceShort() && !$this->test_obj->isRandomTest() && $this->test_obj->hasSingleChoiceQuestions()) {
 
  532            $titles = $this->test_obj->getQuestionTitlesAndIndexes();
 
  533            $positions = array();
 
  536            foreach ($titles as $id => $title) {
 
  537                $positions[$id] = $pos;
 
  541            $usernames = array();
 
  542            $participantcount = count(
$data->getParticipants());
 
  543            $allusersheet = 
false;
 
  546            $worksheet->addSheet($this->lng->txt(
'eval_all_users'));
 
  549            $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'name'));
 
  550            $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'login'));
 
  551            if (count($additionalFields)) {
 
  552                foreach ($additionalFields as $fieldname) {
 
  553                    if (strcmp($fieldname, 
"matriculation") == 0) {
 
  554                        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'matriculation'));
 
  556                    if (strcmp($fieldname, 
"exam_id") == 0) {
 
  557                        $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'exam_id_label'));
 
  561            $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'test'));
 
  562            foreach ($titles as $title) {
 
  563                $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $title);
 
  565            $worksheet->setBold(
'A' . $row . 
':' . $worksheet->getColumnCoord($col - 1) . $row);
 
  568            foreach (
$data->getParticipants() as $active_id => $userdata) {
 
  569                $username = (!is_null($userdata) && $userdata->getName()) ? $userdata->getName() : 
"ID $active_id";
 
  570                if (array_key_exists($username, $usernames)) {
 
  571                    $usernames[$username]++;
 
  572                    $username .= 
" ($usernames[$username])";
 
  574                    $usernames[$username] = 1;
 
  577                $worksheet->setCell($row, $col++, $username);
 
  578                $worksheet->setCell($row, $col++, $userdata->getLogin());
 
  579                if (count($additionalFields)) {
 
  581                    foreach ($additionalFields as $fieldname) {
 
  582                        if (strcmp($fieldname, 
"matriculation") == 0) {
 
  583                            if (strlen($userfields[$fieldname])) {
 
  584                                $worksheet->setCell($row, $col++, $userfields[$fieldname]);
 
  589                        if (strcmp($fieldname, 
"exam_id") == 0) {
 
  590                            if (strlen($userfields[$fieldname])) {
 
  591                                $worksheet->setCell($row, $col++, $userdata->getExamIdFromScoredPass());
 
  598                $worksheet->setCell($row, $col++, $this->test_obj->getTitle());
 
  599                $pass = $userdata->getScoredPass();
 
  600                if (is_object($userdata) && is_array($userdata->getQuestions(
$pass))) {
 
  601                    foreach ($userdata->getQuestions(
$pass) as $question) {
 
  603                        if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(), 
'assSingleChoice') == 0) {
 
  604                            $solution = $objQuestion->getSolutionValues($active_id, 
$pass);
 
  605                            $pos = $positions[$question[
"id"]];
 
  606                            $selectedanswer = 
"x";
 
  607                            foreach ($objQuestion->getAnswers() as $id => $answer) {
 
  608                                if (strlen($solution[0][
"value1"]) && $id == $solution[0][
"value1"]) {
 
  609                                    $selectedanswer = $answer->getAnswertext();
 
  612                            $worksheet->setCell($row, $col + $pos, $selectedanswer);
 
  619            if ($this->test_obj->isSingleChoiceTestWithoutShuffle()) {
 
  623                $usernames = array();
 
  624                $allusersheet = 
false;
 
  627                $worksheet->addSheet($this->lng->txt(
'eval_all_users') . 
' (2)');
 
  630                $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'name'));
 
  631                $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'login'));
 
  632                if (count($additionalFields)) {
 
  633                    foreach ($additionalFields as $fieldname) {
 
  634                        if (strcmp($fieldname, 
"matriculation") == 0) {
 
  635                            $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'matriculation'));
 
  637                        if (strcmp($fieldname, 
"exam_id") == 0) {
 
  638                            $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'exam_id_label'));
 
  642                $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt(
'test'));
 
  643                foreach ($titles as $title) {
 
  644                    $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $title);
 
  646                $worksheet->setBold(
'A' . $row . 
':' . $worksheet->getColumnCoord($col - 1) . $row);
 
  649                foreach (
$data->getParticipants() as $active_id => $userdata) {
 
  650                    $username = (!is_null($userdata) && $userdata->getName()) ? $userdata->getName() : 
"ID $active_id";
 
  651                    if (array_key_exists($username, $usernames)) {
 
  652                        $usernames[$username]++;
 
  653                        $username .= 
" ($usernames[$username])";
 
  655                        $usernames[$username] = 1;
 
  658                    $worksheet->setCell($row, $col++, $username);
 
  659                    $worksheet->setCell($row, $col++, $userdata->getLogin());
 
  660                    if (count($additionalFields)) {
 
  662                        foreach ($additionalFields as $fieldname) {
 
  663                            if (strcmp($fieldname, 
"matriculation") == 0) {
 
  664                                if (strlen($userfields[$fieldname])) {
 
  665                                    $worksheet->setCell($row, $col++, $userfields[$fieldname]);
 
  670                            if (strcmp($fieldname, 
"exam_id") == 0) {
 
  671                                if (strlen($userfields[$fieldname])) {
 
  672                                    $worksheet->setCell($row, $col++, $userdata->getExamIdFromScoredPass());
 
  679                    $worksheet->setCell($row, $col++, $this->test_obj->getTitle());
 
  680                    $pass = $userdata->getScoredPass();
 
  681                    if (is_object($userdata) && is_array($userdata->getQuestions(
$pass))) {
 
  682                        foreach ($userdata->getQuestions(
$pass) as $question) {
 
  684                            if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(), 
'assSingleChoice') == 0) {
 
  685                                $solution = $objQuestion->getSolutionValues($active_id, 
$pass);
 
  686                                $pos = $positions[$question[
"aid"]];
 
  687                                $selectedanswer = chr(65 + $solution[0][
"value1"]);
 
  688                                $worksheet->setCell($row, $col + $pos, $selectedanswer);
 
  697            $usernames = array();
 
  698            $participantcount = count(
$data->getParticipants());
 
  699            $allusersheet = 
false;
 
  702            foreach (
$data->getParticipants() as $active_id => $userdata) {
 
  705                $username = (!is_null($userdata) && $userdata->getName()) ? $userdata->getName() : 
"ID $active_id";
 
  706                if (array_key_exists($username, $usernames)) {
 
  707                    $usernames[$username]++;
 
  708                    $username .= 
" ($i)";
 
  710                    $usernames[$username] = 1;
 
  713                if ($participantcount > 250) {
 
  714                    if (!$allusersheet || ($pages - 1) < floor($row / 64000)) {
 
  715                        $worksheet->addSheet($this->lng->txt(
"eval_all_users") . (($pages > 0) ? 
" (" . ($pages + 1) . 
")" : 
""));
 
  716                        $allusersheet = 
true;
 
  721                    $resultsheet = $worksheet->addSheet($username);
 
  724                $pass = $userdata->getScoredPass();
 
  725                $row = ($allusersheet) ? $row : 1;
 
  726                $worksheet->setCell($row, 0, sprintf($this->lng->txt(
"tst_result_user_name_pass"), 
$pass + 1, $userdata->getName()));
 
  727                $worksheet->setBold($worksheet->getColumnCoord(0) . $row);
 
  729                if (is_object($userdata) && is_array($userdata->getQuestions(
$pass))) {
 
  730                    foreach ($userdata->getQuestions(
$pass) as $question) {
 
  731                        require_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  733                        if (is_object($question)) {
 
  734                            $row = $question->setExportDetailsXLS($worksheet, $row, $active_id, 
$pass);
 
  742            $testname = $this->test_obj->getTitle();
 
  743            switch ($this->mode) {
 
  745                    $testname .= 
'_results';
 
  749            $worksheet->sendToClient($testname);
 
  752            $worksheet->writeToFile($excelfile);
 
  753            return $excelfile . 
'.xlsx';
 
  768    public function exportToCSV($deliver = 
true, $filterby = 
"", $filtertext = 
"", $passedonly = 
false)
 
  770        $this->test_obj->setAccessFilteredParticipantList(
 
  771            $this->test_obj->buildStatisticsAccessFilteredParticipantList()
 
  774        if (strcmp($this->mode, 
"aggregated") == 0) {
 
  781        if ($this->test_obj->getAnonymity()) {
 
  782            array_push($datarow, $this->lng->txt(
"counter"));
 
  785            array_push($datarow, $this->lng->txt(
"name"));
 
  787            array_push($datarow, $this->lng->txt(
"login"));
 
  790        $additionalFields = $this->test_obj->getEvaluationAdditionalFields();
 
  791        if (count($additionalFields)) {
 
  792            foreach ($additionalFields as $fieldname) {
 
  793                if (strcmp($fieldname, 
"exam_id") == 0) {
 
  794                    array_push($datarow, $this->lng->txt(
'exam_id_label'));
 
  798                array_push($datarow, $this->lng->txt($fieldname));
 
  802        array_push($datarow, $this->lng->txt(
"tst_stat_result_resultspoints"));
 
  804        array_push($datarow, $this->lng->txt(
"maximum_points"));
 
  806        array_push($datarow, $this->lng->txt(
"tst_stat_result_resultsmarks"));
 
  808        if ($this->test_obj->getECTSOutput()) {
 
  809            array_push($datarow, $this->lng->txt(
"ects_grade"));
 
  812        array_push($datarow, $this->lng->txt(
"tst_stat_result_qworkedthrough"));
 
  814        array_push($datarow, $this->lng->txt(
"tst_stat_result_qmax"));
 
  816        array_push($datarow, $this->lng->txt(
"tst_stat_result_pworkedthrough"));
 
  818        array_push($datarow, $this->lng->txt(
"tst_stat_result_timeofwork"));
 
  820        array_push($datarow, $this->lng->txt(
"tst_stat_result_atimeofwork"));
 
  822        array_push($datarow, $this->lng->txt(
"tst_stat_result_firstvisit"));
 
  824        array_push($datarow, $this->lng->txt(
"tst_stat_result_lastvisit"));
 
  827        array_push($datarow, $this->lng->txt(
"tst_stat_result_mark_median"));
 
  829        array_push($datarow, $this->lng->txt(
"tst_stat_result_rank_participant"));
 
  831        array_push($datarow, $this->lng->txt(
"tst_stat_result_rank_median"));
 
  833        array_push($datarow, $this->lng->txt(
"tst_stat_result_total_participants"));
 
  835        array_push($datarow, $this->lng->txt(
"tst_stat_result_median"));
 
  837        array_push($datarow, $this->lng->txt(
"scored_pass"));
 
  840        array_push($datarow, $this->lng->txt(
"pass"));
 
  843        $data = &$this->test_obj->getCompleteEvaluationData(
true, $filterby, $filtertext);
 
  844        $headerrow = $datarow;
 
  846        foreach (
$data->getParticipants() as $active_id => $userdata) {
 
  847            $datarow = $headerrow;
 
  850                if (
$data->getParticipant($active_id)->getPassed() == 
false) {
 
  856                if ($this->test_obj->getAnonymity()) {
 
  857                    array_push($datarow2, $counter);
 
  859                    array_push($datarow2, 
$data->getParticipant($active_id)->getName());
 
  860                    array_push($datarow2, 
$data->getParticipant($active_id)->getLogin());
 
  862                if (count($additionalFields)) {
 
  864                    foreach ($additionalFields as $fieldname) {
 
  865                        if (strcmp($fieldname, 
"gender") == 0) {
 
  866                            array_push($datarow2, $this->lng->txt(
"gender_" . $userfields[$fieldname]));
 
  867                        } elseif (strcmp($fieldname, 
"exam_id") == 0) {
 
  868                            array_push($datarow2, $userdata->getExamIdFromScoredPass());
 
  870                            array_push($datarow2, $userfields[$fieldname]);
 
  874                array_push($datarow2, 
$data->getParticipant($active_id)->getReached());
 
  875                array_push($datarow2, 
$data->getParticipant($active_id)->getMaxpoints());
 
  876                array_push($datarow2, 
$data->getParticipant($active_id)->getMark());
 
  877                if ($this->test_obj->getECTSOutput()) {
 
  878                    array_push($datarow2, 
$data->getParticipant($active_id)->getECTSMark());
 
  880                array_push($datarow2, 
$data->getParticipant($active_id)->getQuestionsWorkedThrough());
 
  881                array_push($datarow2, 
$data->getParticipant($active_id)->getNumberOfQuestions());
 
  882                array_push($datarow2, 
$data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() / 100.0);
 
  883                $time = 
$data->getParticipant($active_id)->getTimeOfWork();
 
  884                $time_seconds = $time;
 
  885                $time_hours = floor($time_seconds / 3600);
 
  886                $time_seconds -= $time_hours * 3600;
 
  887                $time_minutes = floor($time_seconds / 60);
 
  888                $time_seconds -= $time_minutes * 60;
 
  889                array_push($datarow2, sprintf(
"%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
 
  890                $time = 
$data->getParticipant($active_id)->getQuestionsWorkedThrough() ? 
$data->getParticipant($active_id)->getTimeOfWork() / 
$data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
 
  891                $time_seconds = $time;
 
  892                $time_hours = floor($time_seconds / 3600);
 
  893                $time_seconds -= $time_hours * 3600;
 
  894                $time_minutes = floor($time_seconds / 60);
 
  895                $time_seconds -= $time_minutes * 60;
 
  896                array_push($datarow2, sprintf(
"%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
 
  898                $fv = 
$data->getParticipant($active_id)->getFirstVisit();
 
  899                $lv = 
$data->getParticipant($active_id)->getLastVisit();
 
  900                foreach (array($fv, $lv) as $ts) {
 
  903                        array_push($datarow2, $visit);
 
  905                        array_push($datarow2, 
"");
 
  909                $median = 
$data->getStatistics()->getStatistics()->median();
 
  910                $pct = 
$data->getParticipant($active_id)->getMaxpoints() ? $median / 
$data->getParticipant($active_id)->getMaxpoints() * 100.0 : 0;
 
  911                $mark = $this->test_obj->mark_schema->getMatchingMark($pct);
 
  912                $mark_short_name = 
"";
 
  913                if (is_object($mark)) {
 
  914                    $mark_short_name = $mark->getShortName();
 
  916                array_push($datarow2, $mark_short_name);
 
  917                array_push($datarow2, 
$data->getStatistics()->getStatistics()->rank(
$data->getParticipant($active_id)->getReached()));
 
  918                array_push($datarow2, 
$data->getStatistics()->getStatistics()->rank_median());
 
  919                array_push($datarow2, 
$data->getStatistics()->getStatistics()->count());
 
  920                array_push($datarow2, $median);
 
  922                    array_push($datarow2, 
$data->getParticipant($active_id)->getBestPass() + 1);
 
  924                    array_push($datarow2, 
$data->getParticipant($active_id)->getLastPass() + 1);
 
  928                    if ($finishdate > 0) {
 
  930                            for (
$i = 1; 
$i < $col - 1; 
$i++) {
 
  931                                array_push($datarow2, 
"");
 
  932                                array_push($datarow, 
"");
 
  934                            array_push($datarow, 
"");
 
  936                        array_push($datarow2, 
$pass + 1);
 
  937                        if (is_object(
$data->getParticipant($active_id)) && is_array(
$data->getParticipant($active_id)->getQuestions(
$pass))) {
 
  938                            foreach (
$data->getParticipant($active_id)->getQuestions(
$pass) as $question) {
 
  939                                $question_data = 
$data->getParticipant($active_id)->getPass(
$pass)->getAnsweredQuestionByQuestionId($question[
"id"]);
 
  940                                array_push($datarow2, $question_data[
"reached"]);
 
  941                                array_push($datarow, preg_replace(
"/<.*?>/", 
"", 
$data->getQuestionTitle($question[
"id"])));
 
  944                        if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions() || ($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";
 
  981        $ilBench->start(
"TestExport", 
"buildExportFile");
 
  985        include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
 
  989        $this->xml->
xmlSetDtdDef(
"<!DOCTYPE Test SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co.dtd\">");
 
  992        $this->xml->xmlSetGenCmt(
"Export of ILIAS Test " .
 
  993            $this->test_obj->getId() . 
" of installation " . $this->inst . 
".");
 
  996        $this->xml->xmlHeader();
 
  998        $this->xml->xmlStartTag(
"ContentObject", array(
'Type' => 
'Test'));
 
 1001        $this->test_obj->createExportDirectory();
 
 1002        include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
 1004        ilUtil::makeDir($this->export_dir . 
"/" . $this->subdir . 
"/objects");
 
 1007        $expDir = $this->test_obj->getExportDirectory();
 
 1008        include_once 
"./Services/Logging/classes/class.ilLog.php";
 
 1009        $expLog = 
new ilLog($expDir, 
"export.log");
 
 1011        $expLog->setLogFormat(
"");
 
 1012        $expLog->write(date(
"[y-m-d H:i:s] ") . 
"Start Export");
 
 1015        $qti_file = fopen($this->export_dir . 
"/" . $this->subdir . 
"/" . $this->qti_filename, 
"w");
 
 1020        $ilBench->start(
"TestExport", 
"buildExportFile_getXML");
 
 1021        $this->test_obj->exportPagesXML(
 
 1024            $this->export_dir . 
"/" . $this->subdir,
 
 1027        $ilBench->stop(
"TestExport", 
"buildExportFile_getXML");
 
 1035        $this->xml->xmlEndTag(
"ContentObject");
 
 1045        $ilBench->start(
"TestExport", 
"buildExportFile_dumpToFile");
 
 1046        $this->xml->xmlDumpFile($this->export_dir . 
"/" . $this->subdir . 
"/" . $this->filename, 
false);
 
 1047        $ilBench->stop(
"TestExport", 
"buildExportFile_dumpToFile");
 
 1051            include_once 
"./Modules/Test/classes/class.ilTestResultsToXML.php";
 
 1052            $resultwriter = 
new ilTestResultsToXML($this->test_obj->getTestId(), $this->test_obj->getAnonymity());
 
 1053            $resultwriter->setIncludeRandomTestQuestionsEnabled($this->test_obj->isRandomTest());
 
 1054            $ilBench->start(
"TestExport", 
"buildExportFile_results");
 
 1055            $resultwriter->xmlDumpFile($this->export_dir . 
"/" . $this->subdir . 
"/" . $this->resultsfile, 
false);
 
 1056            $ilBench->stop(
"TestExport", 
"buildExportFile_results");
 
 1060        $ilBench->start(
"QuestionpoolExport", 
"buildExportFile_saveAdditionalMobs");
 
 1062        $ilBench->stop(
"QuestionpoolExport", 
"buildExportFile_saveAdditionalMobs");
 
 1065        $ilBench->start(
"TestExport", 
"buildExportFile_zipFile");
 
 1067            $this->export_dir . 
"/" . $this->subdir,
 
 1068            $this->export_dir . 
"/" . $this->subdir . 
".zip" 
 1070        $ilBench->stop(
"TestExport", 
"buildExportFile_zipFile");
 
 1073        $this->xml->_XmlWriter;
 
 1075        $expLog->write(date(
"[y-m-d H:i:s] ") . 
"Finished Export");
 
 1076        $ilBench->stop(
"TestExport", 
"buildExportFile");
 
 1078        return $this->export_dir . 
"/" . $this->subdir . 
".zip";
 
 1085        $tstQtiXml = $this->test_obj->toXML();
 
 1088        if (strpos($tstQtiXml, 
"</section>") !== 
false) {
 
 1089            $qtiXml = str_replace(
"</section>", 
"$qstQtiXml</section>", $tstQtiXml);
 
 1091            $qtiXml = str_replace(
"<section ident=\"1\"/>", 
"<section ident=\"1\">\n$qstQtiXml</section>", $tstQtiXml);
 
 1101        include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
 1103        $xml = $questionOBJ->toXML(
false);
 
 1106        $xml = preg_replace(
"/<questestinterop>/", 
"", 
$xml);
 
 1107        $xml = preg_replace(
"/<\/questestinterop>/", 
"", 
$xml);
 
 1114        include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 1117        foreach (
$mobs as $mob) {
 
 1120                $mob_obj->exportFiles($a_export_dir);
 
 1126            foreach (
$mobs as $mob) {
 
 1129                    $mob_obj->exportFiles($a_export_dir);
 
 1142        require_once 
'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentExporter.php';
 
 1144        $skillQuestionAssignmentExporter->setXmlWriter($a_xml_writer);
 
 1145        $skillQuestionAssignmentExporter->setQuestionIds($questions);
 
 1146        $skillQuestionAssignmentExporter->setAssignmentList($assignmentList);
 
 1147        $skillQuestionAssignmentExporter->export();
 
 1155        require_once 
'Modules/Test/classes/class.ilTestSkillLevelThresholdList.php';
 
 1157        $thresholdList->setTestId($this->test_obj->getTestId());
 
 1158        $thresholdList->loadFromDb();
 
 1160        require_once 
'Modules/Test/classes/class.ilTestSkillLevelThresholdExporter.php';
 
 1162        $skillLevelThresholdExporter->setXmlWriter($a_xml_writer);
 
 1163        $skillLevelThresholdExporter->setAssignmentList($assignmentList);
 
 1164        $skillLevelThresholdExporter->setThresholdList($thresholdList);
 
 1165        $skillLevelThresholdExporter->export();
 
 1176        require_once 
'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentList.php';
 
 1178        $assignmentList->setParentObjId($this->test_obj->getId());
 
 1179        $assignmentList->loadFromDb();
 
 1180        $assignmentList->loadAdditionalSkillData();
 
 1182        return $assignmentList;
 
An exception for terminatinating execution or to throw for unit testing.
static _instantiateQuestion($question_id)
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static lookupPassResultsUpdateTimestamp($active_id, $pass)
static _lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
setForcedAccessFilteredParticipantList(ilTestParticipantList $forcedAccessFilteredParticipantList)
__construct(&$a_test_obj, $a_mode="xml")
Constructor.
populateQuestionSetConfigXml(ilXmlWriter $xmlWriter)
$forcedAccessFilteredParticipantList
exportXHTMLMediaObjects($a_export_dir)
getAccessFilteredParticipantList()
buildExportResultFile()
build xml export file
buildExportFile()
build export file (complete zip file)
exportToCSV($deliver=true, $filterby="", $filtertext="", $passedonly=false)
Exports the evaluation data to the CSV file format.
getQuestionQtiXml($questionId)
aggregatedResultsToCSV($deliver=true)
Exports the aggregated results to CSV.
isResultExportingEnabledForTestExport()
getForcedAccessFilteredParticipantList()
buildExportFileXML()
build xml export file
aggregatedResultsToExcel($deliver=true)
Exports the aggregated results to the Microsoft Excel file format.
buildQuestionSkillAssignmentList()
populateSkillLevelThresholdsXml(ilXmlWriter $a_xml_writer, ilAssQuestionSkillAssignmentList $assignmentList)
$resultExportingEnabledForTestExport
populateQuestionSkillAssignmentsXml(ilXmlWriter $a_xml_writer, ilAssQuestionSkillAssignmentList $assignmentList, $questions)
exportToExcel($deliver=true, $filterby="", $filtertext="", $passedonly=false)
Exports the evaluation data to the Microsoft Excel file format.
setResultExportingEnabledForTestExport($resultExprtingEnabledForTestExport)
Test results to XML class.
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
xmlSetDtdDef($dtdDef)
Sets dtd definition.
redirection script todo: (a better solution should control the processing via a xml file)