Esempio n. 1
0
 function createRandomSolutions($number)
 {
     global $ilDB;
     // 1. get a user
     $query = "SELECT usr_id FROM usr_data";
     $result = $ilDB->query($query);
     while ($data = $ilDB->fetchAssoc($result)) {
         $activequery = sprintf("SELECT user_fi FROM tst_active WHERE test_fi = %s AND user_fi = %s", $ilDB->quote($this->getTestId()), $ilDB->quote($data['usr_id']));
         $activeresult = $ilDB->query($activequery);
         if ($activeresult->numRows() == 0) {
             $user_id = $data['usr_id'];
             if ($user_id != 13) {
                 include_once "./Modules/Test/classes/class.ilTestSession.php";
                 $testSession = FALSE;
                 $testSession = new ilTestSession();
                 $testSession->setRefId($this->getRefId());
                 $testSession->setTestId($this->getTestId());
                 $testSession->setUserId($user_id);
                 $testSession->saveToDb();
                 $passes = $this->getNrOfTries() ? $this->getNrOfTries() : 10;
                 $nr_of_passes = rand(1, $passes);
                 $active_id = $testSession->getActiveId();
                 for ($pass = 0; $pass < $nr_of_passes; $pass++) {
                     include_once "./Modules/Test/classes/class.ilTestSequence.php";
                     $testSequence = new ilTestSequence($active_id, $pass, $this->isRandomTest());
                     if (!$testSequence->hasSequence()) {
                         $testSequence->createNewSequence($this->getQuestionCount(), $shuffle);
                         $testSequence->saveToDb();
                     }
                     for ($seq = 1; $seq <= count($this->questions); $seq++) {
                         $question_id = $testSequence->getQuestionForSequence($seq);
                         $objQuestion = ilObjTest::_instanciateQuestion($question_id);
                         $objQuestion->createRandomSolution($testSession->getActiveId(), $pass);
                     }
                     if ($pass < $nr_of_passes - 1) {
                         $testSession->increasePass();
                         $testSession->setLastSequence(0);
                         $testSession->saveToDb();
                     } else {
                         $testSession->setSubmitted(1);
                         $testSession->setSubmittedTimestamp(date('Y-m-d H:i:s'));
                         $testSession->saveToDb();
                     }
                 }
                 $number--;
                 if ($number == 0) {
                     return;
                 }
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Exports the evaluation data to the Microsoft Excel file format
  *
  * @param bool    $deliver
  * @param string  $filterby
  * @param string  $filtertext Filter text for the user data
  * @param boolean $passedonly TRUE if only passed user datasets should be exported, FALSE otherwise
  *
  * @return string
  */
 public function exportToExcel($deliver = TRUE, $filterby = "", $filtertext = "", $passedonly = FALSE)
 {
     if (strcmp($this->mode, "aggregated") == 0) {
         return $this->aggregatedResultsToExcel($deliver);
     }
     require_once './Services/Excel/classes/class.ilExcelWriterAdapter.php';
     $excelfile = ilUtil::ilTempnam();
     $adapter = new ilExcelWriterAdapter($excelfile, FALSE);
     $testname = $this->test_obj->getTitle();
     switch ($this->mode) {
         case 'results':
             $testname .= '_results';
             break;
     }
     $testname = ilUtil::getASCIIFilename(preg_replace("/\\s/", "_", $testname)) . ".xls";
     $workbook = $adapter->getWorkbook();
     $workbook->setVersion(8);
     // Use Excel97/2000 Format
     // Creating a worksheet
     $format_bold =& $workbook->addFormat();
     $format_bold->setBold();
     $format_percent =& $workbook->addFormat();
     $format_percent->setNumFormat("0.00%");
     $format_datetime =& $workbook->addFormat();
     $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
     $format_title =& $workbook->addFormat();
     $format_title->setBold();
     $format_title->setColor('black');
     $format_title->setPattern(1);
     $format_title->setFgColor('silver');
     require_once './Services/Excel/classes/class.ilExcelUtils.php';
     $worksheet =& $workbook->addWorksheet(ilExcelUtils::_convert_text($this->lng->txt("tst_results")));
     $additionalFields = $this->test_obj->getEvaluationAdditionalFields();
     $row = 0;
     $col = 0;
     if ($this->test_obj->getAnonymity()) {
         $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("counter")), $format_title);
     } else {
         $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("name")), $format_title);
         $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("login")), $format_title);
     }
     if (count($additionalFields)) {
         foreach ($additionalFields as $fieldname) {
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt($fieldname)), $format_title);
         }
     }
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_resultspoints")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("maximum_points")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_resultsmarks")), $format_title);
     if ($this->test_obj->getECTSOutput()) {
         $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("ects_grade")), $format_title);
     }
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_qworkedthrough")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_qmax")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_pworkedthrough")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_timeofwork")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_atimeofwork")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_firstvisit")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_lastvisit")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_mark_median")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_rank_participant")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_rank_median")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_total_participants")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_median")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("scored_pass")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("pass")), $format_title);
     $counter = 1;
     $data =& $this->test_obj->getCompleteEvaluationData(TRUE, $filterby, $filtertext);
     $firstrowwritten = false;
     foreach ($data->getParticipants() as $active_id => $userdata) {
         $remove = FALSE;
         if ($passedonly) {
             if ($data->getParticipant($active_id)->getPassed() == FALSE) {
                 $remove = TRUE;
             }
         }
         if (!$remove) {
             $row++;
             if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions()) {
                 $row++;
             }
             $col = 0;
             if ($this->test_obj->getAnonymity()) {
                 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($counter));
             } else {
                 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getName()));
                 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getLogin()));
             }
             if (count($additionalFields)) {
                 $userfields = ilObjUser::_lookupFields($userdata->getUserID());
                 foreach ($additionalFields as $fieldname) {
                     if (strcmp($fieldname, "gender") == 0) {
                         $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("gender_" . $userfields[$fieldname])));
                     } else {
                         $worksheet->write($row, $col++, ilExcelUtils::_convert_text($userfields[$fieldname]));
                     }
                 }
             }
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getReached()));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getMaxpoints()));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getMark()));
             if ($this->test_obj->getECTSOutput()) {
                 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getECTSMark()));
             }
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getQuestionsWorkedThrough()));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getNumberOfQuestions()));
             $worksheet->write($row, $col++, $data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() / 100.0, $format_percent);
             $time = $data->getParticipant($active_id)->getTimeOfWork();
             $time_seconds = $time;
             $time_hours = floor($time_seconds / 3600);
             $time_seconds -= $time_hours * 3600;
             $time_minutes = floor($time_seconds / 60);
             $time_seconds -= $time_minutes * 60;
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text(sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds)));
             $time = $data->getParticipant($active_id)->getQuestionsWorkedThrough() ? $data->getParticipant($active_id)->getTimeOfWork() / $data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
             $time_seconds = $time;
             $time_hours = floor($time_seconds / 3600);
             $time_seconds -= $time_hours * 3600;
             $time_minutes = floor($time_seconds / 60);
             $time_seconds -= $time_minutes * 60;
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text(sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds)));
             $fv = getdate($data->getParticipant($active_id)->getFirstVisit());
             $firstvisit = ilUtil::excelTime($fv["year"], $fv["mon"], $fv["mday"], $fv["hours"], $fv["minutes"], $fv["seconds"]);
             $worksheet->write($row, $col++, $firstvisit, $format_datetime);
             $lv = getdate($data->getParticipant($active_id)->getLastVisit());
             $lastvisit = ilUtil::excelTime($lv["year"], $lv["mon"], $lv["mday"], $lv["hours"], $lv["minutes"], $lv["seconds"]);
             $worksheet->write($row, $col++, $lastvisit, $format_datetime);
             $median = $data->getStatistics()->getStatistics()->median();
             $pct = $data->getParticipant($active_id)->getMaxpoints() ? $median / $data->getParticipant($active_id)->getMaxpoints() * 100.0 : 0;
             $mark = $this->test_obj->mark_schema->getMatchingMark($pct);
             $mark_short_name = "";
             if (is_object($mark)) {
                 $mark_short_name = $mark->getShortName();
             }
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($mark_short_name));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached())));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getStatistics()->getStatistics()->rank_median()));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getStatistics()->getStatistics()->count()));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($median));
             if ($this->test_obj->getPassScoring() == SCORE_BEST_PASS) {
                 $worksheet->write($row, $col++, $data->getParticipant($active_id)->getBestPass() + 1);
             } else {
                 $worksheet->write($row, $col++, $data->getParticipant($active_id)->getLastPass() + 1);
             }
             $startcol = $col;
             for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++) {
                 $col = $startcol;
                 $finishdate = $this->test_obj->getPassFinishDate($active_id, $pass);
                 if ($finishdate > 0) {
                     if ($pass > 0) {
                         $row++;
                         if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions()) {
                             $row++;
                         }
                     }
                     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($pass + 1));
                     if (is_object($data->getParticipant($active_id)) && is_array($data->getParticipant($active_id)->getQuestions($pass))) {
                         foreach ($data->getParticipant($active_id)->getQuestions($pass) as $question) {
                             $question_data = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
                             $worksheet->write($row, $col, ilExcelUtils::_convert_text($question_data["reached"]));
                             if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions()) {
                                 $worksheet->write($row - 1, $col, ilExcelUtils::_convert_text(preg_replace("/<.*?>/", "", $data->getQuestionTitle($question["id"]))), $format_title);
                             } else {
                                 if ($pass == 0 && !$firstrowwritten) {
                                     $worksheet->write(0, $col, ilExcelUtils::_convert_text(preg_replace("/<.*?>/", "", $data->getQuestionTitle($question["id"]))), $format_title);
                                 }
                             }
                             $col++;
                         }
                         $firstrowwritten = true;
                     }
                 }
             }
             $counter++;
         }
     }
     if ($this->test_obj->getExportSettingsSingleChoiceShort() && !$this->test_obj->isRandomTest() && $this->test_obj->hasSingleChoiceQuestions()) {
         // special tab for single choice tests
         $titles =& $this->test_obj->getQuestionTitlesAndIndexes();
         $positions = array();
         $pos = 0;
         $row = 0;
         foreach ($titles as $id => $title) {
             $positions[$id] = $pos;
             $pos++;
         }
         $usernames = array();
         $participantcount = count($data->getParticipants());
         $allusersheet = false;
         $pages = 0;
         $resultsheet =& $workbook->addWorksheet($this->lng->txt("eval_all_users"));
         $col = 0;
         $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('name')), $format_title);
         $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('login')), $format_title);
         if (count($additionalFields)) {
             foreach ($additionalFields as $fieldname) {
                 if (strcmp($fieldname, "matriculation") == 0) {
                     $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('matriculation')), $format_title);
                 }
             }
         }
         $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('test')), $format_title);
         foreach ($titles as $title) {
             $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($title), $format_title);
         }
         $row++;
         foreach ($data->getParticipants() as $active_id => $userdata) {
             $username = !is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName()) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID {$active_id}";
             if (array_key_exists($username, $usernames)) {
                 $usernames[$username]++;
                 $username .= " ({$i})";
             } else {
                 $usernames[$username] = 1;
             }
             $col = 0;
             $resultsheet->write($row, $col++, $username);
             $resultsheet->write($row, $col++, $userdata->getLogin());
             if (count($additionalFields)) {
                 $userfields = ilObjUser::_lookupFields($userdata->getUserID());
                 foreach ($additionalFields as $fieldname) {
                     if (strcmp($fieldname, "matriculation") == 0) {
                         if (strlen($userfields[$fieldname])) {
                             $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($userfields[$fieldname]));
                         } else {
                             $col++;
                         }
                     }
                 }
             }
             $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->test_obj->getTitle()));
             $pass = $userdata->getScoredPass();
             if (is_object($userdata) && is_array($userdata->getQuestions($pass))) {
                 foreach ($userdata->getQuestions($pass) as $question) {
                     $objQuestion =& $this->test_obj->_instanciateQuestion($question["aid"]);
                     if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(), 'assSingleChoice') == 0) {
                         $solution = $objQuestion->getSolutionValues($active_id, $pass);
                         $pos = $positions[$question["aid"]];
                         $selectedanswer = "x";
                         foreach ($objQuestion->getAnswers() as $id => $answer) {
                             if (strlen($solution[0]["value1"]) && $id == $solution[0]["value1"]) {
                                 $selectedanswer = $answer->getAnswertext();
                             }
                         }
                         $resultsheet->write($row, $col + $pos, ilExcelUtils::_convert_text($selectedanswer));
                     }
                 }
             }
             $row++;
         }
         if ($this->test_obj->isSingleChoiceTestWithoutShuffle()) {
             // special tab for single choice tests without shuffle option
             $pos = 0;
             $row = 0;
             $usernames = array();
             $allusersheet = false;
             $pages = 0;
             $resultsheet =& $workbook->addWorksheet($this->lng->txt("eval_all_users") . " (2)");
             $col = 0;
             $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('name')), $format_title);
             $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('login')), $format_title);
             if (count($additionalFields)) {
                 foreach ($additionalFields as $fieldname) {
                     if (strcmp($fieldname, "matriculation") == 0) {
                         $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('matriculation')), $format_title);
                     }
                 }
             }
             $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('test')), $format_title);
             foreach ($titles as $title) {
                 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($title), $format_title);
             }
             $row++;
             foreach ($data->getParticipants() as $active_id => $userdata) {
                 $username = !is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName()) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID {$active_id}";
                 if (array_key_exists($username, $usernames)) {
                     $usernames[$username]++;
                     $username .= " ({$i})";
                 } else {
                     $usernames[$username] = 1;
                 }
                 $col = 0;
                 $resultsheet->write($row, $col++, $username);
                 $resultsheet->write($row, $col++, $userdata->getLogin());
                 if (count($additionalFields)) {
                     $userfields = ilObjUser::_lookupFields($userdata->getUserID());
                     foreach ($additionalFields as $fieldname) {
                         if (strcmp($fieldname, "matriculation") == 0) {
                             if (strlen($userfields[$fieldname])) {
                                 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($userfields[$fieldname]));
                             } else {
                                 $col++;
                             }
                         }
                     }
                 }
                 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->test_obj->getTitle()));
                 $pass = $userdata->getScoredPass();
                 if (is_object($userdata) && is_array($userdata->getQuestions($pass))) {
                     foreach ($userdata->getQuestions($pass) as $question) {
                         $objQuestion =& $this->test_obj->_instanciateQuestion($question["aid"]);
                         if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(), 'assSingleChoice') == 0) {
                             $solution = $objQuestion->getSolutionValues($active_id, $pass);
                             $pos = $positions[$question["aid"]];
                             $selectedanswer = chr(65 + $solution[0]["value1"]);
                             $resultsheet->write($row, $col + $pos, ilExcelUtils::_convert_text($selectedanswer));
                         }
                     }
                 }
                 $row++;
             }
         }
     } else {
         // test participant result export
         $usernames = array();
         $participantcount = count($data->getParticipants());
         $allusersheet = false;
         $pages = 0;
         $i = 0;
         foreach ($data->getParticipants() as $active_id => $userdata) {
             $i++;
             $username = !is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName()) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID {$active_id}";
             if (array_key_exists($username, $usernames)) {
                 $usernames[$username]++;
                 $username .= " ({$i})";
             } else {
                 $usernames[$username] = 1;
             }
             if ($participantcount > 250) {
                 if (!$allusersheet || $pages - 1 < floor($row / 64000)) {
                     $resultsheet =& $workbook->addWorksheet($this->lng->txt("eval_all_users") . ($pages > 0 ? " (" . ($pages + 1) . ")" : ""));
                     $allusersheet = true;
                     $row = 0;
                     $pages++;
                 }
             } else {
                 $resultsheet =& $workbook->addWorksheet($username);
             }
             if (method_exists($resultsheet, "writeString")) {
                 $pass = $userdata->getScoredPass();
                 $row = $allusersheet ? $row : 0;
                 $resultsheet->writeString($row, 0, ilExcelUtils::_convert_text(sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $userdata->getName())), $format_bold);
                 $row += 2;
                 if (is_object($userdata) && is_array($userdata->getQuestions($pass))) {
                     foreach ($userdata->getQuestions($pass) as $question) {
                         require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                         $question = assQuestion::_instanciateQuestion($question["id"]);
                         if (is_object($question)) {
                             $row = $question->setExportDetailsXLS($resultsheet, $row, $active_id, $pass, $format_title, $format_bold);
                         }
                     }
                 }
             }
         }
     }
     $workbook->close();
     if ($deliver) {
         ilUtil::deliverFile($excelfile, $testname, "application/vnd.ms-excel", false, true);
         exit;
     } else {
         return $excelfile;
     }
 }
