/** * Standard Version of Fill Row. Most likely to * be overwritten by derived class. */ protected function fillRow($a_set) { global $ilCtrl; include_once "./Services/User/classes/class.ilObjUser.php"; $user = ilObjUser::_lookupFields($a_set); $ilCtrl->setParameterByClass("ilObjSurveyAdministrationGUI", "item_id", $user["usr_id"]); $this->tpl->setVariable("USER_ID", $user["usr_id"]); $this->tpl->setVariable("LOGIN", $user["login"]); $this->tpl->setVariable("FIRSTNAME", $user["firstname"]); $this->tpl->setVariable("LASTNAME", $user["lastname"]); }
/** * Returns an array containing all variables and values which can be exchanged in the certificate * The values should be calculated from real data. The $params parameter array should contain all * necessary information to calculate the values. * * @param array $params An array of parameters to calculate the certificate parameter values * @return array The certificate variables */ public function getCertificateVariablesForPresentation($params = array()) { global $lng; $user_id = $params["user_id"]; include_once './Services/User/classes/class.ilObjUser.php'; $user_data = ilObjUser::_lookupFields($user_id); include_once './Modules/Course/classes/class.ilCourseParticipants.php'; $completion_date = ilCourseParticipants::getDateTimeOfPassed($this->object->getId(), $user_id); $vars = $this->getBaseVariablesForPresentation($user_data, null, $completion_date); $vars["COURSE_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle()); $insert_tags = array(); foreach ($vars as $id => $caption) { $insert_tags["[" . $id . "]"] = $caption; } return $insert_tags; }
/** * Import relevant properties from given learning module * * @param ilObjSAHSLearningModule $a_lm * @return object */ public static function createFromSCORMLM(ilObjSAHSLearningModule $a_lm, $a_user_id) { global $lng; $lng->loadLanguageModule("sahs"); $newObj = new self(); $newObj->setTitle($a_lm->getTitle()); $newObj->setDescription($a_lm->getDescription()); include_once "Services/Tracking/classes/class.ilLPMarks.php"; $lp_marks = new ilLPMarks($a_lm->getId(), $a_user_id); $newObj->setProperty("issued_on", new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME)); // create certificate if (!stristr(get_class($a_lm), "2004")) { $last_access = ilObjSCORMLearningModule::_lookupLastAccess($a_lm->getId(), $a_user_id); } else { $last_access = ilObjSCORM2004LearningModule::_lookupLastAccess($a_lm->getId(), $a_user_id); } $params = array("user_data" => ilObjUser::_lookupFields($a_user_id), "last_access" => $last_access); include_once "Services/Certificate/classes/class.ilCertificate.php"; include_once "Modules/ScormAicc/classes/class.ilSCORMCertificateAdapter.php"; $certificate = new ilCertificate(new ilSCORMCertificateAdapter($a_lm)); $certificate = $certificate->outCertificate($params, false); // save pdf file if ($certificate) { // we need the object id for storing the certificate file $newObj->create(); $path = self::initStorage($newObj->getId(), "certificate"); $file_name = "sahs_" . $a_lm->getId() . "_" . $a_user_id . ".pdf"; if (file_put_contents($path . $file_name, $certificate)) { $newObj->setProperty("file", $file_name); $newObj->update(); return $newObj; } // file creation failed, so remove to object, too $newObj->delete(); } }
/** * Exports the evaluation data to the CSV file format * * Exports the evaluation data to the CSV file format * * @param string $filtertext Filter text for the user data * @param boolean $passedonly TRUE if only passed user datasets should be exported, FALSE otherwise * @access public */ function exportToCSV($deliver = TRUE, $filterby = "", $filtertext = "", $passedonly = FALSE) { global $ilLog; if (strcmp($this->mode, "aggregated") == 0) { return $this->aggregatedResultsToCSV($deliver); } $rows = array(); $datarow = array(); $col = 1; if ($this->test_obj->getAnonymity()) { array_push($datarow, $this->lng->txt("counter")); $col++; } else { array_push($datarow, $this->lng->txt("name")); $col++; array_push($datarow, $this->lng->txt("login")); $col++; } $additionalFields = $this->test_obj->getEvaluationAdditionalFields(); if (count($additionalFields)) { foreach ($additionalFields as $fieldname) { array_push($datarow, $this->lng->txt($fieldname)); $col++; } } array_push($datarow, $this->lng->txt("tst_stat_result_resultspoints")); $col++; array_push($datarow, $this->lng->txt("maximum_points")); $col++; array_push($datarow, $this->lng->txt("tst_stat_result_resultsmarks")); $col++; if ($this->test_obj->getECTSOutput()) { array_push($datarow, $this->lng->txt("ects_grade")); $col++; } array_push($datarow, $this->lng->txt("tst_stat_result_qworkedthrough")); $col++; array_push($datarow, $this->lng->txt("tst_stat_result_qmax")); $col++; array_push($datarow, $this->lng->txt("tst_stat_result_pworkedthrough")); $col++; array_push($datarow, $this->lng->txt("tst_stat_result_timeofwork")); $col++; array_push($datarow, $this->lng->txt("tst_stat_result_atimeofwork")); $col++; array_push($datarow, $this->lng->txt("tst_stat_result_firstvisit")); $col++; array_push($datarow, $this->lng->txt("tst_stat_result_lastvisit")); $col++; array_push($datarow, $this->lng->txt("tst_stat_result_mark_median")); $col++; array_push($datarow, $this->lng->txt("tst_stat_result_rank_participant")); $col++; array_push($datarow, $this->lng->txt("tst_stat_result_rank_median")); $col++; array_push($datarow, $this->lng->txt("tst_stat_result_total_participants")); $col++; array_push($datarow, $this->lng->txt("tst_stat_result_median")); $col++; array_push($datarow, $this->lng->txt("scored_pass")); $col++; array_push($datarow, $this->lng->txt("pass")); $col++; $data =& $this->test_obj->getCompleteEvaluationData(TRUE, $filterby, $filtertext); $headerrow = $datarow; $counter = 1; foreach ($data->getParticipants() as $active_id => $userdata) { $datarow = $headerrow; $remove = FALSE; if ($passedonly) { if ($data->getParticipant($active_id)->getPassed() == FALSE) { $remove = TRUE; } } if (!$remove) { $datarow2 = array(); if ($this->test_obj->getAnonymity()) { array_push($datarow2, $counter); } else { array_push($datarow2, $data->getParticipant($active_id)->getName()); array_push($datarow2, $data->getParticipant($active_id)->getLogin()); } if (count($additionalFields)) { $userfields = ilObjUser::_lookupFields($userdata->getUserID()); foreach ($additionalFields as $fieldname) { if (strcmp($fieldname, "gender") == 0) { array_push($datarow2, $this->lng->txt("gender_" . $userfields[$fieldname])); } else { array_push($datarow2, $userfields[$fieldname]); } } } array_push($datarow2, $data->getParticipant($active_id)->getReached()); array_push($datarow2, $data->getParticipant($active_id)->getMaxpoints()); array_push($datarow2, $data->getParticipant($active_id)->getMark()); if ($this->test_obj->getECTSOutput()) { array_push($datarow2, $data->getParticipant($active_id)->getECTSMark()); } array_push($datarow2, $data->getParticipant($active_id)->getQuestionsWorkedThrough()); array_push($datarow2, $data->getParticipant($active_id)->getNumberOfQuestions()); array_push($datarow2, $data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() / 100.0); $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; array_push($datarow2, 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; array_push($datarow2, sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds)); $fv = $data->getParticipant($active_id)->getFirstVisit(); $lv = $data->getParticipant($active_id)->getLastVisit(); foreach (array($fv, $lv) as $ts) { if ($ts) { $visit = ilFormat::formatDate(date('Y-m-d H:i:s', $ts), "datetime", false, false); array_push($datarow2, $visit); } else { array_push($datarow2, ""); } } $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(); } array_push($datarow2, $mark_short_name); array_push($datarow2, $data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached())); array_push($datarow2, $data->getStatistics()->getStatistics()->rank_median()); array_push($datarow2, $data->getStatistics()->getStatistics()->count()); array_push($datarow2, $median); if ($this->test_obj->getPassScoring() == SCORE_BEST_PASS) { array_push($datarow2, $data->getParticipant($active_id)->getBestPass() + 1); } else { array_push($datarow2, $data->getParticipant($active_id)->getLastPass() + 1); } for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++) { $finishdate = $this->test_obj->getPassFinishDate($active_id, $pass); if ($finishdate > 0) { if ($pass > 0) { for ($i = 1; $i < $col - 1; $i++) { array_push($datarow2, ""); array_push($datarow, ""); } array_push($datarow, ""); } array_push($datarow2, $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"]); array_push($datarow2, $question_data["reached"]); array_push($datarow, preg_replace("/<.*?>/", "", $data->getQuestionTitle($question["id"]))); } } if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions() || $counter == 1 && $pass == 0) { array_push($rows, $datarow); } $datarow = array(); array_push($rows, $datarow2); $datarow2 = array(); } } $counter++; } } $csv = ""; $separator = ";"; foreach ($rows as $evalrow) { $csvrow =& $this->test_obj->processCSVRow($evalrow, TRUE, $separator); $csv .= join($csvrow, $separator) . "\n"; } if ($deliver) { ilUtil::deliverData($csv, ilUtil::getASCIIFilename($this->test_obj->getTitle() . "_results.csv")); exit; } else { return $csv; } }
/** * Creates a user, sets preferences, lookups data, delete user * @group IL_Init */ public function testCreateSetLookupDelete() { include_once "./Services/User/classes/class.ilObjUser.php"; // delete all aatestuser from previous runs while (($i = ilObjUser::_lookupId("aatestuser")) > 0) { $user = new ilObjUser($i); $user->delete(); } $user = new ilObjUser(); // creation $d = array("login" => "aatestuser", "passwd_type" => IL_PASSWD_PLAIN, "passwd" => "password", "gender" => "m", "firstname" => "Max", "lastname" => "Mutzke", "email" => "*****@*****.**", "client_ip" => "1.2.3.4", "ext_account" => "ext_mutzke"); $user->assignData($d); $user->create(); $user->saveAsNew(); $user->setLanguage("no"); $user->writePrefs(); $id = $user->getId(); $value .= $user->getFirstname() . "-"; // update $user->setFirstname("Maxi"); $user->update(); $value .= $user->getFirstname() . "-"; // other update methods $user->refreshLogin(); // lookups $value .= ilObjUser::_lookupEmail($id) . "-"; $value .= ilObjUser::_lookupGender($id) . "-"; $value .= ilObjUser::_lookupClientIP($id) . "-"; $n = ilObjUser::_lookupName($id); $value .= $n["lastname"] . "-"; ilObjUser::_lookupFields($id); $value .= ilObjUser::_lookupLogin($id) . "-"; $value .= ilObjUser::_lookupExternalAccount($id) . "-"; $value .= ilObjUser::_lookupId("aatestuser") . "-"; ilObjUser::_lookupLastLogin($id); $value .= ilObjUser::_lookupLanguage($id) . "-"; ilObjUser::_readUsersProfileData(array($id)); if (ilObjUser::_loginExists("aatestuser")) { $value .= "le-"; } // preferences... $user->writePref("testpref", "pref1"); $value .= ilObjUser::_lookupPref($id, "testpref") . "-"; $user->deletePref("testpref"); if (ilObjUser::_lookupPref($id, "testpref") == "") { $value .= "pref2" . "-"; } // activation $user->setActive(false); if (!ilObjUser::getStoredActive($id)) { } $value .= "act1-"; $user->setActive(true); if (ilObjUser::getStoredActive($id)) { } $value .= "act2-"; ilObjUser::_toggleActiveStatusOfUsers(array($id), false); if (!ilObjUser::getStoredActive($id)) { } $value .= "act3-"; // deletion $user->delete(); $this->assertEquals("Max-Maxi-de@de.de-m-1.2.3.4-Mutzke-aatestuser-ext_mutzke-{$id}-no-le-" . "pref1-pref2-act1-act2-act3-", $value); }
/** * Returns an array containing all variables and values which can be exchanged in the certificate * The values should be calculated from real data. The $params parameter array should contain all * necessary information to calculate the values. * * @param array $params An array of parameters to calculate the certificate parameter values * @return array The certificate variables */ public function getCertificateVariablesForPresentation($params = array()) { global $lng; $active_id = $params["active_id"]; $pass = $params["pass"]; $userfilter = array_key_exists("userfilter", $params) ? $params["userfilter"] : ""; $passedonly = array_key_exists("passedonly", $params) ? $params["passedonly"] : FALSE; if (strlen($pass)) { $result_array =& $this->object->getTestResult($active_id, $pass); } else { $result_array =& $this->object->getTestResult($active_id); } if ($passedonly && $result_array["test"]["passed"] == FALSE) { return ""; } $passed = $result_array["test"]["passed"] ? $lng->txt("certificate_passed") : $lng->txt("certificate_failed"); if (!$result_array["test"]["total_max_points"]) { $percentage = 0; } else { $percentage = $result_array["test"]["total_reached_points"] / $result_array["test"]["total_max_points"] * 100; } $mark_obj = $this->object->mark_schema->getMatchingMark($percentage); $user_id = $this->object->_getUserIdFromActiveId($active_id); include_once './Services/User/classes/class.ilObjUser.php'; $user_data = ilObjUser::_lookupFields($user_id); if (strlen($userfilter)) { if (!@preg_match("/{$userfilter}/i", $user_data["lastname"] . ", " . $user_data["firstname"] . " " . $user_data["title"])) { return ""; } } if ($user_data["usr_id"] > 0) { $completion_date = $this->getUserCompletionDate($user_data["usr_id"]); } else { $completion_date = false; } $vars = $this->getBaseVariablesForPresentation($user_data, null, $completion_date); $vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($passed); $vars["RESULT_POINTS"] = ilUtil::prepareFormOutput($result_array["test"]["total_reached_points"]); $vars["RESULT_PERCENT"] = sprintf("%2.2f", $percentage) . "%"; $vars["MAX_POINTS"] = ilUtil::prepareFormOutput($result_array["test"]["total_max_points"]); $vars["RESULT_MARK_SHORT"] = ilUtil::prepareFormOutput($mark_obj->getShortName()); $vars["RESULT_MARK_LONG"] = ilUtil::prepareFormOutput($mark_obj->getOfficialName()); $vars["TEST_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle()); foreach ($vars as $id => $caption) { $insert_tags["[" . $id . "]"] = $caption; } return $insert_tags; }
/** * Download the certificate for the active user */ public function downloadCertificate() { global $ilUser, $tree, $ilCtrl; $allowed = false; $last_access = 0; $obj_id = ilObject::_lookupObjId($_GET["ref_id"]); include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php"; if (ilObjSAHSLearningModuleAccess::_lookupUserCertificate($obj_id)) { include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php"; $type = ilObjSAHSLearningModule::_lookupSubType($obj_id); switch ($type) { case "scorm": include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php"; $allowed = true; $last_access = ilObjSCORMLearningModule::_lookupLastAccess($obj_id, $ilUser->getId()); break; case "scorm2004": include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php"; $allowed = true; $last_access = ilObjSCORM2004LearningModule::_lookupLastAccess($obj_id, $ilUser->getId()); break; default: break; } } if ($allowed) { include_once "./Services/Certificate/classes/class.ilCertificate.php"; include_once "./Modules/ScormAicc/classes/class.ilSCORMCertificateAdapter.php"; $certificate = new ilCertificate(new ilSCORMCertificateAdapter($this->slm)); $params = array("user_data" => ilObjUser::_lookupFields($ilUser->getId()), "last_access" => $last_access); $certificate->outCertificate($params, true); exit; } // redirect to parent category if certificate is not accessible $parent = $tree->getParentId($_GET["ref_id"]); $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $parent); $ilCtrl->redirectByClass("ilrepositorygui", ""); }
/** * Returns an array containing all variables and values which can be exchanged in the certificate * The values should be calculated from real data. The $params parameter array should contain all * necessary information to calculate the values. * * @param array $params An array of parameters to calculate the certificate parameter values * @return array The certificate variables */ public function getCertificateVariablesForPresentation($params = array()) { global $lng; $user_id = $params["user_id"]; include_once 'Services/Tracking/classes/class.ilLPMarks.php'; $mark = ilLPMarks::_lookupMark($user_id, $this->object->getId()); include_once 'Modules/Exercise/classes/class.ilExerciseMembers.php'; $status = ilExerciseMembers::_lookupStatus($this->object->getId(), $user_id); $user_data = ilObjUser::_lookupFields($user_id); $completion_date = $this->getUserCompletionDate($user_id); $vars = $this->getBaseVariablesForPresentation($user_data, null, $completion_date); $vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($lng->txt("exc_" . $status)); $vars["RESULT_MARK"] = ilUtil::prepareFormOutput($mark); $vars["EXERCISE_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle()); foreach ($vars as $id => $caption) { $insert_tags["[" . $id . "]"] = $caption; } return $insert_tags; }
/** * Creates the evaluation output for the test * * @access public */ function outEvaluation() { /** * @var $ilAcccess ilAccessHandler * @var $ilToolbar ilToolbarGUI */ global $ilAccess, $ilToolbar; 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"); } include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php"; $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation', $this->object->getAnonymity(), $this->object->isOfferingQuestionHintsEnabled()); $data = array(); $arrFilter = array(); foreach ($table_gui->getFilterItems() as $item) { if ($item->getValue() !== false) { switch ($item->getPostVar()) { case 'group': case 'name': case 'course': $arrFilter[$item->getPostVar()] = $item->getValue(); break; case 'passed_only': $passedonly = $item->getChecked(); break; } } } include_once "./Modules/Test/classes/class.ilTestEvaluationData.php"; $eval = new ilTestEvaluationData($this->object); $eval->setFilterArray($arrFilter); $foundParticipants =& $eval->getParticipants(); $counter = 1; if (count($foundParticipants) > 0) { if ($this->object->getECTSOutput()) { $passed_array =& $this->object->getTotalPointsPassedArray(); } foreach ($foundParticipants as $active_id => $userdata) { /* @var $userdata ilTestEvaluationUserData */ $remove = FALSE; if ($passedonly) { $mark_obj = $this->object->getMarkSchema()->getMatchingMark($userdata->getReachedPointsInPercent()); if ($mark_obj->getPassed() == FALSE || !$userdata->areObligationsAnswered()) { $remove = TRUE; } } if (!$remove) { // build the evaluation row $evaluationrow = array(); if ($this->object->getAnonymity()) { $evaluationrow['name'] = $counter; $evaluationrow['login'] = ''; } else { $evaluationrow['name'] = $userdata->getName(); if (strlen($userdata->getLogin())) { $evaluationrow['login'] = "******" . $userdata->getLogin() . "]"; } else { $evaluationrow['login'] = ''; } } $evaluationrow['reached'] = $userdata->getReached(); $evaluationrow['max'] = $userdata->getMaxpoints(); $evaluationrow['hint_count'] = $userdata->getRequestedHintsCountFromScoredPass(); $percentage = $userdata->getReachedPointsInPercent(); $mark = $this->object->getMarkSchema()->getMatchingMark($percentage); if (is_object($mark)) { $evaluationrow['mark'] = $mark->getShortName(); } if ($this->object->getECTSOutput()) { $ects_mark = $this->object->getECTSGrade($passed_array, $userdata->getReached(), $userdata->getMaxPoints()); $evaluationrow['ects_grade'] = $ects_mark; } $evaluationrow['answered'] = $userdata->getQuestionsWorkedThroughInPercent(); $evaluationrow['questions_worked_through'] = $userdata->getQuestionsWorkedThrough(); $evaluationrow['number_of_questions'] = $userdata->getNumberOfQuestions(); $time_seconds = $userdata->getTimeOfWork(); $time_hours = floor($time_seconds / 3600); $time_seconds -= $time_hours * 3600; $time_minutes = floor($time_seconds / 60); $time_seconds -= $time_minutes * 60; $evaluationrow['working_time'] = sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds); $this->ctrl->setParameter($this, "active_id", $active_id); $href = $this->ctrl->getLinkTarget($this, "detailedEvaluation"); $detailed_evaluation = $this->lng->txt("detailed_evaluation_show"); $evaluationrow['details'] = "<a class=\"il_ContainerItemCommand\" href=\"{$href}\">{$detailed_evaluation}</a>"; $userfields = ilObjUser::_lookupFields($userdata->getUserID()); $evaluationrow['gender'] = $userfields['gender']; $evaluationrow['email'] = $userfields['email']; $evaluationrow['institution'] = $userfields['institution']; $evaluationrow['street'] = $userfields['street']; $evaluationrow['city'] = $userfields['city']; $evaluationrow['zipcode'] = $userfields['zipcode']; $evaluationrow['country'] = $userfields['country']; $evaluationrow['sel_country'] = $userfields['sel_country']; $evaluationrow['department'] = $userfields['department']; $evaluationrow['matriculation'] = $userfields['matriculation']; $counter++; $data[] = $evaluationrow; } } } $table_gui->setData($data); if (count($foundParticipants) > 0) { $ilToolbar->setFormName('form_output_eval'); $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'exportEvaluation')); require_once 'Services/Form/classes/class.ilSelectInputGUI.php'; $export_type = new ilSelectInputGUI($this->lng->txt('exp_eval_data'), 'export_type'); $options = array('excel' => $this->lng->txt('exp_type_excel'), 'csv' => $this->lng->txt('exp_type_spss')); if (!$this->object->getAnonymity()) { include_once 'Services/Certificate/classes/class.ilCertificate.php'; include_once 'Modules/Test/classes/class.ilTestCertificateAdapter.php'; if (ilCertificate::_isComplete(new ilTestCertificateAdapter($this->object))) { $options['certificate'] = $this->lng->txt('exp_type_certificate'); } } $export_type->setOptions($options); $ilToolbar->addInputItem($export_type, true); require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php'; $button = ilSubmitButton::getInstance(); $button->setCommand('exportEvaluation'); $button->setCaption('export'); $button->getOmitPreventDoubleSubmission(); $ilToolbar->addButtonInstance($button); } $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print"); if ($this->object->getShowSolutionAnswersOnly()) { $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print"); } $this->tpl->setContent($table_gui->getHTML()); }
/** * Creates the evaluation output for the test * * @access public */ function outEvaluation() { 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"); } include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php"; $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation', $this->object->getAnonymity(), $this->object->isOfferingQuestionHintsEnabled()); $data = array(); $arrFilter = array(); foreach ($table_gui->getFilterItems() as $item) { if ($item->getValue() !== false) { switch ($item->getPostVar()) { case 'group': case 'name': case 'course': $arrFilter[$item->getPostVar()] = $item->getValue(); break; case 'passed_only': $passedonly = $item->getChecked(); break; } } } include_once "./Modules/Test/classes/class.ilTestEvaluationData.php"; $eval = new ilTestEvaluationData($this->object); $eval->setFilterArray($arrFilter); $foundParticipants =& $eval->getParticipants(); $counter = 1; if (count($foundParticipants) > 0) { if ($this->object->ects_output) { $passed_array =& $this->object->getTotalPointsPassedArray(); } foreach ($foundParticipants as $active_id => $userdata) { /* @var $userdata ilTestEvaluationUserData */ $remove = FALSE; if ($passedonly) { $mark_obj = $this->object->getMarkSchema()->getMatchingMark($userdata->getReachedPointsInPercent()); if ($mark_obj->getPassed() == FALSE || !$userdata->areObligationsAnswered()) { $remove = TRUE; } } if (!$remove) { // build the evaluation row $userfields = ilObjUser::_lookupFields($userdata->getUserID()); foreach ($userfields as $key => $value) { $evaluationrow[$key] = strlen($value) ? $value : ' '; } $evaluationrow = array(); $fullname = ""; if ($this->object->getAnonymity()) { $fullname = $counter; $evaluationrow['name'] = $fullname; $evaluationrow['login'] = ''; } else { $evaluationrow['name'] = $userdata->getName(); if (strlen($userdata->getLogin())) { $evaluationrow['login'] = "******" . $userdata->getLogin() . "]"; } else { $evaluationrow['login'] = ''; } } $evaluationrow['reached'] = $userdata->getReached(); $evaluationrow['max'] = $userdata->getMaxpoints(); $evaluationrow['hint_count'] = $userdata->getRequestedHintsCountFromScoredPass(); $percentage = $userdata->getReachedPointsInPercent(); $mark = $this->object->getMarkSchema()->getMatchingMark($percentage); if (is_object($mark)) { $evaluationrow['mark'] = $mark->getShortName(); } if ($this->object->ects_output) { $ects_mark = $this->object->getECTSGrade($passed_array, $userdata->getReached(), $userdata->getMaxPoints()); $evaluationrow['ects_grade'] = $ects_mark; } $evaluationrow['answered'] = $userdata->getQuestionsWorkedThrough() . " " . strtolower($this->lng->txt("of")) . " " . $userdata->getNumberOfQuestions() . " (" . sprintf("%2.2f", $userdata->getQuestionsWorkedThroughInPercent()) . " %" . ")"; $time_seconds = $userdata->getTimeOfWork(); $time_hours = floor($time_seconds / 3600); $time_seconds -= $time_hours * 3600; $time_minutes = floor($time_seconds / 60); $time_seconds -= $time_minutes * 60; $evaluationrow['working_time'] = sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds); $this->ctrl->setParameter($this, "active_id", $active_id); $href = $this->ctrl->getLinkTarget($this, "detailedEvaluation"); $detailed_evaluation = $this->lng->txt("detailed_evaluation_show"); $evaluationrow['details'] = "<a class=\"il_ContainerItemCommand\" href=\"{$href}\">{$detailed_evaluation}</a>"; $userfields = ilObjUser::_lookupFields($userdata->getUserID()); $evaluationrow['gender'] = $userfields['gender']; $evaluationrow['email'] = $userfields['email']; $evaluationrow['institution'] = $userfields['institution']; $evaluationrow['street'] = $userfields['street']; $evaluationrow['city'] = $userfields['city']; $evaluationrow['zipcode'] = $userfields['zipcode']; $evaluationrow['country'] = $userfields['country']; $evaluationrow['departement'] = $userfields['departement']; $evaluationrow['matriculation'] = $userfields['matriculation']; $counter++; array_push($data, $evaluationrow); } } } $table_gui->setData($data); $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_evaluation.html", "Modules/Test"); $this->tpl->setVariable('EVALUATION_DATA', $table_gui->getHTML()); if (count($foundParticipants) > 0) { $template = new ilTemplate("tpl.il_as_tst_evaluation_export.html", TRUE, TRUE, "Modules/Test"); $template->setVariable("EXPORT_DATA", $this->lng->txt("exp_eval_data")); if (!$this->object->getAnonymity()) { include_once "./Services/Certificate/classes/class.ilCertificate.php"; include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php"; if (ilCertificate::_isComplete(new ilTestCertificateAdapter($this->object))) { $template->setVariable("TEXT_CERTIFICATE", $this->lng->txt("exp_type_certificate")); } } $template->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel")); $template->setVariable("TEXT_CSV", $this->lng->txt("exp_type_spss")); $template->setVariable("CMD_EXPORT", "exportEvaluation"); $template->setVariable("BTN_EXPORT", $this->lng->txt("export")); $template->setVariable("BTN_PRINT", $this->lng->txt("print")); $template->setVariable("BTN_COMMAND", $this->ctrl->getCmd()); $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "exportEvaluation")); $exportoutput = $template->get(); $this->tpl->setVariable("EVALUATION_EXPORT", $exportoutput); } $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print"); if ($this->object->getShowSolutionAnswersOnly()) { $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print"); } }