Skip to content

Commit 217289b

Browse files
committed
MOBILE-3890 mod: Get module forced lang
1 parent 755eba6 commit 217289b

File tree

28 files changed

+433
-44
lines changed

28 files changed

+433
-44
lines changed

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 '@singletons/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 '@singletons/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/bigbluebuttonbn/services/handlers/module.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { makeSingleton } from '@singletons';
2121
import { AddonModBBB } from '../bigbluebuttonbn';
2222
import { ADDON_MOD_BBB_COMPONENT, ADDON_MOD_BBB_MODNAME, ADDON_MOD_BBB_PAGE_NAME } from '../../constants';
2323
import { ModFeature, ModPurpose } from '@addons/mod/constants';
24+
import { CoreSitesReadingStrategy } from '@services/sites';
2425

2526
/**
2627
* Handler to support Big Blue Button activities.
@@ -103,6 +104,19 @@ export class AddonModBBBModuleHandlerService extends CoreModuleHandlerBase imple
103104
return AddonModBBBIndexComponent;
104105
}
105106

107+
/**
108+
* @inheritdoc
109+
*/
110+
async getModuleForcedLang(module: CoreCourseModuleData): Promise<string | undefined> {
111+
const mod = await AddonModBBB.getBBB(
112+
module.course,
113+
module.id,
114+
{ readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
115+
);
116+
117+
return mod?.lang;
118+
}
119+
106120
}
107121

108122
export const AddonModBBBModuleHandler = makeSingleton(AddonModBBBModuleHandlerService);

src/addons/mod/book/services/handlers/module.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { makeSingleton } from '@singletons';
1919
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
2020
import { ADDON_MOD_BOOK_COMPONENT, ADDON_MOD_BOOK_MODNAME, ADDON_MOD_BOOK_PAGE_NAME } from '../../constants';
2121
import { ModFeature, ModArchetype, ModPurpose } from '@addons/mod/constants';
22+
import { CoreCourseModuleData } from '@features/course/services/course-helper';
23+
import { CoreSitesReadingStrategy } from '@services/sites';
2224

2325
/**
2426
* Handler to support book modules.
@@ -59,5 +61,18 @@ export class AddonModBookModuleHandlerService extends CoreModuleHandlerBase impl
5961
return AddonModBookIndexComponent;
6062
}
6163

64+
/**
65+
* @inheritdoc
66+
*/
67+
async getModuleForcedLang(module: CoreCourseModuleData): Promise<string | undefined> {
68+
const mod = await AddonModBook.getBook(
69+
module.course,
70+
module.id,
71+
{ readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
72+
);
73+
74+
return mod?.lang;
75+
}
76+
6277
}
6378
export const AddonModBookModuleHandler = makeSingleton(AddonModBookModuleHandlerService);

src/addons/mod/chat/services/handlers/module.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import { CoreCourseModuleHandler } from '@features/course/services/module-delega
1818
import { makeSingleton } from '@singletons';
1919
import { ADDON_MOD_CHAT_MODNAME, ADDON_MOD_CHAT_PAGE_NAME } from '../../constants';
2020
import { ModFeature, ModPurpose } from '@addons/mod/constants';
21+
import { AddonModChat } from '../chat';
22+
import { CoreCourseModuleData } from '@features/course/services/course-helper';
23+
import { CoreSitesReadingStrategy } from '@services/sites';
2124

2225
/**
2326
* Handler to support chat modules.
@@ -50,6 +53,19 @@ export class AddonModChatModuleHandlerService extends CoreModuleHandlerBase impl
5053
return AddonModChatIndexComponent;
5154
}
5255

56+
/**
57+
* @inheritdoc
58+
*/
59+
async getModuleForcedLang(module: CoreCourseModuleData): Promise<string | undefined> {
60+
const mod = await AddonModChat.getChat(
61+
module.course,
62+
module.id,
63+
{ readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
64+
);
65+
66+
return mod?.lang;
67+
}
68+
5369
}
5470

5571
export const AddonModChatModuleHandler = makeSingleton(AddonModChatModuleHandlerService);

src/addons/mod/choice/services/handlers/module.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import { CoreCourseModuleHandler } from '@features/course/services/module-delega
1818
import { makeSingleton } from '@singletons';
1919
import { ADDON_MOD_CHOICE_MODNAME, ADDON_MOD_CHOICE_PAGE_NAME } from '../../constants';
2020
import { ModFeature, ModPurpose } from '@addons/mod/constants';
21+
import { AddonModChoice } from '../choice';
22+
import { CoreCourseModuleData } from '@features/course/services/course-helper';
23+
import { CoreSitesReadingStrategy } from '@services/sites';
2124

2225
/**
2326
* Handler to support choice modules.
@@ -51,6 +54,19 @@ export class AddonModChoiceModuleHandlerService extends CoreModuleHandlerBase im
5154
return AddonModChoiceIndexComponent;
5255
}
5356

57+
/**
58+
* @inheritdoc
59+
*/
60+
async getModuleForcedLang(module: CoreCourseModuleData): Promise<string | undefined> {
61+
const mod = await AddonModChoice.getChoice(
62+
module.course,
63+
module.id,
64+
{ readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
65+
);
66+
67+
return mod?.lang;
68+
}
69+
5470
}
5571

5672
export const AddonModChoiceModuleHandler = makeSingleton(AddonModChoiceModuleHandlerService);

src/addons/mod/data/services/handlers/module.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import { CoreCourseModuleHandler } from '@features/course/services/module-delega
1818
import { makeSingleton } from '@singletons';
1919
import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_MODNAME, ADDON_MOD_DATA_PAGE_NAME } from '../../constants';
2020
import { ModFeature, ModPurpose } from '@addons/mod/constants';
21+
import { AddonModData } from '../data';
22+
import { CoreCourseModuleData } from '@features/course/services/course-helper';
23+
import { CoreSitesReadingStrategy } from '@services/sites';
2124