Esempio n. 3
0
 function &getSequenceSummary($obligationsFilter = false)
 {
     $correctedsequence = $this->getCorrectedSequence();
     $result_array = array();
     include_once "./Modules/Test/classes/class.ilObjTest.php";
     $solved_questions = ilObjTest::_getSolvedQuestions($this->active_id);
     $key = 1;
     foreach ($correctedsequence as $sequence) {
         $question =& ilObjTest::_instanciateQuestion($this->getQuestionForSequence($sequence));
         if (is_object($question)) {
             $worked_through = $question->_isWorkedThrough($this->active_id, $question->getId(), $this->pass);
             $solved = 0;
             if (array_key_exists($question->getId(), $solved_questions)) {
                 $solved = $solved_questions[$question->getId()]["solved"];
             }
             $is_postponed = $this->isPostponedQuestion($question->getId());
             $row = array("nr" => "{$key}", "title" => $question->getTitle(), "qid" => $question->getId(), "visited" => $worked_through, "solved" => $solved ? "1" : "0", "description" => $question->getComment(), "points" => $question->getMaximumPoints(), "worked_through" => $worked_through, "postponed" => $is_postponed, "sequence" => $sequence, "obligatory" => ilObjTest::isQuestionObligatory($question->getId()), 'isAnswered' => $question->isAnswered($this->active_id, $this->pass));
             if (!$obligationsFilter || $row['obligatory']) {
                 array_push($result_array, $row);
             }
             $key++;
         }
     }
     return $result_array;
 }
 function __read()
 {
     global $ilDB, $tree;
     include_once './Modules/Test/classes/class.ilObjTest.php';
     include_once 'Modules/Course/classes/class.ilCourseObjective.php';
     $container_ref_ids = ilObject::_getAllReferences(ilCourseObjective::_lookupContainerIdByObjectiveId($this->objective_id));
     $container_ref_id = current($container_ref_ids);
     // Read test data
     $query = "SELECT * FROM crs_objective_tst " . "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " ";
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $this->tests[$row->ref_id]['test_objective_id'] = $row->test_objective_id;
         $this->tests[$row->ref_id]['ref_id'] = $row->ref_id;
         $this->tests[$row->ref_id]['obj_id'] = $row->obj_id;
         $this->tests[$row->ref_id]['status'] = $row->tst_status;
         $this->tests[$row->ref_id]['limit'] = $row->tst_limit_p;
     }
     $this->questions = array();
     $query = "SELECT * FROM crs_objective_qst coq " . "JOIN qpl_questions qq ON coq.question_id = qq.question_id " . "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " . "ORDER BY title";
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         if (!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id, $row->ref_id)) {
             $this->__deleteTest($row->ref_id);
             continue;
         }
         if (!($question = ilObjTest::_instanciateQuestion($row->question_id))) {
             $this->delete($row->question_id);
             continue;
         }
         $qst['ref_id'] = $row->ref_id;
         $qst['obj_id'] = $row->obj_id;
         $qst['question_id'] = $row->question_id;
         $qst['qst_ass_id'] = $row->qst_ass_id;
         $qst['title'] = $question->getTitle();
         $qst['description'] = $question->getComment();
         $qst['test_type'] = $this->tests[$row->ref_id]['status'];
         $qst['points'] = $question->getPoints();
         $this->questions[$row->qst_ass_id] = $qst;
     }
     return true;
 }
 /**
  * parse
  *
  * @access public
  * @param array array of assignable nodes (tree node data)
  * @return
  */
 public function parse($a_assignable)
 {
     global $objDefinition;
     // begin-patch lok
     $a_assignable = $this->getTestNode();
     // end-patch lok
     $tests = array();
     foreach ($a_assignable as $node) {
         $tmp_data = array();
         $subobjects = array();
         if (!($tmp_tst = ilObjectFactory::getInstanceByRefId((int) $node['ref_id'], false))) {
             continue;
         }
         include_once './Modules/Test/classes/class.ilObjTest.php';
         $tmp_data['random'] = ilObjTest::_lookupRandomTest($node['obj_id']);
         $tmp_data['random'] = false;
         foreach ($qst = $this->sortQuestions($tmp_tst->getAllQuestions()) as $question_data) {
             $tmp_question = ilObjTest::_instanciateQuestion($question_data['question_id']);
             #$sub['qst_txt'] = $tmp_question->_getQuestionText($question_data['question_id']);
             $sub['qst_txt'] = '';
             $sub['qst_points'] = $tmp_question->_getMaximumPoints($question_data['question_id']);
             $sub['title'] = $tmp_question->getTitle();
             $sub['description'] = $tmp_question->getComment();
             $sub['id'] = $question_data['question_id'];
             $subobjects[] = $sub;
         }
         $tmp_data['title'] = $node['title'];
         $tmp_data['description'] = $node['description'];
         $tmp_data['type'] = $node['type'];
         $tmp_data['id'] = $node['child'];
         $tmp_data['obj_id'] = $node['obj_id'];
         $tmp_data['sub'] = $subobjects;
         $tests[] = $tmp_data;
     }
     $this->setData($tests);
 }
 /**
  * Creates user results for single questions
  *
  * @access public
  */
 function singleResults()
 {
     global $ilAccess;
     if (!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id) && !$ilAccess->checkAccess("write", "", $this->ref_id)) {
         // allow only evaluation access
         ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
         $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
     }
     $data =& $this->object->getCompleteEvaluationData();
     $color_class = array("tblrow1", "tblrow2");
     $counter = 0;
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_single_answers.html", "Modules/Test");
     $foundParticipants =& $data->getParticipants();
     if (count($foundParticipants) == 0) {
         ilUtil::sendInfo($this->lng->txt("tst_no_evaluation_data"));
         return;
     } else {
         $rows = array();
         foreach ($data->getQuestionTitles() as $question_id => $question_title) {
             $answered = 0;
             $reached = 0;
             $max = 0;
             foreach ($foundParticipants as $userdata) {
                 $pass = $userdata->getScoredPass();
                 if (is_object($userdata->getPass($pass))) {
                     $question =& $userdata->getPass($pass)->getAnsweredQuestionByQuestionId($question_id);
                     if (is_array($question)) {
                         $answered++;
                     }
                 }
             }
             $counter++;
             $this->ctrl->setParameter($this, "qid", $question_id);
             $question_object =& ilObjTest::_instanciateQuestion($question_id);
             $download = "";
             if (method_exists($question_object, "hasFileUploads")) {
                 if ($question_object->hasFileUploads($this->object->getTestId())) {
                     $download = "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportFileUploadsForAllParticipants") . "\">" . $this->lng->txt("download") . "</a>";
                 }
             }
             array_push($rows, array($question_title, $answered, "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportQuestionForAllParticipants") . "\">" . $this->lng->txt("pdf_export") . "</a>", $download));
         }
         if (count($rows)) {
             include_once "./Modules/Test/classes/tables/class.ilResultsByQuestionTableGUI.php";
             $table_gui = new ilResultsByQuestionTableGUI($this, "singleResults", $this->object->hasPDFProcessing());
             $table_gui->setTitle($this->lng->txt("tst_answered_questions_test"));
             $table_gui->setData($rows);
             $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $table_gui->getHTML());
         } else {
             $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $this->lng->txt("adm_no_special_users"));
         }
     }
 }
 /**
  * Deletes a question from the question pool
  *
  * @param integer $question_id The database id of the question
  * @access private
  */
 function deleteQuestion($question_id)
 {
     include_once "./Modules/Test/classes/class.ilObjTest.php";
     $question =& ilObjTest::_instanciateQuestion($question_id);
     $question->delete($question_id);
 }