ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
Parameters
ilWACPath$ilWACPath
Returns
bool
More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 

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 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 if object type does not support centralized offline handling. 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 $DIC;
40 $ilUser = $DIC['ilUser'];
41 $lng = $DIC['lng'];
42 $rbacsystem = $DIC['rbacsystem'];
43 $ilAccess = $DIC['ilAccess'];
44
45 if ($a_user_id == "") {
46 $a_user_id = $ilUser->getId();
47 }
48
49 $is_admin = $rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id);
50
51
52 switch ($a_permission) {
53 case "visible":
54 case "read":
56 !$is_admin) {
57 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
58 return false;
59 }
60 break;
61 }
62
63 switch ($a_cmd) {
64 case "eval_a":
65 case "eval_stat":
67 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
68 return false;
69 }
70 break;
71
72 }
73
74 return true;
75 }
const IL_NO_OBJECT_ACCESS
static _lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
$lng
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46

References $DIC, $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 716 of file class.ilObjTestAccess.php.

717 {
718 global $DIC;
719 $ilAccess = $DIC['ilAccess'];
720
721 $t_arr = explode("_", $a_target);
722
723 if ($t_arr[0] != "tst" || ((int) $t_arr[1]) <= 0) {
724 return false;
725 }
726
727 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
728 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
729 return true;
730 }
731 return false;
732 }

References $DIC.

◆ _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 335 of file class.ilObjTestAccess.php.

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

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 554 of file class.ilObjTestAccess.php.

555 {
556 global $DIC;
557 $lng = $DIC['lng'];
558 $ilDB = $DIC['ilDB'];
559
560 $result = $ilDB->queryF(
561 "SELECT * FROM tst_active WHERE active_id = %s",
562 array("integer"),
563 array($active_id)
564 );
565 $row = $ilDB->fetchAssoc($result);
566 $user_id = $row["user_fi"];
567 $test_id = $row["test_fi"];
568 $importname = $row['importname'];
569
570 $result = $ilDB->queryF(
571 "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
572 array("integer"),
573 array($test_id)
574 );
575 $row = $ilDB->fetchAssoc($result);
576 $obj_id = $row["obj_fi"];
577
578 include_once "./Modules/Test/classes/class.ilObjTest.php";
579 $is_anonymous = ilObjTest::_lookupAnonymity($obj_id);
580
581 include_once './Services/User/classes/class.ilObjUser.php';
582 $uname = ilObjUser::_lookupName($user_id);
583
584 $name = "";
585 if (strlen($importname)) {
586 $name = $importname . ' (' . $lng->txt('imported') . ')';
587 } elseif (strlen($uname["firstname"] . $uname["lastname"]) == 0) {
588 $name = $lng->txt("deleted_user");
589 } else {
590 if ($user_id == ANONYMOUS_USER_ID) {
591 $name = $lastname;
592 } else {
593 $name = trim($uname["lastname"] . ", " . $uname["firstname"] . " " . $uname["title"]);
594 }
595 if ($is_anonymous) {
596 $name = $lng->txt("anonymous");
597 }
598 }
599 return $name;
600 }
$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:230
global $ilDB

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

Referenced by assQuestion\_setReachedPoints(), ilTestParticipantList\buildParticipantsFullname(), ilTestResultsToXML\exportActiveIDs(), and ilObjTest\logManualFeedback().

+ 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 608 of file class.ilObjTestAccess.php.

609 {
610 global $DIC;
611 $lng = $DIC['lng'];
612 $ilDB = $DIC['ilDB'];
613
614 $result = $ilDB->queryF(
615 "SELECT user_fi FROM tst_active WHERE active_id = %s",
616 array("integer"),
617 array($active_id)
618 );
619 $row = $ilDB->fetchAssoc($result);
620 return $row["user_fi"];
621 }

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

Referenced by assFileUpload\handleSubmission(), ilTestScoringByQuestionsGUI\saveManScoringByQuestion(), 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 638 of file class.ilObjTestAccess.php.

639 {
640 global $DIC;
641 $ilDB = $DIC['ilDB'];
642
643 $passed_users = array();
644 // Maybe SELECT DISTINCT(tst_active.user_fi)... ?
645 $userresult = $ilDB->queryF(
646 "
647 SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences, tst_active.last_finished_pass,
648 CASE WHEN
649 (tst_tests.nr_of_tries - 1) = tst_active.last_finished_pass
650 THEN '1'
651 ELSE '0'
652 END is_last_pass
653 FROM tst_tests
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
660 ",
661 array('integer'),
662 array($a_obj_id)
663 );
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'];
670 }
671 if ($row['is_last_pass']) {
672 $lastPassUsers[$row['active_id']] = $row['active_id'];
673 }
674
675 $all_participants[$row['active_id']] = $row['active_id'];
676 }
677
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;
680 if (!$found_all) {
681 // if the result cache entries do not exist, create them
682 $found_participants = array();
683 while ($data = $ilDB->fetchAssoc($result)) {
684 array_push($found_participants, $data['active_fi']);
685 }
686 foreach ($all_participants as $active_id) {
687 if (!in_array($active_id, $found_participants)) {
688 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
690 }
691 }
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'));
693 }
694 while ($data = $ilDB->fetchAssoc($result)) {
695 if (isset($notAttempted[$data['active_fi']])) {
696 $data['failed'] = 0;
697 $data['passed'] = 0;
698 $data['not_attempted'] = 1;
699 }
700
701 if ($data['failed'] && !isset($lastPassUsers[$data['active_fi']])) {
702 $data['passed'] = 0;
703 $data['failed'] = 0;
704 $data['in_progress'] = 1;
705 }
706
707 $data['user_id'] = $data['user_fi'];
708 array_push($passed_users, $data);
709 }
710 return $passed_users;
711 }
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
@TODO Move this to a proper place.
$data
Definition: storeScorm.php:23

