ILIAS  release_8 Revision v8.24
ilObjTestAccess Class Reference

Class ilObjTestAccess. More...

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

Public Member Functions

 canBeDelivered (ilWACPath $ilWACPath)
 
 _checkAccess (string $cmd, string $permission, int $ref_id, int $obj_id, int $user_id=null)
 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 (string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
 Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
 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 (int $a_trigger_obj_id, string $a_operator, string $a_value, int $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 (string $target)
 check whether goto script will succeed More...
 
static _isOffline (int $obj_id)
 returns the objects's OFFline status More...
 
static visibleUserResultExists ($testObjId, $userId)
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static _isOffline (int $obj_id)
 Type-specific implementation of general status, has to be overwritten if object type does not support centralized offline handling. More...
 
static _preloadData (array $obj_ids, array $ref_ids)
 Preload data. More...
 
static getConditionOperators ()
 Returns an array with valid operators for the specific object type. More...
 
static checkCondition (int $a_trigger_obj_id, string $a_operator, string $a_value, int $a_usr_id)
 check condition for a specific user and object More...
 

Static Protected Member Functions

static updateTestResultCache ($a_user_id, $a_obj_id)
 

Private Member Functions

 findMatch (string $path, array $array)
 

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

Member Function Documentation

◆ _checkAccess()

ilObjTestAccess::_checkAccess ( string  $cmd,
string  $permission,
int  $ref_id,
int  $obj_id,
int  $user_id = null 
)

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.

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

70 : bool
71 {
72 global $DIC;
73 $ilUser = $DIC['ilUser'];
74 $lng = $DIC['lng'];
75 $rbacsystem = $DIC['rbacsystem'];
76 $ilAccess = $DIC['ilAccess'];
77
78 if (is_null($user_id)) {
79 $user_id = $ilUser->getId();
80 }
81
82 $is_admin = $rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id);
83
84
85 switch ($permission) {
86 case "visible":
87 case "read":
89 !$is_admin) {
90 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
91 return false;
92 }
93 break;
94 }
95
96 switch ($cmd) {
97 case "eval_a":
98 case "eval_stat":
100 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
101 return false;
102 }
103 break;
104
105 }
106
107 return true;
108 }
static _lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
$ref_id
Definition: ltiauth.php:67
$lng

References $DIC, $ilUser, $lng, $ref_id, _lookupCreationComplete(), and ilAccessInfo\IL_NO_OBJECT_ACCESS.

+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjTestAccess::_checkGoto ( string  $target)
static

check whether goto script will succeed

Reimplemented from ilObjectAccess.

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

735 : bool
736 {
737 global $DIC;
738 $ilAccess = $DIC['ilAccess'];
739
740 $t_arr = explode("_", $target);
741
742 if ($t_arr[0] != "tst" || ((int) $t_arr[1]) <= 0) {
743 return false;
744 }
745
746 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
747 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
748 return true;
749 }
750 return false;
751 }

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

357 : array
358 {
359 global $DIC;
360 $DIC->language()->loadLanguageModule('assessment');
361
362 $commands = array(
363 array("permission" => "write", "cmd" => "questionsTabGateway", "lang_var" => "tst_edit_questions"),
364 array("permission" => "write", "cmd" => "ilObjTestSettingsGeneralGUI::showForm", "lang_var" => "settings"),
365 array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "tst_run",
366 "default" => true),
367 //array("permission" => "write", "cmd" => "", "lang_var" => "edit"),
368 array("permission" => "tst_statistics", "cmd" => "outEvaluation", "lang_var" => "tst_statistical_evaluation"),
369 array("permission" => "read", "cmd" => "userResultsGateway", "lang_var" => "tst_user_results"),
370 array("permission" => "write", "cmd" => "testResultsGateway", "lang_var" => "results"),
371 array("permission" => "eval_a", "cmd" => "testResultsGateway", "lang_var" => "results")
372 );
373
374 return $commands;
375 }

References $DIC.

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

