ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjTestAccess Class Reference

Class ilObjTestAccess. More...

+ Inheritance diagram for ilObjTestAccess:
+ Collaboration diagram for ilObjTestAccess:

Public Member Functions

 _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::checkAccess) More...
 
- Public Member Functions inherited from ilObjectAccess
 _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::checkAccess) More...
 
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition More...
 

Static Public Member Functions

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. More...
 
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. More...
 
static getConditionOperators ()
 Get possible conditions operators. More...
 
static checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition More...
 
static _getCommands ()
 get commands More...
 
static _lookupCreationComplete ($a_obj_id)
 checks wether all necessary parts of the test are given More...
 
static hasFinished ($a_user_id, $a_obj_id)
 Returns (request cached) information if a specific user has finished at least one test pass. More...
 
static _getTestIDFromObjectID ($object_id)
 Returns the ILIAS test id for a given object id. More...
 
static _lookupObjIdForTestId ($a_test_id)
 Lookup object id for test id. More...
 
static _getRandomTestsForQuestionPool ($qpl_id)
 Get all tests using a question pool for random selection. More...
 
static _lookupOnlineTestAccess ($a_test_id, $a_user_id)
 Checks if a user is allowd to run an online exam. More...
 
static _getParticipantData ($active_id)
 Retrieves a participant name from active id. More...
 
static _getParticipantId ($active_id)
 Get user id for active id. More...
 
static _getPassedUsers ($a_obj_id)
 Returns an array containing the users who passed the test. More...
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
static _isOffline ($a_obj_id)
 returns the objects's OFFline status More...
 
static _isOnline ($a_obj_id)
 returns the objects's ONline status More...
 
static visibleUserResultExists ($testObjId, $userId)
 
static hasVisibleCertificate ($testObjId, $userId)
 @ideaof Andre Michels amich.nosp@m.els@.nosp@m.datab.nosp@m.ay.d.nosp@m.e More...
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
static _isOffline ($a_obj_id)
 Type-specific implementation of general status, has to be overwritten. More...
 
static _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. More...
 
static getConditionOperators ()
 Returns an array with valid operators for the specific object type. More...
 
static checkCondition ($a_trigger_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition for a specific user and object More...
 

Static Protected Member Functions

static updateTestResultCache ($a_user_id, $a_obj_id)
 Update test result cache. More...
 

Static Private Attributes

static $hasFinishedCache = array()
 

Detailed Description

Class ilObjTestAccess.

This class contains methods that check object specific conditions for accessing test objects.

Author
Helmut Schottmueller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 20 of file class.ilObjTestAccess.php.

Member Function Documentation

◆ _checkAccess()

ilObjTestAccess::_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::checkAccess)

Please do not check any preconditions handled by ilConditionHandler here.

Parameters
string$a_cmdcommand (not permission!)
string$a_permissionpermission
int$a_ref_idreference id
int$a_obj_idobject id
int$a_user_iduser id (if not provided, current user is taken)
Returns
boolean true, if everything is ok

Reimplemented from ilObjectAccess.

Definition at line 37 of file class.ilObjTestAccess.php.

38 {
39 global $ilUser, $lng, $rbacsystem, $ilAccess;
40
41 if ($a_user_id == "") {
42 $a_user_id = $ilUser->getId();
43 }
44
45 $is_admin = $rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id);
46
47 // check "global" online switch
48 if (!self::_isOnline($a_obj_id) && !$is_admin) {
49 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
50 return false;
51 }
52
53 switch ($a_permission) {
54 case "visible":
55 case "read":
57 !$is_admin) {
58 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
59 return false;
60 }
61 break;
62 }
63
64 switch ($a_cmd) {
65 case "eval_a":
66 case "eval_stat":
68 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
69 return false;
70 }
71 break;
72
73 }
74
75 return true;
76 }
const IL_NO_OBJECT_ACCESS
static _lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
global $lng
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:18

References $ilUser, $lng, _lookupCreationComplete(), and IL_NO_OBJECT_ACCESS.