References $data, $DIC, $ilDB, $result, 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 472 of file class.ilObjTestAccess.php.

473 {
474 global $DIC;
475 $ilDB = $DIC['ilDB'];
476
477 $query = "
478 SELECT DISTINCT t.obj_fi
479 FROM tst_tests t
480 INNER JOIN tst_rnd_quest_set_qpls r
481 ON t.test_id = r.test_fi
482 WHERE r.pool_fi = %s
483 ";
484
485 $result = $ilDB->queryF($query, array('integer'), array($qpl_id));
486
487 $tests = array();
488 while ($row = $ilDB->fetchAssoc($result)) {
489 $tests[] = $row['obj_fi'];
490 }
491
492 return $tests;
493 }
$query

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

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 427 of file class.ilObjTestAccess.php.

428 {
429 global $DIC;
430 $ilDB = $DIC['ilDB'];
431 $test_id = false;
432 $result = $ilDB->queryF(
433 "SELECT test_id FROM tst_tests WHERE obj_fi = %s",
434 array('integer'),
435 array($object_id)
436 );
437 if ($result->numRows()) {
438 $row = $ilDB->fetchAssoc($result);
439 $test_id = $row["test_id"];
440 }
441 return $test_id;
442 }

References $DIC, $ilDB, and $result.

Referenced by ilLPStatusTestFinished\getParticipants(), and ilSoapTestAdministration\getTestAccess().

+ 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 742 of file class.ilObjTestAccess.php.

743 {
744 // global $DIC;
745 // $ilUser = $DIC['ilUser'];
746 // return (self::_lookupOnlineTestAccess($a_obj_id, $ilUser->getId()) !== true) ||
747 // (!ilObjTestAccess::_lookupCreationComplete($a_obj_id));
748 return ilObject::lookupOfflineStatus($a_obj_id);
749 }
static lookupOfflineStatus($a_obj_id)
Lookup offline status using objectDataCache.

References ilObject\lookupOfflineStatus().

Referenced by ilLOEditorStatus\checkTestOnline().

+ Here is the call graph for this function:
+ 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 84 of file class.ilObjTestAccess.php.

85 {
86 global $DIC;
87 $ilDB = $DIC['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";
102 assQuestion::_updateTestResultCache($row['active_id']);
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 $DIC, $ilDB, $pass, $res, $result, ASS_MarkSchema\_getMatchingMarkFromObjId(), and assQuestion\_updateTestResultCache().

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

+ 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 357 of file class.ilObjTestAccess.php.

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

References $DIC, $ilDB, and $result.

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 450 of file class.ilObjTestAccess.php.

451 {
452 global $DIC;
453 $ilDB = $DIC['ilDB'];
454
455 $result = $ilDB->queryF(
456 "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
457 array('integer'),
458 array($a_test_id)
459 );
460
461 $row = $ilDB->fetchAssoc($result);
462 return $row["obj_fi"];
463 }

References $DIC, $ilDB, and $result.

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 502 of file class.ilObjTestAccess.php.

503 {
504 global $DIC;
505 $ilDB = $DIC['ilDB'];
506 $lng = $DIC['lng'];
507
508 $result = $ilDB->queryF(
509 "SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
510 array('integer'),
511 array($a_test_id)
512 );
513 if ($result->numRows()) {
514 $row = $ilDB->fetchAssoc($result);
515 if ($row["fixed_participants"]) {
516 $result = $ilDB->queryF(
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)
520 );
521 if ($result->numRows()) {
522 $row = $ilDB->fetchAssoc($result);
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");
530 } else {
531 return true;
532 }
533 } else {
534 return true;
535 }
536 } else {
537 return $lng->txt("tst_user_not_invited");
538 }
539 } else {
540 return true;
541 }
542 } else {
543 return true;
544 }
545 }
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10

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

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 299 of file class.ilObjTestAccess.php.

300 {
301 include_once './Services/Conditions/classes/class.ilConditionHandler.php';
302
303 switch ($a_operator) {
305 return ilObjTestAccess::_isPassed($a_usr_id, $a_obj_id);
306 break;
307
309 return ilObjTestAccess::isFailed($a_usr_id, $a_obj_id);
310
312 return ilObjTestAccess::hasFinished($a_usr_id, $a_obj_id);
313
315 return !ilObjTestAccess::hasFinished($a_usr_id, $a_obj_id);
316
317 default:
318 return true;
319 }
320 return true;
321 }
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 282 of file class.ilObjTestAccess.php.

283 {
284 include_once './Services/Conditions/classes/class.ilConditionHandler.php';
285 return array(
290 );
291 }

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 388 of file class.ilObjTestAccess.php.

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

References $DIC, $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 774 of file class.ilObjTestAccess.php.

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

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

References $DIC, $ilDB, $pass, $res, $result, $ret, 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 247 of file class.ilObjTestAccess.php.

248 {
249 global $DIC;
250 $ilDB = $DIC['ilDB'];
251
252 $result = $ilDB->queryF(
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)
258 );
259 if (!$result->numRows()) {
260 $result = $ilDB->queryF(
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)
264 );
265 $row = $ilDB->fetchAssoc($result);
266 if ($row['active_id'] > 0) {
267 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
268 assQuestion::_updateTestResultCache($row['active_id']);
269 return true;
270 } else {
271 return false;
272 }
273 } else {
274 return true;
275 }
276 }

References $DIC, $ilDB, $result, 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 752 of file class.ilObjTestAccess.php.

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

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 379 of file class.ilObjTestAccess.php.


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