ILIAS  release_7 Revision v7.30-3-g800a261c036
ilObjTestAccess Class Reference

Class ilObjTestAccess. More...

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

Public Member Functions

 canBeDelivered (ilWACPath $ilWACPath)
 
 _checkAccess ($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
 Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
- Public Member Functions inherited from ilObjectAccess
 _checkAccess ($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
 Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
Parameters
ilWACPath$ilWACPath
Returns
bool
More...
 

Static Public Member Functions

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

Static Protected Member Functions

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

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

Member Function Documentation

◆ _checkAccess()

ilObjTestAccess::_checkAccess (   $a_cmd,
  $a_permission,
  $a_ref_id,
  $a_obj_id,
  $a_user_id = "" 
)

Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess)

Please do not check any preconditions handled by ilConditionHandler here.

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

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

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

69  {
70  global $DIC;
71  $ilUser = $DIC['ilUser'];
72  $lng = $DIC['lng'];
73  $rbacsystem = $DIC['rbacsystem'];
74  $ilAccess = $DIC['ilAccess'];
75 
76  if ($a_user_id == "") {
77  $a_user_id = $ilUser->getId();
78  }
79 
80  $is_admin = $rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id);
81 
82 
83  switch ($a_permission) {
84  case "visible":
85  case "read":
87  !$is_admin) {
88  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
89  return false;
90  }
91  break;
92  }
93 
94  switch ($a_cmd) {
95  case "eval_a":
96  case "eval_stat":
98  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
99  return false;
100  }
101  break;
102 
103  }
104 
105  return true;
106  }
static _lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
const IL_NO_OBJECT_ACCESS
$lng
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjTestAccess::_checkGoto (   $a_target)
static

check whether goto script will succeed

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

References $DIC.

758  {
759  global $DIC;
760  $ilAccess = $DIC['ilAccess'];
761 
762  $t_arr = explode("_", $a_target);
763 
764  if ($t_arr[0] != "tst" || ((int) $t_arr[1]) <= 0) {
765  return false;
766  }
767 
768  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
769  $ilAccess->checkAccess("visible", "", $t_arr[1])) {
770  return true;
771  }
772  return false;
773  }
global $DIC
Definition: goto.php:24

◆ _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"), );

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

References $DIC.

Referenced by ilObjTestListGUI\init().

372  {
373  global $DIC;
374  $DIC->language()->loadLanguageModule('assessment');
375 
376  $commands = array(
377  array("permission" => "write", "cmd" => "questionsTabGateway", "lang_var" => "tst_edit_questions"),
378  array("permission" => "write", "cmd" => "ilObjTestSettingsGeneralGUI::showForm", "lang_var" => "settings"),
379  array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "tst_run",
380  "default" => true),
381  //array("permission" => "write", "cmd" => "", "lang_var" => "edit"),
382  array("permission" => "tst_statistics", "cmd" => "outEvaluation", "lang_var" => "tst_statistical_evaluation"),
383  array("permission" => "read", "cmd" => "userResultsGateway", "lang_var" => "tst_user_results"),
384  array("permission" => "write", "cmd" => "testResultsGateway", "lang_var" => "results"),
385  array("permission" => "eval_a", "cmd" => "testResultsGateway", "lang_var" => "results")
386  );
387 
388  return $commands;
389  }
global $DIC
Definition: goto.php:24
+ 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 595 of file class.ilObjTestAccess.php.

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

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

596  {
597  global $DIC;
598  $lng = $DIC['lng'];
599  $ilDB = $DIC['ilDB'];
600 
601  $result = $ilDB->queryF(
602  "SELECT * FROM tst_active WHERE active_id = %s",
603  array("integer"),
604  array($active_id)
605  );
606  $row = $ilDB->fetchAssoc($result);
607  $user_id = $row["user_fi"];
608  $test_id = $row["test_fi"];
609  $importname = $row['importname'];
610 
611  $result = $ilDB->queryF(
612  "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
613  array("integer"),
614  array($test_id)
615  );
616  $row = $ilDB->fetchAssoc($result);
617  $obj_id = $row["obj_fi"];
618 
619  include_once "./Modules/Test/classes/class.ilObjTest.php";
620  $is_anonymous = ilObjTest::_lookupAnonymity($obj_id);
621 
622  include_once './Services/User/classes/class.ilObjUser.php';
623  $uname = ilObjUser::_lookupName($user_id);
624 
625  $name = "";
626  if (strlen($importname)) {
627  $name = $importname . ' (' . $lng->txt('imported') . ')';
628  } elseif (strlen($uname["firstname"] . $uname["lastname"]) == 0) {
629  $name = $lng->txt("deleted_user");
630  } else {
631  if ($user_id == ANONYMOUS_USER_ID) {
632  $name = $lastname;
633  } else {
634  $name = trim($uname["lastname"] . ", " . $uname["firstname"]);
635  }
636  if ($is_anonymous) {
637  $name = $lng->txt("anonymous");
638  }
639  }
640  return $name;
641  }
static _lookupName($a_user_id)
lookup user name
const ANONYMOUS_USER_ID
Definition: constants.php:25
$result
static _lookupAnonymity($a_obj_id)
Returns the anonymity status of a test with a given object id.
if($format !==null) $name
Definition: metadata.php:230
$lng
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 649 of file class.ilObjTestAccess.php.

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

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

