ILIAS  release_4-4 Revision
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...
 
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id=0)
 check condition 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=0)
 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 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...
 

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

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

37  {
38  global $ilUser, $lng, $rbacsystem, $ilAccess;
39 
40  if ($a_user_id == "")
41  {
42  $a_user_id = $ilUser->getId();
43  }
44 
45  $is_admin = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
46 
47  // check "global" online switch
48  if(!self::_isOnline($a_obj_id) && !$is_admin)
49  {
50  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
51  return false;
52  }
53 
54  switch ($a_permission)
55  {
56  case "visible":
57  case "read":
59  !$is_admin)
60  {
61  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
62  return false;
63  }
64  break;
65  }
66 
67  switch ($a_cmd)
68  {
69  case "eval_a":
70  case "eval_stat":
72  {
73  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
74  return false;
75  }
76  break;
77 
78  }
79 
80  return true;
81  }
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:

◆ _checkCondition()

ilObjTestAccess::_checkCondition (   $a_obj_id,
  $a_operator,
  $a_value,
  $a_usr_id = 0 
)

check condition

this method is called by ilConditionHandler

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

References $ilUser, _isPassed(), and hasFinished().

Referenced by ilConditionHandler\_checkCondition(), and ilCourseStart\isFullfilled().

229  {
230  global $ilUser;
231 
232  $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
233 
234  switch($a_operator)
235  {
236  case 'passed':
237  return ilObjTestAccess::_isPassed($a_usr_id, $a_obj_id);
238  break;
239 
240  case 'finished':
241  return ilObjTestAccess::hasFinished($a_usr_id,$a_obj_id);
242 
243  case 'not_finished':
244  return !ilObjTestAccess::hasFinished($a_usr_id,$a_obj_id);
245 
246  default:
247  return true;
248  }
249  return true;
250  }
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...
global $ilUser
Definition: imgupload.php:15
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:

◆ _checkGoto()

ilObjTestAccess::_checkGoto (   $a_target)

check whether goto script will succeed

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

744  {
745  global $ilAccess;
746 
747  $t_arr = explode("_", $a_target);
748 
749  if ($t_arr[0] != "tst" || ((int) $t_arr[1]) <= 0)
750  {
751  return false;
752  }
753 
754  if ($ilAccess->checkAccess("read", "", $t_arr[1]))
755  {
756  return true;
757  }
758  return false;
759  }

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

Referenced by ilObjTestListGUI\init().

265  {
266  $commands = array
267  (
268  array("permission" => "write", "cmd" => "questionsTabGateway", "lang_var" => "tst_edit_questions"),
269  array("permission" => "write", "cmd" => "ilObjTestSettingsGeneralGUI::showForm", "lang_var" => "settings"),
270  array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "tst_run",
271  "default" => true),
272  //array("permission" => "write", "cmd" => "", "lang_var" => "edit"),
273  array("permission" => "tst_statistics", "cmd" => "outEvaluation", "lang_var" => "tst_statistical_evaluation"),
274  );
275 
276  return $commands;
277  }
+ 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 91 of file class.ilObjTestAccess.php.

References $pass, $result, and $row.

92  {
93  global $ilDB;
94  $max = 0;
95  if ($random)
96  {
97  $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",
98  array('integer','integer','integer'),
99  array($test_id, $pass, $user_id)
100  );
101  if ($result->numRows())
102  {
103  $row = $ilDB->fetchAssoc($result);
104  $max = $row["maxpoints"];
105  }
106  }
107  else
108  {
109  $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",
110  array('integer'),
111  array($test_id)
112  );
113  if ($result->numRows())
114  {
115  $row = $ilDB->fetchAssoc($result);
116  $max = $row["maxpoints"];
117  }
118  }
119  return $max;
120  }
$result

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

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

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

