Skip to content

Commit b3c191e

Browse files
committed
Internal: Admin: Fix languages for courses created with data filler
1 parent 6165dea commit b3c191e

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

tests/datafiller/data_courses.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
'title' => 'English for beginners',
1818
'description' => 'English course',
1919
'category_code' => 'LANG',
20-
'course_language' => 'english',
20+
'course_language' => 'en_US',
2121
'user_id' => 1,
2222
'expiration_date' => '2020-09-01 00:00:00',
2323
'exemplary_content' => true,
@@ -28,7 +28,7 @@
2828
'title' => 'Español para iniciantes',
2929
'description' => 'Curso de español',
3030
'category_code' => 'LANG',
31-
'course_language' => 'spanish',
31+
'course_language' => 'es',
3232
'user_id' => 1,
3333
'expiration_date' => '2020-09-01 00:00:00',
3434
'exemplary_content' => true,
@@ -39,7 +39,7 @@
3939
'title' => 'Français pour débutants',
4040
'description' => 'Cours de français',
4141
'category_code' => 'LANG',
42-
'course_language' => 'french',
42+
'course_language' => 'fr_FR',
4343
'user_id' => 1,
4444
'expiration_date' => '2020-09-01 00:00:00',
4545
'exemplary_content' => true,
@@ -50,7 +50,7 @@
5050
'title' => 'History of litterature',
5151
'description' => 'History of English litterature from the Middle Ages to our times',
5252
'category_code' => 'PROJ',
53-
'course_language' => 'english',
53+
'course_language' => 'en_US',
5454
'user_id' => 1,
5555
'expiration_date' => '2020-09-01 00:00:00',
5656
'exemplary_content' => true,
@@ -61,7 +61,7 @@
6161
'title' => 'Our solar system',
6262
'description' => 'Introduction to our solar system and the interactions between planets',
6363
'category_code' => 'PROJ',
64-
'course_language' => 'english',
64+
'course_language' => 'en_US',
6565
'user_id' => 1,
6666
'expiration_date' => '2020-09-01 00:00:00',
6767
'exemplary_content' => true,
@@ -72,7 +72,7 @@
7272
'title' => 'Maritime Navigation',
7373
'description' => 'Preparation course for the International Maritime Navigation exam',
7474
'category_code' => 'PROJ',
75-
'course_language' => 'english',
75+
'course_language' => 'en_US',
7676
'user_id' => 1,
7777
'expiration_date' => '2020-09-01 00:00:00',
7878
'exemplary_content' => true,
@@ -83,7 +83,7 @@
8383
'title' => 'National Geography',
8484
'description' => 'Introduction to geography at a national level',
8585
'category_code' => 'PROJ',
86-
'course_language' => 'english',
86+
'course_language' => 'en_US',
8787
'user_id' => 1,
8888
'expiration_date' => '2020-09-01 00:00:00',
8989
'exemplary_content' => true,
@@ -94,7 +94,7 @@
9494
'title' => '日本語',
9595
'description' => 'Japanese course for beginners',
9696
'category_code' => 'LANG',
97-
'course_language' => 'japanese',
97+
'course_language' => 'ja',
9898
'user_id' => 1,
9999
'expiration_date' => '2020-09-01 00:00:00',
100100
'exemplary_content' => true,
@@ -105,7 +105,7 @@
105105
'title' => 'Time management',
106106
'description' => 'Learn to manage your time efficiently',
107107
'category_code' => 'PROJ',
108-
'course_language' => 'english',
108+
'course_language' => 'en_US',
109109
'user_id' => 1,
110110
'expiration_date' => '2020-09-01 00:00:00',
111111
'exemplary_content' => true,
@@ -116,7 +116,7 @@
116116
'title' => 'SCRUM project management basics',
117117
'description' => 'Introduction to SCRUM project management for busy people',
118118
'category_code' => 'PROJ',
119-
'course_language' => 'english',
119+
'course_language' => 'en_US',
120120
'user_id' => 1,
121121
'expiration_date' => '2020-09-01 00:00:00',
122122
'exemplary_content' => true,
@@ -127,7 +127,7 @@
127127
'title' => 'Day to day mathematics',
128128
'description' => 'Mathematics for busy people',
129129
'category_code' => 'PROJ',
130-
'course_language' => 'english',
130+
'course_language' => 'en_US',
131131
'user_id' => 1,
132132
'expiration_date' => '2020-09-01 00:00:00',
133133
'exemplary_content' => true,

tests/datafiller/fill_courses.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ function fill_courses()
1919
require_once 'data_courses.php'; // fill the $courses array
2020
$output = array();
2121
$output[] = array('title'=>'Courses Filling Report: ');
22-
$languages = SubLanguageManager::getAllLanguages(true);
22+
$languages = array_column(
23+
SubLanguageManager::getAllLanguages(true),
24+
'isocode'
25+
);
2326
$i = 1;
2427
foreach ($courses as $i => $course) {
2528
// First check that the first item doesn't exist already
2629
$output[$i]['line-init'] = $course['title'];
2730
// The wanted code is necessary to avoid interpretation
2831
$course['wanted_code'] = $course['code'];
2932
// Make sure the language defaults to English if others are disabled
30-
if (!isset($languages[$course['course_language']])) {
31-
$course['course_language'] = 'english';
33+
if (!in_array($course['course_language'], $languages)) {
34+
$course['course_language'] = 'en_US';
3235
}
3336
// Effectively create the course
3437
$res = CourseManager::create_course($course);

0 commit comments

Comments
 (0)