19declare(strict_types=1);
59 $this->db =
$DIC[
'ilDB'];
60 $this->
user = $DIC[
'ilUser'];
61 $this->
lng = $DIC[
'lng'];
62 $this->rbac_system =
$DIC[
'rbacsystem'];
63 $this->
access = $DIC[
'ilAccess'];
76 return !$can_it->isOk() || $can_it->value();
83 ),
new Error(
'Not a known path.'));
99 $is_admin = $this->rbac_system->checkAccessOfUser(
$user_id,
'write',
$ref_id)
100 || $this->rbac_system->checkAccessOfUser(
$user_id,
'score_anon',
$ref_id);
104 if (!$is_admin && !$is_online) {
108 switch ($permission) {
151 public static function checkCondition(
int $a_trigger_obj_id,
string $a_operator,
string $a_value,
int $a_usr_id): bool
154 $test_result_repository = TestDIC::dic()[
'results.data.repository'];
156 switch ($a_operator) {
158 return $test_result_repository->isPassed($a_usr_id, $a_trigger_obj_id);
161 return $test_result_repository->isFailed($a_usr_id, $a_trigger_obj_id);
164 return $test_result_repository->hasFinished($a_usr_id, $a_trigger_obj_id);
167 return !$test_result_repository->hasFinished($a_usr_id, $a_trigger_obj_id);
171 if ($percentage_thresholds ===
false) {
174 return $test_result_repository->reachedPercentage(
177 $percentage_thresholds[
'min_percentage'],
178 $percentage_thresholds[
'max_percentage']
188 $DIC->language()->loadLanguageModule(
'assessment');
192 'permission' =>
'write',
193 'cmd' =>
'questionsTabGateway',
194 'lang_var' =>
'tst_edit_questions'
197 'permission' =>
'write',
198 'cmd' =>
'ILIAS\Test\Settings\MainSettings\SettingsMainGUI::showForm',
199 'lang_var' =>
'settings'
202 'permission' =>
'read',
203 'cmd' =>
'ILIAS\Test\Presentation\TestScreenGUI::testScreen',
204 'lang_var' =>
'tst_run',
208 'permission' =>
'score_anon',
209 'cmd' =>
'ILIAS\Test\Scoring\Manual\ConsecutiveScoringGUI::view',
210 'lang_var' =>
'manscoring'
232 'SELECT complete FROM tst_tests WHERE obj_fi=%s',
236 return $result->numRows() > 0 && (bool)
$db->
fetchAssoc($result)[
'complete'];
251 $result =
$ilDB->queryF(
252 'SELECT test_id FROM tst_tests WHERE obj_fi = %s',
256 if ($result->numRows()) {
257 $row =
$ilDB->fetchAssoc($result);
258 $test_id = $row[
'test_id'];
275 $query =
'SELECT DISTINCT t.obj_fi' . PHP_EOL
276 .
'FROM tst_tests t' . PHP_EOL
277 .
'INNER JOIN tst_rnd_quest_set_qpls r' . PHP_EOL
278 .
'ON t.test_id = r.test_fi' . PHP_EOL
279 .
'WHERE r.pool_fi = %s' . PHP_EOL;
284 while ($row =
$ilDB->fetchAssoc($result)) {
285 $tests[] = $row[
'obj_fi'];
304 $result_active =
$ilDB->queryF(
305 'SELECT * FROM tst_active WHERE active_id = %s',
309 $row_active =
$ilDB->fetchAssoc($result_active);
310 $importname = $row_active[
'importname'];
312 if ($importname !==
null
313 && $importname !==
'') {
314 return $importname .
' (' .
$lng->
txt(
'imported') .
')';
323 $result_test =
$ilDB->queryF(
324 'SELECT obj_fi FROM tst_tests WHERE test_id = %s',
326 [$row_active[
'test_fi']]
328 $row_test =
$ilDB->fetchAssoc($result_test);
329 $obj_id = $row_test[
'obj_fi'];
331 $test_obj =
new ilObjTest($obj_id,
false);
332 if ($test_obj->getAnonymity()) {
336 if ($uname[
'firstname'] . $uname[
'lastname'] ===
'') {
337 return $lng->
txt(
'deleted_user');
340 return trim($uname[
'lastname'] .
', ' . $uname[
'firstname']);
354 $result =
$ilDB->queryF(
355 'SELECT user_fi FROM tst_active WHERE active_id = %s',
359 $row =
$ilDB->fetchAssoc($result);
360 return $row[
'user_fi'];
369 $ilAccess =
$DIC[
'ilAccess'];
371 $t_arr = explode(
'_', $target);
373 if ($t_arr[0] !=
'tst' || ((
int) $t_arr[1]) <= 0) {
377 if ($ilAccess->checkAccess(
'read',
'', (
int) $t_arr[1]) ||
378 $ilAccess->checkAccess(
'visible',
'', (
int) $t_arr[1])) {
399 $ilUser =
$DIC[
'ilUser'];
408 $test_session = $test_session_factory->getSessionByUserId(
$user_id);
410 return $test_obj->canShowTestResults($test_session);
413 public static function _preloadData(array $obj_ids, array $ref_ids): void
418 self::$certificate_preloader->preLoad(
$DIC[
'ilUser']->
getId(), $obj_ids);
419 self::$settings_result_summaries_by_obj_id = TestDIC::dic()[
'settings.scoring.repository']
420 ->getSettingsResultSummaryByObjIds($obj_ids);
426 if (self::$certificate_preloader ===
null
427 || !self::$certificate_preloader->isPreloaded(
$user_id, $obj_id)
428 || !isset(self::$settings_result_summaries_by_obj_id[$obj_id])
429 || self::$settings_result_summaries_by_obj_id[$obj_id]->getScoreReporting()
430 === ScoreReportingTypes::SCORE_REPORTING_DISABLED) {
434 $score_reporting = self::$settings_result_summaries_by_obj_id[$obj_id]->getScoreReporting();
435 if ($score_reporting === ScoreReportingTypes::SCORE_REPORTING_IMMIDIATLY) {
439 if ($score_reporting === ScoreReportingTypes::SCORE_REPORTING_DATE
440 && self::$settings_result_summaries_by_obj_id->getReportingDate() <
new \DateTimeImmutable(
'now',
new DateTimeZone(
'UTC'))) {
452 $value_arr = unserialize($value);
454 if ($value_arr ===
false) {
459 'min_percentage' => (float) ($value_arr[
'min_percentage'] ?? 0.0) / 100,
460 'max_percentage' => (float) ($value_arr[
'max_percentage'] ?? 0.0) / 100
A result encapsulates a value or an error and simplifies the handling of those.
const IL_NO_OBJECT_ACCESS
const string OPERATOR_FAILED
const string OPERATOR_NOT_FINISHED
const string OPERATOR_FINISHED
const string OPERATOR_RESULT_RANGE_PERCENTAGE
const string OPERATOR_PASSED
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
canBeDelivered(ilWACPath $ilWACPath)
static array $settings_result_summaries_by_obj_id
findMatch(string $path, array $array)
static getConditionOperators()
Get possible conditions operators.
static _getParticipantData(int $active_id)
Retrieves a participant name from active id.
static _isOffline(int $obj_id)
returns the objects's OFFline status
ilRbacSystem $rbac_system
static ilCertificateObjectsForUserPreloader $certificate_preloader
static _getCommands()
get commands
static _checkGoto(string $target)
check whether goto script will succeed
showCertificateFor(int $user_id, int $obj_id)
static _getParticipantId(int $active_id)
Get user id for active id.
static visibleUserResultExists(int $test_obj_id, int $user_id)
static lookupCreationComplete(int $a_obj_id)
static _getTestIDFromObjectID(int $object_id)
Returns the ILIAS test id for a given object id.
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcce...
static _preloadData(array $obj_ids, array $ref_ids)
Preload data.
static getBypassActivationCheckForPermissions()
static _getRandomTestsForQuestionPool(int $qpl_id)
Get all tests using a question pool for random selection.
static deserializePercentageThresholds(string $value)
static _lookupName(int $a_user_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A result encapsulates a value or an error and simplifies the handling of those.
except(callable $f)
Feed the error into a callable and replace this with the result or do nothing if this is a value.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
Interface for condition handling.
static checkCondition(int $a_trigger_obj_id, string $a_operator, string $a_value, int $a_usr_id)
check condition for a specific user and object
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc