ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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...
 
 showCertificateFor (int $user_id, int $obj_id)
 
- 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 _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 _preloadData ($obj_ids, $ref_ids)
 
- 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 ilCertificateObjectsForUserPreloader $certificate_preloader = null
 
static array $settings_result_summaries_by_obj_id = []
 
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 43 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 93 of file class.ilObjTestAccess.php.

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

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

◆ _checkGoto()

static ilObjTestAccess::_checkGoto ( string  $target)
static

check whether goto script will succeed

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

References $DIC.

682  : bool
683  {
684  global $DIC;
685  $ilAccess = $DIC['ilAccess'];
686 
687  $t_arr = explode("_", $target);
688 
689  if ($t_arr[0] != "tst" || ((int) $t_arr[1]) <= 0) {
690  return false;
691  }
692 
693  if ($ilAccess->checkAccess("read", "", (int) $t_arr[1]) ||
694  $ilAccess->checkAccess("visible", "", (int) $t_arr[1])) {
695  return true;
696  }
697  return false;
698  }
global $DIC
Definition: shib_login.php:22

◆ _getCommands()

static ilObjTestAccess::_getCommands ( )
static

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

References $DIC.

Referenced by ilObjTestListGUI\init().

364  : array
365  {
366  global $DIC;
367  $DIC->language()->loadLanguageModule('assessment');
368 
369  $commands = [
370  ["permission" => "write", "cmd" => "questionsTabGateway", "lang_var" => "tst_edit_questions"],
371  ["permission" => "write", "cmd" => "ILIAS\Test\Settings\MainSettings\SettingsMainGUI::showForm", "lang_var" => "settings"],
372  ["permission" => "read", "cmd" => "ILIAS\Test\Presentation\TestScreenGUI::testScreen", "lang_var" => "tst_run", "default" => true]
373  ];
374 
375  return $commands;
376  }
global $DIC
Definition: shib_login.php:22
+ 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 531 of file class.ilObjTestAccess.php.

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

Referenced by ilTestParticipantList\buildParticipantsFullname(), ilTestResultsToXML\exportActiveIDs(), ilTestParticipantData\getFormatedFullnameByActiveId(), and ilTestParticipantData\getOptionArray().

531  : string
532  {
533  global $DIC;
534  $lng = $DIC['lng'];
535  $ilDB = $DIC['ilDB'];
536 
537  $result_active = $ilDB->queryF(
538  'SELECT * FROM tst_active WHERE active_id = %s',
539  ['integer'],
540  [$active_id]
541  );
542  $row_active = $ilDB->fetchAssoc($result_active);
543  $importname = $row_active['importname'];
544 
545  if ($importname !== null
546  && $importname !== '') {
547  return $importname . ' (' . $lng->txt('imported') . ')';
548  }
549 
550  if ($row_active['user_fi'] === ANONYMOUS_USER_ID) {
551  return '';
552  }
553 
554  $uname = ilObjUser::_lookupName($row_active['user_fi']);
555 
556  $result_test = $ilDB->queryF(
557  "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
558  ["integer"],
559  [$row_active['test_fi']]
560  );
561  $row_test = $ilDB->fetchAssoc($result_test);
562  $obj_id = $row_test["obj_fi"];
563 
564  if (ilObjTest::_lookupAnonymity($obj_id)) {
565  return $lng->txt("anonymous");
566  }
567 
568  if ($uname['firstname'] . $uname['lastname'] === '') {
569  return $lng->txt('deleted_user');
570  }
571 
572  return trim($uname['lastname'] . ', ' . $uname['firstname']);
573  }
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)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
+ 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 581 of file class.ilObjTestAccess.php.

References $DIC, and $ilDB.

Referenced by ILIAS\Test\Scoring\Manual\TestScoringByQuestionGUI\saveManScoringByQuestion(), ILIAS\Test\Scoring\Manual\TestScoringByParticipantGUI\saveManScoringParticipantScreen(), and ilTestPassFinishTasks\updateLearningProgressAfterPassFinishedIsWritten().

