4 include_once
"./Services/Object/classes/class.ilObjectAccess.php";
5 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
6 include_once
'./Services/Conditions/interfaces/interface.ilConditionHandling.php';
37 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id =
"")
42 $rbacsystem = $DIC[
'rbacsystem'];
43 $ilAccess = $DIC[
'ilAccess'];
45 if ($a_user_id ==
"") {
49 $is_admin = $rbacsystem->checkAccessOfUser($a_user_id,
'write', $a_ref_id);
52 switch ($a_permission) {
84 public static function _isPassed($user_id, $a_obj_id)
89 "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
90 array(
'integer',
'integer'),
91 array($user_id, $a_obj_id)
95 "SELECT tst_active.active_id FROM tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s",
96 array(
'integer',
'integer'),
97 array($user_id, $a_obj_id)
100 if (
$row[
'active_id'] > 0) {
101 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
108 "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
109 array(
'integer',
'integer'),
110 array($user_id, $a_obj_id)
114 "SELECT tst_pass_result.*, tst_tests.pass_scoring, tst_tests.random_test, tst_tests.test_id FROM tst_pass_result, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_pass_result.active_fi = tst_active.active_id ORDER BY tst_pass_result.pass",
115 array(
'integer',
'integer'),
116 array($user_id, $a_obj_id)
120 array_push($points,
$row);
124 if ($points[0][
"pass_scoring"] == 0) {
125 $reached = $points[count($points) - 1][
"points"];
126 $max = $points[count($points) - 1][
"maxpoints"];
128 $active_id = $points[count($points) - 1][
"active_fi"];
129 $pass = $points[count($points) - 1][
"pass"];
130 if (strlen($active_id) && strlen(
$pass)) {
131 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
132 $res = assQuestion::_updateTestPassResults($active_id,
$pass, null, $a_obj_id);
133 $max =
$res[
'maxpoints'];
134 $reached =
$res[
'points'];
138 foreach ($points as
$row) {
139 if ($row[
"points"] > $reached) {
140 $reached = $row[
"points"];
141 $max = $row[
"maxpoints"];
143 $active_id = $row[
"active_fi"];
144 $pass = $row[
"pass"];
145 if (strlen($active_id) && strlen(
$pass)) {
146 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
147 $res = assQuestion::_updateTestPassResults($active_id,
$pass, null, $a_obj_id);
148 $max =
$res[
'maxpoints'];
149 $reached =
$res[
'points'];
155 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
156 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
158 return ($mark[
"passed"]) ? true :
false;
161 return (
$row[
'passed']) ? true :
false;
172 public static function isFailed($user_id, $a_obj_id)
175 $ilDB = $DIC[
'ilDB'];
177 $ret = self::updateTestResultCache($user_id, $a_obj_id);
184 "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
185 array(
'integer',
'integer'),
186 array($user_id, $a_obj_id)
191 "SELECT tst_pass_result.*, tst_tests.pass_scoring, tst_tests.random_test, tst_tests.test_id FROM tst_pass_result, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_pass_result.active_fi = tst_active.active_id ORDER BY tst_pass_result.pass",
192 array(
'integer',
'integer'),
193 array($user_id, $a_obj_id)
197 array_push($points,
$row);
201 if ($points[0][
"pass_scoring"] == 0) {
202 $reached = $points[count($points) - 1][
"points"];
203 $max = $points[count($points) - 1][
"maxpoints"];
205 $active_id = $points[count($points) - 1][
"active_fi"];
206 $pass = $points[count($points) - 1][
"pass"];
207 if (strlen($active_id) && strlen(
$pass)) {
208 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
209 $res = assQuestion::_updateTestPassResults($active_id,
$pass, null, $a_obj_id);
210 $max =
$res[
'maxpoints'];
211 $reached =
$res[
'points'];
215 foreach ($points as
$row) {
216 if ($row[
"points"] > $reached) {
217 $reached = $row[
"points"];
218 $max = $row[
"maxpoints"];
220 $active_id = $row[
"active_fi"];
221 $pass = $row[
"pass"];
222 if (strlen($active_id) && strlen(
$pass)) {
223 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
224 $res = assQuestion::_updateTestPassResults($active_id,
$pass, null, $a_obj_id);
225 $max =
$res[
'maxpoints'];
226 $reached =
$res[
'points'];
232 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
233 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
235 return ($mark[
"failed"]) ? true :
false;
238 return (
$row[
'failed']) ? true :
false;
250 $ilDB = $DIC[
'ilDB'];
253 "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests " .
254 "WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s " .
255 "AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
256 array(
'integer',
'integer'),
257 array($a_user_id, $a_obj_id)
261 "SELECT tst_active.active_id FROM tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s",
262 array(
'integer',
'integer'),
263 array($a_user_id, $a_obj_id)
266 if (
$row[
'active_id'] > 0) {
267 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
284 include_once
'./Services/Conditions/classes/class.ilConditionHandler.php';
299 public static function checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
301 include_once
'./Services/Conditions/classes/class.ilConditionHandler.php';
303 switch ($a_operator) {
338 array(
"permission" =>
"write",
"cmd" =>
"questionsTabGateway",
"lang_var" =>
"tst_edit_questions"),
339 array(
"permission" =>
"write",
"cmd" =>
"ilObjTestSettingsGeneralGUI::showForm",
"lang_var" =>
"settings"),
340 array(
"permission" =>
"read",
"cmd" =>
"infoScreen",
"lang_var" =>
"tst_run",
343 array(
"permission" =>
"tst_statistics",
"cmd" =>
"outEvaluation",
"lang_var" =>
"tst_statistical_evaluation"),
344 array(
"permission" =>
"read",
"cmd" =>
"userResultsGateway",
"lang_var" =>
"tst_test_results")
360 $ilDB = $DIC[
'ilDB'];
363 "SELECT complete FROM tst_tests WHERE obj_fi=%s",
371 return (
$row[
'complete']) ? true :
false;
390 if (!isset(self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"])) {
391 require_once
'Modules/Test/classes/class.ilTestParticipantData.php';
392 require_once
'Modules/Test/classes/class.ilTestSessionFactory.php';
393 require_once
'Modules/Test/classes/class.ilTestPassesSelector.php';
396 $ilDB = $DIC[
'ilDB'];
402 $partData->setUserIdsFilter(array($a_user_id));
403 $partData->load($testOBJ->getTestId());
405 $activeId = $partData->getActiveIdByUserId($a_user_id);
408 $testSession = $testSessionFactory->getSession($activeId);
411 $testPassesSelector->setActiveId($activeId);
412 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
414 self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
417 return (
bool) self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"];
430 $ilDB = $DIC[
'ilDB'];
433 "SELECT test_id FROM tst_tests WHERE obj_fi = %s",
439 $test_id =
$row[
"test_id"];
453 $ilDB = $DIC[
'ilDB'];
456 "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
462 return $row[
"obj_fi"];
475 $ilDB = $DIC[
'ilDB'];
478 SELECT DISTINCT t.obj_fi 480 INNER JOIN tst_rnd_quest_set_qpls r 481 ON t.test_id = r.test_fi 505 $ilDB = $DIC[
'ilDB'];
509 "SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
515 if (
$row[
"fixed_participants"]) {
517 "SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
518 array(
'integer',
'integer'),
519 array(
$row[
"test_id"], $a_user_id)
523 if (trim(
$row[
'clientip']) !=
"") {
524 $row[
'clientip'] = preg_replace(
"/[^0-9.?*,:]+/",
"",
$row[
'clientip']);
525 $row[
'clientip'] = str_replace(
".",
"\\.",
$row[
'clientip']);
526 $row[
'clientip'] = str_replace(array(
"?",
"*",
","), array(
"[0-9]",
"[0-9]*",
"|"),
$row[
'clientip']);
527 if (!preg_match(
"/^" .
$row[
'clientip'] .
"$/",
$_SERVER[
"REMOTE_ADDR"])) {
528 $lng->loadLanguageModule(
'assessment');
529 return $lng->txt(
"user_wrong_clientip");
537 return $lng->txt(
"tst_user_not_invited");
558 $ilDB = $DIC[
'ilDB'];
561 "SELECT * FROM tst_active WHERE active_id = %s",
566 $user_id =
$row[
"user_fi"];
567 $test_id =
$row[
"test_fi"];
568 $importname =
$row[
'importname'];
571 "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
576 $obj_id =
$row[
"obj_fi"];
578 include_once
"./Modules/Test/classes/class.ilObjTest.php";
581 include_once
'./Services/User/classes/class.ilObjUser.php';
585 if (strlen($importname)) {
586 $name = $importname .
' (' .
$lng->txt(
'imported') .
')';
587 } elseif (strlen($uname[
"firstname"] . $uname[
"lastname"]) == 0) {
590 if ($user_id == ANONYMOUS_USER_ID) {
593 $name = trim($uname[
"lastname"] .
", " . $uname[
"firstname"] .
" " . $uname[
"title"]);
612 $ilDB = $DIC[
'ilDB'];
615 "SELECT user_fi FROM tst_active WHERE active_id = %s",
620 return $row[
"user_fi"];
641 $ilDB = $DIC[
'ilDB'];
643 $passed_users = array();
645 $userresult =
$ilDB->queryF(
647 SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences, tst_active.last_finished_pass, 649 (tst_tests.nr_of_tries - 1) = tst_active.last_finished_pass 654 INNER JOIN tst_active 655 ON tst_active.test_fi = tst_tests.test_id 656 LEFT JOIN tst_sequence 657 ON tst_sequence.active_fi = tst_active.active_id 658 WHERE tst_tests.obj_fi = %s 659 GROUP BY tst_active.active_id 664 $all_participants = array();
665 $notAttempted = array();
666 $lastPassUsers = array();
667 while (
$row =
$ilDB->fetchAssoc($userresult)) {
668 if (
$row[
'sequences'] == 0) {
669 $notAttempted[
$row[
'active_id']] = $row[
'active_id'];
671 if (
$row[
'is_last_pass']) {
672 $lastPassUsers[
$row[
'active_id']] = $row[
'active_id'];
675 $all_participants[
$row[
'active_id']] = $row[
'active_id'];
678 $result =
$ilDB->query(
"SELECT tst_result_cache.*, tst_active.user_fi FROM tst_result_cache, tst_active WHERE tst_active.active_id = tst_result_cache.active_fi AND " .
$ilDB->in(
'active_fi', $all_participants,
false,
'integer'));
679 $found_all = (
$result->numRows() == count($all_participants)) ?
true :
false;
682 $found_participants = array();
684 array_push($found_participants,
$data[
'active_fi']);
686 foreach ($all_participants as $active_id) {
687 if (!in_array($active_id, $found_participants)) {
688 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
692 $result =
$ilDB->query(
"SELECT tst_result_cache.*, tst_active.user_fi FROM tst_result_cache, tst_active WHERE tst_active.active_id = tst_result_cache.active_fi AND " .
$ilDB->in(
'active_fi', $all_participants,
false,
'integer'));
695 if (isset($notAttempted[
$data[
'active_fi']])) {
698 $data[
'not_attempted'] = 1;
701 if ($data[
'failed'] && !isset($lastPassUsers[$data[
'active_fi']])) {
704 $data[
'in_progress'] = 1;
707 $data[
'user_id'] = $data[
'user_fi'];
708 array_push($passed_users, $data);
710 return $passed_users;
719 $ilAccess = $DIC[
'ilAccess'];
721 $t_arr = explode(
"_", $a_target);
723 if ($t_arr[0] !=
"tst" || ((
int) $t_arr[1]) <= 0) {
727 if ($ilAccess->checkAccess(
"read",
"", $t_arr[1])) {
759 require_once
'Modules/Test/classes/class.ilTestSessionFactory.php';
761 $testSession = $testSessionFactory->getSessionByUserId($userId);
763 return $testOBJ->canShowTestResults($testSession);
777 if (!($testOBJ instanceof
ilObjTest) || !$userId) {
781 require_once
'Modules/Test/classes/class.ilTestSessionFactory.php';
783 $testSession = $testSessionFactory->getSessionByUserId($userId);
785 if (!$testSession->getActiveId()) {
789 return $testOBJ->canShowCertificate($testSession, $testSession->getUserId(), $testSession->getActiveId());
static _lookupName($a_user_id)
lookup user name
static _lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static _getParticipantData($active_id)
Retrieves a participant name from active id.
static _getParticipantId($active_id)
Get user id for active id.
const IL_NO_OBJECT_ACCESS
Interface for condition handling.
static _isOffline($a_obj_id)
returns the objects's OFFline status
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcce...
static _isPassed($user_id, $a_obj_id)
Returns TRUE if the user with the user id $user_id passed the test with the object id $a_obj_id...
static _lookupAnonymity($a_obj_id)
Returns the anonymity status of a test with a given object id.
static _lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
static _getRandomTestsForQuestionPool($qpl_id)
Get all tests using a question pool for random selection.
static _lookupObjIdForTestId($a_test_id)
Lookup object id for test id.
static _getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
foreach($_POST as $key=> $value) $res
static visibleUserResultExists($testObjId, $userId)
static lookupOfflineStatus($a_obj_id)
Lookup offline status using objectDataCache.
static _getPassedUsers($a_obj_id)
Returns an array containing the users who passed the test.
static _getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
static hasVisibleCertificate($testObjId, $userId)
Andre Michels amichels@databay.de
static isFailed($user_id, $a_obj_id)
Returns TRUE if the user with the user id $user_id failed the test with the object id $a_obj_id...
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
const OPERATOR_NOT_FINISHED
static getConditionOperators()
Get possible conditions operators.
static updateTestResultCache($a_user_id, $a_obj_id)
Update test result cache.
static _getCommands()
get commands
static checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
check condition
static hasFinished($a_user_id, $a_obj_id)
Returns (request cached) information if a specific user has finished at least one test pass...
static _checkGoto($a_target)
check whether goto script will succeed