+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjTestAccess::_checkGoto (   $a_target)
static

check whether goto script will succeed

Reimplemented from ilObjectAccess.

Definition at line 701 of file class.ilObjTestAccess.php.

702 {
703 global $ilAccess;
704
705 $t_arr = explode("_", $a_target);
706
707 if ($t_arr[0] != "tst" || ((int) $t_arr[1]) <= 0) {
708 return false;
709 }
710
711 if ($ilAccess->checkAccess("read", "", $t_arr[1])) {
712 return true;
713 }
714 return false;
715 }

◆ _getCommands()

static ilObjTestAccess::_getCommands ( )
static

get commands

this method returns an array of all possible commands/permission combinations

example: $commands = array ( array("permission" => "read", "cmd" => "view", "lang_var" => "show"), array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"), );

Reimplemented from ilObjectAccess.

Definition at line 333 of file class.ilObjTestAccess.php.

334 {
335 $commands = array(
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",
339 "default" => true),
340 //array("permission" => "write", "cmd" => "", "lang_var" => "edit"),
341 array("permission" => "tst_statistics", "cmd" => "outEvaluation", "lang_var" => "tst_statistical_evaluation"),
342 array("permission" => "read", "cmd" => "userResultsGateway", "lang_var" => "tst_test_results")
343 );
344
345 return $commands;
346 }

Referenced by ilObjTestListGUI\init().

+ Here is the caller graph for this function:

◆ _getParticipantData()

static ilObjTestAccess::_getParticipantData (   $active_id)
static

Retrieves a participant name from active id.

Parameters
integer$active_idActive ID of the participant
Returns
string The output name of the user @access public

Definition at line 544 of file class.ilObjTestAccess.php.

545 {
546 global $lng, $ilDB;
547
548 $result = $ilDB->queryF(
549 "SELECT * FROM tst_active WHERE active_id = %s",
550 array("integer"),
551 array($active_id)
552 );
553 $row = $ilDB->fetchAssoc($result);
554 $user_id = $row["user_fi"];
555 $test_id = $row["test_fi"];
556 $importname = $row['importname'];
557
558 $result = $ilDB->queryF(
559 "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
560 array("integer"),
561 array($test_id)
562 );
563 $row = $ilDB->fetchAssoc($result);
564 $obj_id = $row["obj_fi"];
565
566 include_once "./Modules/Test/classes/class.ilObjTest.php";
567 $is_anonymous = ilObjTest::_lookupAnonymity($obj_id);
568
569 include_once './Services/User/classes/class.ilObjUser.php';
570 $uname = ilObjUser::_lookupName($user_id);
571
572 $name = "";
573 if (strlen($importname)) {
574 $name = $importname . ' (' . $lng->txt('imported') . ')';
575 } elseif (strlen($uname["firstname"] . $uname["lastname"]) == 0) {
576 $name = $lng->txt("deleted_user");
577 } else {
578 if ($user_id == ANONYMOUS_USER_ID) {
579 $name = $lastname;
580 } else {
581 $name = trim($uname["lastname"] . ", " . $uname["firstname"] . " " . $uname["title"]);
582 }
583 if ($is_anonymous) {
584 $name = $lng->txt("anonymous");
585 }
586 }
587 return $name;
588 }
$result
static _lookupAnonymity($a_obj_id)
Returns the anonymity status of a test with a given object id.
static _lookupName($a_user_id)
lookup user name
if($format !==null) $name
Definition: metadata.php:146
global $ilDB

References $ilDB, $lng, $name, $result, $row, ilObjTest\_lookupAnonymity(), and ilObjUser\_lookupName().

Referenced by assQuestion\_setReachedPoints(), ilTestResultsToXML\exportActiveIDs(), and ilObjTestGUI\participantsObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getParticipantId()

static ilObjTestAccess::_getParticipantId (   $active_id)
static

Get user id for active id.

Parameters
intactive ID of the participant
Returns
int user id