650  {
651  global $DIC;
652  $lng = $DIC['lng'];
653  $ilDB = $DIC['ilDB'];
654 
655  $result = $ilDB->queryF(
656  "SELECT user_fi FROM tst_active WHERE active_id = %s",
657  array("integer"),
658  array($active_id)
659  );
660  $row = $ilDB->fetchAssoc($result);
661  return $row["user_fi"];
662  }
$result
$lng
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 ) public

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

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

Referenced by ilLPStatusTestPassed\_getStatusInfo().

680  {
681  global $DIC;
682  $ilDB = $DIC['ilDB'];
683 
684  $passed_users = array();
685  // Maybe SELECT DISTINCT(tst_active.user_fi)... ?
686  $userresult = $ilDB->queryF(
687  "
688  SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences, tst_active.last_finished_pass,
689  CASE WHEN
690  (tst_tests.nr_of_tries - 1) = tst_active.last_finished_pass
691  THEN '1'
692  ELSE '0'
693  END is_last_pass
694  FROM tst_tests
695  INNER JOIN tst_active
696  ON tst_active.test_fi = tst_tests.test_id
697  LEFT JOIN tst_sequence
698  ON tst_sequence.active_fi = tst_active.active_id
699  WHERE tst_tests.obj_fi = %s
700  GROUP BY tst_active.active_id
701  ",
702  array('integer'),
703  array($a_obj_id)
704  );
705  $all_participants = array();
706  $notAttempted = array();
707  $lastPassUsers = array();
708  while ($row = $ilDB->fetchAssoc($userresult)) {
709  if ($row['sequences'] == 0) {
710  $notAttempted[$row['active_id']] = $row['active_id'];
711  }
712  if ($row['is_last_pass']) {
713  $lastPassUsers[$row['active_id']] = $row['active_id'];
714  }
715 
716  $all_participants[$row['active_id']] = $row['active_id'];
717  }
718 
719  $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'));
720  $found_all = ($result->numRows() == count($all_participants)) ? true : false;
721  if (!$found_all) {
722  // if the result cache entries do not exist, create them
723  $found_participants = array();
724  while ($data = $ilDB->fetchAssoc($result)) {
725  array_push($found_participants, $data['active_fi']);
726  }
727  foreach ($all_participants as $active_id) {
728  if (!in_array($active_id, $found_participants)) {
729  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
731  }
732  }
733  $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'));
734  }
735  while ($data = $ilDB->fetchAssoc($result)) {
736  if (isset($notAttempted[$data['active_fi']])) {
737  $data['failed'] = 0;
738  $data['passed'] = 0;
739  $data['not_attempted'] = 1;
740  }
741 
742  if ($data['failed'] && !isset($lastPassUsers[$data['active_fi']])) {
743  $data['passed'] = 0;
744  $data['failed'] = 0;
745  $data['in_progress'] = 1;
746  }
747 
748  $data['user_id'] = $data['user_fi'];
749  array_push($passed_users, $data);
750  }
751  return $passed_users;
752  }
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
$data
Definition: storeScorm.php:23
$result
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 public

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

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

Referenced by ilObjMediaObjectAccess\checkAccessTestQuestion().

514  {
515  global $DIC;
516  $ilDB = $DIC['ilDB'];
517 
518  $query = "
519  SELECT DISTINCT t.obj_fi
520  FROM tst_tests t
521  INNER JOIN tst_rnd_quest_set_qpls r
522  ON t.test_id = r.test_fi
523  WHERE r.pool_fi = %s
524  ";
525 
526  $result = $ilDB->queryF($query, array('integer'), array($qpl_id));
527 
528  $tests = array();
529  while ($row = $ilDB->fetchAssoc($result)) {
530  $tests[] = $row['obj_fi'];
531  }
532 
533  return $tests;
534  }
$result
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ 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 468 of file class.ilObjTestAccess.php.

