ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilObjTestAccess Class Reference

Class ilObjTestAccess. More...

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

Public Member Functions

 _checkAccess ($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
 Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 _getMaxPointsForTestPass ($random, $user_id, $test_id, $pass)
 Returns the maximum number of points available for a test pass. More...
 
 _getCommands ()
 get commands More...
 
 _lookupCreationComplete ($a_obj_id)
 checks wether all necessary parts of the test are given More...
 
 _getTestIDFromObjectID ($object_id)
 Returns the ILIAS test id for a given object id. More...
 
_getTestQuestions ($active_id, $pass=NULL)
 
 _isComplete ($a_obj_id)
 Returns true, if a test is complete for use. More...
 
_getTestData ($test_id)
 Returns the database content of a test with a given id. More...
 
 _lookupObjIdForTestId ($a_test_id)
 Lookup object id for test id. More...
 
 _getRandomTestsForQuestionPool ($qpl_id)
 Get all tests using a question pool for random selection. More...
 
 _lookupOnlineTestAccess ($a_test_id, $a_user_id)
 Checks if a user is allowd to run an online exam. More...
 
 _getParticipantData ($active_id)
 Retrieves a participant name from active id. More...
 
 _getParticipantId ($active_id)
 Get user id for active id. More...
 
_getPassedUsers ($a_obj_id)
 Returns an array containing the users who passed the test. More...
 
 _checkGoto ($a_target)
 check whether goto script will succeed 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...
 
 _getCommands ()
 get commands More...
 
 _checkGoto ($a_target)
 check whether goto script will succeed More...
 
 _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. 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 hasFinished ($a_user_id, $a_obj_id)
 Returns (request cached) information if a specific user has finished at least one test pass. More...
 
static _isOffline ($a_obj_id)
 returns the objects's OFFline status More...
 
static _isOnline ($a_obj_id)
 returns the objects's ONline status More...
 
- Static Public Member Functions inherited from ilObjectAccess
static _isOffline ($a_obj_id)
 Type-specific implementation of general status, has to be overwritten. More...
 

Protected Member Functions

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

Static Private Attributes

static $hasFinishedCache = array()
 

Detailed Description

Class ilObjTestAccess.

This class contains methods that check object specific conditions for accessing test objects.

Author
Helmut Schottmueller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Member Function Documentation

◆ _checkAccess()

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

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

Please do not check any preconditions handled by ilConditionHandler here.

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

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

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

38  {
39  global $ilUser, $lng, $rbacsystem, $ilAccess;
40 
41  if ($a_user_id == "")
42  {
43  $a_user_id = $ilUser->getId();
44  }
45 
46  $is_admin = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
47 
48  // check "global" online switch
49  if(!self::_isOnline($a_obj_id) && !$is_admin)
50  {
51  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
52  return false;
53  }
54 
55  switch ($a_permission)
56  {
57  case "visible":
58  case "read":
60  !$is_admin)
61  {
62  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
63  return false;
64  }
65  break;
66  }
67 
68  switch ($a_cmd)
69  {
70  case "eval_a":
71  case "eval_stat":
73  {
74  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
75  return false;
76  }
77  break;
78 
79  }
80 
81  return true;
82  }
const IL_NO_OBJECT_ACCESS
_lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ _checkGoto()

ilObjTestAccess::_checkGoto (   $a_target)

check whether goto script will succeed

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

890  {
891  global $ilAccess;
892 
893  $t_arr = explode("_", $a_target);
894 
895  if ($t_arr[0] != "tst" || ((int) $t_arr[1]) <= 0)
896  {
897  return false;
898  }
899 
900  if ($ilAccess->checkAccess("read", "", $t_arr[1]))
901  {
902  return true;
903  }
904  return false;
905  }

◆ _getCommands()

ilObjTestAccess::_getCommands ( )

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

Referenced by ilObjTestListGUI\init().

411  {
412  $commands = array
413  (
414  array("permission" => "write", "cmd" => "questionsTabGateway", "lang_var" => "tst_edit_questions"),
415  array("permission" => "write", "cmd" => "ilObjTestSettingsGeneralGUI::showForm", "lang_var" => "settings"),
416  array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "tst_run",
417  "default" => true),
418  //array("permission" => "write", "cmd" => "", "lang_var" => "edit"),
419  array("permission" => "tst_statistics", "cmd" => "outEvaluation", "lang_var" => "tst_statistical_evaluation"),
420  );
421 
422  return $commands;
423  }
+ Here is the caller graph for this function:

◆ _getMaxPointsForTestPass()

ilObjTestAccess::_getMaxPointsForTestPass (   $random,
  $user_id,
  $test_id,
  $pass 
)

Returns the maximum number of points available for a test pass.

Parameters
boolean$randomTRUE if the test is a random test, otherwise FALSE
int$test_idThe test id
int$passThe test pass
Returns
int The available points for the test pass

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

References $ilDB, $pass, $result, and $row.

93  {
94  global $ilDB;
95  $max = 0;
96  if ($random)
97  {
98  $result = $ilDB->queryF("SELECT SUM(qpl_questions.points) maxpoints FROM tst_test_rnd_qst, qpl_questions, tst_active WHERE tst_active.active_id = tst_test_rnd_qst.active_fi AND tst_test_rnd_qst.question_fi = qpl_questions.question_id AND tst_active.test_fi = %s AND tst_test_rnd_qst.pass = %s AND tst_active.user_fi = %s",
99  array('integer','integer','integer'),
100  array($test_id, $pass, $user_id)
101  );
102  if ($result->numRows())
103  {
104  $row = $ilDB->fetchAssoc($result);
105  $max = $row["maxpoints"];
106  }
107  }
108  else
109  {
110  $result = $ilDB->queryF("SELECT SUM(qpl_questions.points) maxpoints FROM tst_test_question, qpl_questions WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = %s",
111  array('integer'),
112  array($test_id)
113  );
114  if ($result->numRows())
115  {
116  $row = $ilDB->fetchAssoc($result);
117  $max = $row["maxpoints"];
118  }
119  }
120  return $max;
121  }
$result
global $ilDB

◆ _getParticipantData()

ilObjTestAccess::_getParticipantData (   $active_id)

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

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

Referenced by assQuestion\_setReachedPoints(), ilTestResultsToXML\exportActiveIDs(), ilObjTest\getManualFeedback(), assFileUpload\hasFileUploads(), and ilObjTestGUI\participantsObject().

737  {
738  global $lng, $ilDB;
739 
740  $result = $ilDB->queryF("SELECT * FROM tst_active WHERE active_id = %s",
741  array("integer"),
742  array($active_id)
743  );
744  $row = $ilDB->fetchAssoc($result);
745  $user_id = $row["user_fi"];
746  $test_id = $row["test_fi"];
747  $importname = $row['importname'];
748 
749  $result = $ilDB->queryF("SELECT obj_fi FROM tst_tests WHERE test_id = %s",
750  array("integer"),
751  array($test_id)
752  );
753  $row = $ilDB->fetchAssoc($result);
754  $obj_id = $row["obj_fi"];
755 
756  include_once "./Modules/Test/classes/class.ilObjTest.php";
757  $is_anonymous = ilObjTest::_lookupAnonymity($obj_id);
758 
759  include_once './Services/User/classes/class.ilObjUser.php';
760  $uname = ilObjUser::_lookupName($user_id);
761 
762  $name = "";
763  if (strlen($importname))
764  {
765  $name = $importname . ' (' . $lng->txt('imported') . ')';
766  }
767  else if (strlen($uname["firstname"].$uname["lastname"]) == 0)
768  {
769  $name = $lng->txt("deleted_user");
770  }
771  else
772  {
773  if ($user_id == ANONYMOUS_USER_ID)
774  {
775  $name = $lastname;
776  }
777  else
778  {
779  $name = trim($uname["lastname"] . ", " . $uname["firstname"] . " " . $uname["title"]);
780  }
781  if ($is_anonymous)
782  {
783  $name = $lng->txt("anonymous");
784  }
785  }
786  return $name;
787  }
static _lookupName($a_user_id)
lookup user name
_lookupAnonymity($a_obj_id)
Returns the anonymity status of a test with a given object id.
$result
global $lng
Definition: privfeed.php:40
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getParticipantId()