582 : string
583 {
584 global $DIC;
585 $lng = $DIC['lng'];
586 $ilDB = $DIC['ilDB'];
587
588 $result = $ilDB->queryF(
589 "SELECT * FROM tst_active WHERE active_id = %s",
590 array("integer"),
591 array($active_id)
592 );
593 $row = $ilDB->fetchAssoc($result);
594 $user_id = $row["user_fi"];
595 $test_id = $row["test_fi"];
596 $importname = $row['importname'];
597
598 $result = $ilDB->queryF(
599 "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
600 array("integer"),
601 array($test_id)
602 );
603 $row = $ilDB->fetchAssoc($result);
604 $obj_id = $row["obj_fi"];
605
606 $is_anonymous = ilObjTest::_lookupAnonymity($obj_id);
607
608 $uname = ilObjUser::_lookupName($user_id);
609
610 $name = "";
611 if (strlen($importname)) {
612 $name = $importname . ' (' . $lng->txt('imported') . ')';
613 } elseif (strlen($uname["firstname"] . $uname["lastname"]) == 0) {
614 $name = $lng->txt("deleted_user");
615 } else {
616 if ($user_id == ANONYMOUS_USER_ID) {
617 $name = "";
618 } else {
619 $name = trim($uname["lastname"] . ", " . $uname["firstname"]);
620 }
621 if ($is_anonymous) {
622 $name = $lng->txt("anonymous");
623 }
624 }
625 return $name;
626 }
static _lookupAnonymity($a_obj_id)
Returns the anonymity status of a test with a given object id.
static _lookupName(int $a_user_id)
lookup user name
const ANONYMOUS_USER_ID
Definition: constants.php:27
if($format !==null) $name
Definition: metadata.php:247

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

Referenced by assQuestion\_setReachedPoints(), ilTestParticipantList\buildParticipantsFullname(), ilTestResultsToXML\exportActiveIDs(), ilTestParticipantData\getFormatedFullnameByActiveId(), ilTestParticipantData\getOptionArray(), 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 634 of file class.ilObjTestAccess.php.

634 : int
635 {
636 global $DIC;
637 $lng = $DIC['lng'];
638 $ilDB = $DIC['ilDB'];
639
640 $result = $ilDB->queryF(
641 "SELECT user_fi FROM tst_active WHERE active_id = %s",
642 array("integer"),
643 array($active_id)
644 );
645 $row = $ilDB->fetchAssoc($result);
646 return $row["user_fi"];
647 }

References $DIC, $ilDB, and $lng.

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

664 : array
665 {
666 global $DIC;
667 $ilDB = $DIC['ilDB'];
668
669 $passed_users = array();
670 // Maybe SELECT DISTINCT(tst_active.user_fi)... ?
671 $userresult = $ilDB->queryF(
672 "
673 SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences, tst_active.last_finished_pass,
674 CASE WHEN
675 (tst_tests.nr_of_tries - 1) = tst_active.last_finished_pass
676 THEN '1'
677 ELSE '0'
678 END is_last_pass
679 FROM tst_tests
680 INNER JOIN tst_active
681 ON tst_active.test_fi = tst_tests.test_id
682 LEFT JOIN tst_sequence
683 ON tst_sequence.active_fi = tst_active.active_id
684 WHERE tst_tests.obj_fi = %s
685 GROUP BY tst_active.active_id
686 ",
687 array('integer'),
688 array($a_obj_id)
689 );
690 $all_participants = array();
691 $notAttempted = array();
692 $lastPassUsers = array();
693 while ($row = $ilDB->fetchAssoc($userresult)) {
694 if ($row['sequences'] == 0) {
695 $notAttempted[$row['active_id']] = $row['active_id'];
696 }
697 if ($row['is_last_pass']) {
698 $lastPassUsers[$row['active_id']] = $row['active_id'];
699 }
700
701 $all_participants[$row['active_id']] = $row['active_id'];
702 }
703
704 $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'));
705 $found_all = ($result->numRows() == count($all_participants)) ? true : false;
706 if (!$found_all) {
707 // if the result cache entries do not exist, create them
708 $found_participants = array();
709 while ($data = $ilDB->fetchAssoc($result)) {
710 array_push($found_participants, $data['active_fi']);
711 }
712 foreach ($all_participants as $active_id) {
713 if (!in_array($active_id, $found_participants)) {
715 }
716 }
717 $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'));
718 }
719 while ($data = $ilDB->fetchAssoc($result)) {
720 if (isset($notAttempted[$data['active_fi']])) {
721 $data['failed'] = 0;
722 $data['passed'] = 0;
723 $data['not_attempted'] = 1;
724 }
725
726 $data['user_id'] = $data['user_fi'];
727 array_push($passed_users, $data);
728 }
729 return $passed_users;
730 }
static _updateTestResultCache(int $active_id, ilAssQuestionProcessLocker $processLocker=null)
@TODO Move this to a proper place.

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

500 : array
501 {
502 global $DIC;
503 $ilDB = $DIC['ilDB'];
504
505 $query = "
506 SELECT DISTINCT t.obj_fi
507 FROM tst_tests t
508 INNER JOIN tst_rnd_quest_set_qpls r
509 ON t.test_id = r.test_fi
510 WHERE r.pool_fi = %s
511 ";
512
513 $result = $ilDB->queryF($query, array('integer'), array($qpl_id));
514
515 $tests = array();
516 while ($row = $ilDB->fetchAssoc($result)) {
517 $tests[] = $row['obj_fi'];
518 }
519
520 return $tests;
521 }
$query