References $DIC, $ilDB, and $result.

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

469  {
470  global $DIC;
471  $ilDB = $DIC['ilDB'];
472  $test_id = false;
473  $result = $ilDB->queryF(
474  "SELECT test_id FROM tst_tests WHERE obj_fi = %s",
475  array('integer'),
476  array($object_id)
477  );
478  if ($result->numRows()) {
479  $row = $ilDB->fetchAssoc($result);
480  $test_id = $row["test_id"];
481  }
482  return $test_id;
483  }
$result
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ _isOffline()

static ilObjTestAccess::_isOffline (   $a_obj_id)
static

returns the objects's OFFline status

Used in ListGUI and Learning Progress

Parameters
int$a_obj_id
Returns
bool

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

References ilObject\lookupOfflineStatus().

Referenced by ilLOEditorStatus\checkTestOnline().

784  {
785  // global $DIC;
786  // $ilUser = $DIC['ilUser'];
787  // return (self::_lookupOnlineTestAccess($a_obj_id, $ilUser->getId()) !== true) ||
788  // (!ilObjTestAccess::_lookupCreationComplete($a_obj_id));
789  return ilObject::lookupOfflineStatus($a_obj_id);
790  }
static lookupOfflineStatus($a_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 115 of file class.ilObjTestAccess.php.

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

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

116  {
117  global $DIC;
118  $ilDB = $DIC['ilDB'];
119  $result = $ilDB->queryF(
120  "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",
121  array('integer','integer'),
122  array($user_id, $a_obj_id)
123  );
124  if (!$result->numRows()) {
125  $result = $ilDB->queryF(
126  "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",
127  array('integer','integer'),
128  array($user_id, $a_obj_id)
129  );
130  $row = $ilDB->fetchAssoc($result);
131  if ($row['active_id'] > 0) {
132  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
133  assQuestion::_updateTestResultCache($row['active_id']);
134  } else {
135  return false;
136  }
137  }
138  $result = $ilDB->queryF(
139  "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",
140  array('integer','integer'),
141  array($user_id, $a_obj_id)
142  );
143  if (!$result->numRows()) {
144  $result = $ilDB->queryF(
145  "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",
146  array('integer','integer'),
147  array($user_id, $a_obj_id)
148  );
149 
150  if (!$result->numRows()) {
151  return false;
152  }
153 
154  $points = array();
155  while ($row = $ilDB->fetchAssoc($result)) {
156  array_push($points, $row);
157  }
158  $reached = 0;
159  $max = 0;
160  if ($points[0]["pass_scoring"] == 0) {
161  $reached = $points[count($points) - 1]["points"];
162  $max = $points[count($points) - 1]["maxpoints"];
163  if (!$max) {
164  $active_id = $points[count($points) - 1]["active_fi"];
165  $pass = $points[count($points) - 1]["pass"];
166  if (strlen($active_id) && strlen($pass)) {
167  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
168  $res = assQuestion::_updateTestPassResults($active_id, $pass, 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  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
183  $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
184  $max = $res['maxpoints'];
185  $reached = $res['points'];
186  }
187  }
188  }
189  }
190  }
191  include_once "./Modules/Test/classes/class.assMarkSchema.php";
192  $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
193  $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
194  return ($mark["passed"]) ? true : false;
195  } else {
196  $row = $ilDB->fetchAssoc($result);
197  return ($row['passed']) ? true : false;
198  }
199  }
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
$result
static _getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 398 of file class.ilObjTestAccess.php.

References $DIC, $ilDB, and $result.

Referenced by _checkAccess().

399  {
400  global $DIC;
401  $ilDB = $DIC['ilDB'];
402 
403  $result = $ilDB->queryF(
404  "SELECT complete FROM tst_tests WHERE obj_fi=%s",
405  array('integer'),
406  array($a_obj_id)
407  );
408  if ($result->numRows() == 1) {
409  $row = $ilDB->fetchAssoc($result);
410  }
411 
412  return ($row['complete']) ? true : false;
413  }
$result
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 491 of file class.ilObjTestAccess.php.

References $DIC, $ilDB, and $result.

Referenced by ilTestSessionDynamicQuestionSet\saveToDb().

492  {
493  global $DIC;
494  $ilDB = $DIC['ilDB'];
495 
496  $result = $ilDB->queryF(
497  "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
498  array('integer'),
499  array($a_test_id)
500  );
501 
502  $row = $ilDB->fetchAssoc($result);
503  return $row["obj_fi"];
504  }
$result
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 public

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

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

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

