Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/CoreBundle/Helpers/CourseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Repository\CourseCategoryRepository;
use Chamilo\CoreBundle\Repository\Node\CourseRepository;
use Chamilo\CoreBundle\Repository\Node\IllustrationRepository;
use Chamilo\CoreBundle\Repository\Node\UserRepository;
use Chamilo\CoreBundle\Settings\SettingsManager;
use Chamilo\CourseBundle\Component\CourseCopy\CourseBuilder;
Expand All @@ -39,6 +40,7 @@
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
Expand All @@ -65,7 +67,8 @@ public function __construct(
private readonly EventLoggerHelper $eventLoggerHelper,
private readonly ParameterBagInterface $parameterBag,
private readonly RequestStack $requestStack,
private readonly AccessUrlHelper $accessUrlHelper
private readonly AccessUrlHelper $accessUrlHelper,
private readonly IllustrationRepository $illustrationRepository
) {}

public function createCourse(array $params): ?Course
Expand Down Expand Up @@ -196,6 +199,26 @@ public function registerCourse(array $rawParams): ?Course
$this->courseRepository->create($course);
$this->debugLog('registerCourse:persisted', ['courseId' => $course->getId()]);

if (!empty($rawParams['illustration_path'])) {
if (file_exists($rawParams['illustration_path'])) {
$mimeType = mime_content_type($rawParams['illustration_path']);
$uploadedFile = new UploadedFile(
$rawParams['illustration_path'],
basename($rawParams['illustration_path']),
$mimeType,
null,
true // test mode to allow local files
);

$this->illustrationRepository->addIllustration(
$course,
$currentUser,
$uploadedFile
);
$this->debugLog('registerCourse:illustrationAdded', ['path' => $rawParams['illustration_path']]);
}
}

if (!empty($rawParams['exemplary_content'])) {
$this->debugLog('registerCourse:willFillCourse', [
'request_demo' => true,
Expand Down
12 changes: 12 additions & 0 deletions tests/datafiller/data_courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'user_id' => 1,
'expiration_date' => '2030-09-01 00:00:00',
'exemplary_content' => false,
'illustration_path' => __DIR__.'/images/english101s.png',
];
// 2
$courses[] = [
Expand All @@ -32,6 +33,7 @@
'user_id' => 1,
'expiration_date' => '2030-09-01 00:00:00',
'exemplary_content' => false,
'illustration_path' => __DIR__.'/images/spanish101s.png',
];
// 3
$courses[] = [
Expand All @@ -43,6 +45,7 @@
'user_id' => 1,
'expiration_date' => '2030-09-01 00:00:00',
'exemplary_content' => false,
'illustration_path' => __DIR__.'/images/french101s.png',
];
// 4
$courses[] = [
Expand All @@ -54,6 +57,7 @@
'user_id' => 1,
'expiration_date' => '2030-09-01 00:00:00',
'exemplary_content' => false,
'illustration_path' => __DIR__.'/images/arabic101s.png',
];
// 5
$courses[] = [
Expand All @@ -65,6 +69,7 @@
'user_id' => 1,
'expiration_date' => '2030-09-01 00:00:00',
'exemplary_content' => false,
'illustration_path' => __DIR__.'/images/solarsystems.png',
];
// 6
$courses[] = [
Expand All @@ -76,6 +81,7 @@
'user_id' => 1,
'expiration_date' => '2030-09-01 00:00:00',
'exemplary_content' => false,
'illustration_path' => __DIR__.'/images/marnavigations.png',
];
// 7
$courses[] = [
Expand All @@ -87,6 +93,7 @@
'user_id' => 1,
'expiration_date' => '2030-09-01 00:00:00',
'exemplary_content' => false,
'illustration_path' => __DIR__.'/images/natgeos.png',
];
// 8
$courses[] = [
Expand All @@ -98,6 +105,7 @@
'user_id' => 1,
'expiration_date' => '2030-09-01 00:00:00',
'exemplary_content' => false,
'illustration_path' => __DIR__.'/images/japanese101s.png',
];
// 9
$courses[] = [
Expand All @@ -109,6 +117,7 @@
'user_id' => 1,
'expiration_date' => '2030-09-01 00:00:00',
'exemplary_content' => false,
'illustration_path' => __DIR__.'/images/timemgmts.png',
];
// 10
$courses[] = [
Expand All @@ -120,6 +129,7 @@
'user_id' => 1,
'expiration_date' => '2030-09-01 00:00:00',
'exemplary_content' => false,
'illustration_path' => __DIR__.'/images/hebrew101s.png',
];
// 11
$courses[] = [
Expand All @@ -131,6 +141,7 @@
'user_id' => 1,
'expiration_date' => '2030-09-01 00:00:00',
'exemplary_content' => false,
'illustration_path' => __DIR__.'/images/chinese101s.png',
];
// 12
$courses[] = [
Expand All @@ -142,4 +153,5 @@
'user_id' => 1,
'expiration_date' => '2030-09-01 00:00:00',
'exemplary_content' => false,
'illustration_path' => __DIR__.'/images/myanmar101s.png',
];
1 change: 1 addition & 0 deletions tests/datafiller/fill_courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function fill_courses(): array
'wanted_code' => $course['wanted_code'],
'course_language' => $course['course_language'],
'exemplary_content' => $course['exemplary_content'] ?? false,
'illustration_path' => $course['illustration_path'] ?? null,
]);

if ($created) {
Expand Down
6 changes: 6 additions & 0 deletions tests/datafiller/images/psyche/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The images in this folder are used to give a branded illustration to courses created automatically by the courses filler.
A larger version of these images was generated through midjourney.com.
Type of prompt used:
"dense psychedelic blue-and-gold line art, intricate obsessive detailing, illuminated manuscript meets mandala surrealism, deep cobalt base + radiant gold-orange accents, hyper-patterned, empty center --ar 16:9 --stylize 50"
Images are then resized to 366x188 and text is added in Arial Bold, size 18, pure white.
Image names are defined in ../data_courses.php under 'illustration_path', as the course code + 's' for 'small'.
Binary file added tests/datafiller/images/psyche/arabic101s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/datafiller/images/psyche/chinese101s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/datafiller/images/psyche/english101s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/datafiller/images/psyche/french101s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/datafiller/images/psyche/hebrew101s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/datafiller/images/psyche/japanese101s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/datafiller/images/psyche/marnavigations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/datafiller/images/psyche/myanmar101s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/datafiller/images/psyche/natgeos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/datafiller/images/psyche/solarsystems.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/datafiller/images/psyche/spanish101s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/datafiller/images/psyche/timemgmts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading