Skip to content

Commit

Permalink
Internal: Admin: Fix languages for courses created with data filler
Browse files Browse the repository at this point in the history
AngelFQC committed Jan 30, 2025
1 parent 6165dea commit b3c191e
Showing 2 changed files with 17 additions and 14 deletions.
22 changes: 11 additions & 11 deletions tests/datafiller/data_courses.php
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
'title' => 'English for beginners',
'description' => 'English course',
'category_code' => 'LANG',
'course_language' => 'english',
'course_language' => 'en_US',
'user_id' => 1,
'expiration_date' => '2020-09-01 00:00:00',
'exemplary_content' => true,
@@ -28,7 +28,7 @@
'title' => 'Español para iniciantes',
'description' => 'Curso de español',
'category_code' => 'LANG',
'course_language' => 'spanish',
'course_language' => 'es',
'user_id' => 1,
'expiration_date' => '2020-09-01 00:00:00',
'exemplary_content' => true,
@@ -39,7 +39,7 @@
'title' => 'Français pour débutants',
'description' => 'Cours de français',
'category_code' => 'LANG',
'course_language' => 'french',
'course_language' => 'fr_FR',
'user_id' => 1,
'expiration_date' => '2020-09-01 00:00:00',
'exemplary_content' => true,
@@ -50,7 +50,7 @@
'title' => 'History of litterature',
'description' => 'History of English litterature from the Middle Ages to our times',
'category_code' => 'PROJ',
'course_language' => 'english',
'course_language' => 'en_US',
'user_id' => 1,
'expiration_date' => '2020-09-01 00:00:00',
'exemplary_content' => true,
@@ -61,7 +61,7 @@
'title' => 'Our solar system',
'description' => 'Introduction to our solar system and the interactions between planets',
'category_code' => 'PROJ',
'course_language' => 'english',
'course_language' => 'en_US',
'user_id' => 1,
'expiration_date' => '2020-09-01 00:00:00',
'exemplary_content' => true,
@@ -72,7 +72,7 @@
'title' => 'Maritime Navigation',
'description' => 'Preparation course for the International Maritime Navigation exam',
'category_code' => 'PROJ',
'course_language' => 'english',
'course_language' => 'en_US',
'user_id' => 1,
'expiration_date' => '2020-09-01 00:00:00',
'exemplary_content' => true,
@@ -83,7 +83,7 @@
'title' => 'National Geography',
'description' => 'Introduction to geography at a national level',
'category_code' => 'PROJ',
'course_language' => 'english',
'course_language' => 'en_US',
'user_id' => 1,
'expiration_date' => '2020-09-01 00:00:00',
'exemplary_content' => true,
@@ -94,7 +94,7 @@
'title' => '日本語',
'description' => 'Japanese course for beginners',
'category_code' => 'LANG',
'course_language' => 'japanese',
'course_language' => 'ja',
'user_id' => 1,
'expiration_date' => '2020-09-01 00:00:00',
'exemplary_content' => true,
@@ -105,7 +105,7 @@
'title' => 'Time management',
'description' => 'Learn to manage your time efficiently',
'category_code' => 'PROJ',
'course_language' => 'english',
'course_language' => 'en_US',
'user_id' => 1,
'expiration_date' => '2020-09-01 00:00:00',
'exemplary_content' => true,
@@ -116,7 +116,7 @@
'title' => 'SCRUM project management basics',
'description' => 'Introduction to SCRUM project management for busy people',
'category_code' => 'PROJ',
'course_language' => 'english',
'course_language' => 'en_US',
'user_id' => 1,
'expiration_date' => '2020-09-01 00:00:00',
'exemplary_content' => true,
@@ -127,7 +127,7 @@
'title' => 'Day to day mathematics',
'description' => 'Mathematics for busy people',
'category_code' => 'PROJ',
'course_language' => 'english',
'course_language' => 'en_US',
'user_id' => 1,
'expiration_date' => '2020-09-01 00:00:00',
'exemplary_content' => true,
9 changes: 6 additions & 3 deletions tests/datafiller/fill_courses.php
Original file line number Diff line number Diff line change
@@ -19,16 +19,19 @@ function fill_courses()
require_once 'data_courses.php'; // fill the $courses array
$output = array();
$output[] = array('title'=>'Courses Filling Report: ');
$languages = SubLanguageManager::getAllLanguages(true);
$languages = array_column(
SubLanguageManager::getAllLanguages(true),
'isocode'
);
$i = 1;
foreach ($courses as $i => $course) {
// First check that the first item doesn't exist already
$output[$i]['line-init'] = $course['title'];
// The wanted code is necessary to avoid interpretation
$course['wanted_code'] = $course['code'];
// Make sure the language defaults to English if others are disabled
if (!isset($languages[$course['course_language']])) {
$course['course_language'] = 'english';
if (!in_array($course['course_language'], $languages)) {
$course['course_language'] = 'en_US';
}
// Effectively create the course
$res = CourseManager::create_course($course);

0 comments on commit b3c191e

Please sign in to comment.