From 2fb5d4c29ed70a89042c9d99a01c1330e9eb90aa Mon Sep 17 00:00:00 2001
From: Angel Fernando Quiroz Campos <1697880+AngelFQC@users.noreply.github.com>
Date: Mon, 9 Dec 2024 11:47:48 -0500
Subject: [PATCH] Minor: Format code
---
.../Command/LpProgressReminderCommand.php | 69 ++++++++++---------
.../Command/SendEventRemindersCommand.php | 5 +-
.../Controller/CourseController.php | 2 +-
src/CoreBundle/Entity/ExtraField.php | 3 +-
.../Schema/V200/Version20230913162700.php | 5 +-
.../Schema/V200/Version20231022124700.php | 16 +++--
.../Schema/V200/Version20241209103000.php | 18 ++---
.../Repository/CourseRelUserRepository.php | 3 +-
.../Repository/ExtraFieldValuesRepository.php | 3 +-
.../SessionRelCourseRelUserRepository.php | 3 +-
.../Repository/TrackEDefaultRepository.php | 22 +++---
src/CourseBundle/Repository/CLpRepository.php | 3 +-
.../Repository/CQuizRepository.php | 3 +-
13 files changed, 86 insertions(+), 69 deletions(-)
diff --git a/src/CoreBundle/Command/LpProgressReminderCommand.php b/src/CoreBundle/Command/LpProgressReminderCommand.php
index 0ba3be8a49..d9b72bab1b 100644
--- a/src/CoreBundle/Command/LpProgressReminderCommand.php
+++ b/src/CoreBundle/Command/LpProgressReminderCommand.php
@@ -15,13 +15,14 @@ use Chamilo\CoreBundle\Repository\TrackEDefaultRepository;
use Chamilo\CoreBundle\ServiceHelper\MessageHelper;
use DateTime;
use DateTimeZone;
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
-use Symfony\Contracts\Translation\TranslatorInterface;
-use Twig\Environment;
+use Exception;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
+use Twig\Environment;
class LpProgressReminderCommand extends Command
{
@@ -44,8 +45,7 @@ class LpProgressReminderCommand extends Command
parent::__construct();
}
-
- protected function configure()
+ protected function configure(): void
{
$this
->setDescription('Send LP progress reminders to users based on "number_of_days_for_completion".')
@@ -54,7 +54,8 @@ class LpProgressReminderCommand extends Command
null,
InputOption::VALUE_NONE,
'If set, will output detailed debug information'
- );
+ )
+ ;
}
protected function execute(InputInterface $input, OutputInterface $output): int
@@ -65,11 +66,12 @@ class LpProgressReminderCommand extends Command
// Retrieve LPs with completion days
$lpItems = $this->extraFieldValuesRepository->getLpIdWithDaysForCompletion();
if ($debugMode && !empty($lpItems)) {
- $output->writeln('LP Items retrieved: ' . print_r($lpItems, true));
+ $output->writeln('LP Items retrieved: '.print_r($lpItems, true));
}
if (empty($lpItems)) {
$output->writeln('No learning paths with days for completion found.');
+
return Command::SUCCESS;
}
@@ -82,7 +84,7 @@ class LpProgressReminderCommand extends Command
// Retrieve all courses from the CourseRepository
$courses = $this->courseRepository->findAll();
if ($debugMode && !empty($courses)) {
- $output->writeln('Courses retrieved: ' . count($courses));
+ $output->writeln('Courses retrieved: '.\count($courses));
}
foreach ($courses as $course) {
@@ -94,14 +96,14 @@ class LpProgressReminderCommand extends Command
$sessionCourseUsers = $this->sessionRelCourseRelUserRepository->getSessionCourseUsers($courseId, $lpIds);
if ($debugMode && (!empty($courseUsers) || !empty($sessionCourseUsers))) {
- $output->writeln('Processing course ID: ' . $courseId);
+ $output->writeln('Processing course ID: '.$courseId);
if (!empty($courseUsers)) {
- $output->writeln('Course users retrieved: ' . count($courseUsers));
- //$output->writeln('Course retrieved: ' . print_r($courseUsers, true));
+ $output->writeln('Course users retrieved: '.\count($courseUsers));
+ // $output->writeln('Course retrieved: ' . print_r($courseUsers, true));
}
if (!empty($sessionCourseUsers)) {
- $output->writeln('Session users retrieved: ' . count($sessionCourseUsers));
- //$output->writeln('Session retrieved: ' . print_r($sessionCourseUsers, true));
+ $output->writeln('Session users retrieved: '.\count($sessionCourseUsers));
+ // $output->writeln('Session retrieved: ' . print_r($sessionCourseUsers, true));
}
}
@@ -113,6 +115,7 @@ class LpProgressReminderCommand extends Command
}
$output->writeln('LP progress reminder process finished.');
+
return Command::SUCCESS;
}
@@ -129,7 +132,7 @@ class LpProgressReminderCommand extends Command
$sessionId = $checkSession ? ($user['sessionId'] ?? 0) : 0;
- if ($lpId === null) {
+ if (null === $lpId) {
foreach ($lpItems as $lpId => $nbDaysForLpCompletion) {
$this->sendReminderIfNeeded(
$userId,
@@ -177,11 +180,12 @@ class LpProgressReminderCommand extends Command
if ($debugMode) {
echo "No registration date found for user $userId in course $courseId (session ID: $sessionId).\n";
}
+
return;
}
if ($debugMode) {
- $sessionInfo = $sessionId > 0 ? "in session ID $sessionId" : "without a session";
+ $sessionInfo = $sessionId > 0 ? "in session ID $sessionId" : 'without a session';
echo "Registration date: {$registrationDate->format('Y-m-d H:i:s')}, Days for completion: $nbDaysForLpCompletion, LP ID: {$lpId}, $sessionInfo\n";
}
@@ -202,8 +206,8 @@ class LpProgressReminderCommand extends Command
private function logReminderSent(int $userId, string $courseTitle, int $nbRemind, bool $debugMode, int $lpId, int $sessionId = 0): void
{
if ($debugMode) {
- $sessionInfo = $sessionId > 0 ? sprintf("in session ID %d", $sessionId) : "without a session";
- echo sprintf(
+ $sessionInfo = $sessionId > 0 ? \sprintf('in session ID %d', $sessionId) : 'without a session';
+ echo \sprintf(
"Reminder number %d sent to user ID %d for the course %s (LP ID: %d) %s.\n",
$nbRemind,
$userId,
@@ -244,11 +248,10 @@ class LpProgressReminderCommand extends Command
$interval = $reminderStartDate->diff($currentDate);
$diffDays = (int) $interval->format('%a');
- return ($diffDays >= self::NUMBER_OF_DAYS_TO_RESEND_NOTIFICATION &&
- $diffDays % self::NUMBER_OF_DAYS_TO_RESEND_NOTIFICATION === 0) || $diffDays === 0;
+ return ($diffDays >= self::NUMBER_OF_DAYS_TO_RESEND_NOTIFICATION
+ && 0 === $diffDays % self::NUMBER_OF_DAYS_TO_RESEND_NOTIFICATION) || 0 === $diffDays;
}
-
/**
* Sends a reminder email to the user regarding their LP progress.
*/
@@ -256,7 +259,7 @@ class LpProgressReminderCommand extends Command
{
$user = $this->userRepository->find($toUserId);
if (!$user) {
- throw new \Exception("User not found");
+ throw new Exception('User not found');
}
$platformUrl = $this->urlGenerator->generate('index', [], UrlGeneratorInterface::ABSOLUTE_URL);
@@ -265,17 +268,17 @@ class LpProgressReminderCommand extends Command
$trainingCenterName = 'Your Training Center';
$trainers = 'Trainer Name';
- $hello = $this->translator->trans("Hello %s");
- $youAreRegCourse = $this->translator->trans("You are registered in the training %s since the %s");
- $thisMessageIsAbout = $this->translator->trans("You are receiving this message because you have completed a learning path with a %s progress of your training.
Your progress must be 100 to consider that your training was carried out.
If you have the slightest problem, you should contact with your trainer.");
+ $hello = $this->translator->trans('Hello %s');
+ $youAreRegCourse = $this->translator->trans('You are registered in the training %s since the %s');
+ $thisMessageIsAbout = $this->translator->trans('You are receiving this message because you have completed a learning path with a %s progress of your training.
Your progress must be 100 to consider that your training was carried out.
If you have the slightest problem, you should contact with your trainer.');
$stepsToRemind = $this->translator->trans("As a reminder, to access the training platform:
1. Connect to the platform at the address: %s
2. Then enter:
Your username: %s
Your password: This was emailed to you.
if you forgot it and can't find it, you can retrieve it by going to %s
Thank you for doing what is necessary.");
- $lpRemindFooter = $this->translator->trans("The training center
%s
Trainers:
%s");
+ $lpRemindFooter = $this->translator->trans('The training center%s
Trainers:
%s');
- $hello = sprintf($hello, $user->getFullName());
- $youAreRegCourse = sprintf($youAreRegCourse, $courseName, $registrationDate->format('Y-m-d'));
- $thisMessageIsAbout = sprintf($thisMessageIsAbout, $lpProgress);
- $stepsToRemind = sprintf($stepsToRemind, $platformUrl, $user->getUsername(), $recoverPasswordUrl);
- $lpRemindFooter = sprintf($lpRemindFooter, $trainingCenterName, $trainers);
+ $hello = \sprintf($hello, $user->getFullName());
+ $youAreRegCourse = \sprintf($youAreRegCourse, $courseName, $registrationDate->format('Y-m-d'));
+ $thisMessageIsAbout = \sprintf($thisMessageIsAbout, $lpProgress);
+ $stepsToRemind = \sprintf($stepsToRemind, $platformUrl, $user->getUsername(), $recoverPasswordUrl);
+ $lpRemindFooter = \sprintf($lpRemindFooter, $trainingCenterName, $trainers);
$messageContent = $this->twig->render('@ChamiloCore/Mailer/Legacy/lp_progress_reminder_body.html.twig', [
'HelloX' => $hello,
@@ -288,13 +291,13 @@ class LpProgressReminderCommand extends Command
try {
$this->messageHelper->sendMessageSimple(
$toUserId,
- sprintf("Reminder number %d for the course %s", $nbRemind, $courseName),
+ \sprintf('Reminder number %d for the course %s', $nbRemind, $courseName),
$messageContent
);
return true;
- } catch (\Exception $e) {
- throw new \Exception('Error sending reminder: ' . $e->getMessage());
+ } catch (Exception $e) {
+ throw new Exception('Error sending reminder: '.$e->getMessage());
}
}
}
diff --git a/src/CoreBundle/Command/SendEventRemindersCommand.php b/src/CoreBundle/Command/SendEventRemindersCommand.php
index bfdf3e241e..639ebbbd9c 100644
--- a/src/CoreBundle/Command/SendEventRemindersCommand.php
+++ b/src/CoreBundle/Command/SendEventRemindersCommand.php
@@ -47,7 +47,8 @@ class SendEventRemindersCommand extends Command
$this
->setDescription('Send notification messages to users that have reminders from events in their agenda.')
->addOption('debug', null, InputOption::VALUE_NONE, 'Enable debug mode')
- ->setHelp('This command sends notifications to users who have pending reminders for calendar events.');
+ ->setHelp('This command sends notifications to users who have pending reminders for calendar events.')
+ ;
}
protected function execute(InputInterface $input, OutputInterface $output): int
@@ -127,6 +128,7 @@ class SendEventRemindersCommand extends Command
$this->sendReminderMessage($user, $event, $senderId, $debug, $io, $sentRemindersCount);
}
}
+
break;
case 'course':
@@ -146,6 +148,7 @@ class SendEventRemindersCommand extends Command
if ($debug) {
error_log("No course found for resource link in session ID: {$session->getId()}");
}
+
break;
}
diff --git a/src/CoreBundle/Controller/CourseController.php b/src/CoreBundle/Controller/CourseController.php
index 65d764f61c..6d034b1e19 100644
--- a/src/CoreBundle/Controller/CourseController.php
+++ b/src/CoreBundle/Controller/CourseController.php
@@ -784,7 +784,7 @@ class CourseController extends ToolBaseController
public function getAutoLaunchLPId(
Request $request,
Course $course,
- CLPRepository $lpRepository,
+ CLpRepository $lpRepository,
EntityManagerInterface $em
): JsonResponse {
$data = $request->getContent();
diff --git a/src/CoreBundle/Entity/ExtraField.php b/src/CoreBundle/Entity/ExtraField.php
index 7d06c1cdc5..97a8f8a610 100644
--- a/src/CoreBundle/Entity/ExtraField.php
+++ b/src/CoreBundle/Entity/ExtraField.php
@@ -34,7 +34,8 @@ use Symfony\Component\Validator\Constraints as Assert;
denormalizationContext: [
'groups' => ['extra_field:write'],
],
- security: "is_granted('ROLE_ADMIN')"),
+ security: "is_granted('ROLE_ADMIN')"
+),
]
#[ORM\Table(name: 'extra_field')]
#[ORM\Entity]
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20230913162700.php b/src/CoreBundle/Migrations/Schema/V200/Version20230913162700.php
index e29735be5f..064cb2dae2 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20230913162700.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20230913162700.php
@@ -210,6 +210,7 @@ final class Version20230913162700 extends AbstractMigrationChamilo
$existingDocument = $documentRepo->findResourceByTitleInCourse($title, $course);
if ($existingDocument) {
error_log("Document '$title' already exists for course {$course->getId()}. Skipping creation.");
+
return $existingDocument;
}
@@ -230,6 +231,7 @@ final class Version20230913162700 extends AbstractMigrationChamilo
$documentRepo->addFileFromPath($document, $title, $appCourseOldPath);
error_log("Document '$title' successfully created for course $courseId.");
+
return $document;
}
$generalCoursesPath = $this->getUpdateRootPath().'/app/courses/';
@@ -255,9 +257,10 @@ final class Version20230913162700 extends AbstractMigrationChamilo
}
error_log("File '$title' not found for course $courseId. Skipping.");
+
return null;
} catch (Exception $e) {
- error_log('Error in createNewDocument: ' . $e->getMessage());
+ error_log('Error in createNewDocument: '.$e->getMessage());
return null;
}
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20231022124700.php b/src/CoreBundle/Migrations/Schema/V200/Version20231022124700.php
index 048a6f05a0..e8e549003c 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20231022124700.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20231022124700.php
@@ -12,8 +12,6 @@ use Chamilo\CourseBundle\Repository\CDocumentRepository;
use Doctrine\DBAL\Schema\Schema;
use Exception;
-use const PREG_NO_ERROR;
-
final class Version20231022124700 extends AbstractMigrationChamilo
{
public function getDescription(): string
@@ -123,7 +121,8 @@ final class Version20231022124700 extends AbstractMigrationChamilo
$code = $matches[5] ?? null;
if (!$code) {
- error_log('Missing cidReq in URL: ' . $matches[0]);
+ error_log('Missing cidReq in URL: '.$matches[0]);
+
return $matches[0];
}
@@ -137,7 +136,8 @@ final class Version20231022124700 extends AbstractMigrationChamilo
}
if (null === $courseId) {
- error_log('Course ID not found for cidReq: ' . $code);
+ error_log('Course ID not found for cidReq: '.$code);
+
return $matches[0];
}
@@ -152,7 +152,7 @@ final class Version20231022124700 extends AbstractMigrationChamilo
// Ensure other parameters are maintained
if (!empty($remainingParams)) {
- $newParams .= '&' . ltrim($remainingParams, '&');
+ $newParams .= '&'.ltrim($remainingParams, '&');
}
$finalUrl = $matches[1].'?'.$beforeCidReqParams.$newParams;
@@ -163,11 +163,13 @@ final class Version20231022124700 extends AbstractMigrationChamilo
);
if (false === $newContent || null === $newContent) {
- error_log('preg_replace_callback failed for content: ' . substr($content, 0, 500));
+ error_log('preg_replace_callback failed for content: '.substr($content, 0, 500));
+
return $content;
}
} catch (Exception $e) {
- error_log('Exception in replaceURLParametersInContent: ' . $e->getMessage());
+ error_log('Exception in replaceURLParametersInContent: '.$e->getMessage());
+
return $content;
}
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20241209103000.php b/src/CoreBundle/Migrations/Schema/V200/Version20241209103000.php
index 3290d98224..5c2633b7db 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20241209103000.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20241209103000.php
@@ -11,22 +11,18 @@ use Doctrine\DBAL\Schema\Schema;
class Version20241209103000 extends AbstractMigrationChamilo
{
-
public function getDescription(): string
{
- return "Change extra field boolean columns (visible_to_self, visible_to_others, changeable, filter) to not accept null values.";
+ return 'Change extra field boolean columns (visible_to_self, visible_to_others, changeable, filter) to not accept null values.';
}
- /**
- * @inheritDoc
- */
public function up(Schema $schema): void
{
- $this->addSql("UPDATE extra_field SET visible_to_self = 0 WHERE visible_to_self IS NULL");
- $this->addSql("UPDATE extra_field SET visible_to_others = 0 WHERE visible_to_others IS NULL");
- $this->addSql("UPDATE extra_field SET changeable = 0 WHERE changeable IS NULL");
- $this->addSql("UPDATE extra_field SET filter = 0 WHERE filter IS NULL");
+ $this->addSql('UPDATE extra_field SET visible_to_self = 0 WHERE visible_to_self IS NULL');
+ $this->addSql('UPDATE extra_field SET visible_to_others = 0 WHERE visible_to_others IS NULL');
+ $this->addSql('UPDATE extra_field SET changeable = 0 WHERE changeable IS NULL');
+ $this->addSql('UPDATE extra_field SET filter = 0 WHERE filter IS NULL');
- $this->addSql("ALTER TABLE extra_field CHANGE visible_to_self visible_to_self TINYINT(1) DEFAULT 0 NOT NULL, CHANGE visible_to_others visible_to_others TINYINT(1) DEFAULT 0 NOT NULL, CHANGE changeable changeable TINYINT(1) DEFAULT 0 NOT NULL, CHANGE filter filter TINYINT(1) DEFAULT 0 NOT NULL");
+ $this->addSql('ALTER TABLE extra_field CHANGE visible_to_self visible_to_self TINYINT(1) DEFAULT 0 NOT NULL, CHANGE visible_to_others visible_to_others TINYINT(1) DEFAULT 0 NOT NULL, CHANGE changeable changeable TINYINT(1) DEFAULT 0 NOT NULL, CHANGE filter filter TINYINT(1) DEFAULT 0 NOT NULL');
}
-}
\ No newline at end of file
+}
diff --git a/src/CoreBundle/Repository/CourseRelUserRepository.php b/src/CoreBundle/Repository/CourseRelUserRepository.php
index f35e35080e..dc77f68f48 100644
--- a/src/CoreBundle/Repository/CourseRelUserRepository.php
+++ b/src/CoreBundle/Repository/CourseRelUserRepository.php
@@ -35,7 +35,8 @@ class CourseRelUserRepository extends ServiceEntityRepository
->andWhere('rn.parent = c.resourceNode')
->andWhere('(lpv.progress < 100 OR lpv.progress IS NULL)')
->setParameter('courseId', $courseId)
- ->setParameter('lpIds', $lpIds);
+ ->setParameter('lpIds', $lpIds)
+ ;
return $qb->getQuery()->getResult();
}
diff --git a/src/CoreBundle/Repository/ExtraFieldValuesRepository.php b/src/CoreBundle/Repository/ExtraFieldValuesRepository.php
index e2a7f2742d..282ec603d8 100644
--- a/src/CoreBundle/Repository/ExtraFieldValuesRepository.php
+++ b/src/CoreBundle/Repository/ExtraFieldValuesRepository.php
@@ -193,7 +193,8 @@ class ExtraFieldValuesRepository extends ServiceEntityRepository
->innerJoin(CLp::class, 'lp', 'WITH', 'lp.iid = efv.itemId')
->where('ef.variable = :variable')
->andWhere('efv.fieldValue > 0')
- ->setParameter('variable', 'number_of_days_for_completion');
+ ->setParameter('variable', 'number_of_days_for_completion')
+ ;
return $qb->getQuery()->getResult();
}
diff --git a/src/CoreBundle/Repository/SessionRelCourseRelUserRepository.php b/src/CoreBundle/Repository/SessionRelCourseRelUserRepository.php
index d786a698ab..4c018dbd21 100644
--- a/src/CoreBundle/Repository/SessionRelCourseRelUserRepository.php
+++ b/src/CoreBundle/Repository/SessionRelCourseRelUserRepository.php
@@ -35,7 +35,8 @@ class SessionRelCourseRelUserRepository extends ServiceEntityRepository
->andWhere('rn.parent = c.resourceNode')
->andWhere('(lpv.progress < 100 OR lpv.progress IS NULL)')
->setParameter('courseId', $courseId)
- ->setParameter('lpIds', $lpIds);
+ ->setParameter('lpIds', $lpIds)
+ ;
return $qb->getQuery()->getResult();
}
diff --git a/src/CoreBundle/Repository/TrackEDefaultRepository.php b/src/CoreBundle/Repository/TrackEDefaultRepository.php
index 03c70afd8f..0a10a41bbe 100644
--- a/src/CoreBundle/Repository/TrackEDefaultRepository.php
+++ b/src/CoreBundle/Repository/TrackEDefaultRepository.php
@@ -10,6 +10,8 @@ use Chamilo\CoreBundle\Entity\TrackEDefault;
use DateTime;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
+use Exception;
+use RuntimeException;
class TrackEDefaultRepository extends ServiceEntityRepository
{
@@ -21,9 +23,9 @@ class TrackEDefaultRepository extends ServiceEntityRepository
/**
* Retrieves the registration date of a user in a specific course or session.
*/
- public function getUserCourseRegistrationAt(int $courseId, int $userId, ?int $sessionId = 0): ?\DateTime
+ public function getUserCourseRegistrationAt(int $courseId, int $userId, ?int $sessionId = 0): ?DateTime
{
- $serializedPattern = sprintf('s:2:"id";i:%d;', $userId);
+ $serializedPattern = \sprintf('s:2:"id";i:%d;', $userId);
$qb = $this->createQueryBuilder('te')
->select('te.defaultDate')
@@ -34,12 +36,14 @@ class TrackEDefaultRepository extends ServiceEntityRepository
->setParameter('courseId', $courseId)
->setParameter('valueType', 'user_object')
->setParameter('eventType', 'user_subscribed')
- ->setParameter('serializedPattern', '%' . $serializedPattern . '%');
+ ->setParameter('serializedPattern', '%'.$serializedPattern.'%')
+ ;
if ($sessionId > 0) {
$qb->andWhere('te.sessionId = :sessionId')
- ->setParameter('sessionId', $sessionId);
- } elseif ($sessionId === 0) {
+ ->setParameter('sessionId', $sessionId)
+ ;
+ } elseif (0 === $sessionId) {
$qb->andWhere('te.sessionId = 0');
} else {
$qb->andWhere('te.sessionId IS NULL');
@@ -51,12 +55,12 @@ class TrackEDefaultRepository extends ServiceEntityRepository
try {
$result = $query->getOneOrNullResult();
if ($result && isset($result['defaultDate'])) {
- return $result['defaultDate'] instanceof \DateTime
+ return $result['defaultDate'] instanceof DateTime
? $result['defaultDate']
- : new \DateTime($result['defaultDate']);
+ : new DateTime($result['defaultDate']);
}
- } catch (\Exception $e) {
- throw new \RuntimeException('Error fetching registration date: ' . $e->getMessage());
+ } catch (Exception $e) {
+ throw new RuntimeException('Error fetching registration date: '.$e->getMessage());
}
return null;
diff --git a/src/CourseBundle/Repository/CLpRepository.php b/src/CourseBundle/Repository/CLpRepository.php
index c11c919bd4..affb60f566 100644
--- a/src/CourseBundle/Repository/CLpRepository.php
+++ b/src/CourseBundle/Repository/CLpRepository.php
@@ -99,7 +99,8 @@ final class CLpRepository extends ResourceRepository implements ResourceWithLink
{
$qb = $this->getResourcesByCourse($course, $session)
->select('resource.iid')
- ->andWhere('resource.autolaunch = 1');
+ ->andWhere('resource.autolaunch = 1')
+ ;
$qb->setMaxResults(1);
diff --git a/src/CourseBundle/Repository/CQuizRepository.php b/src/CourseBundle/Repository/CQuizRepository.php
index 08f20b322d..2c870f3ed3 100644
--- a/src/CourseBundle/Repository/CQuizRepository.php
+++ b/src/CourseBundle/Repository/CQuizRepository.php
@@ -143,7 +143,8 @@ final class CQuizRepository extends ResourceRepository implements ResourceWithLi
{
$qb = $this->getResourcesByCourse($course, $session)
->select('resource.iid')
- ->andWhere('resource.autoLaunch = 1');
+ ->andWhere('resource.autoLaunch = 1')
+ ;
$qb->setMaxResults(1);