Definition at line 596 of file class.ilObjTestAccess.php.

597 {
598 global $lng, $ilDB;
599
600 $result = $ilDB->queryF(
601 "SELECT user_fi FROM tst_active WHERE active_id = %s",
602 array("integer"),
603 array($active_id)
604 );
605 $row = $ilDB->fetchAssoc($result);
606 return $row["user_fi"];
607 }

References $ilDB, $lng, $result, and $row.

Referenced by assFileUpload\handleSubmission(), ilTestScoringGUI\saveManScoringParticipantScreen(), ilTestSessionDynamicQuestionSet\saveToDb(), and ilTestPassFinishTasks\updateLearningProgressAfterPassFinishedIsWritten().

+ Here is the caller graph for this function:

◆ _getPassedUsers()

static ilObjTestAccess::_getPassedUsers (   $a_obj_id)
static

Returns an array containing the users who passed the test.

Returns
array An array containing the users who passed the test. Format of the values of the resulting array: array( "user_id" => user ID, "max_points" => maximum available points in the test "reached_points" => maximum reached points of the user "mark_short" => short text of the passed mark "mark_official" => official text of the passed mark ) @access public

Definition at line 624 of file class.ilObjTestAccess.php.

625 {
626 global $ilDB;
627
628 $passed_users = array();
629 // Maybe SELECT DISTINCT(tst_active.user_fi)... ?
630 $userresult = $ilDB->queryF(
631 "
632 SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences, tst_active.last_finished_pass,
633 CASE WHEN
634 (tst_tests.nr_of_tries - 1) = tst_active.last_finished_pass
635 THEN '1'
636 ELSE '0'
637 END is_last_pass
638 FROM tst_tests
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
645 ",
646 array('integer'),
647 array($a_obj_id)
648 );
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'];
655 }
656 if ($row['is_last_pass']) {
657 $lastPassUsers[$row['active_id']] = $row['active_id'];
658 }
659
660 $all_participants[$row['active_id']] = $row['active_id'];
661 }
662
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;
665 if (!$found_all) {
666 // if the result cache entries do not exist, create them
667 $found_participants = array();
668 while ($data = $ilDB->fetchAssoc($result)) {
669 array_push($found_participants, $data['active_fi']);
670 }
671 foreach ($all_participants as $active_id) {
672 if (!in_array($active_id, $found_participants)) {
673 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
675 }
676 }
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'));
678 }
679 while ($data = $ilDB->fetchAssoc($result)) {
680 if (isset($notAttempted[$data['active_fi']])) {
681 $data['failed'] = 0;
682 $data['passed'] = 0;
683 $data['not_attempted'] = 1;
684 }
685
686 if ($data['failed'] && !isset($lastPassUsers[$data['active_fi']])) {
687 $data['passed'] = 0;
688 $data['failed'] = 0;
689 $data['in_progress'] = 1;
690 }
691
692 $data['user_id'] = $data['user_fi'];
693 array_push($passed_users, $data);
694 }
695 return $passed_users;
696 }
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
@TODO Move this to a proper place.

References $data, $ilDB, $result, $row, and assQuestion\_updateTestResultCache().

Referenced by ilLPStatusTestPassed\_getStatusInfo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getRandomTestsForQuestionPool()

static ilObjTestAccess::_getRandomTestsForQuestionPool (   $qpl_id)
static

Get all tests using a question pool for random selection.

Parameters
intquestion pool id
Returns
array list if test obj ids @access public

Definition at line 465 of file class.ilObjTestAccess.php.

466 {
467 global $ilDB;
468
469 $query = "
470 SELECT DISTINCT t.obj_fi
471 FROM tst_tests t
472 INNER JOIN tst_rnd_quest_set_qpls r
473 ON t.test_id = r.test_fi
474 WHERE r.pool_fi = %s
475 ";
476
477 $result = $ilDB->queryF($query, array('integer'), array($qpl_id));
478
479 $tests = array();
480 while ($row = $ilDB->fetchAssoc($result)) {
481 $tests[] = $row['obj_fi'];
482 }
483
484 return $tests;
485 }
$query

