4 include_once
"./Services/Object/classes/class.ilObjectAccess.php";
5 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
6 include_once
'./Services/AccessControl/interfaces/interface.ilConditionHandling.php';
37 function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id =
"")
43 $a_user_id = $ilUser->getId();
46 $is_admin = $rbacsystem->checkAccessOfUser($a_user_id,
'write',$a_ref_id);
49 if(!self::_isOnline($a_obj_id) && !$is_admin)
55 switch ($a_permission)
91 public static function _isPassed($user_id, $a_obj_id)
94 $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",
95 array(
'integer',
'integer'),
96 array($user_id, $a_obj_id)
100 $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",
101 array(
'integer',
'integer'),
102 array($user_id, $a_obj_id)
105 if (
$row[
'active_id'] > 0)
107 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
115 $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",
116 array(
'integer',
'integer'),
117 array($user_id, $a_obj_id)
121 $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",
122 array(
'integer',
'integer'),
123 array($user_id, $a_obj_id)
128 array_push($points,
$row);
132 if ($points[0][
"pass_scoring"] == 0)
134 $reached = $points[count($points)-1][
"points"];
135 $max = $points[count($points)-1][
"maxpoints"];
138 $active_id = $points[count($points)-1][
"active_fi"];
139 $pass = $points[count($points)-1][
"pass"];
140 if (strlen($active_id) && strlen(
$pass))
142 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
143 $res = assQuestion::_updateTestPassResults($active_id,
$pass, null, $a_obj_id);
144 $max =
$res[
'maxpoints'];
145 $reached =
$res[
'points'];
151 foreach ($points as
$row)
153 if ($row[
"points"] > $reached)
155 $reached = $row[
"points"];
156 $max = $row[
"maxpoints"];
159 $active_id = $row[
"active_fi"];
160 $pass = $row[
"pass"];
161 if (strlen($active_id) && strlen(
$pass))
163 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
164 $res = assQuestion::_updateTestPassResults($active_id,
$pass, null, $a_obj_id);
165 $max =
$res[
'maxpoints'];
166 $reached =
$res[
'points'];
172 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
173 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
175 return ($mark[
"passed"]) ? TRUE : FALSE;
180 return (
$row[
'passed']) ? true :
false;
191 public static function isFailed($user_id, $a_obj_id)
195 $ret = self::updateTestResultCache($user_id, $a_obj_id);
202 $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",
203 array(
'integer',
'integer'),
204 array($user_id, $a_obj_id)
209 $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",
210 array(
'integer',
'integer'),
211 array($user_id, $a_obj_id)
216 array_push($points,
$row);
220 if ($points[0][
"pass_scoring"] == 0)
222 $reached = $points[count($points)-1][
"points"];
223 $max = $points[count($points)-1][
"maxpoints"];
226 $active_id = $points[count($points)-1][
"active_fi"];
227 $pass = $points[count($points)-1][
"pass"];
228 if (strlen($active_id) && strlen(
$pass))
230 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
231 $res = assQuestion::_updateTestPassResults($active_id,
$pass, null, $a_obj_id);
232 $max =
$res[
'maxpoints'];
233 $reached =
$res[
'points'];
239 foreach ($points as
$row)
241 if ($row[
"points"] > $reached)
243 $reached = $row[
"points"];
244 $max = $row[
"maxpoints"];
247 $active_id = $row[
"active_fi"];
248 $pass = $row[
"pass"];
249 if (strlen($active_id) && strlen(
$pass))
251 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
252 $res = assQuestion::_updateTestPassResults($active_id,
$pass, null, $a_obj_id);
253 $max =
$res[
'maxpoints'];
254 $reached =
$res[
'points'];
260 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
261 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
263 return ($mark[
"failed"]) ? TRUE : FALSE;
268 return (
$row[
'failed']) ? TRUE : FALSE;
282 "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests ".
283 "WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s ".
284 "AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
285 array(
'integer',
'integer'),
286 array($a_user_id, $a_obj_id)
290 $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",
291 array(
'integer',
'integer'),
292 array($a_user_id, $a_obj_id)
295 if (
$row[
'active_id'] > 0)
297 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
319 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
334 public static function checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
336 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
375 array(
"permission" =>
"write",
"cmd" =>
"questionsTabGateway",
"lang_var" =>
"tst_edit_questions"),
376 array(
"permission" =>
"write",
"cmd" =>
"ilObjTestSettingsGeneralGUI::showForm",
"lang_var" =>
"settings"),
377 array(
"permission" =>
"read",
"cmd" =>
"infoScreen",
"lang_var" =>
"tst_run",
380 array(
"permission" =>
"tst_statistics",
"cmd" =>
"outEvaluation",
"lang_var" =>
"tst_statistical_evaluation"),
381 array(
"permission" =>
"read",
"cmd" =>
"userResultsGateway",
"lang_var" =>
"tst_test_results")
398 $result = $ilDB->queryF(
"SELECT complete FROM tst_tests WHERE obj_fi=%s",
407 return (
$row[
'complete']) ? true :
false;
426 if( !isset(self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"]) )
428 require_once
'Modules/Test/classes/class.ilTestParticipantData.php';
429 require_once
'Modules/Test/classes/class.ilTestSessionFactory.php';
430 require_once
'Modules/Test/classes/class.ilTestPassesSelector.php';
437 $partData->setUserIds(
array($a_user_id));
438 $partData->load($testOBJ->getTestId());
440 $activeId = $partData->getActiveIdByUserId($a_user_id);
443 $testSession = $testSessionFactory->getSession($activeId);
446 $testPassesSelector->setActiveId($activeId);
447 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
449 self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
452 return (
bool) self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"];
466 $result = $ilDB->queryF(
"SELECT test_id FROM tst_tests WHERE obj_fi = %s",
473 $test_id =
$row[
"test_id"];
488 $result = $ilDB->queryF(
"SELECT obj_fi FROM tst_tests WHERE test_id = %s",
494 return $row[
"obj_fi"];
509 SELECT DISTINCT t.obj_fi 511 INNER JOIN tst_rnd_quest_set_qpls r 512 ON t.test_id = r.test_fi 521 $tests[] =
$row[
'obj_fi'];
538 $result = $ilDB->queryF(
"SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
545 if (
$row[
"fixed_participants"])
547 $result = $ilDB->queryF(
"SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
548 array(
'integer',
'integer'),
554 if (trim(
$row[
'clientip']) !=
"")
556 $row[
'clientip'] = preg_replace(
"/[^0-9.?*,:]+/",
"",
$row[
'clientip']);
557 $row[
'clientip'] = str_replace(
".",
"\\.",
$row[
'clientip']);
558 $row[
'clientip'] = str_replace(Array(
"?",
"*",
","), Array(
"[0-9]",
"[0-9]*",
"|"),
$row[
'clientip']);
559 if (!preg_match(
"/^".
$row[
'clientip'].
"$/",
$_SERVER[
"REMOTE_ADDR"]))
561 return $lng->txt(
"tst_user_wrong_clientip");
575 return $lng->txt(
"tst_user_not_invited");
600 $result = $ilDB->queryF(
"SELECT * FROM tst_active WHERE active_id = %s",
605 $user_id =
$row[
"user_fi"];
606 $test_id =
$row[
"test_fi"];
607 $importname =
$row[
'importname'];
609 $result = $ilDB->queryF(
"SELECT obj_fi FROM tst_tests WHERE test_id = %s",
614 $obj_id =
$row[
"obj_fi"];
616 include_once
"./Modules/Test/classes/class.ilObjTest.php";
619 include_once
'./Services/User/classes/class.ilObjUser.php';
623 if (strlen($importname))
625 $name = $importname .
' (' . $lng->txt(
'imported') .
')';
627 else if (strlen($uname[
"firstname"].$uname[
"lastname"]) == 0)
629 $name = $lng->txt(
"deleted_user");
633 if ($user_id == ANONYMOUS_USER_ID)
639 $name = trim($uname[
"lastname"] .
", " . $uname[
"firstname"] .
" " . $uname[
"title"]);
643 $name = $lng->txt(
"anonymous");
659 $result = $ilDB->queryF(
"SELECT user_fi FROM tst_active WHERE active_id = %s",
664 return $row[
"user_fi"];
686 $passed_users =
array();
688 $userresult = $ilDB->queryF(
" 689 SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences, tst_active.last_finished_pass, 691 (tst_tests.nr_of_tries - 1) = tst_active.last_finished_pass 696 INNER JOIN tst_active 697 ON tst_active.test_fi = tst_tests.test_id 698 LEFT JOIN tst_sequence 699 ON tst_sequence.active_fi = tst_active.active_id 700 WHERE tst_tests.obj_fi = %s 701 GROUP BY tst_active.active_id 705 $all_participants =
array();
706 $notAttempted =
array();
707 $lastPassUsers =
array();
708 while (
$row = $ilDB->fetchAssoc($userresult))
710 if(
$row[
'sequences'] == 0)
712 $notAttempted[
$row[
'active_id']] = $row[
'active_id'];
714 if(
$row[
'is_last_pass'])
716 $lastPassUsers[
$row[
'active_id']] = $row[
'active_id'];
719 $all_participants[
$row[
'active_id']] = $row[
'active_id'];
722 $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'));
723 $found_all = (
$result->numRows() == count($all_participants)) ?
true :
false;
727 $found_participants =
array();
730 array_push($found_participants,
$data[
'active_fi']);
732 foreach ($all_participants as $active_id)
734 if (!in_array($active_id, $found_participants))
736 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
740 $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'));
744 if( isset($notAttempted[
$data[
'active_fi']]) )
748 $data[
'not_attempted'] = 1;
751 if( $data[
'failed'] && !isset($lastPassUsers[$data[
'active_fi']]) )
755 $data[
'in_progress'] = 1;
758 $data[
'user_id'] = $data[
'user_fi'];
759 array_push($passed_users, $data);
761 return $passed_users;
771 $t_arr = explode(
"_", $a_target);
773 if ($t_arr[0] !=
"tst" || ((
int) $t_arr[1]) <= 0)
778 if ($ilAccess->checkAccess(
"read",
"", $t_arr[1]))
798 return !self::_isOnline($a_obj_id);
815 AND online_status = 1 820 return $result->numRows() == 1;
832 require_once
'Modules/Test/classes/class.ilTestSessionFactory.php';
834 $testSession = $testSessionFactory->getSessionByUserId($userId);
836 return $testOBJ->canShowTestResults($testSession);
850 if( !($testOBJ instanceof
ilObjTest) || !$userId )
855 require_once
'Modules/Test/classes/class.ilTestSessionFactory.php';
857 $testSession = $testSessionFactory->getSessionByUserId($userId);
859 if( !$testSession->getActiveId() )
864 return $testOBJ->canShowCertificate($testSession, $testSession->getUserId(), $testSession->getActiveId());
static _lookupName($a_user_id)
lookup user name
static _lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static _getParticipantData($active_id)
Retrieves a participant name from active id.
static _getParticipantId($active_id)
Get user id for active id.
const IL_NO_OBJECT_ACCESS
Interface for condition handling.
static _isOffline($a_obj_id)
returns the objects's OFFline status
static _isOnline($a_obj_id)
returns the objects's ONline status
_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::checkAcce...
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 _lookupAnonymity($a_obj_id)
Returns the anonymity status of a test with a given object id.
static _lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
static _getRandomTestsForQuestionPool($qpl_id)
Get all tests using a question pool for random selection.
static _lookupObjIdForTestId($a_test_id)
Lookup object id for test id.
static _getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
static visibleUserResultExists($testObjId, $userId)
static _getPassedUsers($a_obj_id)
Returns an array containing the users who passed the test.
static _getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
static hasVisibleCertificate($testObjId, $userId)
Andre Michels amichels@databay.de
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 getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
const OPERATOR_NOT_FINISHED
Create styles array
The data for the language used.
static getConditionOperators()
Get possible conditions operators.
static updateTestResultCache($a_user_id, $a_obj_id)
Update test result cache.
static _getCommands()
get commands
static checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
check condition
static hasFinished($a_user_id, $a_obj_id)
Returns (request cached) information if a specific user has finished at least one test pass...
static _checkGoto($a_target)
check whether goto script will succeed