591  {
592  global $lng, $ilDB;
593 
594  $result = $ilDB->queryF("SELECT * FROM tst_active WHERE active_id = %s",
595  array("integer"),
596  array($active_id)
597  );
598  $row = $ilDB->fetchAssoc($result);
599  $user_id = $row["user_fi"];
600  $test_id = $row["test_fi"];
601  $importname = $row['importname'];
602 
603  $result = $ilDB->queryF("SELECT obj_fi FROM tst_tests WHERE test_id = %s",
604  array("integer"),
605  array($test_id)
606  );
607  $row = $ilDB->fetchAssoc($result);
608  $obj_id = $row["obj_fi"];
609 
610  include_once "./Modules/Test/classes/class.ilObjTest.php";
611  $is_anonymous = ilObjTest::_lookupAnonymity($obj_id);
612 
613  include_once './Services/User/classes/class.ilObjUser.php';
614  $uname = ilObjUser::_lookupName($user_id);
615 
616  $name = "";
617  if (strlen($importname))
618  {
619  $name = $importname . ' (' . $lng->txt('imported') . ')';
620  }
621  else if (strlen($uname["firstname"].$uname["lastname"]) == 0)
622  {
623  $name = $lng->txt("deleted_user");
624  }
625  else
626  {
627  if ($user_id == ANONYMOUS_USER_ID)
628  {
629  $name = $lastname;
630  }
631  else
632  {
633  $name = trim($uname["lastname"] . ", " . $uname["firstname"] . " " . $uname["title"]);
634  }
635  if ($is_anonymous)
636  {
637  $name = $lng->txt("anonymous");
638  }
639  }
640  return $name;
641  }
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
+ 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 649 of file class.ilObjTestAccess.php.

References $lng, $result, and $row.

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

650  {
651  global $lng, $ilDB;
652 
653  $result = $ilDB->queryF("SELECT user_fi FROM tst_active WHERE active_id = %s",
654  array("integer"),
655  array($active_id)
656  );
657  $row = $ilDB->fetchAssoc($result);
658  return $row["user_fi"];
659  }
$result
global $lng
Definition: privfeed.php:40
+ 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 676 of file class.ilObjTestAccess.php.

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

Referenced by ilLPStatusTestPassed\_getStatusInfo().

677  {
678  global $ilDB;
679 
680  $passed_users = array();
681  // Maybe SELECT DISTINCT(tst_active.user_fi)... ?
682  $userresult = $ilDB->queryF("
683  SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences
684  FROM tst_tests
685  INNER JOIN tst_active
686  ON tst_active.test_fi = tst_tests.test_id
687  LEFT JOIN tst_sequence
688  ON tst_sequence.active_fi = tst_active.active_id
689  WHERE tst_tests.obj_fi = %s
690  GROUP BY tst_active.active_id
691  ",
692  array('integer'), array($a_obj_id)
693  );
694  $all_participants = array();
695  $notAttempted = array();
696  while ($row = $ilDB->fetchAssoc($userresult))
697  {
698  if($row['sequences'] == 0)
699  {
700  $notAttempted[$row['active_id']] = $row['active_id'];
701  }
702 
703  $all_participants[$row['active_id']] = $row['active_id'];
704  }
705 
706  $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'));
707  $found_all = ($result->numRows() == count($all_participants)) ? true : false;
708  if (!$found_all)
709  {
710  // if the result cache entries do not exist, create them
711  $found_participants = array();
712  while ($data = $ilDB->fetchAssoc($result))
713  {
714  array_push($found_participants, $data['active_fi']);
715  }
716  foreach ($all_participants as $active_id)
717  {
718  if (!in_array($active_id, $found_participants))
719  {
720  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
722  }
723  }
724  $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'));
725  }
726  while ($data = $ilDB->fetchAssoc($result))
727  {
728  if( isset($notAttempted[$data['active_fi']]) )
729  {
730  $data['failed'] = 0;
731  $data['passed'] = 0;
732  }
733 
734  $data['user_id'] = $data['user_fi'];
735  array_push($passed_users, $data);
736  }
737  return $passed_users;
738  }
$result
fetchAssoc($a_set)
Fetch row as associative array from result set.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
_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 498 of file class.ilObjTestAccess.php.

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

Referenced by ilWebAccessChecker\checkAccessTestQuestion().

499  {
500  global $ilDB;
501 
502  $query = "
503  SELECT DISTINCT t.obj_fi
504  FROM tst_tests t
505  INNER JOIN tst_rnd_quest_set_qpls r
506  ON t.test_id = r.test_fi
507  WHERE r.pool_fi = %s
508  ";
509 
510  $result = $ilDB->queryF($query, array('integer'), array($qpl_id));
511 
512  $tests = array();
513  while ($row = $ilDB->fetchAssoc($result))
514  {
515  $tests[] = $row['obj_fi'];
516  }
517 
518  return $tests;
519  }
$result
+ 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 458 of file class.ilObjTestAccess.php.

References $result.

459  {
460  global $ilDB;
461  $result = $ilDB->queryF("SELECT * FROM tst_tests WHERE test_id = %s",
462  array('integer'),
463  array($test_id)
464  );
465  if (!$result->numRows())
466  {
467  return 0;
468  }
469  return $ilDB->fetchAssoc($result);
470  }
$result

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

References $result, and $row.

Referenced by ilLPStatusTestFinished\getParticipants().

355  {
356  global $ilDB;
357  $test_id = FALSE;
358  $result = $ilDB->queryF("SELECT test_id FROM tst_tests WHERE obj_fi = %s",
359  array('integer'),
360  array($object_id)
361  );
362  if ($result->numRows())
363  {
364  $row = $ilDB->fetchAssoc($result);
365  $test_id = $row["test_id"];
366  }
367  return $test_id;
368  }
$result
+ Here is the caller graph for this function:

◆ _getTestQuestions()

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

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

References $pass, $result, and $row.

371  {
372  if (is_null($pass))
373  {
374  $pass = 0;
375  }
376  $questions = array();
377 
378  global $ilDB;
379  $result = $ilDB->queryF("SELECT test_fi FROM tst_active WHERE active_id = %s",
380  array('integer'),
381  array($active_id)
382  );
383  $test_id = "";
384  if ($result->numRows())
385  {
386  $row = $ilDB->fetchAssoc($result);
387  $test_id = $row["test_fi"];
388  }
389  else
390  {
391  return $questions;
392  }
393  $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",
394  array('integer'),
395  array($test_id)
396  );
397  if ($result->numRows())
398  {
399  // standard test
400  while ($row = $ilDB->fetchAssoc($result))
401  {
402  array_push($questions, $row);
403  }
404  }
405  else
406  {
407  // random test
408  $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",
409  array('integer','integer'),
410  array($active_id, $pass)
411  );
412  if ($result->numRows())
413  {
414  while ($row = $ilDB->fetchAssoc($result))
415  {
416  array_push($questions, $row);
417  }
418  }
419  }
420  return $questions;
421  }
$result

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

References $query, $res, and $row.

430  {
431  global $ilDB;
432 
433  $query = "
434  SELECT tst_tests.complete
435  FROM object_data
436  INNER JOIN tst_tests
437  ON tst_tests.obj_fi = object_data.obj_id
438  WHERE object_data.obj_id = %s
439  ";
440 
441  $res = $ilDB->queryF($query, array('integer'), array($a_obj_id));
442 
443  while( $row = $ilDB->fetchAssoc($res) )
444  {
445  return (bool)$row['complete'];
446  }
447 
448  return false;
449  }

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

770  {
771 // global $ilUser;
772 // return (self::_lookupOnlineTestAccess($a_obj_id, $ilUser->getId()) !== true) ||
773 // (!ilObjTestAccess::_lookupCreationComplete($a_obj_id));
774  return !self::_isOnline($a_obj_id);
775  }

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

References $query, and $result.

Referenced by ilObjTestListGUI\getProperties().