ilObjTestAccess::_getParticipantId (   $active_id)

Get user id for active id.

Parameters
intactive ID of the participant
Returns
int user id

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

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

Referenced by ilTestScoringByQuestionsGUI\__construct(), assFileUpload\handleSubmission(), ilTestSession\increaseTestPass(), ilTestScoringGUI\saveManScoringParticipantScreen(), ilTestSessionDynamicQuestionSet\saveToDb(), and ilTestSession\saveToDb().

796  {
797  global $lng, $ilDB;
798 
799  $result = $ilDB->queryF("SELECT user_fi FROM tst_active WHERE active_id = %s",
800  array("integer"),
801  array($active_id)
802  );
803  $row = $ilDB->fetchAssoc($result);
804  return $row["user_fi"];
805  }
$result
global $lng
Definition: privfeed.php:40
global $ilDB
+ Here is the caller graph for this function:

◆ _getPassedUsers()

& ilObjTestAccess::_getPassedUsers (   $a_obj_id)

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

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

Referenced by ilLPStatusTestPassed\_getStatusInfo().

823  {
824  global $ilDB;
825 
826  $passed_users = array();
827  // Maybe SELECT DISTINCT(tst_active.user_fi)... ?
828  $userresult = $ilDB->queryF("
829  SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences
830  FROM tst_tests
831  INNER JOIN tst_active
832  ON tst_active.test_fi = tst_tests.test_id
833  LEFT JOIN tst_sequence
834  ON tst_sequence.active_fi = tst_active.active_id
835  WHERE tst_tests.obj_fi = %s
836  GROUP BY tst_active.active_id
837  ",
838  array('integer'), array($a_obj_id)
839  );
840  $all_participants = array();
841  $notAttempted = array();
842  while ($row = $ilDB->fetchAssoc($userresult))
843  {
844  if($row['sequences'] == 0)
845  {
846  $notAttempted[$row['active_id']] = $row['active_id'];
847  }
848 
849  $all_participants[$row['active_id']] = $row['active_id'];
850  }
851 
852  $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'));
853  $found_all = ($result->numRows() == count($all_participants)) ? true : false;
854  if (!$found_all)
855  {
856  // if the result cache entries do not exist, create them
857  $found_participants = array();
858  while ($data = $ilDB->fetchAssoc($result))
859  {
860  array_push($found_participants, $data['active_fi']);
861  }
862  foreach ($all_participants as $active_id)
863  {
864  if (!in_array($active_id, $found_participants))
865  {
866  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
868  }
869  }
870  $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'));
871  }
872  while ($data = $ilDB->fetchAssoc($result))
873  {
874  if( isset($notAttempted[$data['active_fi']]) )
875  {
876  $data['failed'] = 0;
877  $data['passed'] = 0;
878  }
879 
880  $data['user_id'] = $data['user_fi'];
881  array_push($passed_users, $data);
882  }
883  return $passed_users;
884  }
$result
global $ilDB
_updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getRandomTestsForQuestionPool()

ilObjTestAccess::_getRandomTestsForQuestionPool (   $qpl_id)

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

References $ilDB, $query, $result, $row, and $tests.

Referenced by ilWebAccessChecker\checkAccessTestQuestion().

