MOBILE-4543 course: Improvements on course options delegate
This commit is contained in:
		
							parent
							
								
									0d56f802f2
								
							
						
					
					
						commit
						4f56e08f9b
					
				@ -64,7 +64,7 @@ export class AddonBadgesUserHandlerService implements CoreUserProfileHandler {
 | 
				
			|||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (navOptions && navOptions.badges !== undefined) {
 | 
					        if (navOptions?.badges !== undefined) {
 | 
				
			||||||
            return navOptions.badges;
 | 
					            return navOptions.badges;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -61,7 +61,7 @@ export class AddonBlogCourseOptionHandlerService implements CoreCourseOptionsHan
 | 
				
			|||||||
    ): Promise<boolean> {
 | 
					    ): Promise<boolean> {
 | 
				
			||||||
        const enabled = await CoreCourseHelper.hasABlockNamed(courseId, 'blog_menu');
 | 
					        const enabled = await CoreCourseHelper.hasABlockNamed(courseId, 'blog_menu');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (enabled && navOptions && navOptions.blogs !== undefined) {
 | 
					        if (enabled && navOptions?.blogs !== undefined) {
 | 
				
			||||||
            return navOptions.blogs;
 | 
					            return navOptions.blogs;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@
 | 
				
			|||||||
// limitations under the License.
 | 
					// limitations under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { Injectable } from '@angular/core';
 | 
					import { Injectable } from '@angular/core';
 | 
				
			||||||
import { CoreCourseProvider } from '@features/course/services/course';
 | 
					import { CoreCourseAccessDataType } from '@features/course/services/course';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    CoreCourseAccess,
 | 
					    CoreCourseAccess,
 | 
				
			||||||
    CoreCourseOptionsHandler,
 | 
					    CoreCourseOptionsHandler,
 | 
				
			||||||
@ -50,11 +50,11 @@ export class AddonCompetencyCourseOptionHandlerService implements CoreCourseOpti
 | 
				
			|||||||
        accessData: CoreCourseAccess,
 | 
					        accessData: CoreCourseAccess,
 | 
				
			||||||
        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
    ): Promise<boolean> {
 | 
					    ): Promise<boolean> {
 | 
				
			||||||
        if (accessData && accessData.type === CoreCourseProvider.ACCESS_GUEST) {
 | 
					        if (accessData && accessData.type === CoreCourseAccessDataType.ACCESS_GUEST) {
 | 
				
			||||||
            return false; // Not enabled for guest access.
 | 
					            return false; // Not enabled for guest access.
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (navOptions && navOptions.competencies !== undefined) {
 | 
					        if (navOptions?.competencies !== undefined) {
 | 
				
			||||||
            return navOptions.competencies;
 | 
					            return navOptions.competencies;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -82,7 +82,7 @@ export class AddonCompetencyCourseOptionHandlerService implements CoreCourseOpti
 | 
				
			|||||||
     * @inheritdoc
 | 
					     * @inheritdoc
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    async invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> {
 | 
					    async invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> {
 | 
				
			||||||
        if (navOptions && navOptions.competencies !== undefined) {
 | 
					        if (navOptions?.competencies !== undefined) {
 | 
				
			||||||
            // No need to invalidate anything.
 | 
					            // No need to invalidate anything.
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@
 | 
				
			|||||||
// limitations under the License.
 | 
					// limitations under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { Injectable } from '@angular/core';
 | 
					import { Injectable } from '@angular/core';
 | 
				
			||||||
import { CoreCourseProvider } from '@features/course/services/course';
 | 
					import { CoreCourseAccessDataType } from '@features/course/services/course';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    CoreCourseAccess,
 | 
					    CoreCourseAccess,
 | 
				
			||||||
    CoreCourseOptionsHandler,
 | 
					    CoreCourseOptionsHandler,
 | 
				
			||||||
@ -43,7 +43,7 @@ export class AddonCourseCompletionCourseOptionHandlerService implements CoreCour
 | 
				
			|||||||
     * @inheritdoc
 | 
					     * @inheritdoc
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    async isEnabledForCourse(courseId: number, accessData: CoreCourseAccess): Promise<boolean> {
 | 
					    async isEnabledForCourse(courseId: number, accessData: CoreCourseAccess): Promise<boolean> {
 | 
				
			||||||
        if (accessData && accessData.type === CoreCourseProvider.ACCESS_GUEST) {
 | 
					        if (accessData && accessData.type === CoreCourseAccessDataType.ACCESS_GUEST) {
 | 
				
			||||||
            return false; // Not enabled for guest access.
 | 
					            return false; // Not enabled for guest access.
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@
 | 
				
			|||||||
// limitations under the License.
 | 
					// limitations under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { Injectable } from '@angular/core';
 | 
					import { Injectable } from '@angular/core';
 | 
				
			||||||
import { CoreCourseProvider } from '@features/course/services/course';
 | 
					import { CoreCourseAccessDataType } from '@features/course/services/course';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    CoreCourseAccess,
 | 
					    CoreCourseAccess,
 | 
				
			||||||
    CoreCourseOptionsHandler,
 | 
					    CoreCourseOptionsHandler,
 | 
				
			||||||
@ -47,11 +47,11 @@ export class AddonNotesCourseOptionHandlerService implements CoreCourseOptionsHa
 | 
				
			|||||||
        accessData: CoreCourseAccess,
 | 
					        accessData: CoreCourseAccess,
 | 
				
			||||||
        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
    ): Promise<boolean> {
 | 
					    ): Promise<boolean> {
 | 
				
			||||||
        if (accessData && accessData.type === CoreCourseProvider.ACCESS_GUEST) {
 | 
					        if (accessData && accessData.type === CoreCourseAccessDataType.ACCESS_GUEST) {
 | 
				
			||||||
            return false; // Not enabled for guest access.
 | 
					            return false; // Not enabled for guest access.
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (navOptions && navOptions.notes !== undefined) {
 | 
					        if (navOptions?.notes !== undefined) {
 | 
				
			||||||
            return navOptions.notes;
 | 
					            return navOptions.notes;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -254,7 +254,7 @@ export class CoreCourseSummaryPage implements OnInit, OnDestroy {
 | 
				
			|||||||
     * @returns Promise resolved when done.
 | 
					     * @returns Promise resolved when done.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected async loadMenuHandlers(refresh?: boolean): Promise<void> {
 | 
					    protected async loadMenuHandlers(refresh?: boolean): Promise<void> {
 | 
				
			||||||
        if (!this.course) {
 | 
					        if (!this.course || !this.canAccessCourse) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -24,10 +24,9 @@ import {
 | 
				
			|||||||
    CoreCoursesProvider,
 | 
					    CoreCoursesProvider,
 | 
				
			||||||
    CoreCourseUserAdminOrNavOptionIndexed,
 | 
					    CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
} from '@features/courses/services/courses';
 | 
					} from '@features/courses/services/courses';
 | 
				
			||||||
import { CoreCourseProvider } from './course';
 | 
					import { CoreCourseAccessDataType } from './course';
 | 
				
			||||||
import { Params } from '@angular/router';
 | 
					import { Params } from '@angular/router';
 | 
				
			||||||
import { makeSingleton } from '@singletons';
 | 
					import { makeSingleton } from '@singletons';
 | 
				
			||||||
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper';
 | 
					 | 
				
			||||||
import { CorePromisedValue } from '@classes/promised-value';
 | 
					import { CorePromisedValue } from '@classes/promised-value';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -313,20 +312,20 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
     * @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
 | 
					     * @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
 | 
				
			||||||
     * @returns Promise resolved with array of handlers.
 | 
					     * @returns Promise resolved with array of handlers.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected async getHandlersForAccess(
 | 
					    protected async updateHandlersForAccess(
 | 
				
			||||||
        courseId: number,
 | 
					        courseId: number,
 | 
				
			||||||
        refresh: boolean,
 | 
					        refresh: boolean,
 | 
				
			||||||
        accessData: CoreCourseAccess,
 | 
					        accessData: CoreCourseAccess,
 | 
				
			||||||
        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
        admOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					        admOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
    ): Promise<CoreCourseOptionsHandler[]> {
 | 
					    ): Promise<void> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // If the handlers aren't loaded, do not refresh.
 | 
					        // If the handlers aren't loaded, do not refresh.
 | 
				
			||||||
        if (!this.loaded[courseId]) {
 | 
					        if (!this.loaded[courseId]) {
 | 
				
			||||||
            refresh = false;
 | 
					            refresh = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (refresh || !this.coursesHandlers[courseId] || this.coursesHandlers[courseId].access.type != accessData.type) {
 | 
					        if (refresh || !this.coursesHandlers[courseId] || this.coursesHandlers[courseId].access.type !== accessData.type) {
 | 
				
			||||||
            if (!this.coursesHandlers[courseId]) {
 | 
					            if (!this.coursesHandlers[courseId]) {
 | 
				
			||||||
                this.coursesHandlers[courseId] = {
 | 
					                this.coursesHandlers[courseId] = {
 | 
				
			||||||
                    access: accessData,
 | 
					                    access: accessData,
 | 
				
			||||||
@ -347,8 +346,6 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await this.coursesHandlers[courseId].deferred;
 | 
					        await this.coursesHandlers[courseId].deferred;
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return this.coursesHandlers[courseId].enabledHandlers;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -358,18 +355,14 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
     * @param course The course object.
 | 
					     * @param course The course object.
 | 
				
			||||||
     * @param refresh True if it should refresh the list.
 | 
					     * @param refresh True if it should refresh the list.
 | 
				
			||||||
     * @param isGuest Whether user is using an ACCESS_GUEST enrolment method.
 | 
					     * @param isGuest Whether user is using an ACCESS_GUEST enrolment method.
 | 
				
			||||||
     * @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
 | 
					 | 
				
			||||||
     * @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
 | 
					 | 
				
			||||||
     * @returns Promise resolved with array of handlers.
 | 
					     * @returns Promise resolved with array of handlers.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    getHandlersToDisplay(
 | 
					    getHandlersToDisplay(
 | 
				
			||||||
        course: CoreCourseAnyCourseData,
 | 
					        course: CoreCourseAnyCourseData,
 | 
				
			||||||
        refresh = false,
 | 
					        refresh = false,
 | 
				
			||||||
        isGuest = false,
 | 
					        isGuest = false,
 | 
				
			||||||
        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					 | 
				
			||||||
        admOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					 | 
				
			||||||
    ): Promise<CoreCourseOptionsHandlerToDisplay[]> {
 | 
					    ): Promise<CoreCourseOptionsHandlerToDisplay[]> {
 | 
				
			||||||
        return this.getHandlersToDisplayInternal(false, course, refresh, isGuest, navOptions, admOptions) as
 | 
					        return this.getHandlersToDisplayInternal(false, course, refresh, isGuest) as
 | 
				
			||||||
            Promise<CoreCourseOptionsHandlerToDisplay[]>;
 | 
					            Promise<CoreCourseOptionsHandlerToDisplay[]>;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -380,18 +373,14 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
     * @param course The course object.
 | 
					     * @param course The course object.
 | 
				
			||||||
     * @param refresh True if it should refresh the list.
 | 
					     * @param refresh True if it should refresh the list.
 | 
				
			||||||
     * @param isGuest Whether user is using an ACCESS_GUEST enrolment method.
 | 
					     * @param isGuest Whether user is using an ACCESS_GUEST enrolment method.
 | 
				
			||||||
     * @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
 | 
					 | 
				
			||||||
     * @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
 | 
					 | 
				
			||||||
     * @returns Promise resolved with array of handlers.
 | 
					     * @returns Promise resolved with array of handlers.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    getMenuHandlersToDisplay(
 | 
					    getMenuHandlersToDisplay(
 | 
				
			||||||
        course: CoreCourseAnyCourseData,
 | 
					        course: CoreCourseAnyCourseData,
 | 
				
			||||||
        refresh = false,
 | 
					        refresh = false,
 | 
				
			||||||
        isGuest = false,
 | 
					        isGuest = false,
 | 
				
			||||||
        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					 | 
				
			||||||
        admOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					 | 
				
			||||||
    ): Promise<CoreCourseOptionsMenuHandlerToDisplay[]> {
 | 
					    ): Promise<CoreCourseOptionsMenuHandlerToDisplay[]> {
 | 
				
			||||||
        return this.getHandlersToDisplayInternal(true, course, refresh, isGuest, navOptions, admOptions) as
 | 
					        return this.getHandlersToDisplayInternal(true, course, refresh, isGuest) as
 | 
				
			||||||
            Promise<CoreCourseOptionsMenuHandlerToDisplay[]>;
 | 
					            Promise<CoreCourseOptionsMenuHandlerToDisplay[]>;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -403,8 +392,6 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
     * @param course The course object.
 | 
					     * @param course The course object.
 | 
				
			||||||
     * @param refresh True if it should refresh the list.
 | 
					     * @param refresh True if it should refresh the list.
 | 
				
			||||||
     * @param isGuest Whether user is using an ACCESS_GUEST enrolment method.
 | 
					     * @param isGuest Whether user is using an ACCESS_GUEST enrolment method.
 | 
				
			||||||
     * @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
 | 
					 | 
				
			||||||
     * @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
 | 
					 | 
				
			||||||
     * @returns Promise resolved with array of handlers.
 | 
					     * @returns Promise resolved with array of handlers.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected async getHandlersToDisplayInternal(
 | 
					    protected async getHandlersToDisplayInternal(
 | 
				
			||||||
@ -412,36 +399,30 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
        course: CoreCourseAnyCourseData,
 | 
					        course: CoreCourseAnyCourseData,
 | 
				
			||||||
        refresh = false,
 | 
					        refresh = false,
 | 
				
			||||||
        isGuest = false,
 | 
					        isGuest = false,
 | 
				
			||||||
        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					 | 
				
			||||||
        admOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					 | 
				
			||||||
    ): Promise<CoreCourseOptionsHandlerToDisplay[] | CoreCourseOptionsMenuHandlerToDisplay[]> {
 | 
					    ): Promise<CoreCourseOptionsHandlerToDisplay[] | CoreCourseOptionsMenuHandlerToDisplay[]> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const courseWithOptions: CoreCourseAnyCourseDataWithOptions = course;
 | 
					        const courseWithOptions: CoreCourseAnyCourseDataWithOptions = course;
 | 
				
			||||||
        const accessData = {
 | 
					        const accessData = {
 | 
				
			||||||
            type: isGuest ? CoreCourseProvider.ACCESS_GUEST : CoreCourseProvider.ACCESS_DEFAULT,
 | 
					            type: isGuest ? CoreCourseAccessDataType.ACCESS_GUEST : CoreCourseAccessDataType.ACCESS_DEFAULT,
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        const handlersToDisplay: CoreCourseOptionsHandlerToDisplay[] | CoreCourseOptionsMenuHandlerToDisplay[] = [];
 | 
					        const handlersToDisplay: CoreCourseOptionsHandlerToDisplay[] | CoreCourseOptionsMenuHandlerToDisplay[] = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (navOptions) {
 | 
					 | 
				
			||||||
            courseWithOptions.navOptions = navOptions;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if (admOptions) {
 | 
					 | 
				
			||||||
            courseWithOptions.admOptions = admOptions;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        await this.loadCourseOptions(courseWithOptions, refresh);
 | 
					        await this.loadCourseOptions(courseWithOptions, refresh);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Call getHandlersForAccess to make sure the handlers have been loaded.
 | 
					        // Call updateHandlersForAccess to make sure the handlers have been loaded.
 | 
				
			||||||
        await this.getHandlersForAccess(course.id, refresh, accessData, courseWithOptions.navOptions, courseWithOptions.admOptions);
 | 
					        await this.updateHandlersForAccess(
 | 
				
			||||||
 | 
					            course.id,
 | 
				
			||||||
 | 
					            refresh,
 | 
				
			||||||
 | 
					            accessData,
 | 
				
			||||||
 | 
					            courseWithOptions.navOptions,
 | 
				
			||||||
 | 
					            courseWithOptions.admOptions,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const promises: Promise<void>[] = [];
 | 
					        const promises: Promise<void>[] = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let handlerList: CoreCourseOptionsMenuHandler[] | CoreCourseOptionsHandler[];
 | 
					        const handlerList = menu
 | 
				
			||||||
        if (menu) {
 | 
					            ? this.coursesHandlers[course.id].enabledMenuHandlers
 | 
				
			||||||
            handlerList = this.coursesHandlers[course.id].enabledMenuHandlers;
 | 
					            : this.coursesHandlers[course.id].enabledHandlers;
 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            handlerList = this.coursesHandlers[course.id].enabledHandlers;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        handlerList.forEach((handler: CoreCourseOptionsMenuHandler | CoreCourseOptionsHandler) => {
 | 
					        handlerList.forEach((handler: CoreCourseOptionsMenuHandler | CoreCourseOptionsHandler) => {
 | 
				
			||||||
            const getFunction = menu
 | 
					            const getFunction = menu
 | 
				
			||||||
@ -461,8 +442,8 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }).catch((err) => {
 | 
					            }).catch((error) => {
 | 
				
			||||||
                this.logger.error('Error getting data for handler', handler.name, err);
 | 
					                this.logger.error(`Error getting data for handler ${handler.name}`, error);
 | 
				
			||||||
            }));
 | 
					            }));
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -477,17 +458,44 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
        return handlersToDisplay;
 | 
					        return handlersToDisplay;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Get the handlers for a course using a certain access type.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param courseId The course ID.
 | 
				
			||||||
 | 
					     * @param refresh True if it should refresh the list.
 | 
				
			||||||
 | 
					     * @param accessData Access type and data. Default, guest, ...
 | 
				
			||||||
 | 
					     * @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
 | 
				
			||||||
 | 
					     * @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
 | 
				
			||||||
 | 
					     * @returns Promise resolved with array of handlers.
 | 
				
			||||||
 | 
					     * @deprecated since 4.4.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected async hasHandlersForAccess(
 | 
				
			||||||
 | 
					        courseId: number,
 | 
				
			||||||
 | 
					        refresh: boolean,
 | 
				
			||||||
 | 
					        accessData: CoreCourseAccess,
 | 
				
			||||||
 | 
					        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
 | 
					        admOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
 | 
					    ): Promise<boolean> {
 | 
				
			||||||
 | 
					        await this.updateHandlersForAccess(courseId, refresh, accessData, navOptions, admOptions);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const handlers = this.coursesHandlers[courseId].enabledHandlers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return !!(handlers && handlers.length);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Check if a course has any handler enabled for default access, using course object.
 | 
					     * Check if a course has any handler enabled for default access, using course object.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param course The course object.
 | 
					     * @param course The course object.
 | 
				
			||||||
     * @param refresh True if it should refresh the list.
 | 
					     * @param refresh True if it should refresh the list.
 | 
				
			||||||
     * @returns Promise resolved with boolean: true if it has handlers, false otherwise.
 | 
					     * @returns Promise resolved with boolean: true if it has handlers, false otherwise.
 | 
				
			||||||
 | 
					     * @deprecated since 4.4.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    async hasHandlersForCourse(course: CoreEnrolledCourseDataWithExtraInfoAndOptions, refresh = false): Promise<boolean> {
 | 
					    async hasHandlersForCourse(course: CoreCourseAnyCourseDataWithOptions, refresh = false): Promise<boolean> {
 | 
				
			||||||
        // Load course options if missing.
 | 
					        // Load course options if missing.
 | 
				
			||||||
        await this.loadCourseOptions(course, refresh);
 | 
					        await this.loadCourseOptions(course, refresh);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // eslint-disable-next-line deprecation/deprecation
 | 
				
			||||||
        return this.hasHandlersForDefault(course.id, refresh, course.navOptions, course.admOptions);
 | 
					        return this.hasHandlersForDefault(course.id, refresh, course.navOptions, course.admOptions);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -499,6 +507,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
     * @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
 | 
					     * @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
 | 
				
			||||||
     * @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
 | 
					     * @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
 | 
				
			||||||
     * @returns Promise resolved with boolean: true if it has handlers, false otherwise.
 | 
					     * @returns Promise resolved with boolean: true if it has handlers, false otherwise.
 | 
				
			||||||
 | 
					     * @deprecated since 4.4.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    async hasHandlersForDefault(
 | 
					    async hasHandlersForDefault(
 | 
				
			||||||
        courseId: number,
 | 
					        courseId: number,
 | 
				
			||||||
@ -506,14 +515,14 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
        admOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					        admOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
    ): Promise<boolean> {
 | 
					    ): Promise<boolean> {
 | 
				
			||||||
        // Default access.
 | 
					        // eslint-disable-next-line deprecation/deprecation
 | 
				
			||||||
        const accessData = {
 | 
					        return await this.hasHandlersForAccess(
 | 
				
			||||||
            type: CoreCourseProvider.ACCESS_DEFAULT,
 | 
					            courseId,
 | 
				
			||||||
        };
 | 
					            refresh,
 | 
				
			||||||
 | 
					            { type: CoreCourseAccessDataType.ACCESS_DEFAULT },
 | 
				
			||||||
        const handlers = await this.getHandlersForAccess(courseId, refresh, accessData, navOptions, admOptions);
 | 
					            navOptions,
 | 
				
			||||||
 | 
					            admOptions,
 | 
				
			||||||
        return !!(handlers && handlers.length);
 | 
					        );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -524,6 +533,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
     * @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
 | 
					     * @param navOptions Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
 | 
				
			||||||
     * @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
 | 
					     * @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
 | 
				
			||||||
     * @returns Promise resolved with boolean: true if it has handlers, false otherwise.
 | 
					     * @returns Promise resolved with boolean: true if it has handlers, false otherwise.
 | 
				
			||||||
 | 
					     * @deprecated since 4.4.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    async hasHandlersForGuest(
 | 
					    async hasHandlersForGuest(
 | 
				
			||||||
        courseId: number,
 | 
					        courseId: number,
 | 
				
			||||||
@ -531,14 +541,14 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
        admOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					        admOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
    ): Promise<boolean> {
 | 
					    ): Promise<boolean> {
 | 
				
			||||||
        // Guest access.
 | 
					        // eslint-disable-next-line deprecation/deprecation
 | 
				
			||||||
        const accessData = {
 | 
					        return await this.hasHandlersForAccess(
 | 
				
			||||||
            type: CoreCourseProvider.ACCESS_GUEST,
 | 
					            courseId,
 | 
				
			||||||
        };
 | 
					            refresh,
 | 
				
			||||||
 | 
					            { type: CoreCourseAccessDataType.ACCESS_GUEST },
 | 
				
			||||||
        const handlers = await this.getHandlersForAccess(courseId, refresh, accessData, navOptions, admOptions);
 | 
					            navOptions,
 | 
				
			||||||
 | 
					            admOptions,
 | 
				
			||||||
        return !!(handlers && handlers.length);
 | 
					        );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -547,7 +557,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
     * @param courseId Course ID.
 | 
					     * @param courseId Course ID.
 | 
				
			||||||
     * @returns Promise resolved when done.
 | 
					     * @returns Promise resolved when done.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    async invalidateCourseHandlers(courseId: number): Promise<void> {
 | 
					    protected async invalidateCourseHandlers(courseId: number): Promise<void> {
 | 
				
			||||||
        const promises: Promise<void>[] = [];
 | 
					        const promises: Promise<void>[] = [];
 | 
				
			||||||
        const courseData = this.coursesHandlers[courseId];
 | 
					        const courseData = this.coursesHandlers[courseId];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -556,7 +566,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        courseData.enabledHandlers.forEach((handler) => {
 | 
					        courseData.enabledHandlers.forEach((handler) => {
 | 
				
			||||||
            if (handler?.invalidateEnabledForCourse) {
 | 
					            if (handler.invalidateEnabledForCourse) {
 | 
				
			||||||
                promises.push(
 | 
					                promises.push(
 | 
				
			||||||
                    handler.invalidateEnabledForCourse(courseId, courseData.navOptions, courseData.admOptions),
 | 
					                    handler.invalidateEnabledForCourse(courseId, courseData.navOptions, courseData.admOptions),
 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
@ -579,7 +589,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return time == this.lastUpdateHandlersForCoursesStart[courseId];
 | 
					        return time === this.lastUpdateHandlersForCoursesStart[courseId];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -590,12 +600,13 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
     * @returns Promise resolved when done.
 | 
					     * @returns Promise resolved when done.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected async loadCourseOptions(course: CoreCourseAnyCourseDataWithOptions, refresh = false): Promise<void> {
 | 
					    protected async loadCourseOptions(course: CoreCourseAnyCourseDataWithOptions, refresh = false): Promise<void> {
 | 
				
			||||||
        if (course.navOptions === undefined || course.admOptions === undefined || refresh) {
 | 
					        if (!refresh && course.navOptions !== undefined && course.admOptions !== undefined) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
            const options = await CoreCourses.getCoursesAdminAndNavOptions([course.id]);
 | 
					 | 
				
			||||||
            course.navOptions = options.navOptions[course.id];
 | 
					 | 
				
			||||||
            course.admOptions = options.admOptions[course.id];
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const options = await CoreCourses.getCoursesAdminAndNavOptions([course.id]);
 | 
				
			||||||
 | 
					        course.navOptions = options.navOptions[course.id];
 | 
				
			||||||
 | 
					        course.admOptions = options.admOptions[course.id];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -618,7 +629,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
     * @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
 | 
					     * @param admOptions Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
 | 
				
			||||||
     * @returns Resolved when updated.
 | 
					     * @returns Resolved when updated.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    async updateHandlersForCourse(
 | 
					    protected async updateHandlersForCourse(
 | 
				
			||||||
        courseId: number,
 | 
					        courseId: number,
 | 
				
			||||||
        accessData: CoreCourseAccess,
 | 
					        accessData: CoreCourseAccess,
 | 
				
			||||||
        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
@ -676,5 +687,5 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
 | 
				
			|||||||
export const CoreCourseOptionsDelegate = makeSingleton(CoreCourseOptionsDelegateService);
 | 
					export const CoreCourseOptionsDelegate = makeSingleton(CoreCourseOptionsDelegateService);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type CoreCourseAccess = {
 | 
					export type CoreCourseAccess = {
 | 
				
			||||||
    type: string; // Either CoreCourseProvider.ACCESS_GUEST or CoreCourseProvider.ACCESS_DEFAULT.
 | 
					    type: CoreCourseAccessDataType;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -80,7 +80,7 @@ declare module '@singletons/events' {
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * Course Module completion status enumeration.
 | 
					 * Course Module completion status enumeration.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export enum CoreCourseModuleCompletionStatus {
 | 
					export const enum CoreCourseModuleCompletionStatus {
 | 
				
			||||||
    COMPLETION_INCOMPLETE = 0,
 | 
					    COMPLETION_INCOMPLETE = 0,
 | 
				
			||||||
    COMPLETION_COMPLETE = 1,
 | 
					    COMPLETION_COMPLETE = 1,
 | 
				
			||||||
    COMPLETION_COMPLETE_PASS = 2,
 | 
					    COMPLETION_COMPLETE_PASS = 2,
 | 
				
			||||||
@ -90,7 +90,7 @@ export enum CoreCourseModuleCompletionStatus {
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * @deprecated since 4.3 Not used anymore.
 | 
					 * @deprecated since 4.3 Not used anymore.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export enum CoreCourseCompletionMode {
 | 
					export const enum CoreCourseCompletionMode {
 | 
				
			||||||
    FULL = 'full',
 | 
					    FULL = 'full',
 | 
				
			||||||
    BASIC = 'basic',
 | 
					    BASIC = 'basic',
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -98,12 +98,20 @@ export enum CoreCourseCompletionMode {
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * Completion tracking valid values.
 | 
					 * Completion tracking valid values.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export enum CoreCourseModuleCompletionTracking {
 | 
					export const enum CoreCourseModuleCompletionTracking {
 | 
				
			||||||
    COMPLETION_TRACKING_NONE = 0,
 | 
					    COMPLETION_TRACKING_NONE = 0,
 | 
				
			||||||
    COMPLETION_TRACKING_MANUAL = 1,
 | 
					    COMPLETION_TRACKING_MANUAL = 1,
 | 
				
			||||||
    COMPLETION_TRACKING_AUTOMATIC = 2,
 | 
					    COMPLETION_TRACKING_AUTOMATIC = 2,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const CoreCourseAccessDataType = {
 | 
				
			||||||
 | 
					    ACCESS_GUEST: 'courses_access_guest', // eslint-disable-line @typescript-eslint/naming-convention
 | 
				
			||||||
 | 
					    ACCESS_DEFAULT: 'courses_access_default', // eslint-disable-line @typescript-eslint/naming-convention
 | 
				
			||||||
 | 
					} as const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// eslint-disable-next-line @typescript-eslint/no-redeclare
 | 
				
			||||||
 | 
					export type CoreCourseAccessDataType = typeof CoreCourseAccessDataType[keyof typeof CoreCourseAccessDataType];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Service that provides some features regarding a course.
 | 
					 * Service that provides some features regarding a course.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@ -112,10 +120,17 @@ export class CoreCourseProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    static readonly ALL_SECTIONS_ID = -2;
 | 
					    static readonly ALL_SECTIONS_ID = -2;
 | 
				
			||||||
    static readonly STEALTH_MODULES_SECTION_ID = -1;
 | 
					    static readonly STEALTH_MODULES_SECTION_ID = -1;
 | 
				
			||||||
    static readonly ACCESS_GUEST = 'courses_access_guest';
 | 
					 | 
				
			||||||
    static readonly ACCESS_DEFAULT = 'courses_access_default';
 | 
					 | 
				
			||||||
    static readonly ALL_COURSES_CLEARED = -1;
 | 
					    static readonly ALL_COURSES_CLEARED = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @deprecated since 4.4 Not used anymore. Use CoreCourseAccessDataType instead.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    static readonly ACCESS_GUEST = CoreCourseAccessDataType.ACCESS_GUEST;
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @deprecated since 4.4 Not used anymore. Use CoreCourseAccessDataType instead.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    static readonly ACCESS_DEFAULT = CoreCourseAccessDataType.ACCESS_DEFAULT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static readonly COMPONENT = 'CoreCourse';
 | 
					    static readonly COMPONENT = 'CoreCourse';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    readonly CORE_MODULES = [
 | 
					    readonly CORE_MODULES = [
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,7 @@ import {
 | 
				
			|||||||
    CoreCourseSearchedData,
 | 
					    CoreCourseSearchedData,
 | 
				
			||||||
    CoreCourseUserAdminOrNavOptionIndexed,
 | 
					    CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
} from '@features/courses/services/courses';
 | 
					} from '@features/courses/services/courses';
 | 
				
			||||||
import { CoreCourse, CoreCourseProvider } from '@features/course/services/course';
 | 
					import { CoreCourse, CoreCourseAccessDataType } from '@features/course/services/course';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    CoreGrades,
 | 
					    CoreGrades,
 | 
				
			||||||
    CoreGradesGradeItem,
 | 
					    CoreGradesGradeItem,
 | 
				
			||||||
@ -680,11 +680,11 @@ export class CoreGradesHelperProvider {
 | 
				
			|||||||
        accessData: CoreCourseAccess,
 | 
					        accessData: CoreCourseAccess,
 | 
				
			||||||
        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
    ): Promise<boolean> {
 | 
					    ): Promise<boolean> {
 | 
				
			||||||
        if (accessData && accessData.type == CoreCourseProvider.ACCESS_GUEST) {
 | 
					        if (accessData && accessData.type === CoreCourseAccessDataType.ACCESS_GUEST) {
 | 
				
			||||||
            return false; // Not enabled for guests.
 | 
					            return false; // Not enabled for guests.
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (navOptions && navOptions.grades !== undefined) {
 | 
					        if (navOptions?.grades !== undefined) {
 | 
				
			||||||
            return navOptions.grades;
 | 
					            return navOptions.grades;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -38,7 +38,7 @@ export class CoreGradesCourseOptionHandlerService implements CoreCourseOptionsHa
 | 
				
			|||||||
    async invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> {
 | 
					    async invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> {
 | 
				
			||||||
        await CoreGrades.invalidateCourseGradesPermissionsData(courseId);
 | 
					        await CoreGrades.invalidateCourseGradesPermissionsData(courseId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (navOptions && navOptions.grades !== undefined) {
 | 
					        if (navOptions?.grades !== undefined) {
 | 
				
			||||||
            // No need to invalidate user courses.
 | 
					            // No need to invalidate user courses.
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -38,7 +38,7 @@ export class CoreGradesCourseParticipantsOptionHandlerService implements CoreCou
 | 
				
			|||||||
    async invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> {
 | 
					    async invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> {
 | 
				
			||||||
        await CoreGrades.invalidateCourseGradesPermissionsData(courseId);
 | 
					        await CoreGrades.invalidateCourseGradesPermissionsData(courseId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (navOptions && navOptions.grades !== undefined) {
 | 
					        if (navOptions?.grades !== undefined) {
 | 
				
			||||||
            // No need to invalidate user courses.
 | 
					            // No need to invalidate user courses.
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@
 | 
				
			|||||||
// limitations under the License.
 | 
					// limitations under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { Injectable } from '@angular/core';
 | 
					import { Injectable } from '@angular/core';
 | 
				
			||||||
import { CoreCourseProvider } from '@features/course/services/course';
 | 
					import { CoreCourseAccessDataType } from '@features/course/services/course';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    CoreCourseAccess,
 | 
					    CoreCourseAccess,
 | 
				
			||||||
    CoreCourseOptionsHandler,
 | 
					    CoreCourseOptionsHandler,
 | 
				
			||||||
@ -37,7 +37,7 @@ export class CoreUserCourseOptionHandlerService implements CoreCourseOptionsHand
 | 
				
			|||||||
     * @inheritdoc
 | 
					     * @inheritdoc
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> {
 | 
					    invalidateEnabledForCourse(courseId: number, navOptions?: CoreCourseUserAdminOrNavOptionIndexed): Promise<void> {
 | 
				
			||||||
        if (navOptions && navOptions.participants !== undefined) {
 | 
					        if (navOptions?.participants !== undefined) {
 | 
				
			||||||
            // No need to invalidate anything.
 | 
					            // No need to invalidate anything.
 | 
				
			||||||
            return Promise.resolve();
 | 
					            return Promise.resolve();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -60,11 +60,11 @@ export class CoreUserCourseOptionHandlerService implements CoreCourseOptionsHand
 | 
				
			|||||||
        accessData: CoreCourseAccess,
 | 
					        accessData: CoreCourseAccess,
 | 
				
			||||||
        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
					        navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
 | 
				
			||||||
    ): boolean | Promise<boolean> {
 | 
					    ): boolean | Promise<boolean> {
 | 
				
			||||||
        if (accessData && accessData.type == CoreCourseProvider.ACCESS_GUEST) {
 | 
					        if (accessData && accessData.type === CoreCourseAccessDataType.ACCESS_GUEST) {
 | 
				
			||||||
            return false; // Not enabled for guests.
 | 
					            return false; // Not enabled for guests.
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (navOptions && navOptions.participants !== undefined) {
 | 
					        if (navOptions?.participants !== undefined) {
 | 
				
			||||||
            return navOptions.participants;
 | 
					            return navOptions.participants;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user