544  {
545  global $DIC;
546  $ilDB = $DIC['ilDB'];
547  $lng = $DIC['lng'];
548 
549  $result = $ilDB->queryF(
550  "SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
551  array('integer'),
552  array($a_test_id)
553  );
554  if ($result->numRows()) {
555  $row = $ilDB->fetchAssoc($result);
556  if ($row["fixed_participants"]) {
557  $result = $ilDB->queryF(
558  "SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
559  array('integer','integer'),
560  array($row["test_id"], $a_user_id)
561  );
562  if ($result->numRows()) {
563  $row = $ilDB->fetchAssoc($result);
564  if (trim($row['clientip']) != "") {
565  $row['clientip'] = preg_replace("/[^0-9.?*,:]+/", "", $row['clientip']);
566  $row['clientip'] = str_replace(".", "\\.", $row['clientip']);
567  $row['clientip'] = str_replace(array("?","*",","), array("[0-9]","[0-9]*","|"), $row['clientip']);
568  if (!preg_match("/^" . $row['clientip'] . "$/", $_SERVER["REMOTE_ADDR"])) {
569  $lng->loadLanguageModule('assessment');
570  return $lng->txt("user_wrong_clientip");
571  } else {
572  return true;
573  }
574  } else {
575  return true;
576  }
577  } else {
578  return $lng->txt("tst_user_not_invited");
579  }
580  } else {
581  return true;
582  }
583  } else {
584  return true;
585  }
586  }
$result
$lng
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ canBeDelivered()

ilObjTestAccess::canBeDelivered ( ilWACPath  $ilWACPath)
Parameters
ilWACPath$ilWACPath
Returns
bool

Implements ilWACCheckingClass.

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

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

31  {
32  global $DIC;
33  $readable = new Readable($DIC);
34 
35  $can_it = $this->findMatch($ilWACPath->getPath(), [
36  new AccessFileUploadAnswer($DIC, $readable),
37  new AccessQuestionImage($readable),
38  new AccessFileUploadPreview($DIC->database(), $DIC->access()),
39  ]);
40 
41  return !$can_it->isOk() || $can_it->value();
42  }
global $DIC
Definition: goto.php:24
findMatch(string $path, array $array)
+ Here is the call graph for this function:

◆ checkCondition()

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

check condition

this method is called by ilConditionHandler

Implements ilConditionHandling.

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

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

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

336  {
337  include_once './Services/Conditions/classes/class.ilConditionHandler.php';
338 
339  switch ($a_operator) {
341  return ilObjTestAccess::_isPassed($a_usr_id, $a_obj_id);
342  break;
343 
345  return ilObjTestAccess::isFailed($a_usr_id, $a_obj_id);
346 
348  return ilObjTestAccess::hasFinished($a_usr_id, $a_obj_id);
349 
351  return !ilObjTestAccess::hasFinished($a_usr_id, $a_obj_id);
352 
353  default:
354  return true;
355  }
356  return true;
357  }
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...
static hasFinished($a_user_id, $a_obj_id)
Returns (request cached) information if a specific user has finished at least one test pass...
+ 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 44 of file class.ilObjTestAccess.php.

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

Referenced by canBeDelivered().

44  : Result
45  {
46  return array_reduce($array, static function (Result $result, SimpleAccess $access) use ($path): Result {
47  return $result->except(static function () use ($access, $path): Result {
48  return $access->isPermitted($path);
49  });
50  }, new Error('Not a known path.'));
51  }
$result
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:11
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Error.php:13
+ 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

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

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

Referenced by checkCondition().