References $DIC, $ilDB, and $query.

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

456 {
457 global $DIC;
458 $ilDB = $DIC['ilDB'];
459 $test_id = false;
460 $result = $ilDB->queryF(
461 "SELECT test_id FROM tst_tests WHERE obj_fi = %s",
462 array('integer'),
463 array($object_id)
464 );
465 if ($result->numRows()) {
466 $row = $ilDB->fetchAssoc($result);
467 $test_id = $row["test_id"];
468 }
469 return $test_id;
470 }

References $DIC, and $ilDB.

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

+ Here is the caller graph for this function:

◆ _isOffline()

static ilObjTestAccess::_isOffline ( int  $obj_id)
static

returns the objects's OFFline status

Used in ListGUI and Learning Progress

Reimplemented from ilObjectAccess.

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

758 : bool
759 {
760 // global $DIC;
761 // $ilUser = $DIC['ilUser'];
762 // return (self::_lookupOnlineTestAccess($obj_id, $ilUser->getId()) !== true) ||
763 // (!ilObjTestAccess::_lookupCreationComplete($obj_id));
764 return ilObject::lookupOfflineStatus($obj_id);
765 }
static lookupOfflineStatus(int $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 117 of file class.ilObjTestAccess.php.

117 : bool
118 {
119 global $DIC;
120 $ilDB = $DIC['ilDB'];
121 $result = $ilDB->queryF(
122 "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",
123 array('integer','integer'),
124 array($user_id, $a_obj_id)
125 );
126 if (!$result->numRows()) {
127 $result = $ilDB->queryF(
128 "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",
129 array('integer','integer'),
130 array($user_id, $a_obj_id)
131 );
132 $row = $ilDB->fetchAssoc($result);
133 if ($row !== null && $row['active_id'] > 0) {
134 assQuestion::_updateTestResultCache($row['active_id']);
135 } else {
136 return false;
137 }
138 }
139 $result = $ilDB->queryF(
140 "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",
141 array('integer','integer'),
142 array($user_id, $a_obj_id)
143 );
144 if (!$result->numRows()) {
145 $result = $ilDB->queryF(
146 "SELECT tst_pass_result.*, tst_tests.pass_scoring, 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",
147 array('integer','integer'),
148 array($user_id, $a_obj_id)
149 );
150
151 if (!$result->numRows()) {
152 return false;
153 }
154
155 $points = array();
156 while ($row = $ilDB->fetchAssoc($result)) {
157 array_push($points, $row);
158 }
159 $reached = 0;
160 $max = 0;
161 if ($points[0]["pass_scoring"] == 0) {
162 $reached = $points[count($points) - 1]["points"];
163 $max = $points[count($points) - 1]["maxpoints"];
164 if (!$max) {
165 $active_id = $points[count($points) - 1]["active_fi"];
166 $pass = $points[count($points) - 1]["pass"];
167 if (strlen($active_id) && strlen($pass)) {
168 $res = assQuestion::_updateTestPassResults($active_id, $pass, false, null, $a_obj_id);
169 $max = $res['maxpoints'];
170 $reached = $res['points'];
171 }
172 }
173 } else {
174 foreach ($points as $row) {
175 if ($row["points"] > $reached) {
176 $reached = $row["points"];
177 $max = $row["maxpoints"];
178 if (!$max) {
179 $active_id = $row["active_fi"];
180 $pass = $row["pass"];
181 if (strlen($active_id) && strlen($pass)) {
182 $res = assQuestion::_updateTestPassResults($active_id, $pass, false, null, $a_obj_id);
183 $max = $res['maxpoints'];
184 $reached = $res['points'];
185 }
186 }
187 }
188 }
189 }
190 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
191 $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
192 return ($mark["passed"]) ? true : false;
193 } else {
194 $row = $ilDB->fetchAssoc($result);
195 return ($row['passed']) ? true : false;
196 }
197 }
static _getMatchingMarkFromObjId($a_obj_id, float $percentage)
Returns the matching mark for a given percentage.
return true
$res
Definition: ltiservices.php:69

References $DIC, $ilDB, $res, ASS_MarkSchema\_getMatchingMarkFromObjId(), assQuestion\_updateTestResultCache(), and true.

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

384 : bool
385 {
386 global $DIC;
387 $ilDB = $DIC['ilDB'];
388
389 $result = $ilDB->queryF(
390 "SELECT complete FROM tst_tests WHERE obj_fi=%s",
391 array('integer'),
392 array($a_obj_id)
393 );
394 if ($result->numRows() == 1) {
395 $row = $ilDB->fetchAssoc($result);
396 }
397
398 return isset($row['complete']) && $row['complete'];
399 }

References $DIC, and $ilDB.

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

478 : int
479 {
480 global $DIC;
481 $ilDB = $DIC['ilDB'];
482
483 $result = $ilDB->queryF(
484 "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
485 array('integer'),
486 array($a_test_id)
487 );
488
489 $row = $ilDB->fetchAssoc($result);
490 return $row["obj_fi"];
491 }

References $DIC, and $ilDB.

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

531 {
532 global $DIC;
533 $ilDB = $DIC['ilDB'];
534 $lng = $DIC['lng'];
535
536 $result = $ilDB->queryF(
537 "SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
538 array('integer'),
539 array($a_test_id)
540 );
541 if ($result->numRows()) {
542 $row = $ilDB->fetchAssoc($result);
543 if ($row["fixed_participants"]) {
544 $result = $ilDB->queryF(
545 "SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
546 array('integer','integer'),
547 array($row["test_id"], $a_user_id)
548 );
549 if ($result->numRows()) {
550 $row = $ilDB->fetchAssoc($result);
551 if (trim($row['clientip']) != "") {
552 $row['clientip'] = preg_replace("/[^0-9.?*,:]+/", "", $row['clientip']);
553 $row['clientip'] = str_replace(".", "\\.", $row['clientip']);
554 $row['clientip'] = str_replace(array("?","*",","), array("[0-9]","[0-9]*","|"), $row['clientip']);
555 if (!preg_match("/^" . $row['clientip'] . "$/", $_SERVER["REMOTE_ADDR"])) {
556 $lng->loadLanguageModule('assessment');
557 return $lng->txt("user_wrong_clientip");
558 } else {
559 return true;
560 }
561 } else {
562 return true;
563 }
564 } else {
565 return $lng->txt("tst_user_not_invited");
566 }
567 } else {
568 return true;
569 }
570 } else {
571 return true;
572 }
573 }
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10

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

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

+ Here is the caller graph for this function:

◆ canBeDelivered()

ilObjTestAccess::canBeDelivered ( ilWACPath  $ilWACPath)

Reimplemented from ilObjectAccess.

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

41 : bool
42 {
43 global $DIC;
44 $readable = new Readable($DIC);
45
46 $can_it = $this->findMatch($ilWACPath->getPath(), [
47 new AccessFileUploadAnswer($DIC, $readable),
48 new AccessQuestionImage($readable),
49 new AccessFileUploadPreview($DIC->database(), $DIC->access()),
50 ]);
51
52
53 return !$can_it->isOk() || $can_it->value();
54 }
findMatch(string $path, array $array)

References $DIC, findMatch(), and ilWACPath\getPath().

+ Here is the call graph for this function:

◆ checkCondition()

static ilObjTestAccess::checkCondition ( int  $a_trigger_obj_id,
string  $a_operator,
string  $a_value,
int  $a_usr_id 
)
static

check condition

this method is called by ilConditionHandler

Implements ilConditionHandling.

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

323 : bool
324 {
325 switch ($a_operator) {
327 return ilObjTestAccess::_isPassed($a_usr_id, $a_trigger_obj_id);
328 break;
329
331 return ilObjTestAccess::isFailed($a_usr_id, $a_trigger_obj_id);
332
334 return ilObjTestAccess::hasFinished($a_usr_id, $a_trigger_obj_id);
335
337 return !ilObjTestAccess::hasFinished($a_usr_id, $a_trigger_obj_id);
338
339 default:
340 return true;
341 }
342 return true;
343 }
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(), and ilCourseStart\isFullfilled().

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

◆ findMatch()

ilObjTestAccess::findMatch ( string  $path,
array  $array 
)
private

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

56 : Result
57 {
58 return array_reduce($array, fn (Result $result, SimpleAccess $access) => $result->except(
59 fn () => $access->isPermitted($path)
60 ), new Error('Not a known path.'));
61 }
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Error.php:18
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:15
except(callable $f)
Feed the error into a callable and replace this with the result or do nothing if this is a value.
$path
Definition: ltiservices.php:32

References $path, ILIAS\Data\Result\except(), and ILIAS\Modules\Test\SimpleAccess\isPermitted().

Referenced by canBeDelivered().

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

◆ getConditionOperators()

static ilObjTestAccess::getConditionOperators ( )
static

◆ 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

@noinspection PhpParamsInspection

@noinspection PhpParamsInspection

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

415 : bool
416 {
417 if (!isset(self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"])) {
418 require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
419 require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
420 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
421
422 global $DIC;
423 $ilDB = $DIC['ilDB'];
424 $lng = $DIC['lng'];
425
426 $testOBJ = ilObjectFactory::getInstanceByObjId($a_obj_id);
427
428 $partData = new ilTestParticipantData($ilDB, $lng);
429 $partData->setUserIdsFilter(array($a_user_id));
430 $partData->load($testOBJ->getTestId());
431
432 $activeId = $partData->getActiveIdByUserId($a_user_id);
433
435 $testSessionFactory = new ilTestSessionFactory($testOBJ);
436 $testSession = $testSessionFactory->getSession($activeId);
438 $testPassesSelector = new ilTestPassesSelector($ilDB, $testOBJ);
439 $testPassesSelector->setActiveId($activeId);
440 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
441
442 self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
443 }
444
445 return (bool) self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"];
446 }
static getInstanceByObjId(?int $obj_id, bool $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:

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

206 : bool
207 {
208 global $DIC;
209 $ilDB = $DIC['ilDB'];
210
211 $ret = self::updateTestResultCache($user_id, $a_obj_id);
212
213 if (!$ret) {
214 return false;
215 }
216
217 $result = $ilDB->queryF(
218 "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",
219 array('integer','integer'),
220 array($user_id, $a_obj_id)
221 );
222
223 if (!$result->numRows()) {
224 $result = $ilDB->queryF(
225 "SELECT tst_pass_result.*, tst_tests.pass_scoring 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",
226 array('integer','integer'),
227 array($user_id, $a_obj_id)
228 );
229
230 while ($row = $ilDB->fetchAssoc($result)) {
231 array_push($points, $row);
232 }
233 $reached = 0;
234 $max = 0;
235 if ($points[0]["pass_scoring"] == 0) {
236 $reached = $points[count($points) - 1]["points"];
237 $max = $points[count($points) - 1]["maxpoints"];
238 if (!$max) {
239 $active_id = $points[count($points) - 1]["active_fi"];
240 $pass = $points[count($points) - 1]["pass"];
241 if (strlen($active_id) && strlen($pass)) {
242 $res = assQuestion::_updateTestPassResults($active_id, $pass, false, null, $a_obj_id);
243 $max = $res['maxpoints'];
244 $reached = $res['points'];
245 }
246 }
247 } else {
248 foreach ($points as $row) {
249 if ($row["points"] > $reached) {
250 $reached = $row["points"];
251 $max = $row["maxpoints"];
252 if (!$max) {
253 $active_id = $row["active_fi"];
254 $pass = $row["pass"];
255 if (strlen($active_id) && strlen($pass)) {
256 $res = assQuestion::_updateTestPassResults($active_id, $pass, false, null, $a_obj_id);
257 $max = $res['maxpoints'];
258 $reached = $res['points'];
259 }
260 }
261 }
262 }
263 }
264 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
265 $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
266 return ($mark["failed"]) ? true : false;
267 } else {
268 $row = $ilDB->fetchAssoc($result);
269 return ($row['failed']) ? true : false;
270 }
271 }
static updateTestResultCache($a_user_id, $a_obj_id)

References $DIC, $ilDB, $res, ASS_MarkSchema\_getMatchingMarkFromObjId(), true, 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

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

273 : bool
274 {
275 global $DIC;
276 $ilDB = $DIC['ilDB'];
277
278 $result = $ilDB->queryF(
279 "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests " .
280 "WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s " .
281 "AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
282 array('integer','integer'),
283 array($a_user_id, $a_obj_id)
284 );
285 if (!$result->numRows()) {
286 $result = $ilDB->queryF(
287 "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",
288 array('integer','integer'),
289 array($a_user_id, $a_obj_id)
290 );
291 $row = $ilDB->fetchAssoc($result);
292 if ($row !== null && $row['active_id'] > 0) {
293 assQuestion::_updateTestResultCache($row['active_id']);
294 return true;
295 } else {
296 return false;
297 }
298 } else {
299 return true;
300 }
301 }

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

768 : bool
769 {
770 $testOBJ = ilObjectFactory::getInstanceByObjId($testObjId, false);
771
772 if (!($testOBJ instanceof ilObjTest)) {
773 return false;
774 }
775
776 require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
777 $testSessionFactory = new ilTestSessionFactory($testOBJ);
778 $testSession = $testSessionFactory->getSessionByUserId($userId);
779
780 return $testOBJ->canShowTestResults($testSession);
781 }

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


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