Skip to content

Commit 6469453

Browse files
authored
Merge pull request #4632 from crazyserver/MOBILE-3890
MOBILE-3890: Support course forced language in the app interface
2 parents 04c9177 + e2c0f1d commit 6469453

File tree

111 files changed

+1463
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1463
-89
lines changed

UPGRADE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ For more information about upgrading, read the official documentation: https://m
66
=====
77

88
- The core-files component now treats the `files` input array as immutable to simplify the change detection strategy and improve performance. To trigger an update, you must provide a new array reference (e.g. using `concat()` or the spread operator) rather than mutating the existing one with `push()` or `splice()`.
9+
- CoreCourses.getCoursesByField and CoreCourses.getCourseByField now accepts CoreSitesCommonWSOptions, direct usage of siteId has been deprecated.
910

1011
5.1.0
1112
=====

src/addons/badges/badges.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { CoreTagAreaDelegate } from '@features/tag/services/tag-area-delegate';
2828
import { AddonBadgesTagAreaHandler } from './services/handlers/tag-area';
2929
import { conditionalRoutes } from '@/app/app-routing.module';
3030
import { CoreScreen } from '@services/screen';
31+
import { CoreCourseForceLanguageSource } from '@features/course/constants';
3132

3233
/**
3334
* Get badges services.
@@ -47,11 +48,12 @@ const mobileRoutes: Routes = [
4748
path: '',
4849
pathMatch: 'full',
4950
loadComponent: () => import('./pages/user-badges/user-badges'),
51+
data: { checkForcedLanguage: CoreCourseForceLanguageSource.COURSE },
5052
},
5153
{
5254
path: ':badgeHash',
5355
loadComponent: () => import('./pages/issued-badge/issued-badge'),
54-
data: { usesSwipeNavigation: true },
56+
data: { usesSwipeNavigation: true, checkForcedLanguage: CoreCourseForceLanguageSource.COURSE },
5557
},
5658
];
5759

@@ -66,6 +68,7 @@ const tabletRoutes: Routes = [
6668
data: { usesSwipeNavigation: true },
6769
},
6870
],
71+
data: { checkForcedLanguage: CoreCourseForceLanguageSource.COURSE },
6972
},
7073
];
7174

src/addons/blog/blog.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ import { CORE_SITE_SCHEMAS } from '@services/sites';
3333
import { BLOG_OFFLINE_SITE_SCHEMA } from './services/database/blog';
3434
import { CoreCronDelegate } from '@services/cron';
3535
import { AddonBlogSyncCronHandler } from './services/handlers/sync-cron';
36+
import { CoreCourseForceLanguageSource } from '@features/course/constants';
3637

3738
const routes: Routes = [
3839
{
3940
path: ADDON_BLOG_MAINMENU_PAGE_NAME,
4041
loadChildren: () => import('@addons/blog/blog-lazy.module'),
42+
data: { checkForcedLanguage: CoreCourseForceLanguageSource.COURSE },
4143
},
4244
];
4345

src/addons/competency/competency.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { Routes } from '@angular/router';
2828
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
2929
import { CoreCourseIndexRoutingModule } from '@features/course/course-routing.module';
3030
import { PARTICIPANTS_PAGE_NAME } from '@features/user/constants';
31-
import { CORE_COURSE_PAGE_NAME } from '@features/course/constants';
31+
import { CORE_COURSE_PAGE_NAME, CoreCourseForceLanguageSource } from '@features/course/constants';
3232
import {
3333
ADDON_COMPETENCY_LEARNING_PLANS_PAGE,
3434
ADDON_COMPETENCY_COMPETENCIES_PAGE,
@@ -155,10 +155,12 @@ const mainMenuChildrenRoutes: Routes = [
155155
{
156156
path: `${CORE_COURSE_PAGE_NAME}/:courseId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`,
157157
loadChildren: () => getCompetencyCourseDetailsRoutes(),
158+
data: { checkForcedLanguage: CoreCourseForceLanguageSource.COURSE },
158159
},
159160
{
160161
path: `${CORE_COURSE_PAGE_NAME}/:courseId/${PARTICIPANTS_PAGE_NAME}/:userId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`,
161162
loadChildren: () => getCompetencyCourseDetailsRoutes(),
163+
data: { checkForcedLanguage: CoreCourseForceLanguageSource.COURSE },
162164
},
163165
];
164166

src/addons/coursecompletion/coursecompletion.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { CoreUserDelegate } from '@features/user/services/user-delegate';
2222
import { AddonCourseCompletionStatusLinkHandler } from './services/handlers/completionstatus-link';
2323
import { AddonCourseCompletionCourseOptionHandler } from './services/handlers/course-option';
2424
import { AddonCourseCompletionUserHandler } from './services/handlers/user';
25+
import { CoreCourseForceLanguageSource } from '@features/course/constants';
2526

2627
/**
2728
* Get course completion services.
@@ -40,6 +41,7 @@ const routes: Routes = [
4041
{
4142
path: 'coursecompletion',
4243
loadComponent: () => import('./pages/report/report'),
44+
data: { checkForcedLanguage: CoreCourseForceLanguageSource.COURSE },
4345
},
4446
];
4547

src/addons/filter/mathjaxloader/services/handlers/mathjaxloader.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan
6767

6868
await this.window.MathJax?.startup.promise;
6969

70-
// @todo: Once MathJax supports locale, set current language and listen for CoreEvents.LANGUAGE_CHANGED events.
70+
// @todo: Once MathJax supports locale, set current language and listen for Translate.onLangChange events.
7171
}
7272

7373
/**
@@ -164,6 +164,8 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan
164164

165165
/**
166166
* Called by the filter when an equation is found while rendering the content.
167+
*
168+
* @param container The container element.
167169
*/
168170
protected async typeset(container: HTMLElement): Promise<void> {
169171
const equations = Array.from(container.getElementsByClassName('filter_mathjaxloader_equation'));

src/addons/mod/assign/assign.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { ADDON_MOD_ASSIGN_COMPONENT_LEGACY, ADDON_MOD_ASSIGN_PAGE_NAME } from '.
3535
import { conditionalRoutes } from '@/app/app-routing.module';
3636
import { canLeaveGuard } from '@guards/can-leave';
3737
import { CoreScreen } from '@services/screen';
38+
import { CoreCourseForceLanguageSource } from '@features/course/constants';
3839

3940
/**
4041
* Get mod assign services.
@@ -121,6 +122,7 @@ const routes: Routes = [
121122
...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile),
122123
...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet),
123124
],
125+
data: { checkForcedLanguage: CoreCourseForceLanguageSource.MODULE },
124126
},
125127
];
126128

src/addons/mod/assign/services/assign.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646
AddonModAssignSubmissionStatusValues,
4747
} from '../constants';
4848
import { CoreTextFormat } from '@static/text';
49-
import { CoreCourseModuleHelper } from '@features/course/services/course-module-helper';
49+
import { CoreCourseModuleHelper, CoreCourseModuleStandardElements } from '@features/course/services/course-module-helper';
5050
import { CoreUserDescriptionExporter } from '@features/user/services/user';
5151

5252
declare module '@static/events' {
@@ -1460,12 +1460,12 @@ export type AddonModAssignSubmissionStatusOptions = CoreCourseCommonModWSOptions
14601460

14611461
/**
14621462
* Assign data returned by mod_assign_get_assignments.
1463+
* We're using Omit to exclude properties because type is not consistent with the rest of the WS but
1464+
* it should be.
14631465
*/
1464-
export type AddonModAssignAssign = {
1465-
id: number; // Assignment id.
1466+
export type AddonModAssignAssign =
1467+
Omit<CoreCourseModuleStandardElements, 'coursemodule'|'section'|'visible'|'groupmode'|'groupingid'|'lang'> & {
14661468
cmid: number; // Course module id.
1467-
course: number; // Course id.
1468-
name: string; // Assignment name.
14691469
nosubmissions: number; // No submissions.
14701470
submissiondrafts: number; // Submissions drafts.
14711471
sendnotifications: number; // Send notifications.
@@ -1493,9 +1493,6 @@ export type AddonModAssignAssign = {
14931493
submissionstatement?: string; // Submission statement formatted.
14941494
submissionstatementformat?: CoreTextFormat; // Submissionstatement format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN).
14951495
configs: AddonModAssignConfig[]; // Configuration settings.
1496-
intro?: string; // Assignment intro, not allways returned because it deppends on the activity configuration.
1497-
introformat?: CoreTextFormat; // Intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN).
1498-
introfiles?: CoreWSExternalFile[];
14991496
introattachments?: CoreWSExternalFile[];
15001497
activity?: string; // @since 4.0. Description of activity.
15011498
activityformat?: CoreTextFormat; // @since 4.0. Format of activity.

src/addons/mod/assign/services/handlers/prefetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
256256

257257
promises.push(CoreCourse.getModuleBasicInfoByInstance(assign.id, ADDON_MOD_ASSIGN_MODNAME, { siteId }));
258258
// Get course data, needed to determine upload max size if it's configured to be course limit.
259-
promises.push(CorePromiseUtils.ignoreErrors(CoreCourses.getCourseByField('id', courseId, siteId)));
259+
promises.push(CorePromiseUtils.ignoreErrors(CoreCourses.getCourseByField('id', courseId, { siteId })));
260260

261261
// Download intro files and attachments. Do not call getFiles because it'd call some WS twice.
262262
let files: CoreWSFile[] = assign.introattachments || [];
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@app_parallel_run_assign @addon_mod_assign @app @mod @mod_assign @javascript @forced_language
2+
3+
Feature: Forced activity language is applied in the app
4+
In order to ensure users see the activity in the correct language
5+
As a user
6+
I want the app to apply the forced activity language when set
7+
8+
Background:
9+
Given the following "courses" exist:
10+
| fullname | shortname | lang |
11+
| Course 1 | C1 | es |
12+
And the following "activities" exist:
13+
| activity | name | intro | course | lang |
14+
| assign | Test assignment name | - | C1 | ca |
15+
And the following "users" exist:
16+
| username | firstname | lastname |
17+
| student | Student | 1 |
18+
And the following "course enrolments" exist:
19+
| user | course | role |
20+
| student | C1 | student |
21+
And the following "language pack" exists:
22+
| language | es | ca |
23+
24+
Scenario: Forced course and module language is applied when entering a course or activity
25+
Given I entered the course "Course 1" as "student" in the app
26+
Then I should find "Curso" in the app
27+
28+
# Assignment does not have any force language support in the app.
29+
# Until MDL-87241 is solved, the fallback will be the course language.
30+
When I press "Test assignment name" in the app
31+
Then I should find "Estado de la entrega" in the app

0 commit comments

Comments
 (0)