Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal: Add course access tracking- BT#21694 #5508

Merged
merged 2 commits into from
May 16, 2024

Conversation

christianbeeznest
Copy link
Contributor

No description provided.

@chamilo chamilo deleted a comment from codeclimate bot May 15, 2024
@chamilo chamilo deleted a comment from codeclimate bot May 15, 2024
@chamilo chamilo deleted a comment from codeclimate bot May 15, 2024
@chamilo chamilo deleted a comment from codeclimate bot May 15, 2024
@chamilo chamilo deleted a comment from codeclimate bot May 15, 2024
Comment on lines 345 to 358
$access = $this->entityManager->getRepository(TrackECourseAccess::class)
->createQueryBuilder('a')
->where('a.user = :user AND a.cId = :courseId AND a.sessionId = :sessionId')
->andWhere('a.loginCourseDate > :limitTime')
->setParameters([
'user' => $user,
'courseId' => $courseId,
'sessionId' => $sessionId,
'limitTime' => $limitTime,
])
->orderBy('a.loginCourseDate', 'DESC')
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Es mejor pasar la query a un método de TrackECourseAccessRepository

Comment on lines 42 to 43
$user = $this->tokenStorage->getToken()?->getUser();
if ($user instanceof User) {
Copy link
Member

@AngelFQC AngelFQC May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puedes usar el helper Chamilo\CoreBundle\ServiceHelper\UserHelper en el constructor

Suggested change
$user = $this->tokenStorage->getToken()?->getUser();
if ($user instanceof User) {
$user = $this->userHelper->getCurrent();
if ($user) {

if ($courseId > 0) {
$user = $this->tokenStorage->getToken()?->getUser();
if ($user instanceof User) {
$ip = $this->requestStack->getCurrentRequest()->getClientIp();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La request puedes obtenerla desde el mismo envento

Suggested change
$ip = $this->requestStack->getCurrentRequest()->getClientIp();
$ip = $event->getRequest()->getClientIp();

}

public function __invoke(CourseAccess $event): void
private function findExistingAccess(User $user, int $courseId, int $sessionId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Este método debería estar en TrackeECourseAccess

tags:
- {name: kernel.event_listener, event: chamilo_course.course.access}
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 6 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El CidReqListener tiene la misma prioridad (de 6). Y en ambos hay una función que puede registrar un $access = new TrackECourseAccess();

Copy link

codecov bot commented May 16, 2024

Codecov Report

Attention: Patch coverage is 86.66667% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 39.81%. Comparing base (7b51cc5) to head (e550fc5).
Report is 17 commits behind head on master.

Files Patch % Lines
...Bundle/Repository/TrackECourseAccessRepository.php 79.59% 10 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5508      +/-   ##
============================================
+ Coverage     39.66%   39.81%   +0.14%     
- Complexity    10567    10593      +26     
============================================
  Files           840      841       +1     
  Lines         44173    44255      +82     
============================================
+ Hits          17522    17619      +97     
+ Misses        26651    26636      -15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codeclimate bot commented May 16, 2024

An error occurred when fetching issues.

View more on Code Climate.

@NicoDucou NicoDucou merged commit 3a3b1a2 into chamilo:master May 16, 2024
5 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants