ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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)
 

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 ()
 
static _lookupCreationComplete ($a_obj_id)
 checks wether all necessary parts of the test are given 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 ($test_obj_id, $user_id)
 
- 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 Protected Member Functions

static updateTestResultCache ($a_user_id, $a_obj_id)
 

Private Member Functions

 findMatch (string $path, array $array)
 

Private Attributes

ilDBInterface $db
 
ilObjUser $user
 
ilLanguage $lng
 
ilRbacSystem $rbac_system
 
ilAccessHandler $access
 

Static Private Attributes

static $hasFinishedCache = []
 

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

References _lookupCreationComplete(), ILIAS\Repository\access(), ilAccessInfo\IL_NO_OBJECT_ACCESS, ILIAS\Repository\lng(), and ILIAS\Repository\user().

88  : bool
89  {
90  if (is_null($user_id)) {
91  $user_id = $this->user->getId();
92  }
93 
94  $is_admin = $this->rbac_system->checkAccessOfUser($user_id, 'write', $ref_id);
95 
96 
97  switch ($permission) {
98  case "visible":
99  case "read":
101  !$is_admin) {
102  $this->access->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $this->lng->txt("tst_warning_test_not_complete"));
103  return false;
104  }
105  break;
106  }
107 
108  switch ($cmd) {
109  case "eval_a":
110  case "eval_stat":
112  $this->access->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $this->lng->txt("tst_warning_test_not_complete"));
113  return false;
114  }
115  break;
116  }
117 
118  return true;
119  }
static _lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjTestAccess::_checkGoto ( string  $target)
static

check whether goto script will succeed

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

References $DIC.

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

◆ _getCommands()

static ilObjTestAccess::_getCommands ( )
static

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

References $DIC.

Referenced by ilObjTestListGUI\init().

360  : array
361  {
362  global $DIC;
363  $DIC->language()->loadLanguageModule('assessment');
364 
365  $commands = [
366  ["permission" => "write", "cmd" => "questionsTabGateway", "lang_var" => "tst_edit_questions"],
367  ["permission" => "write", "cmd" => "ilObjTestSettingsMainGUI::showForm", "lang_var" => "settings"],
368  ["permission" => "read", "cmd" => "ilTestScreenGUI::testScreen", "lang_var" => "tst_run", "default" => true],
369  ["permission" => "tst_statistics", "cmd" => "outEvaluation", "lang_var" => "tst_statistical_evaluation"],
370  ["permission" => "read", "cmd" => "userResultsGateway", "lang_var" => "tst_user_results"],
371  ["permission" => "write", "cmd" => "testResultsGateway", "lang_var" => "results"],
372  ["permission" => "eval_a", "cmd" => "testResultsGateway", "lang_var" => "results"]
373  ];
374 
375  return $commands;
376  }
global $DIC
Definition: feed.php:28
+ 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 public

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

References $DIC, $ilDB, ilObjTest\_lookupAnonymity(), ilObjUser\_lookupName(), ANONYMOUS_USER_ID, and ilLanguage\txt().

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