645  {
646  global $ilDB;
647 
648  $query = "
649  SELECT DISTINCT t.obj_fi
650  FROM tst_tests t
651  INNER JOIN tst_rnd_quest_set_qpls r
652  ON t.test_id = r.test_fi
653  WHERE r.pool_fi = %s
654  ";
655 
656  $result = $ilDB->queryF($query, array('integer'), array($qpl_id));
657 
658  $tests = array();
659  while ($row = $ilDB->fetchAssoc($result))
660  {
661  $tests[] = $row['obj_fi'];
662  }
663 
664  return $tests;
665  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ _getTestData()

& ilObjTestAccess::_getTestData (   $test_id)

Returns the database content of a test with a given id.

Parameters
int$test_idDatabase id of the test
Returns
array An associative array with the contents of the tst_tests database row public

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

References $ilDB, and $result.

605  {
606  global $ilDB;
607  $result = $ilDB->queryF("SELECT * FROM tst_tests WHERE test_id = %s",
608  array('integer'),
609  array($test_id)
610  );
611  if (!$result->numRows())
612  {
613  return 0;
614  }
615  return $ilDB->fetchAssoc($result);
616  }
$result
global $ilDB

◆ _getTestIDFromObjectID()

ilObjTestAccess::_getTestIDFromObjectID (   $object_id)

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

References $ilDB, $result, and $row.

Referenced by ilLPStatusTestFinished\getParticipants().

501  {
502  global $ilDB;
503  $test_id = FALSE;
504  $result = $ilDB->queryF("SELECT test_id FROM tst_tests WHERE obj_fi = %s",
505  array('integer'),
506  array($object_id)
507  );
508  if ($result->numRows())
509  {
510  $row = $ilDB->fetchAssoc($result);
511  $test_id = $row["test_id"];
512  }
513  return $test_id;
514  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ _getTestQuestions()

& ilObjTestAccess::_getTestQuestions (   $active_id,
  $pass = NULL 
)

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

References $ilDB, $pass, $result, and $row.

517  {
518  if (is_null($pass))
519  {
520  $pass = 0;
521  }
522  $questions = array();
523 
524  global $ilDB;
525  $result = $ilDB->queryF("SELECT test_fi FROM tst_active WHERE active_id = %s",
526  array('integer'),
527  array($active_id)
528  );
529  $test_id = "";
530  if ($result->numRows())
531  {
532  $row = $ilDB->fetchAssoc($result);
533  $test_id = $row["test_fi"];
534  }
535  else
536  {
537  return $questions;
538  }
539  $result = $ilDB->queryF("SELECT qpl_questions.question_id, qpl_questions.points FROM qpl_questions, tst_test_question WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = %s ORDER BY tst_test_question.sequence",
540  array('integer'),
541  array($test_id)
542  );
543  if ($result->numRows())
544  {
545  // standard test
546  while ($row = $ilDB->fetchAssoc($result))
547  {
548  array_push($questions, $row);
549  }
550  }
551  else
552  {
553  // random test
554  $result = $ilDB->queryF("SELECT qpl_questions.question_id, qpl_questions.points FROM qpl_questions, tst_test_rnd_qst WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id AND tst_test_rnd_qst.active_fi = %s AND tst_test_rnd_qst.pass = %s ORDER BY tst_test_rnd_qst.sequence",
555  array('integer','integer'),
556  array($active_id, $pass)
557  );
558  if ($result->numRows())
559  {
560  while ($row = $ilDB->fetchAssoc($result))
561  {
562  array_push($questions, $row);
563  }
564  }
565  }
566  return $questions;
567  }
$result
global $ilDB

◆ _isComplete()

ilObjTestAccess::_isComplete (   $a_obj_id)

Returns true, if a test is complete for use.

Returns
boolean True, if the test is complete for use, otherwise false public

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

References $ilDB, $query, $res, and $row.

576  {
577  global $ilDB;
578 
579  $query = "
580  SELECT tst_tests.complete
581  FROM object_data
582  INNER JOIN tst_tests
583  ON tst_tests.obj_fi = object_data.obj_id
584  WHERE object_data.obj_id = %s
585  ";
586 
587  $res = $ilDB->queryF($query, array('integer'), array($a_obj_id));
588 
589  while( $row = $ilDB->fetchAssoc($res) )
590  {
591  return (bool)$row['complete'];
592  }
593 
594  return false;
595  }
global $ilDB

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

916  {
917 // global $ilUser;
918 // return (self::_lookupOnlineTestAccess($a_obj_id, $ilUser->getId()) !== true) ||
919 // (!ilObjTestAccess::_lookupCreationComplete($a_obj_id));
920  return !self::_isOnline($a_obj_id);
921  }

◆ _isOnline()

static ilObjTestAccess::_isOnline (   $a_obj_id)
static

returns the objects's ONline status

Parameters
integer$a_obj_id
Returns
boolean $online

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

References $ilDB, $query, and $result.

Referenced by ilObjTestListGUI\getProperties().

930  {
931  global $ilDB;
932 
933  $query = "
934  SELECT test_id
935  FROM tst_tests
936  WHERE obj_fi = %s
937  AND online_status = 1
938  ";
939 
940  $result = $ilDB->queryF( $query, array('integer'), array($a_obj_id) );
941 
942  return $result->numRows() == 1;
943  }
$result
global $ilDB
+ 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 130 of file class.ilObjTestAccess.php.

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

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

131  {
132  global $ilDB;
133  $result = $ilDB->queryF("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",
134  array('integer','integer'),
135  array($user_id, $a_obj_id)
136  );
137  if (!$result->numRows())
138  {
139  $result = $ilDB->queryF("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",
140  array('integer','integer'),
141  array($user_id, $a_obj_id)
142  );
143  $row = $ilDB->fetchAssoc($result);
144  if ($row['active_id'] > 0)
145  {
146  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
148  }
149  else
150  {
151  return false;
152  }
153  }
154  $result = $ilDB->queryF("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  array('integer','integer'),
156  array($user_id, $a_obj_id)
157  );
158  if (!$result->numRows())
159  {
160  $result = $ilDB->queryF("SELECT tst_pass_result.*, tst_tests.pass_scoring, tst_tests.random_test, tst_tests.test_id FROM tst_pass_result, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_pass_result.active_fi = tst_active.active_id ORDER BY tst_pass_result.pass",
161  array('integer','integer'),
162  array($user_id, $a_obj_id)
163  );
164  $points = array();
165  while ($row = $ilDB->fetchAssoc($result))
166  {
167  array_push($points, $row);
168  }
169  $reached = 0;
170  $max = 0;
171  if ($points[0]["pass_scoring"] == 0)
172  {
173  $reached = $points[count($points)-1]["points"];
174  $max = $points[count($points)-1]["maxpoints"];
175  if (!$max)
176  {
177  $active_id = $points[count($points)-1]["active_fi"];
178  $pass = $points[count($points)-1]["pass"];
179  if (strlen($active_id) && strlen($pass))
180  {
181  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
182  $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
183  $max = $res['maxpoints'];
184  $reached = $res['points'];
185  }
186  }
187  }
188  else
189  {
190  foreach ($points as $row)
191  {
192  if ($row["points"] > $reached)
193  {
194  $reached = $row["points"];
195  $max = $row["maxpoints"];
196  if (!$max)
197  {
198  $active_id = $row["active_fi"];
199  $pass = $row["pass"];
200  if (strlen($active_id) && strlen($pass))
201  {
202  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
203  $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
204  $max = $res['maxpoints'];
205  $reached = $res['points'];
206  }
207  }
208  }
209  }
210  }
211  include_once "./Modules/Test/classes/class.assMarkSchema.php";
212  $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
213  $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
214  return ($mark["passed"]) ? TRUE : FALSE;
215  }
216  else
217  {
218  $row = $ilDB->fetchAssoc($result);
219  return ($row['passed']) ? true : false;
220  }
221  }
$result
_getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
global $ilDB
_updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupCreationComplete()

ilObjTestAccess::_lookupCreationComplete (   $a_obj_id)

checks wether all necessary parts of the test are given

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

References $ilDB, $result, and $row.

Referenced by _checkAccess().

433  {
434  global $ilDB;
435 
436  $result = $ilDB->queryF("SELECT complete FROM tst_tests WHERE obj_fi=%s",
437  array('integer'),
438  array($a_obj_id)
439  );
440  if ($result->numRows() == 1)
441  {
442  $row = $ilDB->fetchAssoc($result);
443  }
444 
445  return ($row['complete']) ? true : false;
446  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupObjIdForTestId()

ilObjTestAccess::_lookupObjIdForTestId (   $a_test_id)

Lookup object id for test id.

Parameters
inttest id
Returns
int object id

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

References $ilDB, $result, and $row.

Referenced by ilTestSession\increaseTestPass(), ilTestSessionDynamicQuestionSet\saveToDb(), and ilTestSession\saveToDb().

625  {
626  global $ilDB;
627 
628  $result = $ilDB->queryF("SELECT obj_fi FROM tst_tests WHERE test_id = %s",
629  array('integer'),
630  array($a_test_id)
631  );
632 
633  $row = $ilDB->fetchAssoc($result);
634  return $row["obj_fi"];
635  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupOnlineTestAccess()

ilObjTestAccess::_lookupOnlineTestAccess (   $a_test_id,
  $a_user_id 
)

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

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

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

675  {
676  global $ilDB, $lng;
677 
678  $result = $ilDB->queryF("SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
679  array('integer'),
680  array($a_test_id)
681  );
682  if ($result->numRows())
683  {
684  $row = $ilDB->fetchAssoc($result);
685  if ($row["fixed_participants"])
686  {
687  $result = $ilDB->queryF("SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
688  array('integer','integer'),
689  array($row["test_id"], $a_user_id)
690  );
691  if ($result->numRows())
692  {
693  $row = $ilDB->fetchAssoc($result);
694  if (trim($row['clientip']) != "")
695  {
696  $row['clientip'] = preg_replace("/[^0-9.?*,:]+/","",$row['clientip']);
697  $row['clientip'] = str_replace(".","\\.",$row['clientip']);
698  $row['clientip'] = str_replace(Array("?","*",","), Array("[0-9]","[0-9]*","|"), $row['clientip']);
699  if (!preg_match("/^".$row['clientip']."$/", $_SERVER["REMOTE_ADDR"]))
700  {
701  return $lng->txt("tst_user_wrong_clientip");
702  }
703  else
704  {
705  return true;
706  }
707  }
708  else
709  {
710  return true;
711  }
712  }
713  else
714  {
715  return $lng->txt("tst_user_not_invited");
716  }
717  }
718  else
719  {
720  return true;
721  }
722  }
723  else
724  {
725  return true;
726  }
727  }
$result
global $lng
Definition: privfeed.php:40
global $ilDB
+ Here is the caller graph for this function:

◆ checkCondition()

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

check condition

this method is called by ilConditionHandler

Implements ilConditionHandling.

Definition at line 373 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 ilCourseStart\isFullfilled(), and ilContainerStartObjects\isFullfilled().

374  {
375  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
376 
377  switch($a_operator)
378  {
380  return ilObjTestAccess::_isPassed($a_usr_id, $a_obj_id);
381  break;
382 
384  return ilObjTestAccess::isFailed($a_usr_id, $a_obj_id);
385 
387  return ilObjTestAccess::hasFinished($a_usr_id,$a_obj_id);
388 
390  return !ilObjTestAccess::hasFinished($a_usr_id,$a_obj_id);
391 
392  default:
393  return true;
394  }
395  return true;
396  }
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:

◆ getConditionOperators()

static ilObjTestAccess::getConditionOperators ( )
static

Get possible conditions operators.

Implements ilConditionHandling.

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

References ilConditionHandler\OPERATOR_FAILED, ilConditionHandler\OPERATOR_FINISHED, ilConditionHandler\OPERATOR_NOT_FINISHED, and ilConditionHandler\OPERATOR_PASSED.

357  {
358  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
359  return array(
364  );
365  }

◆ 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$user_idobj_id of the user
integer$a_obj_idobj_id of the test
Returns
bool

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

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

Referenced by checkCondition().

463  {
464  if( !isset(self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"]) )
465  {
466  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
467  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
468  require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
469 
470  global $ilDB, $lng;
471 
472  $testOBJ = ilObjectFactory::getInstanceByObjId($a_obj_id);
473 
474  $partData = new ilTestParticipantData($ilDB, $lng);
475  $partData->setUserIds(array($a_user_id));
476  $partData->load($testOBJ->getTestId());
477 
478  $activeId = $partData->getActiveIdByUserId($a_user_id);
479 
480  $testSessionFactory = new ilTestSessionFactory($testOBJ);
481  $testSession = $testSessionFactory->getSession($activeId);
482 
483  $testPassesSelector = new ilTestPassesSelector($ilDB, $testOBJ);
484  $testPassesSelector->setActiveId($activeId);
485  $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
486 
487  self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
488  }
489 
490  return self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"];
491  }
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
global $lng
Definition: privfeed.php:40
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFailed()

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

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

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

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

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

Referenced by checkCondition().

231  {
232  global $ilDB;
233 
234  $ret = self::updateTestResultCache($user_id, $a_obj_id);
235 
236  if(!$ret)
237  {
238  return false;
239  }
240 
241  $result = $ilDB->queryF("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",
242  array('integer','integer'),
243  array($user_id, $a_obj_id)
244  );
245 
246  if (!$result->numRows())
247  {
248  $result = $ilDB->queryF("SELECT tst_pass_result.*, tst_tests.pass_scoring, tst_tests.random_test, tst_tests.test_id FROM tst_pass_result, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_pass_result.active_fi = tst_active.active_id ORDER BY tst_pass_result.pass",
249  array('integer','integer'),
250  array($user_id, $a_obj_id)
251  );
252 
253  while ($row = $ilDB->fetchAssoc($result))
254  {
255  array_push($points, $row);
256  }
257  $reached = 0;
258  $max = 0;
259  if ($points[0]["pass_scoring"] == 0)
260  {
261  $reached = $points[count($points)-1]["points"];
262  $max = $points[count($points)-1]["maxpoints"];
263  if (!$max)
264  {
265  $active_id = $points[count($points)-1]["active_fi"];
266  $pass = $points[count($points)-1]["pass"];
267  if (strlen($active_id) && strlen($pass))
268  {
269  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
270  $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
271  $max = $res['maxpoints'];
272  $reached = $res['points'];
273  }
274  }
275  }
276  else
277  {
278  foreach ($points as $row)
279  {
280  if ($row["points"] > $reached)
281  {
282  $reached = $row["points"];
283  $max = $row["maxpoints"];
284  if (!$max)
285  {
286  $active_id = $row["active_fi"];
287  $pass = $row["pass"];
288  if (strlen($active_id) && strlen($pass))
289  {
290  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
291  $res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
292  $max = $res['maxpoints'];
293  $reached = $res['points'];
294  }
295  }
296  }
297  }
298  }
299  include_once "./Modules/Test/classes/class.assMarkSchema.php";
300  $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
301  $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
302  return ($mark["failed"]) ? TRUE : FALSE;
303  }
304  else
305  {
306  $row = $ilDB->fetchAssoc($result);
307  return ($row['failed']) ? TRUE : FALSE;
308  }
309  }
$result
_getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateTestResultCache()

ilObjTestAccess::updateTestResultCache (   $a_user_id,
  $a_obj_id 
)
protected

Update test result cache.

Parameters
type$a_user_id
type$a_obj_id

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

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

317  {
318  global $ilDB;
319 
320  $result = $ilDB->queryF(
321  "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests ".
322  "WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s ".
323  "AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
324  array('integer','integer'),
325  array($a_user_id, $a_obj_id)
326  );
327  if (!$result->numRows())
328  {
329  $result = $ilDB->queryF("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",
330  array('integer','integer'),
331  array($a_user_id, $a_obj_id)
332  );
333  $row = $ilDB->fetchAssoc($result);
334  if ($row['active_id'] > 0)
335  {
336  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
338  return true;
339  }
340  else
341  {
342  return false;
343  }
344 
345  }
346  else
347  {
348  return true;
349  }
350  }
$result
global $ilDB
_updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
+ Here is the call graph for this function:

Field Documentation

◆ $hasFinishedCache

ilObjTestAccess::$hasFinishedCache = array()
staticprivate

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


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