-
Notifications
You must be signed in to change notification settings - Fork 532
Course: Refactor course creation service #5302
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
Course: Refactor course creation service #5302
Conversation
| return $queryBuilder; | ||
| } | ||
|
|
||
| public function courseCodeExists(string $code): bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing function doc comment
| return (int) $qb->getSingleScalarResult() > 0; | ||
| } | ||
|
|
||
| public function findCourseAsArray($id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing function doc comment
|
Code Climate has analyzed commit 576b2a4 and detected 69 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mejor moverlo a src/CoreBundle/ServiceHelper/EventLoggerHelper
| public function addEvent( | ||
| string $eventType, | ||
| string $valueType, | ||
| $value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
El tipado podría ser mixed $value
| if (empty($params['title'])) { | ||
| throw new \InvalidArgumentException('The course title cannot be empty.'); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto está validado en la misma entidad como Assert\NotBlank
| } else { | ||
| console.error(tempResponse.message) | ||
| } | ||
| const response = await courseService.createCourse(formData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Este servicio que hace la llamada ajax a createCourse, tiene que ser a través de api-platform
| } | ||
| } catch (\Exception $e) { | ||
|
|
||
| return new JsonResponse([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aquí se debería lanzar una exception en lugar de devolver una respuesta con json
| } | ||
| } | ||
|
|
||
| public function sendEmailToAdmin(Course $course): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
El correo debería enviarse en un EventListener después de crear el curso
| $entityManager->flush(); | ||
| } | ||
|
|
||
| private function insertCourseSettings(Course $course): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
También debería hacerse en un entity o event listener
| return $gradebookCategory; | ||
| } | ||
|
|
||
| private function insertExampleContent(Course $course, GradebookCategory $gradebook): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Este método podría ser un servicio a parte, como el de CreateDefaultPages
| $this->createExampleGradebookContent($course, $gradebook, $exercise->id); | ||
| } | ||
|
|
||
| private function createExampleGradebookContent(Course $course, GradebookCategory $parentCategory, int $refId): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Este método podría ser un servicio a parte, como el de CreateDefaultPages
| #[Route('/create', name: 'chamilo_core_course_create')] | ||
| public function createCourse(Request $request, TranslatorInterface $translator): JsonResponse | ||
| { | ||
| public function createCourse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debería estar en un StateProcessor de ApiPlatform para tener un solo endpoint de creación de curso
No description provided.