References $ilDB, $query, $result, and $row.

Referenced by ilObjMediaObjectAccess\checkAccessTestQuestion().

+ Here is the caller graph for this function:

◆ _getTestIDFromObjectID()

static ilObjTestAccess::_getTestIDFromObjectID (   $object_id)
static

Returns the ILIAS test id for a given object id.

Parameters
integer$object_idThe object id
Returns
mixed The ILIAS test id or FALSE if the query was not successful @access public

Definition at line 422 of file class.ilObjTestAccess.php.

423 {
424 global $ilDB;
425 $test_id = false;
426 $result = $ilDB->queryF(
427 "SELECT test_id FROM tst_tests WHERE obj_fi = %s",
428 array('integer'),
429 array($object_id)
430 );
431 if ($result->numRows()) {
432 $row = $ilDB->fetchAssoc($result);
433 $test_id = $row["test_id"];
434 }
435 return $test_id;
436 }

References $ilDB, $result, and $row.

Referenced by ilLPStatusTestFinished\getParticipants().

+ Here is the caller graph for this function:

◆ _isOffline()

static ilObjTestAccess::_isOffline (   $a_obj_id)
static

returns the objects's OFFline status

Used in ListGUI and Learning Progress

Parameters
int$a_obj_id
Returns
bool

Reimplemented from ilObjectAccess.

Definition at line 725 of file class.ilObjTestAccess.php.

726 {
727 // global $ilUser;
728 // return (self::_lookupOnlineTestAccess($a_obj_id, $ilUser->getId()) !== true) ||
729 // (!ilObjTestAccess::_lookupCreationComplete($a_obj_id));
730 return !self::_isOnline($a_obj_id);
731 }
static _isOnline($a_obj_id)
returns the objects's ONline status

References _isOnline().

+ Here is the call graph for this function:

◆ _isOnline()

static ilObjTestAccess::_isOnline (   $a_obj_id)
static

returns the objects's ONline status

Parameters
integer$a_obj_id
Returns
boolean $online

Definition at line 739 of file class.ilObjTestAccess.php.

740 {
741 global $ilDB;
742
743 $query = "
744 SELECT test_id
745 FROM tst_tests
746 WHERE obj_fi = %s
747 AND online_status = 1
748 ";
749
750 $result = $ilDB->queryF($query, array('integer'), array($a_obj_id));
751
752 return $result->numRows() == 1;
753 }

References $ilDB, $query, and $result.

Referenced by _isOffline(), ilLOEditorStatus\checkTestOnline(), and ilObjTestListGUI\getProperties().

+ Here is the caller graph for this function:

◆ _isPassed()

static ilObjTestAccess::_isPassed (   $user_id,
  $a_obj_id 
)
static

Returns TRUE if the user with the user id $user_id passed the test with the object id $a_obj_id.

Parameters
int$user_idThe user id
int$a_obj_idThe object id
Returns
boolean TRUE if the user passed the test, FALSE otherwise

Definition at line 85 of file class.ilObjTestAccess.php.

86 {
87 global $ilDB;
88 $result = $ilDB->queryF(
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)
92 );
93 if (!$result->numRows()) {
94 $result = $ilDB->queryF(
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)
98 );
99 $row = $ilDB->fetchAssoc($result);
100 if ($row['active_id'] > 0) {
101 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
103 } else {
104 return false;
105 }
106 }
107 $result = $ilDB->queryF(
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)
111 );
112 if (!$result->numRows()) {
113 $result = $ilDB->queryF(
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)
117 );
118 $points = array();
119 while ($row = $ilDB->fetchAssoc($result)) {
120 array_push($points, $row);
121 }
122 $reached = 0;
123 $max = 0;
124 if ($points[0]["pass_scoring"] == 0) {
125 $reached = $points[count($points)-1]["points"];
126 $max = $points[count($points)-1]["maxpoints"];
127 if (!$max) {
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'];
135 }
136 }
137 } else {
138 foreach ($points as $row) {
139 if ($row["points"] > $reached) {
140 $reached = $row["points"];
141 $max = $row["maxpoints"];
142 if (!$max) {
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'];
150 }
151 }
152 }
153 }
154 }
155 include_once "./Modules/Test/classes/class.assMarkSchema.php";
156 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
157 $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
158 return ($mark["passed"]) ? true : false;
159 } else {
160 $row = $ilDB->fetchAssoc($result);
161 return ($row['passed']) ? true : false;
162 }
163 }
static _getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
foreach($_POST as $key=> $value) $res

