4 include_once
"./Services/Object/classes/class.ilObjectAccess.php";
5 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
6 include_once
'./Services/AccessControl/interfaces/interface.ilConditionHandling.php';
37 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id =
"")
41 if ($a_user_id ==
"") {
42 $a_user_id = $ilUser->getId();
45 $is_admin = $rbacsystem->checkAccessOfUser($a_user_id,
'write', $a_ref_id);
48 if (!self::_isOnline($a_obj_id) && !$is_admin) {
53 switch ($a_permission) {
85 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)
176 $ret = self::updateTestResultCache($user_id, $a_obj_id);
183 "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",
184 array(
'integer',
'integer'),
185 array($user_id, $a_obj_id)
190 "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",
191 array(
'integer',
'integer'),
192 array($user_id, $a_obj_id)
196 array_push($points,
$row);
200 if ($points[0][
"pass_scoring"] == 0) {
201 $reached = $points[count($points)-1][
"points"];
202 $max = $points[count($points)-1][
"maxpoints"];
204 $active_id = $points[count($points)-1][
"active_fi"];
205 $pass = $points[count($points)-1][
"pass"];
206 if (strlen($active_id) && strlen(
$pass)) {
207 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
208 $res = assQuestion::_updateTestPassResults($active_id,
$pass, null, $a_obj_id);
209 $max =
$res[
'maxpoints'];
210 $reached =
$res[
'points'];
214 foreach ($points as
$row) {
215 if ($row[
"points"] > $reached) {
216 $reached = $row[
"points"];
217 $max = $row[
"maxpoints"];
219 $active_id = $row[
"active_fi"];
220 $pass = $row[
"pass"];
221 if (strlen($active_id) && strlen(
$pass)) {
222 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
223 $res = assQuestion::_updateTestPassResults($active_id,
$pass, null, $a_obj_id);
224 $max =
$res[
'maxpoints'];
225 $reached =
$res[
'points'];
231 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
232 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
234 return ($mark[
"failed"]) ? true :
false;
237 return (
$row[
'failed']) ? true :
false;
251 "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests " .
252 "WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s " .
253 "AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
254 array(
'integer',
'integer'),
255 array($a_user_id, $a_obj_id)
259 "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",
260 array(
'integer',
'integer'),
261 array($a_user_id, $a_obj_id)
264 if (
$row[
'active_id'] > 0) {
265 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
282 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
297 public static function checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
299 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
301 switch ($a_operator) {
336 array(
"permission" =>
"write",
"cmd" =>
"questionsTabGateway",
"lang_var" =>
"tst_edit_questions"),
337 array(
"permission" =>
"write",
"cmd" =>
"ilObjTestSettingsGeneralGUI::showForm",
"lang_var" =>
"settings"),
338 array(
"permission" =>
"read",
"cmd" =>
"infoScreen",
"lang_var" =>
"tst_run",
341 array(
"permission" =>
"tst_statistics",
"cmd" =>
"outEvaluation",
"lang_var" =>
"tst_statistical_evaluation"),
342 array(
"permission" =>
"read",
"cmd" =>
"userResultsGateway",
"lang_var" =>
"tst_test_results")
360 "SELECT complete FROM tst_tests WHERE obj_fi=%s",
368 return (
$row[
'complete']) ? true :
false;
387 if (!isset(self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"])) {
388 require_once
'Modules/Test/classes/class.ilTestParticipantData.php';
389 require_once
'Modules/Test/classes/class.ilTestSessionFactory.php';
390 require_once
'Modules/Test/classes/class.ilTestPassesSelector.php';
397 $partData->setUserIds(
array($a_user_id));
398 $partData->load($testOBJ->getTestId());
400 $activeId = $partData->getActiveIdByUserId($a_user_id);
403 $testSession = $testSessionFactory->getSession($activeId);
406 $testPassesSelector->setActiveId($activeId);
407 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
409 self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
412 return (
bool) self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"];
427 "SELECT test_id FROM tst_tests WHERE obj_fi = %s",
433 $test_id =
$row[
"test_id"];
449 "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
455 return $row[
"obj_fi"];
470 SELECT DISTINCT t.obj_fi 472 INNER JOIN tst_rnd_quest_set_qpls r 473 ON t.test_id = r.test_fi 481 $tests[] =
$row[
'obj_fi'];
499 "SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
505 if (
$row[
"fixed_participants"]) {
507 "SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
508 array(
'integer',
'integer'),
513 if (trim(
$row[
'clientip']) !=
"") {
514 $row[
'clientip'] = preg_replace(
"/[^0-9.?*,:]+/",
"",
$row[
'clientip']);
515 $row[
'clientip'] = str_replace(
".",
"\\.",
$row[
'clientip']);
516 $row[
'clientip'] = str_replace(
array(
"?",
"*",
","),
array(
"[0-9]",
"[0-9]*",
"|"),
$row[
'clientip']);
517 if (!preg_match(
"/^" .
$row[
'clientip'] .
"$/",
$_SERVER[
"REMOTE_ADDR"])) {
518 $lng->loadLanguageModule(
'assessment');
519 return $lng->txt(
"user_wrong_clientip");
527 return $lng->txt(
"tst_user_not_invited");
549 "SELECT * FROM tst_active WHERE active_id = %s",
554 $user_id =
$row[
"user_fi"];
555 $test_id =
$row[
"test_fi"];
556 $importname =
$row[
'importname'];
559 "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
564 $obj_id =
$row[
"obj_fi"];
566 include_once
"./Modules/Test/classes/class.ilObjTest.php";
569 include_once
'./Services/User/classes/class.ilObjUser.php';
573 if (strlen($importname)) {
574 $name = $importname .
' (' . $lng->txt(
'imported') .
')';
575 } elseif (strlen($uname[
"firstname"] . $uname[
"lastname"]) == 0) {
576 $name = $lng->txt(
"deleted_user");
578 if ($user_id == ANONYMOUS_USER_ID) {
581 $name = trim($uname[
"lastname"] .
", " . $uname[
"firstname"] .
" " . $uname[
"title"]);
584 $name = $lng->txt(
"anonymous");
601 "SELECT user_fi FROM tst_active WHERE active_id = %s",
606 return $row[
"user_fi"];
628 $passed_users =
array();
630 $userresult = $ilDB->queryF(
632 SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences, tst_active.last_finished_pass, 634 (tst_tests.nr_of_tries - 1) = tst_active.last_finished_pass 639 INNER JOIN tst_active 640 ON tst_active.test_fi = tst_tests.test_id 641 LEFT JOIN tst_sequence 642 ON tst_sequence.active_fi = tst_active.active_id 643 WHERE tst_tests.obj_fi = %s 644 GROUP BY tst_active.active_id 649 $all_participants =
array();
650 $notAttempted =
array();
651 $lastPassUsers =
array();
652 while (
$row = $ilDB->fetchAssoc($userresult)) {
653 if (
$row[
'sequences'] == 0) {
654 $notAttempted[
$row[
'active_id']] = $row[
'active_id'];
656 if (
$row[
'is_last_pass']) {
657 $lastPassUsers[
$row[
'active_id']] = $row[
'active_id'];
660 $all_participants[
$row[
'active_id']] = $row[
'active_id'];
663 $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'));
664 $found_all = (
$result->numRows() == count($all_participants)) ?
true :
false;
667 $found_participants =
array();
669 array_push($found_participants,
$data[
'active_fi']);
671 foreach ($all_participants as $active_id) {
672 if (!in_array($active_id, $found_participants)) {
673 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
677 $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'));
680 if (isset($notAttempted[
$data[
'active_fi']])) {
683 $data[
'not_attempted'] = 1;
686 if ($data[
'failed'] && !isset($lastPassUsers[$data[
'active_fi']])) {
689 $data[
'in_progress'] = 1;
692 $data[
'user_id'] = $data[
'user_fi'];
693 array_push($passed_users, $data);
695 return $passed_users;
705 $t_arr = explode(
"_", $a_target);
707 if ($t_arr[0] !=
"tst" || ((
int) $t_arr[1]) <= 0) {
711 if ($ilAccess->checkAccess(
"read",
"", $t_arr[1])) {
730 return !self::_isOnline($a_obj_id);
747 AND online_status = 1 752 return $result->numRows() == 1;
763 require_once
'Modules/Test/classes/class.ilTestSessionFactory.php';
765 $testSession = $testSessionFactory->getSessionByUserId($userId);
767 return $testOBJ->canShowTestResults($testSession);
781 if (!($testOBJ instanceof
ilObjTest) || !$userId) {
785 require_once
'Modules/Test/classes/class.ilTestSessionFactory.php';
787 $testSession = $testSessionFactory->getSessionByUserId($userId);
789 if (!$testSession->getActiveId()) {
793 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
static _isOnline($a_obj_id)
returns the objects's ONline 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 _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
Create styles array
The data for the language used.
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