430  {
431  if (!isset(self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"])) {
432  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
433  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
434  require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
435 
436  global $DIC;
437  $ilDB = $DIC['ilDB'];
438  $lng = $DIC['lng'];
439 
440  $testOBJ = ilObjectFactory::getInstanceByObjId($a_obj_id);
441 
442  $partData = new ilTestParticipantData($ilDB, $lng);
443  $partData->setUserIdsFilter(array($a_user_id));
444  $partData->load($testOBJ->getTestId());
445 
446  $activeId = $partData->getActiveIdByUserId($a_user_id);
447 
448  $testSessionFactory = new ilTestSessionFactory($testOBJ);
449  $testSession = $testSessionFactory->getSession($activeId);
450 
451  $testPassesSelector = new ilTestPassesSelector($ilDB, $testOBJ);
452  $testPassesSelector->setActiveId($activeId);
453  $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
454 
455  self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
456  }
457 
458  return (bool) self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"];
459  }
$lng
global $DIC
Definition: goto.php:24
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasVisibleCertificate()

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

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

Parameters
$testObjId
$userId
Returns
bool

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

References ilObjectFactory\getInstanceByObjId().

816  {
817  $testOBJ = ilObjectFactory::getInstanceByObjId($testObjId, false);
818 
819  if (!($testOBJ instanceof ilObjTest) || !$userId) {
820  return false;
821  }
822 
823  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
824  $testSessionFactory = new ilTestSessionFactory($testOBJ);
825  $testSession = $testSessionFactory->getSessionByUserId($userId);
826 
827  if (!$testSession->getActiveId()) {
828  return false;
829  }
830 
831  return $testOBJ->canShowCertificate($testSession, $testSession->getUserId(), $testSession->getActiveId());
832  }
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ isFailed()

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

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

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

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

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

Referenced by checkCondition().

209  {
210  global $DIC;
211  $ilDB = $DIC['ilDB'];
212 
213  $ret = self::updateTestResultCache($user_id, $a_obj_id);
214 
215  if (!$ret) {
216  return false;
217  }
218 
219  $result = $ilDB->queryF(
220  "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",
221  array('integer','integer'),
222  array($user_id, $a_obj_id)
223  );
224 
225  if (!$result->numRows()) {
226  $result = $ilDB->queryF(
227  "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",
228  array('integer','integer'),
229  array($user_id, $a_obj_id)
230  );
231 
232  while ($row = $ilDB->fetchAssoc($result)) {
233  array_push($points, $row);
234  }
235  $reached = 0;
236  $max = 0;
237  if ($points[0]["pass_scoring"] == 0) {
238  $reached = $points[count($points) - 1]["points"];
239  $max = $points[count($points) - 1]["maxpoints"];
240  if (!$max) {
241  $active_id = $points[count($points) - 1]["active_fi"];
242  $pass = $points[count($points) - 1]["pass"];
243  if (strlen($active_id) && strlen($pass)) {
244  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
245  $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
246  $max = $res['maxpoints'];
247  $reached = $res['points'];
248  }
249  }
250  } else {
251  foreach ($points as $row) {
252  if ($row["points"] > $reached) {
253  $reached = $row["points"];
254  $max = $row["maxpoints"];
255  if (!$max) {
256  $active_id = $row["active_fi"];
257  $pass = $row["pass"];
258  if (strlen($active_id) && strlen($pass)) {
259  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
260  $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
261  $max = $res['maxpoints'];
262  $reached = $res['points'];
263  }
264  }
265  }
266  }
267  }
268  include_once "./Modules/Test/classes/class.assMarkSchema.php";
269  $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
270  $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
271  return ($mark["failed"]) ? true : false;
272  } else {
273  $row = $ilDB->fetchAssoc($result);
274  return ($row['failed']) ? true : false;
275  }
276  }
$result
static _getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
global $ilDB
$ret
Definition: parser.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateTestResultCache()

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

Update test result cache.

Parameters
type$a_user_id
type$a_obj_id

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

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

284  {
285  global $DIC;
286  $ilDB = $DIC['ilDB'];
287 
288  $result = $ilDB->queryF(
289  "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests " .
290  "WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s " .
291  "AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
292  array('integer','integer'),
293  array($a_user_id, $a_obj_id)
294  );
295  if (!$result->numRows()) {
296  $result = $ilDB->queryF(
297  "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",
298  array('integer','integer'),
299  array($a_user_id, $a_obj_id)
300  );
301  $row = $ilDB->fetchAssoc($result);
302  if ($row['active_id'] > 0) {
303  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
304  assQuestion::_updateTestResultCache($row['active_id']);
305  return true;
306  } else {
307  return false;
308  }
309  } else {
310  return true;
311  }
312  }
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
$result
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the call graph for this function:

◆ visibleUserResultExists()

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

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

References ilObjectFactory\getInstanceByObjId().

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

794  {
795  $testOBJ = ilObjectFactory::getInstanceByObjId($testObjId, false);
796 
797  if (!($testOBJ instanceof ilObjTest)) {
798  return false;
799  }
800 
801  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
802  $testSessionFactory = new ilTestSessionFactory($testOBJ);
803  $testSession = $testSessionFactory->getSessionByUserId($userId);
804 
805  return $testOBJ->canShowTestResults($testSession);
806  }
static getInstanceByObjId($a_obj_id, $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

◆ $hasFinishedCache

ilObjTestAccess::$hasFinishedCache = array()
staticprivate

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


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