References $ilDB, $pass, $res, $result, $row, ASS_MarkSchema\_getMatchingMarkFromObjId(), and assQuestion\_updateTestResultCache().

Referenced by checkCondition(), and ilLPStatusTestPassed\determineStatus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupCreationComplete()

static ilObjTestAccess::_lookupCreationComplete (   $a_obj_id)
static

checks wether all necessary parts of the test are given

Definition at line 355 of file class.ilObjTestAccess.php.

356 {
357 global $ilDB;
358
359 $result = $ilDB->queryF(
360 "SELECT complete FROM tst_tests WHERE obj_fi=%s",
361 array('integer'),
362 array($a_obj_id)
363 );
364 if ($result->numRows() == 1) {
365 $row = $ilDB->fetchAssoc($result);
366 }
367
368 return ($row['complete']) ? true : false;
369 }

References $ilDB, $result, and $row.

Referenced by _checkAccess().

+ Here is the caller graph for this function:

◆ _lookupObjIdForTestId()

static ilObjTestAccess::_lookupObjIdForTestId (   $a_test_id)
static

Lookup object id for test id.

Parameters
inttest id
Returns
int object id

Definition at line 444 of file class.ilObjTestAccess.php.

445 {
446 global $ilDB;
447
448 $result = $ilDB->queryF(
449 "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
450 array('integer'),
451 array($a_test_id)
452 );
453
454 $row = $ilDB->fetchAssoc($result);
455 return $row["obj_fi"];
456 }

References $ilDB, $result, and $row.

Referenced by ilTestSessionDynamicQuestionSet\saveToDb().

+ Here is the caller graph for this function:

◆ _lookupOnlineTestAccess()

static ilObjTestAccess::_lookupOnlineTestAccess (   $a_test_id,
  $a_user_id 
)
static

Checks if a user is allowd to run an online exam.

Returns
mixed true if the user is allowed to run the online exam or if the test isn't an online exam, an alert message if the test is an online exam and the user is not allowed to run it @access public

Definition at line 494 of file class.ilObjTestAccess.php.

495 {
496 global $ilDB, $lng;
497
498 $result = $ilDB->queryF(
499 "SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
500 array('integer'),
501 array($a_test_id)
502 );
503 if ($result->numRows()) {
504 $row = $ilDB->fetchAssoc($result);
505 if ($row["fixed_participants"]) {
506 $result = $ilDB->queryF(
507 "SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
508 array('integer','integer'),
509 array($row["test_id"], $a_user_id)
510 );
511 if ($result->numRows()) {
512 $row = $ilDB->fetchAssoc($result);
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");
520 } else {
521 return true;
522 }
523 } else {
524 return true;
525 }
526 } else {
527 return $lng->txt("tst_user_not_invited");
528 }
529 } else {
530 return true;
531 }
532 } else {
533 return true;
534 }
535 }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

References $_SERVER, $ilDB, $lng, $result, and $row.

Referenced by ilTestInfoScreenToolbarGUI\build(), ilObjTestGUI\buildPageViewToolbar(), ilObjTestListGUI\getProperties(), and ilObjTestGUI\questionsObject().

+ Here is the caller graph for this function:

◆ checkCondition()

