protected function exportActiveIDs() { global $ilDB, $ilSetting; include_once "./Modules/Test/classes/class.ilObjTestAccess.php"; $assessmentSetting = new ilSetting("assessment"); $user_criteria = $assessmentSetting->get("user_criteria"); if (strlen($user_criteria) == 0) { $user_criteria = 'usr_id'; } if ($this->anonymized) { $result = $ilDB->queryF("SELECT * FROM tst_active WHERE test_fi = %s", array('integer'), array($this->test_id)); } else { $result = $ilDB->queryF("SELECT tst_active.*, usr_data." . $user_criteria . " FROM tst_active, usr_data WHERE tst_active.test_fi = %s AND tst_active.user_fi = usr_data.usr_id", array('integer'), array($this->test_id)); } $this->xmlStartTag("tst_active", NULL); while ($row = $ilDB->fetchAssoc($result)) { $attrs = array('active_id' => $row['active_id'], 'user_fi' => $row['user_fi'], 'anonymous_id' => $row['anonymous_id'], 'test_fi' => $row['test_fi'], 'lastindex' => $row['lastindex'], 'tries' => $row['tries'], 'submitted' => $row['submitted'], 'submittimestamp' => $row['submittimestamp'], 'tstamp' => $row['tstamp']); $attrs['fullname'] = ilObjTestAccess::_getParticipantData($row['active_id']); if (!$this->anonymized) { $attrs['user_criteria'] = $user_criteria; $attrs[$user_criteria] = $row[$user_criteria]; } array_push($this->active_ids, $row['active_id']); $this->xmlElement("row", $attrs); } $this->xmlEndTag("tst_active"); }
/** * Saves the manual feedback for a question in a test * * @param integer $active_id Active ID of the user * @param integer $question_id Question ID * @param integer $pass Pass number * @param string $feedback The feedback text * @return boolean TRUE if the operation succeeds, FALSE otherwise * @access public */ function saveManualFeedback($active_id, $question_id, $pass, $feedback) { global $ilDB; $affectedRows = $ilDB->manipulateF("DELETE FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $question_id, $pass)); if (strlen($feedback)) { $next_id = $ilDB->nextId('tst_manual_fb'); /** @var ilDB $ilDB */ $result = $ilDB->insert('tst_manual_fb', array('manual_feedback_id' => array('integer', $next_id), 'active_fi' => array('integer', $active_id), 'question_fi' => array('integer', $question_id), 'pass' => array('integer', $pass), 'feedback' => array('clob', ilRTE::_replaceMediaObjectImageSrc($feedback, 0)), 'tstamp' => array('integer', time()))); include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { global $lng, $ilUser; include_once "./Modules/Test/classes/class.ilObjTestAccess.php"; $username = ilObjTestAccess::_getParticipantData($active_id); include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $this->logAction(sprintf($lng->txtlng("assessment", "log_manual_feedback", ilObjAssessmentFolder::_getLogLanguage()), $ilUser->getFullname() . " (" . $ilUser->getLogin() . ")", $username, assQuestion::_getQuestionTitle($question_id), $feedback)); } } if (PEAR::isError($result)) { global $ilias; $ilias->raiseError($result->getMessage()); } else { return TRUE; } }
/** * Creates the output of the test participants * * @access public */ function participantsObject() { global $ilAccess, $ilToolbar, $lng; $this->getParticipantsSubTabs(); if (!$ilAccess->checkAccess("write", "", $this->ref_id)) { // allow only write access ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true); $this->ctrl->redirect($this, "infoScreen"); } if ($this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken($this->tree)) { ilUtil::sendFailure($this->testQuestionSetConfigFactory->getQuestionSetConfig()->getDepenciesBrokenMessage($this->lng)); } elseif ($this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesInVulnerableState($this->tree)) { ilUtil::sendInfo($this->questionSetConfig->getDepenciesInVulnerableStateMessage($this->lng)); } if ($this->object->getFixedParticipants()) { // search button include_once './Services/Search/classes/class.ilRepositorySearchGUI.php'; ilRepositorySearchGUI::fillAutoCompleteToolbar($this, $tb, array('auto_complete_name' => $lng->txt('user'), 'submit_name' => $lng->txt('add'))); // search button $ilToolbar->addButton($this->lng->txt("tst_search_users"), $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI', 'start')); $participants =& $this->object->getInvitedUsers(); $rows = array(); foreach ($participants as $data) { $maxpass = $this->object->_getMaxPass($data["active_id"]); if (!is_null($maxpass)) { $maxpass += 1; } $access = ""; if (strlen($data["active_id"])) { $last_access = $this->object->_getLastAccess($data["active_id"]); $access = $last_access; } $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']); if ($data['active_id'] == null) { if (strlen($data["firstname"] . $data["lastname"]) == 0) { $fullname = $lng->txt("deleted_user"); } else { if ($this->object->getAnonymity()) { $fullname = $lng->txt('anonymous'); } else { $fullname = trim($data["lastname"] . ", " . $data["firstname"] . " " . $data["title"]); } } } else { include_once "./Modules/Test/classes/class.ilObjTestAccess.php"; $fullname = ilObjTestAccess::_getParticipantData($data['active_id']); } array_push($rows, array('usr_id' => $data["usr_id"], 'active_id' => $data['active_id'], 'login' => $data["login"], 'clientip' => $data["clientip"], 'firstname' => $data["firstname"], 'lastname' => $data["lastname"], 'name' => $fullname, 'started' => $data["active_id"] > 0 ? 1 : 0, 'finished' => $data["test_finished"] == 1 ? 1 : 0, 'access' => $access, 'maxpass' => $maxpass, 'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview'))); } include_once "./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php"; $table_gui = new ilTestFixedParticipantsTableGUI($this, 'participants', $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken(), $this->object->getAnonymity(), count($rows)); $table_gui->setFilterCommand('fpSetFilter'); $table_gui->setResetCommand('fpResetFiler'); $rows = $this->applyFilterCriteria($rows); $table_gui->setData($rows); $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML()); } else { $participants =& $this->object->getTestParticipants(); $rows = array(); foreach ($participants as $data) { $maxpass = $this->object->_getMaxPass($data["active_id"]); if (!is_null($maxpass)) { $maxpass += 1; } $access = ""; if (strlen($data["active_id"])) { $last_access = $this->object->_getLastAccess($data["active_id"]); $access = $last_access; } $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']); include_once "./Modules/Test/classes/class.ilObjTestAccess.php"; $fullname = ilObjTestAccess::_getParticipantData($data['active_id']); array_push($rows, array('usr_id' => $data["active_id"], 'active_id' => $data['active_id'], 'login' => $data["login"], 'name' => $fullname, 'firstname' => $data["firstname"], 'lastname' => $data["lastname"], 'started' => $data["active_id"] > 0 ? 1 : 0, 'finished' => $data["test_finished"] == 1 ? 1 : 0, 'access' => $access, 'maxpass' => $maxpass, 'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview'))); } include_once "./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php"; $table_gui = new ilTestParticipantsTableGUI($this, 'participants', $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken(), $this->object->getAnonymity(), count($rows)); $table_gui->setFilterCommand('npSetFilter'); $table_gui->setResetCommand('npResetFilter'); $rows = $this->applyFilterCriteria($rows); $table_gui->setData($rows); $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML()); } }
/** * Generates a ZIP file containing all file uploads for a given test and the original id of the question * * @param int $test_id */ public function getFileUploadZIPFile($test_id) { /** @var ilDB $ilDB */ global $ilDB; $query = "\n\t\tSELECT \n\t\t\ttst_solutions.solution_id, tst_solutions.pass, tst_solutions.active_fi, tst_solutions.question_fi, \n\t\t\ttst_solutions.value1, tst_solutions.value2, tst_solutions.tstamp \n\t\tFROM tst_solutions, tst_active, qpl_questions \n\t\tWHERE tst_solutions.active_fi = tst_active.active_id \n\t\tAND tst_solutions.question_fi = qpl_questions.question_id \n\t\tAND tst_solutions.question_fi = %s \n\t\tAND tst_active.test_fi = %s \n\t\tORDER BY tst_solutions.active_fi, tst_solutions.tstamp"; $result = $ilDB->queryF($query, array("integer", "integer"), array($this->getId(), $test_id)); $zipfile = ilUtil::ilTempnam() . ".zip"; $tempdir = ilUtil::ilTempnam(); if ($result->numRows()) { $userdata = array(); $data .= "<html><head>"; $data .= '<meta http-equiv="content-type" content="text/html; charset=UTF-8" />'; $data .= '<style> table { border: 1px #333 solid; border-collapse:collapse;} td, th { border: 1px #333 solid; padding: 0.25em;} th { color: #fff; background-color: #666;} </style> '; $data .= "<title>" . $this->getTitle() . "</title></head><body>\n"; $data .= "<h1>" . $this->getTitle() . "</h1>\n"; $data .= "<table><thead>\n"; $data .= "<tr><th>" . $this->lng->txt("name") . "</th><th>" . $this->lng->txt("filename") . "</th><th>" . $this->lng->txt("pass") . "</th><th>" . $this->lng->txt("location") . "</th><th>" . $this->lng->txt("date") . "</th></tr></thead><tbody>\n"; while ($row = $ilDB->fetchAssoc($result)) { ilUtil::makeDirParents($tempdir . "/" . $row["active_fi"] . "/" . $row["question_fi"]); @copy($this->getFileUploadPath($test_id, $row["active_fi"], $row["question_fi"]) . $row["value1"], $tempdir . "/" . $row["active_fi"] . "/" . $row["question_fi"] . "/" . $row["value1"]); if (!array_key_exists($row["active_fi"], $userdata)) { include_once "./Modules/Test/classes/class.ilObjTestAccess.php"; $userdata[$row["active_fi"]] = ilObjTestAccess::_getParticipantData($row["active_fi"]); } $data .= "<tr><td>" . $userdata[$row["active_fi"]] . "</td><td><a href=\"" . $row["active_fi"] . "/" . $row["question_fi"] . "/" . $row["value1"] . "\" target=\"_blank\">" . $row["value2"] . "</a></td><td>" . $row["pass"] . "</td><td>" . $row["active_fi"] . "/" . $row["question_fi"] . "/" . $row["value1"] . "</td>"; $data .= "<td>" . ilFormat::fmtDateTime(ilFormat::unixtimestamp2datetime($row["tstamp"]), $this->lng->txt("lang_dateformat"), $this->lng->txt("lang_timeformat"), "datetime", FALSE) . "</td>"; $data .= "</tr>\n"; } $data .= "</tbody></table>\n"; $data .= "</body></html>\n"; $indexfile = $tempdir . "/index.html"; $fh = fopen($indexfile, 'w'); fwrite($fh, $data); fclose($fh); } ilUtil::zip($tempdir, $zipfile); ilUtil::delDir($tempdir); ilUtil::deliverFile($zipfile, ilUtil::getASCIIFilename($this->getTitle() . ".zip"), "application/zip", false, true); }
/** * Sets the points, a learner has reached answering the question * Additionally objective results are updated * * @param integer $user_id The database ID of the learner * @param integer $test_id The database Id of the test containing the question * @param integer $points The points the user has reached answering the question * @return boolean true on success, otherwise false * @access public */ function _setReachedPoints($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled) { global $ilDB; if ($points <= $maxpoints) { if (is_null($pass)) { $pass = assQuestion::_getSolutionMaxPass($question_id, $active_id); } // retrieve the already given points $old_points = 0; $result = $ilDB->queryF("SELECT points FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $question_id, $pass)); $manual = $manualscoring ? 1 : 0; $rowsnum = $result->numRows(); if ($rowsnum) { $row = $ilDB->fetchAssoc($result); $old_points = $row["points"]; if ($old_points != $points) { $affectedRows = $ilDB->manipulateF("UPDATE tst_test_result SET points = %s, manual = %s, tstamp = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('float', 'integer', 'integer', 'integer', 'integer', 'integer'), array($points, $manual, time(), $active_id, $question_id, $pass)); } } else { $next_id = $ilDB->nextId('tst_test_result'); $affectedRows = $ilDB->manipulateF("INSERT INTO tst_test_result (test_result_id, active_fi, question_fi, points, pass, manual, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)", array('integer', 'integer', 'integer', 'float', 'integer', 'integer', 'integer'), array($next_id, $active_id, $question_id, $points, $pass, $manual, time())); } if ($old_points != $points || !$rowsnum) { assQuestion::_updateTestPassResults($active_id, $pass, $obligationsEnabled); // finally update objective result include_once "./Modules/Test/classes/class.ilObjTest.php"; include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php'; ilCourseObjectiveResult::_updateObjectiveResult(ilObjTest::_getUserIdFromActiveId($active_id), $question_id, $points); include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { global $lng, $ilUser; include_once "./Modules/Test/classes/class.ilObjTestAccess.php"; $username = ilObjTestAccess::_getParticipantData($active_id); assQuestion::_logAction(sprintf($lng->txtlng("assessment", "log_answer_changed_points", ilObjAssessmentFolder::_getLogLanguage()), $username, $old_points, $points, $ilUser->getFullname() . " (" . $ilUser->getLogin() . ")"), $active_id, $question_id); } } return TRUE; } else { return FALSE; } }