784  {
785  global $ilDB;
786 
787  $query = "
788  SELECT test_id
789  FROM tst_tests
790  WHERE obj_fi = %s
791  AND online_status = 1
792  ";
793 
794  $result = $ilDB->queryF( $query, array('integer'), array($a_obj_id) );
795 
796  return $result->numRows() == 1;
797  }
$result
+ 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 129 of file class.ilObjTestAccess.php.

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

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

130  {
131  global $ilDB;
132 
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);
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);
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.
_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 286 of file class.ilObjTestAccess.php.

References $result, and $row.

Referenced by _checkAccess().

287  {
288  global $ilDB;
289 
290  $result = $ilDB->queryF("SELECT complete FROM tst_tests WHERE obj_fi=%s",
291  array('integer'),
292  array($a_obj_id)
293  );
294  if ($result->numRows() == 1)
295  {
296  $row = $ilDB->fetchAssoc($result);
297  }
298 
299  return ($row['complete']) ? true : false;
300  }
$result
+ 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 478 of file class.ilObjTestAccess.php.

References $result, and $row.

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

479  {
480  global $ilDB;
481 
482  $result = $ilDB->queryF("SELECT obj_fi FROM tst_tests WHERE test_id = %s",
483  array('integer'),
484  array($a_test_id)
485  );
486 
487  $row = $ilDB->fetchAssoc($result);
488  return $row["obj_fi"];
489  }
$result
+ 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 528 of file class.ilObjTestAccess.php.

References $lng, $result, and $row.

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

529  {
530  global $ilDB, $lng;
531 
532  $result = $ilDB->queryF("SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
533  array('integer'),
534  array($a_test_id)
535  );
536  if ($result->numRows())
537  {
538  $row = $ilDB->fetchAssoc($result);
539  if ($row["fixed_participants"])
540  {
541  $result = $ilDB->queryF("SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
542  array('integer','integer'),
543  array($row["test_id"], $a_user_id)
544  );
545  if ($result->numRows())
546  {
547  $row = $ilDB->fetchAssoc($result);
548  if (trim($row['clientip']) != "")
549  {
550  $row['clientip'] = preg_replace("/[^0-9.?*,:]+/","",$row['clientip']);
551  $row['clientip'] = str_replace(".","\\.",$row['clientip']);
552  $row['clientip'] = str_replace(Array("?","*",","), Array("[0-9]","[0-9]*","|"), $row['clientip']);
553  if (!preg_match("/^".$row['clientip']."$/", $_SERVER["REMOTE_ADDR"]))
554  {
555  return $lng->txt("tst_user_wrong_clientip");
556  }
557  else
558  {
559  return true;
560  }
561  }
562  else
563  {
564  return true;
565  }
566  }
567  else
568  {
569  return $lng->txt("tst_user_not_invited");
570  }
571  }
572  else
573  {
574  return true;
575  }
576  }
577  else
578  {
579  return true;
580  }
581  }
$result
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

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

References $lng, and ilObjectFactory\getInstanceByObjId().

Referenced by _checkCondition().

317  {
318  if( !isset(self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"]) )
319  {
320  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
321  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
322  require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
323 
324  global $ilDB, $lng;
325 
326  $testOBJ = ilObjectFactory::getInstanceByObjId($a_obj_id);
327 
328  $partData = new ilTestParticipantData($ilDB, $lng);
329  $partData->setUserIds(array($a_user_id));
330  $partData->load($testOBJ->getTestId());
331 
332  $activeId = $partData->getActiveIdByUserId($a_user_id);
333 
334  $testSessionFactory = new ilTestSessionFactory($testOBJ);
335  $testSession = $testSessionFactory->getSession($activeId);
336 
337  $testPassesSelector = new ilTestPassesSelector($ilDB, $testOBJ);
338  $testPassesSelector->setActiveId($activeId);
339  $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
340 
341  self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
342  }
343 
344  return self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"];
345  }
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
global $lng
Definition: privfeed.php:40
+ 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 307 of file class.ilObjTestAccess.php.


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