static ilObjTestAccess::checkCondition (   $a_obj_id,
  $a_operator,
  $a_value,
  $a_usr_id 
)
static

check condition

this method is called by ilConditionHandler

Implements ilConditionHandling.

Definition at line 297 of file class.ilObjTestAccess.php.

298 {
299 include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
300
301 switch ($a_operator) {
303 return ilObjTestAccess::_isPassed($a_usr_id, $a_obj_id);
304 break;
305
307 return ilObjTestAccess::isFailed($a_usr_id, $a_obj_id);
308
310 return ilObjTestAccess::hasFinished($a_usr_id, $a_obj_id);
311
313 return !ilObjTestAccess::hasFinished($a_usr_id, $a_obj_id);
314
315 default:
316 return true;
317 }
318 return true;
319 }
static hasFinished($a_user_id, $a_obj_id)
Returns (request cached) information if a specific user has finished at least one test pass.
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 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.

References _isPassed(), hasFinished(), isFailed(), ilConditionHandler\OPERATOR_FAILED, ilConditionHandler\OPERATOR_FINISHED, ilConditionHandler\OPERATOR_NOT_FINISHED, and ilConditionHandler\OPERATOR_PASSED.

Referenced by ilContainerObjectiveGUI\getMainContent(), ilContainerStartObjects\isFullfilled(), ilCourseStart\isFullfilled(), and ilContainerObjectiveGUI\renderObjective().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getConditionOperators()

static ilObjTestAccess::getConditionOperators ( )
static

Get possible conditions operators.

Implements ilConditionHandling.

Definition at line 280 of file class.ilObjTestAccess.php.

281 {
282 include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
283 return array(
288 );
289 }

References ilConditionHandler\OPERATOR_FAILED, ilConditionHandler\OPERATOR_FINISHED, ilConditionHandler\OPERATOR_NOT_FINISHED, and ilConditionHandler\OPERATOR_PASSED.

◆ hasFinished()

static ilObjTestAccess::hasFinished (   $a_user_id,
  $a_obj_id 
)
static

Returns (request cached) information if a specific user has finished at least one test pass.

Parameters
integer$a_user_idobj_id of the user
integer$a_obj_idobj_id of the test
Returns
bool

Definition at line 385 of file class.ilObjTestAccess.php.

386 {
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';
391
392 global $ilDB, $lng;
393
394 $testOBJ = ilObjectFactory::getInstanceByObjId($a_obj_id);
395
396 $partData = new ilTestParticipantData($ilDB, $lng);
397 $partData->setUserIds(array($a_user_id));
398 $partData->load($testOBJ->getTestId());
399
400 $activeId = $partData->getActiveIdByUserId($a_user_id);
401
402 $testSessionFactory = new ilTestSessionFactory($testOBJ);
403 $testSession = $testSessionFactory->getSession($activeId);
404
405 $testPassesSelector = new ilTestPassesSelector($ilDB, $testOBJ);
406 $testPassesSelector->setActiveId($activeId);
407 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
408
409 self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
410 }
411
412 return (bool) self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"];
413 }
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id

References $ilDB, $lng, and ilObjectFactory\getInstanceByObjId().

Referenced by checkCondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasVisibleCertificate()

static ilObjTestAccess::hasVisibleCertificate (   $testObjId,
  $userId 
)
static

@ideaof Andre Michels amich.nosp@m.els@.nosp@m.datab.nosp@m.ay.d.nosp@m.e

Parameters
$testObjId
$userId
Returns
bool

Definition at line 777 of file class.ilObjTestAccess.php.

778 {
779 $testOBJ = ilObjectFactory::getInstanceByObjId($testObjId, false);
780
781 if (!($testOBJ instanceof ilObjTest) || !$userId) {
782 return false;
783 }
784
785 require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
786 $testSessionFactory = new ilTestSessionFactory($testOBJ);
787 $testSession = $testSessionFactory->getSessionByUserId($userId);
788
789 if (!$testSession->getActiveId()) {
790 return false;
791 }
792
793 return $testOBJ->canShowCertificate($testSession, $testSession->getUserId(), $testSession->getActiveId());
794 }