2225
/**
2326
* Handler to support data modules.
@@ -53,5 +56,18 @@ export class AddonModDataModuleHandlerService extends CoreModuleHandlerBase impl
5356
return AddonModDataIndexComponent;
5457
}
5558

59+
/**
60+
* @inheritdoc
61+
*/
62+
async getModuleForcedLang(module: CoreCourseModuleData): Promise<string | undefined> {
63+
const mod = await AddonModData.getDatabase(
64+
module.course,
65+
module.id,
66+
{ readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
67+
);
68+
69+
return mod?.lang;
70+
}
71+
5672
}
5773
export const AddonModDataModuleHandler = makeSingleton(AddonModDataModuleHandlerService);

src/addons/mod/feedback/services/handlers/module.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import { makeSingleton } from '@singletons';
1818
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
1919
import { ADDON_MOD_FEEDBACK_MODNAME, ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
2020
import { ModFeature, ModPurpose } from '@addons/mod/constants';
21+
import { AddonModFeedback } from '../feedback';
22+
import { CoreCourseModuleData } from '@features/course/services/course-helper';
23+
import { CoreSitesReadingStrategy } from '@services/sites';
2124

2225
/**
2326
* Handler to support feedback modules.
@@ -51,6 +54,19 @@ export class AddonModFeedbackModuleHandlerService extends CoreModuleHandlerBase
5154
return AddonModFeedbackIndexComponent;
5255
}
5356

57+
/**
58+
* @inheritdoc
59+
*/
60+
async getModuleForcedLang(module: CoreCourseModuleData): Promise<string | undefined> {
61+
const mod = await AddonModFeedback.getFeedback(
62+
module.course,
63+
module.id,
64+
{ readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
65+
);
66+
67+
return mod?.lang;
68+
}
69+
5470
}
5571

5672
export const AddonModFeedbackModuleHandler = makeSingleton(AddonModFeedbackModuleHandlerService);

src/addons/mod/folder/services/handlers/module.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { convertTextToHTMLElement } from '@/core/utils/create-html-element';
2121
import { makeSingleton } from '@singletons';
2222
import { ADDON_MOD_FOLDER_MODNAME, ADDON_MOD_FOLDER_PAGE_NAME } from '../../constants';
2323
import { ModFeature, ModArchetype, ModPurpose } from '@addons/mod/constants';
24+
import { AddonModFolder } from '../folder';
25+
import { CoreSitesReadingStrategy } from '@services/sites';
2426

2527
/**
2628
* Handler to support folder modules.
@@ -89,5 +91,18 @@ export class AddonModFolderModuleHandlerService extends CoreModuleHandlerBase im
8991
return AddonModFolderIndexComponent;
9092
}
9193

94+
/**
95+
* @inheritdoc
96+
*/
97+
async getModuleForcedLang(module: CoreCourseModuleData): Promise<string | undefined> {
98+
const mod = await AddonModFolder.getFolder(
99+
module.course,
100+
module.id,
101+
{ readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
102+
);
103+
104+
return mod?.lang;
105+
}
106+
92107
}
93108
export const AddonModFolderModuleHandler = makeSingleton(AddonModFolderModuleHandlerService);

src/addons/mod/forum/services/forum.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import { CorePromiseUtils } from '@singletons/promise-utils';
5353
import { CoreWSError } from '@classes/errors/wserror';
5454
import { CoreObject } from '@singletons/object';
5555
import { CoreTextFormat } from '@singletons/text';
56-
import { CoreCourseModuleHelper } from '@features/course/services/course-module-helper';
56+
import { CoreCourseModuleHelper, CoreCourseModuleStandardElements } from '@features/course/services/course-module-helper';
5757
import { CoreUserPreferences } from '@features/user/services/user-preferences';
5858

5959
declare module '@singletons/events' {
@@ -1375,15 +1375,12 @@ type AddonModForumGetForumsByCoursesWSParams = {
13751375

13761376
/**
13771377
* General forum activity data.
1378+
* We're using Omit to exclude properties because type is not consistent with the rest of the WS but
1379+
* it should be.
13781380
*/
1379-
export type AddonModForumData = {
1380-
id: number; // Forum id.
1381-
course: number; // Course id.
1381+
export type AddonModForumData =
1382+
Omit<CoreCourseModuleStandardElements, 'coursemodule'|'section'|'visible'|'groupmode'|'groupingid'> & {
13821383
type: AddonModForumType; // The forum type.
1383-
name: string; // Forum name.
1384-
intro: string; // The forum intro.
1385-
introformat: CoreTextFormat; // Intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN).
1386-
introfiles?: CoreWSExternalFile[];
13871384
duedate?: number; // Duedate for the user.
13881385
cutoffdate?: number; // Cutoffdate for the user.
13891386
assessed: number; // Aggregate type.

src/addons/mod/forum/services/handlers/module.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@ export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase imp
180180
return super.getOverviewItemContent(item, activity, courseId);
181181
}
182182

183+
/**
184+
* @inheritdoc
185+
*/
186+
async getModuleForcedLang(module: CoreCourseModuleData): Promise<string | undefined> {
187+
const mod = await AddonModForum.getForum(
188+
module.course,
189+
module.id,
190+
{ readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
191+
);
192+
193+
return mod?.lang;
194+
}
195+
183196
}
184197

185198
export const AddonModForumModuleHandler = makeSingleton(AddonModForumModuleHandlerService);

0 commit comments

Comments
 (0)