581  : int
582  {
583  global $DIC;
584  $ilDB = $DIC['ilDB'];
585 
586  $result = $ilDB->queryF(
587  'SELECT user_fi FROM tst_active WHERE active_id = %s',
588  ['integer'],
589  [$active_id]
590  );
591  $row = $ilDB->fetchAssoc($result);
592  return $row['user_fi'];
593  }
global $DIC
Definition: shib_login.php:22
+ 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 610 of file class.ilObjTestAccess.php.

References $data, $DIC, and $ilDB.

Referenced by ilLPStatusTestPassed\_getStatusInfo().

610  : array
611  {
612  global $DIC;
613  $ilDB = $DIC['ilDB'];
614 
615  $passed_users = [];
616  // Maybe SELECT DISTINCT(tst_active.user_fi)... ?
617  $userresult = $ilDB->queryF(
618  "
619  SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences, tst_active.last_finished_pass,
620  CASE WHEN
621  (tst_tests.nr_of_tries - 1) = tst_active.last_finished_pass
622  THEN '1'
623  ELSE '0'
624  END is_last_pass
625  FROM tst_tests
626  INNER JOIN tst_active
627  ON tst_active.test_fi = tst_tests.test_id
628  LEFT JOIN tst_sequence
629  ON tst_sequence.active_fi = tst_active.active_id
630  WHERE tst_tests.obj_fi = %s
631  GROUP BY tst_active.active_id
632  ",
633  ['integer'],
634  [$a_obj_id]
635  );
636  $all_participants = [];
637  $notAttempted = [];
638  $lastPassUsers = [];
639  while ($row = $ilDB->fetchAssoc($userresult)) {
640  if ($row['sequences'] == 0) {
641  $notAttempted[$row['active_id']] = $row['active_id'];
642  }
643  if ($row['is_last_pass']) {
644  $lastPassUsers[$row['active_id']] = $row['active_id'];
645  }
646 
647  $all_participants[$row['active_id']] = $row['active_id'];
648  }
649 
650  $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'));
651  $found_all = ($result->numRows() == count($all_participants)) ? true : false;
652  if (!$found_all) {
653  $test = new ilObjTest($a_obj_id, false);
654  // if the result cache entries do not exist, create them
655  $found_participants = [];
656  while ($data = $ilDB->fetchAssoc($result)) {
657  array_push($found_participants, $data['active_fi']);
658  }
659  foreach ($all_participants as $active_id) {
660  if (!in_array($active_id, $found_participants)) {
661  $test->updateTestResultCache($active_id);
662  }
663  }
664  $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'));
665  }
666  while ($data = $ilDB->fetchAssoc($result)) {
667  if (isset($notAttempted[$data['active_fi']])) {
668  $data['failed'] = 0;
669  $data['passed'] = 0;
670  $data['not_attempted'] = 1;
671  }
672 
673  $data['user_id'] = $data['user_fi'];
674  array_push($passed_users, $data);
675  }
676  return $passed_users;
677  }
global $DIC
Definition: shib_login.php:22
+ 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 ilMobStakeholder\checkAccessTestQuestion(), and 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: shib_login.php:22
+ 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: shib_login.php:22
+ 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 705 of file class.ilObjTestAccess.php.

References ilObject\lookupOfflineStatus().

Referenced by ilLOEditorStatus\checkTestOnline().

705  : bool
706  {
707  return ilObject::lookupOfflineStatus($obj_id);
708  }
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 132 of file class.ilObjTestAccess.php.

References $DIC, $ilDB, $res, $user_id, and null.

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

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

◆ _preloadData()

static ilObjTestAccess::_preloadData (   $obj_ids,
  $ref_ids 
)
static

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

References $DIC, and ILIAS\Survey\Mode\getId().

729  : void
730  {
731  global $DIC;
732  if ((new ilCertificateActiveValidator())->validate()) {
733  self::$certificate_preloader = new ilCertificateObjectsForUserPreloader(new ilUserCertificateRepository());
734  self::$certificate_preloader->preLoad($DIC['ilUser']->getId(), $obj_ids);
735  self::$settings_result_summaries_by_obj_id = (new ScoreSettingsDatabaseRepository($DIC['ilDB']))
736  ->getSettingsResultSummaryByObjIds($obj_ids);
737  }
738  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ canBeDelivered()

ilObjTestAccess::canBeDelivered ( ilWACPath  $ilWACPath)

Implements ilWACCheckingClass.

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

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

65  : bool
66  {
67  $readable = new Readable($this->access);
68 
69  $can_it = $this->findMatch($ilWACPath->getPath(), [
70  new AccessFileUploadAnswer($this->user, $this->db, $readable),
71  new AccessQuestionImage($readable),
72  new AccessFileUploadPreview($this->db, $this->access),
73  ]);
74 
75 
76  return !$can_it->isOk() || $can_it->value();
77  }
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 342 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().

342  : bool
343  {
344  switch ($a_operator) {
346  return ilObjTestAccess::_isPassed($a_usr_id, $a_trigger_obj_id);
347  break;
348 
350  return ilObjTestAccess::isFailed($a_usr_id, $a_trigger_obj_id);
351 
353  return ilObjTestAccess::hasFinished($a_usr_id, $a_trigger_obj_id);
354 
356  return !ilObjTestAccess::hasFinished($a_usr_id, $a_trigger_obj_id);
357 
358  default:
359  return true;
360  }
361  return true;
362  }
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 79 of file class.ilObjTestAccess.php.

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

Referenced by canBeDelivered().

79  : Result
80  {
81  return array_reduce($array, fn(Result $result, SimpleAccess $access) => $result->except(
82  fn() => $access->isPermitted($path)
83  ), new Error('Not a known path.'));
84  }
except(callable $f)
Feed the error into a callable and replace this with the result or do nothing if this is a value...
ilAccessHandler $access
$path
Definition: ltiservices.php:29
+ 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 223 of file class.ilObjTestAccess.php.

References $DIC, $ilDB, $res, $user_id, and null.

Referenced by checkCondition().

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

◆ showCertificateFor()

ilObjTestAccess::showCertificateFor ( int  $user_id,
int  $obj_id 
)

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

References null.

740  : bool
741  {
742  if (self::$certificate_preloader === null
743  || !self::$certificate_preloader->isPreloaded($user_id, $obj_id)
744  || !isset(self::$settings_result_summaries_by_obj_id[$obj_id])
745  || self::$settings_result_summaries_by_obj_id[$obj_id]->getScoreReporting()
746  === ScoreReportingTypes::SCORE_REPORTING_DISABLED) {
747  return false;
748  }
749 
750  $score_reporting = self::$settings_result_summaries_by_obj_id[$obj_id]->getScoreReporting();
751  if ($score_reporting === ScoreReportingTypes::SCORE_REPORTING_IMMIDIATLY) {
752  return true;
753  }
754 
755  if ($score_reporting === ScoreReportingTypes::SCORE_REPORTING_DATE
756  && self::$settings_result_summaries_by_obj_id->getReportingDate() < new \DateTimeImmutable('now', new DateTimeZone('UTC'))) {
757  return true;
758  }
759 
760  return false;
761  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ updateTestResultCache()

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

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

References $DIC, $ilDB, and null.

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

◆ visibleUserResultExists()

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

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

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

Referenced by ilLOUtils\getTestResultLinkForUser().

711  : bool
712  {
713  global $DIC;
714  $ilDB = $DIC['ilDB'];
715  $ilUser = $DIC['ilUser'];
716 
717  $test_obj = ilObjectFactory::getInstanceByObjId($test_obj_id, false);
718 
719  if (!($test_obj instanceof ilObjTest)) {
720  return false;
721  }
722 
723  $test_session_factory = new ilTestSessionFactory($test_obj, $ilDB, $ilUser);
724  $test_session = $test_session_factory->getSessionByUserId($user_id);
725 
726  return $test_obj->canShowTestResults($test_session);
727  }
global $DIC
Definition: shib_login.php:22
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 49 of file class.ilObjTestAccess.php.

◆ $certificate_preloader

ilCertificateObjectsForUserPreloader ilObjTestAccess::$certificate_preloader = null
staticprivate

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

◆ $db

ilDBInterface ilObjTestAccess::$db
private

Definition at line 45 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 47 of file class.ilObjTestAccess.php.

◆ $rbac_system

ilRbacSystem ilObjTestAccess::$rbac_system
private

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

◆ $settings_result_summaries_by_obj_id

array ilObjTestAccess::$settings_result_summaries_by_obj_id = []
staticprivate

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

◆ $user

ilObjUser ilObjTestAccess::$user
private

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


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