References ilObjectFactory\getInstanceByObjId().

+ Here is the call graph for this function:

◆ isFailed()

static ilObjTestAccess::isFailed (   $user_id,
  $a_obj_id 
)
static

Returns TRUE if the user with the user id $user_id failed the test with the object id $a_obj_id.

Parameters
int$user_idThe user id
int$a_obj_idThe object id
Returns
boolean TRUE if the user failed the test, FALSE otherwise

Definition at line 172 of file class.ilObjTestAccess.php.

173 {
174 global $ilDB;
175
176 $ret = self::updateTestResultCache($user_id, $a_obj_id);
177
178 if (!$ret) {
179 return false;
180 }
181
182 $result = $ilDB->queryF(
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)
186 );
187
188 if (!$result->numRows()) {
189 $result = $ilDB->queryF(
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)
193 );
194
195 while ($row = $ilDB->fetchAssoc($result)) {
196 array_push($points, $row);
197 }
198 $reached = 0;
199 $max = 0;
200 if ($points[0]["pass_scoring"] == 0) {
201 $reached = $points[count($points)-1]["points"];
202 $max = $points[count($points)-1]["maxpoints"];
203 if (!$max) {
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'];
211 }
212 }
213 } else {
214 foreach ($points as $row) {
215 if ($row["points"] > $reached) {
216 $reached = $row["points"];
217 $max = $row["maxpoints"];
218 if (!$max) {
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'];
226 }
227 }
228 }
229 }
230 }
231 include_once "./Modules/Test/classes/class.assMarkSchema.php";
232 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
233 $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
234 return ($mark["failed"]) ? true : false;
235 } else {
236 $row = $ilDB->fetchAssoc($result);
237 return ($row['failed']) ? true : false;
238 }
239 }
static updateTestResultCache($a_user_id, $a_obj_id)
Update test result cache.
$ret
Definition: parser.php:6

References $ilDB, $pass, $res, $result, $ret, $row, ASS_MarkSchema\_getMatchingMarkFromObjId(), and updateTestResultCache().

Referenced by checkCondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateTestResultCache()

static ilObjTestAccess::updateTestResultCache (   $a_user_id,
  $a_obj_id 
)
staticprotected

Update test result cache.

Parameters
type$a_user_id
type$a_obj_id

Definition at line 246 of file class.ilObjTestAccess.php.

247 {
248 global $ilDB;
249
250 $result = $ilDB->queryF(
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)
256 );
257 if (!$result->numRows()) {
258 $result = $ilDB->queryF(
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)
262 );
263 $row = $ilDB->fetchAssoc($result);
264 if ($row['active_id'] > 0) {
265 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
267 return true;
268 } else {
269 return false;
270 }
271 } else {
272 return true;
273 }
274 }

References $ilDB, $result, $row, and assQuestion\_updateTestResultCache().

Referenced by isFailed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ visibleUserResultExists()

static ilObjTestAccess::visibleUserResultExists (   $testObjId,
  $userId 
)
static

Definition at line 755 of file class.ilObjTestAccess.php.

756 {
757 $testOBJ = ilObjectFactory::getInstanceByObjId($testObjId, false);
758
759 if (!($testOBJ instanceof ilObjTest)) {
760 return false;
761 }
762
763 require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
764 $testSessionFactory = new ilTestSessionFactory($testOBJ);
765 $testSession = $testSessionFactory->getSessionByUserId($userId);
766
767 return $testOBJ->canShowTestResults($testSession);
768 }

References ilObjectFactory\getInstanceByObjId().

Referenced by ilLOUtils\getTestResultLinkForUser(), and ilObjTestListGUI\handleUserResultsCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $hasFinishedCache

ilObjTestAccess::$hasFinishedCache = array()
staticprivate

Definition at line 376 of file class.ilObjTestAccess.php.


The documentation for this class was generated from the following file: