Skip to content

Commit d91092a

Browse files
committed
MOBILE-4860 course: Add course option names constants
1 parent 2a0d441 commit d91092a

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed

src/core/features/grades/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
export const GRADES_PAGE_NAME = 'grades';
1616
export const GRADES_PARTICIPANTS_PAGE_NAME = 'participant-grades';
1717

18+
export const CORE_GRADES_COURSE_OPTION_NAME = 'CoreGrades'; // Tabname.
19+
1820
export const enum CoreGradeType {
1921
NONE = 0, // Moodle's GRADE_TYPE_NONE.
2022
VALUE = 1, // Moodle's GRADE_TYPE_VALUE.

src/core/features/grades/services/grades-helper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import { CoreCourseAccessDataType } from '@features/course/constants';
4949
import { CorePromiseUtils } from '@singletons/promise-utils';
5050
import { CoreArray } from '@singletons/array';
5151
import { CoreCourseModuleHelper } from '@features/course/services/course-module-helper';
52-
import { GRADES_PAGE_NAME } from '../constants';
52+
import { CORE_GRADES_COURSE_OPTION_NAME, GRADES_PAGE_NAME } from '../constants';
5353

5454
/**
5555
* Service that provides some features regarding grades information.
@@ -505,13 +505,13 @@ export class CoreGradesHelperProvider {
505505
// View own grades. Check if we already are in the course index page.
506506
if (CoreCourse.currentViewIsCourse(courseId)) {
507507
// Current view is this course, just select the grades tab.
508-
CoreCourse.selectCourseTab('CoreGrades');
508+
CoreCourse.selectCourseTab(CORE_GRADES_COURSE_OPTION_NAME);
509509

510510
return;
511511
}
512512

513513
// Open the course with the grades tab selected.
514-
await CoreCourseHelper.getAndOpenCourse(courseId, { selectedTab: 'CoreGrades' }, siteId);
514+
await CoreCourseHelper.getAndOpenCourse(courseId, { selectedTab: CORE_GRADES_COURSE_OPTION_NAME }, siteId);
515515
} catch {
516516
// Cannot get course for some reason, just open the grades page.
517517
await CoreNavigator.navigateToSitePath(`/${GRADES_PAGE_NAME}/${courseId}`, { siteId });

src/core/features/grades/services/handlers/course-option.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
CoreCourseOptionsHandlerData,
2020
} from '@features/course/services/course-options-delegate';
2121
import { CoreCourseAnyCourseData, CoreCourses, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses';
22-
import { GRADES_PAGE_NAME } from '../../constants';
22+
import { CORE_GRADES_COURSE_OPTION_NAME, GRADES_PAGE_NAME } from '../../constants';
2323
import { makeSingleton } from '@singletons';
2424
import { CoreGrades } from '../grades';
2525
import { CoreGradesHelper } from '../grades-helper';
@@ -30,7 +30,7 @@ import { CoreGradesHelper } from '../grades-helper';
3030
@Injectable({ providedIn: 'root' })
3131
export class CoreGradesCourseOptionHandlerService implements CoreCourseOptionsHandler {
3232

33-
name = 'CoreGrades';
33+
name = CORE_GRADES_COURSE_OPTION_NAME;
3434
priority = 400;
3535

3636
/**

src/core/features/user/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
export const PARTICIPANTS_PAGE_NAME = 'participants';
1616

17+
export const CORE_PARTICIPANTS_COURSE_OPTION_NAME = 'CoreUserParticipants'; // Tabname.
18+
1719
// Events.
1820
export const CORE_USER_AUTO_SYNCED = 'core_user_autom_synced';
1921

src/core/features/user/services/handlers/course-option.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
CoreCourseOptionsHandlerData,
2121
} from '@features/course/services/course-options-delegate';
2222
import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses';
23-
import { PARTICIPANTS_PAGE_NAME } from '@features/user/constants';
23+
import { CORE_PARTICIPANTS_COURSE_OPTION_NAME, PARTICIPANTS_PAGE_NAME } from '@features/user/constants';
2424
import { makeSingleton } from '@singletons';
2525
import { CoreUser } from '../user';
2626

@@ -30,7 +30,7 @@ import { CoreUser } from '../user';
3030
@Injectable({ providedIn: 'root' })
3131
export class CoreUserCourseOptionHandlerService implements CoreCourseOptionsHandler {
3232

33-
name = 'CoreUserParticipants';
33+
name = CORE_PARTICIPANTS_COURSE_OPTION_NAME;
3434
priority = 600;
3535

3636
/**

src/core/features/user/services/handlers/participants-link.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Injectable } from '@angular/core';
1717
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
1818
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
1919
import { CoreCourseHelper } from '@features/course/services/course-helper';
20+
import { CORE_PARTICIPANTS_COURSE_OPTION_NAME } from '@features/user/constants';
2021
import { makeSingleton } from '@singletons';
2122

2223
/**
@@ -41,7 +42,11 @@ export class CoreUserParticipantsLinkHandlerService extends CoreContentLinksHand
4142

4243
return [{
4344
action: async (siteId): Promise<void> => {
44-
await CoreCourseHelper.getAndOpenCourse(courseIdentifier, { selectedTab: 'CoreUserParticipants' }, siteId);
45+
await CoreCourseHelper.getAndOpenCourse(
46+
courseIdentifier,
47+
{ selectedTab: CORE_PARTICIPANTS_COURSE_OPTION_NAME },
48+
siteId,
49+
);
4550
},
4651
}];
4752
}

0 commit comments

Comments
 (0)