582  : string
583  {
584  global $DIC;
585  $lng = $DIC['lng'];
586  $ilDB = $DIC['ilDB'];
587 
588  $result_active = $ilDB->queryF(
589  'SELECT * FROM tst_active WHERE active_id = %s',
590  ['integer'],
591  [$active_id]
592  );
593  $row_active = $ilDB->fetchAssoc($result_active);
594  $importname = $row_active['importname'];
595 
596  if ($importname !== null
597  && $importname !== '') {
598  return $importname . ' (' . $lng->txt('imported') . ')';
599  }
600 
601  if ($row_active['user_fi'] === ANONYMOUS_USER_ID) {
602  return '';
603  }
604 
605  $uname = ilObjUser::_lookupName($row_active['user_fi']);
606 
607  $result_test = $ilDB->queryF(
608  "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
609  ["integer"],
610  [$row_active['test_fi']]
611  );
612  $row_test = $ilDB->fetchAssoc($result_test);
613  $obj_id = $row_test["obj_fi"];
614 
615  if (ilObjTest::_lookupAnonymity($obj_id)) {
616  return $lng->txt("anonymous");
617  }
618 
619  if ($uname['firstname'] . $uname['lastname'] === '') {
620  return $lng->txt('deleted_user');
621  }
622 
623  return trim($uname['lastname'] . ', ' . $uname['firstname']);
624  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _lookupName(int $a_user_id)
lookup user name
static _lookupAnonymity($a_obj_id)
global $DIC
Definition: feed.php:28
+ 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 632 of file class.ilObjTestAccess.php.

References $DIC, and $ilDB.

Referenced by assFileUpload\handleSubmission(), ilTestScoringByQuestionsGUI\saveManScoringByQuestion(), ilTestScoringGUI\saveManScoringParticipantScreen(), and ilTestPassFinishTasks\updateLearningProgressAfterPassFinishedIsWritten().

632  : int
633  {
634  global $DIC;
635  $lng = $DIC['lng'];
636  $ilDB = $DIC['ilDB'];
637 
638  $result = $ilDB->queryF(
639  "SELECT user_fi FROM tst_active WHERE active_id = %s",
640  ["integer"],
641  [$active_id]
642  );
643  $row = $ilDB->fetchAssoc($result);
644  return $row["user_fi"];
645  }
global $DIC
Definition: feed.php:28
+ 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: [ "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 ] public

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

References $data, $DIC, and $ilDB.

Referenced by ilLPStatusTestPassed\_getStatusInfo().

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

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

References $DIC, and $ilDB.

Referenced by ilObjMediaObjectAccess\checkAccessTestQuestion().

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, ['integer'], [$qpl_id]);
514 
515  $tests = [];
516  while ($row = $ilDB->fetchAssoc($result)) {
517  $tests[] = $row['obj_fi'];
518  }
519 
520  return $tests;
521  }
global $DIC
Definition: feed.php:28
+ 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 public

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

References $DIC, and $ilDB.

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

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  ['integer'],
463  [$object_id]
464  );
465  if ($result->numRows()) {
466  $row = $ilDB->fetchAssoc($result);
467  $test_id = $row["test_id"];
468  }
469  return $test_id;
470  }
global $DIC
Definition: feed.php:28
+ 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

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

References ilObject\lookupOfflineStatus().

Referenced by ilLOEditorStatus\checkTestOnline().

757  : bool
758  {
759  return ilObject::lookupOfflineStatus($obj_id);
760  }
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
+ 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 128 of file class.ilObjTestAccess.php.

References $DIC, $ilDB, and $res.

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

128  : bool
129  {
130  global $DIC;
131  $ilDB = $DIC['ilDB'];
132 
133  $test = new ilObjTest($a_obj_id, false);
134 
135  $result = $ilDB->queryF(
136  "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",
137  ['integer','integer'],
138  [$user_id, $a_obj_id]
139  );
140  if (!$result->numRows()) {
141  $result = $ilDB->queryF(
142  "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",
143  ['integer','integer'],
144  [$user_id, $a_obj_id]
145  );
146  $row = $ilDB->fetchAssoc($result);
147  if ($row !== null && $row['active_id'] > 0) {
148  $test->updateTestResultCache($row['active_id']);
149  } else {
150  return false;
151  }
152  }
153  $result = $ilDB->queryF(
154  "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",
155  ['integer','integer'],
156  [$user_id, $a_obj_id]
157  );
158  if (!$result->numRows()) {
159  $result = $ilDB->queryF(
160  "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",
161  ['integer','integer'],
162  [$user_id, $a_obj_id]
163  );
164 
165  if (!$result->numRows()) {
166  return false;
167  }
168 
169  $points = [];
170  while ($row = $ilDB->fetchAssoc($result)) {
171  array_push($points, $row);
172  }
173  $reached = 0;
174  $max = 0;
175  if ($points[0]["pass_scoring"] == 0) {
176  $reached = $points[count($points) - 1]["points"];
177  $max = $points[count($points) - 1]["maxpoints"];
178  if (!$max) {
179  $active_id = $points[count($points) - 1]["active_fi"];
180  $pass = $points[count($points) - 1]["pass"];
181  if (strlen($active_id) && strlen($pass)) {
182  $res = $test->updateTestPassResults($active_id, $pass, false, null, $a_obj_id);
183  $max = $res['maxpoints'];
184  $reached = $res['points'];
185  }
186  }
187  } else {
188  foreach ($points as $row) {
189  if ($row["points"] > $reached) {
190  $reached = $row["points"];
191  $max = $row["maxpoints"];
192  if (!$max) {
193  $active_id = $row["active_fi"];
194  $pass = $row["pass"];
195  if (strlen($active_id) && strlen($pass)) {
196  $res = $test->updateTestPassResults($active_id, $pass, false, null, $a_obj_id);
197  $max = $res['maxpoints'];
198  $reached = $res['points'];
199  }
200  }
201  }
202  }
203  }
204  $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
205  return $test->getMarkSchema()->getMatchingMark($percentage)->getPassed() === 1;
206  } else {
207  $row = $ilDB->fetchAssoc($result);
208  return ($row['passed']) ? true : false;
209  }
210  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ 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 385 of file class.ilObjTestAccess.php.

References $DIC, and $ilDB.

Referenced by _checkAccess().

385  : bool
386  {
387  global $DIC;
388  $ilDB = $DIC['ilDB'];
389 
390  $result = $ilDB->queryF(
391  "SELECT complete FROM tst_tests WHERE obj_fi=%s",
392  ['integer'],
393  [$a_obj_id]
394  );
395  if ($result->numRows() == 1) {
396  $row = $ilDB->fetchAssoc($result);
397  }
398 
399  return isset($row['complete']) && $row['complete'];
400  }
global $DIC
Definition: feed.php:28
+ 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.

References $DIC, and $ilDB.

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  ['integer'],
486  [$a_test_id]
487  );
488 
489  $row = $ilDB->fetchAssoc($result);
490  return $row["obj_fi"];
491  }
global $DIC
Definition: feed.php:28

