19 declare(strict_types=1);
51 $this->db = $DIC[
'ilDB'];
52 $this->
lng = $DIC[
'lng'];
54 $this->participant_repository = TestDIC::dic()[
'participant.repository'];
55 $this->
access = $DIC->access();
56 $this->main_settings_repository = TestDIC::dic()[
'settings.main.repository'];
152 if ($this->
getAccess()->checkRbacOrPositionPermissionAccess(
153 'read_learning_progress',
166 $participantData->setActiveIdsFilter([$active_id]);
167 $participantData->setParticipantAccessFilter($access_filter);
168 $participantData->load($test_id);
170 return in_array($active_id, $participantData->getActiveIds());
175 $access_filter = $this->participant_access_filter->getAccessResultsUserFilter($this->
getRefId());
181 $access_filter = $this->participant_access_filter->getScoreParticipantsUserFilter($this->
getRefId());
188 $access_settings = $this->main_settings_repository->getForObjFi($obj_id)
189 ->getAccessSettings();
191 return ParticipantAccess::BROKEN_TEST;
194 $participant = $this->participant_repository->getParticipantByUserId(
201 if ($access_settings->getFixedParticipants()
202 && ($participant ===
null || !$participant->isInvitedParticipant())) {
203 return ParticipantAccess::NOT_INVITED;
209 if ($allowed_individual ===
false) {
210 return ParticipantAccess::INDIVIDUAL_CLIENT_IP_MISMATCH;
214 if ($allowed_individual ===
true 215 || !$access_settings->isIpRangeEnabled()) {
216 return ParticipantAccess::ALLOWED;
220 return ParticipantAccess::TEST_LEVEL_CLIENT_IP_MISMATCH;
223 return ParticipantAccess::ALLOWED;
233 if ($range_start ===
null && $range_end ===
null) {
237 if ($this->
isIpTypeOf(FILTER_FLAG_IPV4, $ip, $range_start, $range_end)) {
241 if ($this->
isIpTypeOf(FILTER_FLAG_IPV6, $ip, $range_start, $range_end)) {
259 if ($this->
isIpTypeOf(FILTER_FLAG_IPV4, $ip, $range_start, $range_end)) {
263 if ($this->
isIpTypeOf(FILTER_FLAG_IPV6, $ip, $range_start, $range_end)) {
270 private function isIpTypeOf(
int $ip_type_flag,
string $ip,
string $range_start,
string $range_end): bool
272 return filter_var($ip, FILTER_VALIDATE_IP, $ip_type_flag) !==
false 273 && filter_var($range_start, FILTER_VALIDATE_IP, $ip_type_flag) !==
false 274 && filter_var($range_end, FILTER_VALIDATE_IP, $ip_type_flag) !==
false;
277 private function isIpv4Between(
string $ip,
string $range_start,
string $range_end): bool
279 return ip2long($range_start) <= ip2long($ip)
280 && ip2long($ip) <= ip2long($range_end);
283 private function isIpv6Between(
string $ip,
string $range_start,
string $range_end): bool
285 return bin2hex(inet_pton($range_start)) <= bin2hex(inet_pton($ip))
286 && bin2hex(inet_pton($ip)) <= bin2hex(inet_pton($range_end));
isIpTypeOf(int $ip_type_flag, string $ip, string $range_start, string $range_end)
checkScoreParticipantsAccess()
ParticipantRepository $participant_repository
setAccess(ilAccessHandler $access)
MainSettingsDatabaseRepository $main_settings_repository
static _lookupObjId(int $ref_id)
checkResultsAccessForActiveId(int $active_id, int $test_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
checkParticipantsResultsAccess()
checkOtherParticipantsLearningProgressAccess()
const OP_READ_LEARNING_PROGRESS
const OP_SCORE_PARTICIPANTS
checkAccessForActiveId(Closure $access_filter, int $active_id, int $test_id)
isParticipantExplicitelyAllowedByIndividualIPRange(?Participant $participant, string $ip)
const OP_MANAGE_PARTICIPANTS
isIpv4Between(string $ip, string $range_start, string $range_end)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
checkManageParticipantsAccess()
checkScoreParticipantsAccessForActiveId(int $active_id, int $test_id)
isIpAllowedToAccessTest(string $ip, SettingsAccess $access_settings)
checkScoreParticipantsAccessAnon()
__construct(Container $dic, ilPlugin $plugin)
isIpv6Between(string $ip, string $range_start, string $range_end)
isParticipantAllowed(int $obj_id, int $user_id)
ilTestParticipantAccessFilterFactory $participant_access_filter