◆ _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 public

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

References $_SERVER, $DIC, $ilDB, ilLanguage\loadLanguageModule(), and ilLanguage\txt().

Referenced by ilObjTestGUI\buildPageViewToolbar(), ilTestPlayerAbstractGUI\checkReadAccess(), ilTestScreenGUI\getLauncher(), and ilObjTestListGUI\getProperties().

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  ['integer'],
539  [$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  ['integer','integer'],
547  [$row["test_id"], $a_user_id]
548  );
549  if ($result->numRows()) {
550  $row = $ilDB->fetchAssoc($result);
551  if ($row['clientip'] !== null && trim($row['clientip']) != "") {
552  $row['clientip'] = preg_replace("/[^0-9.?*,:]+/", "", $row['clientip']);
553  $row['clientip'] = str_replace(".", "\\.", $row['clientip']);
554  $row['clientip'] = str_replace(["?","*",","], ["[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  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
loadLanguageModule(string $a_module)
Load language module.
global $DIC
Definition: feed.php:28
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ canBeDelivered()

ilObjTestAccess::canBeDelivered ( ilWACPath  $ilWACPath)

Implements ilWACCheckingClass.

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

References ILIAS\Repository\access(), findMatch(), ilWACPath\getPath(), and ILIAS\Repository\user().

60  : bool
61  {
62  $readable = new Readable($this->access);
63 
64  $can_it = $this->findMatch($ilWACPath->getPath(), [
65  new AccessFileUploadAnswer($this->user, $this->db, $readable),
66  new AccessQuestionImage($readable),
67  new AccessFileUploadPreview($this->db, $this->access),
68  ]);
69 
70 
71  return !$can_it->isOk() || $can_it->value();
72  }
findMatch(string $path, array $array)
+ 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 338 of file class.ilObjTestAccess.php.

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

Referenced by ilCourseStart\isFullfilled(), ilContainerStartObjects\isFullfilled(), ILIAS\Containter\Content\ObjectiveRenderer\renderObjective(), and ILIAS\Containter\Content\ObjectiveRenderer\renderObjectives().

338  : bool
339  {
340  switch ($a_operator) {
342  return ilObjTestAccess::_isPassed($a_usr_id, $a_trigger_obj_id);
343  break;
344 
346  return ilObjTestAccess::isFailed($a_usr_id, $a_trigger_obj_id);
347 
349  return ilObjTestAccess::hasFinished($a_usr_id, $a_trigger_obj_id);
350 
352  return !ilObjTestAccess::hasFinished($a_usr_id, $a_trigger_obj_id);
353 
354  default:
355  return true;
356  }
357  return true;
358  }
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...
+ 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 74 of file class.ilObjTestAccess.php.

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

Referenced by canBeDelivered().

74  : Result
75  {
76  return array_reduce($array, fn(Result $result, SimpleAccess $access) => $result->except(
77  fn() => $access->isPermitted($path)
78  ), new Error('Not a known path.'));
79  }
except(callable $f)
Feed the error into a callable and replace this with the result or do nothing if this is a value...
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:14
ilAccessHandler $access
$path
Definition: ltiservices.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getConditionOperators()

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

References $DIC, $ilDB, and $res.

Referenced by checkCondition().

219  : bool
220  {
221  global $DIC;
222  $ilDB = $DIC['ilDB'];
223 
224  $ret = self::updateTestResultCache($user_id, $a_obj_id);
225 
226  if (!$ret) {
227  return false;
228  }
229 
230  $test = new ilObjTest($a_obj_id, false);
231 
232  $result = $ilDB->queryF(
233  "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",
234  ['integer','integer'],
235  [$user_id, $a_obj_id]
236  );
237 
238  if (!$result->numRows()) {
239  $result = $ilDB->queryF(
240  "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",
241  ['integer','integer'],
242  [$user_id, $a_obj_id]
243  );
244 
245  while ($row = $ilDB->fetchAssoc($result)) {
246  array_push($points, $row);
247  }
248  $reached = 0;
249  $max = 0;
250  if ($points[0]["pass_scoring"] == 0) {
251  $reached = $points[count($points) - 1]["points"];
252  $max = $points[count($points) - 1]["maxpoints"];
253  if (!$max) {
254  $active_id = $points[count($points) - 1]["active_fi"];
255  $pass = $points[count($points) - 1]["pass"];
256  if (strlen($active_id) && strlen($pass)) {
257  $res = $test->updateTestPassResults($active_id, $pass, false, null, $a_obj_id);
258  $max = $res['maxpoints'];
259  $reached = $res['points'];
260  }
261  }
262  } else {
263  foreach ($points as $row) {
264  if ($row["points"] > $reached) {
265  $reached = $row["points"];
266  $max = $row["maxpoints"];
267  if (!$max) {
268  $active_id = $row["active_fi"];
269  $pass = $row["pass"];
270  if (strlen($active_id) && strlen($pass)) {
271  $res = $test->updateTestPassResults($active_id, $pass, false, null, $a_obj_id);
272  $max = $res['maxpoints'];
273  $reached = $res['points'];
274  }
275  }
276  }
277  }
278  }
279  $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
280  return $test->getMarkSchema()->getMatchingMark($percentage)->getPassed() === 0;
281  } else {
282  $row = $ilDB->fetchAssoc($result);
283  return ($row['failed']) ? true : false;
284  }
285  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ updateTestResultCache()

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

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

References $DIC, and $ilDB.

287  : bool
288  {
289  global $DIC;
290  $ilDB = $DIC['ilDB'];
291 
292  $result = $ilDB->queryF(
293  "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests " .
294  "WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s " .
295  "AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
296  ['integer','integer'],
297  [$a_user_id, $a_obj_id]
298  );
299  if (!$result->numRows()) {
300  $result = $ilDB->queryF(
301  "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",
302  ['integer','integer'],
303  [$a_user_id, $a_obj_id]
304  );
305  $row = $ilDB->fetchAssoc($result);
306  if ($row !== null && $row['active_id'] > 0) {
307  $test = new ilObjTest($a_obj_id, false);
308  $test->updateTestResultCache($row['active_id']);
309  return true;
310  } else {
311  return false;
312  }
313  } else {
314  return true;
315  }
316  }
global $DIC
Definition: feed.php:28

◆ visibleUserResultExists()

static ilObjTestAccess::visibleUserResultExists (   $test_obj_id,
  $user_id 
)
static

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

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

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

763  : bool
764  {
765  global $DIC;
766  $ilDB = $DIC['ilDB'];
767  $ilUser = $DIC['ilUser'];
768 
769  $test_obj = ilObjectFactory::getInstanceByObjId($test_obj_id, false);
770 
771  if (!($test_obj instanceof ilObjTest)) {
772  return false;
773  }
774 
775  $test_session_factory = new ilTestSessionFactory($test_obj, $ilDB, $ilUser);
776  $test_session = $test_session_factory->getSessionByUserId($user_id);
777 
778  return $test_obj->canShowTestResults($test_session);
779  }
global $DIC
Definition: feed.php:28
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilObjTestAccess::$access
private

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

◆ $db

ilDBInterface ilObjTestAccess::$db
private

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

◆ $hasFinishedCache

ilObjTestAccess::$hasFinishedCache = []
staticprivate

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

◆ $lng

ilLanguage ilObjTestAccess::$lng
private

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

◆ $rbac_system

ilRbacSystem ilObjTestAccess::$rbac_system
private

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

◆ $user

ilObjUser ilObjTestAccess::$user
private

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


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