MOBILE-3608 core: Implement missing parts of Course and filters
This commit is contained in:
		
							parent
							
								
									d0af70be5a
								
							
						
					
					
						commit
						f8320f6b58
					
				| @ -16,7 +16,7 @@ import { CoreContentLinksAction } from '../services/contentlinks-delegate'; | |||||||
| import { CoreContentLinksHandlerBase } from './base-handler'; | import { CoreContentLinksHandlerBase } from './base-handler'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| // import { CoreCourseHelperProvider } from '@features/course/providers/helper';
 | // import { CoreCourseHelper } from '@features/course/services/helper';
 | ||||||
| import { Params } from '@angular/router'; | import { Params } from '@angular/router'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -77,7 +77,7 @@ export class CoreContentLinksModuleGradeHandler extends CoreContentLinksHandlerB | |||||||
|                 const site = await CoreSites.instance.getSite(siteId); |                 const site = await CoreSites.instance.getSite(siteId); | ||||||
|                 if (!params.userid || params.userid == site.getUserId()) { |                 if (!params.userid || params.userid == site.getUserId()) { | ||||||
|                     // No user specified or current user. Navigate to module.
 |                     // No user specified or current user. Navigate to module.
 | ||||||
|                     // @todo this.courseHelper.navigateToModule(parseInt(params.id, 10), siteId, courseId, undefined,
 |                     // @todo CoreCourseHelper.instance.navigateToModule(parseInt(params.id, 10), siteId, courseId, undefined,
 | ||||||
|                     //        this.useModNameToGetModule ? this.modName : undefined, undefined, navCtrl);
 |                     //        this.useModNameToGetModule ? this.modName : undefined, undefined, navCtrl);
 | ||||||
|                 } else if (this.canReview) { |                 } else if (this.canReview) { | ||||||
|                     // Use the goToReview function.
 |                     // Use the goToReview function.
 | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import { PopoverController } from '@ionic/angular'; | |||||||
| import { CoreEventCourseStatusChanged, CoreEventObserver, CoreEvents } from '@singletons/events'; | import { CoreEventCourseStatusChanged, CoreEventObserver, CoreEvents } from '@singletons/events'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| // import { CoreUserProvider } from '@core/user/providers/user';
 | // import { CoreUser } from '@core/user/services/user';
 | ||||||
| import { CoreCourses } from '@features/courses/services/courses'; | import { CoreCourses } from '@features/courses/services/courses'; | ||||||
| import { CoreCourse, CoreCourseProvider } from '@features/course/services/course'; | import { CoreCourse, CoreCourseProvider } from '@features/course/services/course'; | ||||||
| import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/services/course-helper'; | import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/services/course-helper'; | ||||||
| @ -252,7 +252,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy { | |||||||
|      * Hide/Unhide the course from the course list. |      * Hide/Unhide the course from the course list. | ||||||
|      * |      * | ||||||
|      * @param hide True to hide and false to show. |      * @param hide True to hide and false to show. | ||||||
|      * @todo |      * @todo CoreUser | ||||||
|      */ |      */ | ||||||
|     // eslint-disable-next-line @typescript-eslint/no-unused-vars
 |     // eslint-disable-next-line @typescript-eslint/no-unused-vars
 | ||||||
|     protected setCourseHidden(hide: boolean): void { |     protected setCourseHidden(hide: boolean): void { | ||||||
| @ -263,7 +263,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy { | |||||||
|      * Favourite/Unfavourite the course from the course list. |      * Favourite/Unfavourite the course from the course list. | ||||||
|      * |      * | ||||||
|      * @param favourite True to favourite and false to unfavourite. |      * @param favourite True to favourite and false to unfavourite. | ||||||
|      * @todo |      * @todo CoreUser | ||||||
|      */ |      */ | ||||||
|     // eslint-disable-next-line @typescript-eslint/no-unused-vars
 |     // eslint-disable-next-line @typescript-eslint/no-unused-vars
 | ||||||
|     protected setCourseFavourite(favourite: boolean): void { |     protected setCourseFavourite(favourite: boolean): void { | ||||||
|  | |||||||
| @ -24,8 +24,8 @@ import { | |||||||
|     CoreFilterClassifiedFilters, |     CoreFilterClassifiedFilters, | ||||||
|     CoreFiltersGetAvailableInContextWSParamContext, |     CoreFiltersGetAvailableInContextWSParamContext, | ||||||
| } from './filter'; | } from './filter'; | ||||||
| // import { CoreCourseProvider } from '@features/course/providers/course';
 | import { CoreCourse } from '@features/course/services/course'; | ||||||
| // import { CoreCoursesProvider } from '@features/courses/providers/courses';
 | import { CoreCourses } from '@features/courses/services/courses'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| import { CoreEvents, CoreEventSiteData } from '@singletons/events'; | import { CoreEvents, CoreEventSiteData } from '@singletons/events'; | ||||||
| import { CoreLogger } from '@singletons/logger'; | import { CoreLogger } from '@singletons/logger'; | ||||||
| @ -73,22 +73,19 @@ export class CoreFilterHelperProvider { | |||||||
|      * @param siteId Site ID. If not defined, current site. |      * @param siteId Site ID. If not defined, current site. | ||||||
|      * @return Promise resolved with the contexts. |      * @return Promise resolved with the contexts. | ||||||
|      */ |      */ | ||||||
|     // eslint-disable-next-line @typescript-eslint/no-unused-vars
 |  | ||||||
|     async getBlocksContexts(courseId: number, siteId?: string): Promise<CoreFiltersGetAvailableInContextWSParamContext[]> { |     async getBlocksContexts(courseId: number, siteId?: string): Promise<CoreFiltersGetAvailableInContextWSParamContext[]> { | ||||||
|         return []; |         const blocks = await CoreCourse.instance.getCourseBlocks(courseId, siteId); | ||||||
|         // @todo
 |  | ||||||
|         // const blocks = await this.courseProvider.getCourseBlocks(courseId, siteId);
 |  | ||||||
| 
 | 
 | ||||||
|         // const contexts: CoreFiltersGetAvailableInContextWSParamContext[] = [];
 |         const contexts: CoreFiltersGetAvailableInContextWSParamContext[] = []; | ||||||
| 
 | 
 | ||||||
|         // blocks.forEach((block) => {
 |         blocks.forEach((block) => { | ||||||
|         //     contexts.push({
 |             contexts.push({ | ||||||
|         //         contextlevel: 'block',
 |                 contextlevel: 'block', | ||||||
|         //         instanceid: block.instanceid,
 |                 instanceid: block.instanceid, | ||||||
|         //     });
 |             }); | ||||||
|         // });
 |         }); | ||||||
| 
 | 
 | ||||||
|         // return contexts;
 |         return contexts; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -132,22 +129,19 @@ export class CoreFilterHelperProvider { | |||||||
|      * @param siteId Site ID. If not defined, current site. |      * @param siteId Site ID. If not defined, current site. | ||||||
|      * @return Promise resolved with the contexts. |      * @return Promise resolved with the contexts. | ||||||
|      */ |      */ | ||||||
|     // eslint-disable-next-line @typescript-eslint/no-unused-vars
 |  | ||||||
|     async getCourseContexts(courseId: number, siteId?: string): Promise<CoreFiltersGetAvailableInContextWSParamContext[]> { |     async getCourseContexts(courseId: number, siteId?: string): Promise<CoreFiltersGetAvailableInContextWSParamContext[]> { | ||||||
|         // @todo
 |         const courseIds = await CoreCourses.instance.getCourseIdsIfEnrolled(courseId, siteId); | ||||||
|         return []; |  | ||||||
|         // const courseIds = await this.coursesProvider.getCourseIdsIfEnrolled(courseId, siteId);
 |  | ||||||
| 
 | 
 | ||||||
|         // const contexts: CoreFiltersGetAvailableInContextWSParamContext[] = [];
 |         const contexts: CoreFiltersGetAvailableInContextWSParamContext[] = []; | ||||||
| 
 | 
 | ||||||
|         // courseIds.forEach((courseId) => {
 |         courseIds.forEach((courseId) => { | ||||||
|         //     contexts.push({
 |             contexts.push({ | ||||||
|         //         contextlevel: 'course',
 |                 contextlevel: 'course', | ||||||
|         //         instanceid: courseId
 |                 instanceid: courseId, | ||||||
|         //     });
 |             }); | ||||||
|         // });
 |         }); | ||||||
| 
 | 
 | ||||||
|         // return contexts;
 |         return contexts; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -157,29 +151,25 @@ export class CoreFilterHelperProvider { | |||||||
|      * @param siteId Site ID. If not defined, current site. |      * @param siteId Site ID. If not defined, current site. | ||||||
|      * @return Promise resolved with the contexts. |      * @return Promise resolved with the contexts. | ||||||
|      */ |      */ | ||||||
|     // eslint-disable-next-line @typescript-eslint/no-unused-vars
 |  | ||||||
|     async getCourseModulesContexts(courseId: number, siteId?: string): Promise<CoreFiltersGetAvailableInContextWSParamContext[]> { |     async getCourseModulesContexts(courseId: number, siteId?: string): Promise<CoreFiltersGetAvailableInContextWSParamContext[]> { | ||||||
|         // @todo
 |         const sections = await CoreCourse.instance.getSections(courseId, false, true, undefined, siteId); | ||||||
|         return []; |  | ||||||
| 
 | 
 | ||||||
|         // const sections = await this.courseProvider.getSections(courseId, false, true, undefined, siteId);
 |         const contexts: CoreFiltersGetAvailableInContextWSParamContext[] = []; | ||||||
| 
 | 
 | ||||||
|         // const contexts: CoreFiltersGetAvailableInContextWSParamContext[] = [];
 |         sections.forEach((section) => { | ||||||
|  |             if (section.modules) { | ||||||
|  |                 section.modules.forEach((module) => { | ||||||
|  |                     if (module.uservisible) { | ||||||
|  |                         contexts.push({ | ||||||
|  |                             contextlevel: 'module', | ||||||
|  |                             instanceid: module.id, | ||||||
|  |                         }); | ||||||
|  |                     } | ||||||
|  |                 }); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
| 
 | 
 | ||||||
|         // sections.forEach((section) => {
 |         return contexts; | ||||||
|         //     if (section.modules) {
 |  | ||||||
|         //         section.modules.forEach((module) => {
 |  | ||||||
|         //             if (module.uservisible) {
 |  | ||||||
|         //                 contexts.push({
 |  | ||||||
|         //                     contextlevel: 'module',
 |  | ||||||
|         //                     instanceid: module.id
 |  | ||||||
|         //                 });
 |  | ||||||
|         //             }
 |  | ||||||
|         //         });
 |  | ||||||
|         //     }
 |  | ||||||
|         // });
 |  | ||||||
| 
 |  | ||||||
|         // return contexts;
 |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -243,7 +233,7 @@ export class CoreFilterHelperProvider { | |||||||
|                 const getFilters = this.getCourseContexts.bind(this, instanceId, siteId); |                 const getFilters = this.getCourseContexts.bind(this, instanceId, siteId); | ||||||
| 
 | 
 | ||||||
|                 return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); |                 return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); | ||||||
|             } else if (contextLevel == 'block' && options.courseId) { // @todo && this.courseProvider.canGetCourseBlocks(site)
 |             } else if (contextLevel == 'block' && options.courseId && CoreCourse.instance.canGetCourseBlocks(site)) { | ||||||
|                 // Get all the course blocks filters with a single call to decrease number of WS calls.
 |                 // Get all the course blocks filters with a single call to decrease number of WS calls.
 | ||||||
|                 const getFilters = this.getBlocksContexts.bind(this, options.courseId, siteId); |                 const getFilters = this.getBlocksContexts.bind(this, options.courseId, siteId); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ import { CoreEventObserver, CoreEvents, CoreEventSiteUpdatedData } from '@single | |||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| // import { CoreSplitViewComponent } from '@components/split-view/split-view';
 | // import { CoreSplitViewComponent } from '@components/split-view/split-view';
 | ||||||
| // import { CoreSharedFiles } from '@features/sharedfiles/providers/sharedfiles';
 | // import { CoreSharedFiles } from '@features/sharedfiles/services/sharedfiles';
 | ||||||
| import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../services/settings-helper'; | import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../services/settings-helper'; | ||||||
| import { CoreApp } from '@services/app'; | import { CoreApp } from '@services/app'; | ||||||
| import { CoreSiteInfo } from '@classes/site'; | import { CoreSiteInfo } from '@classes/site'; | ||||||
|  | |||||||
| @ -22,7 +22,7 @@ import { CoreSites } from '@services/sites'; | |||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { CoreConstants } from '@/core/constants'; | import { CoreConstants } from '@/core/constants'; | ||||||
| import { CoreConfig } from '@services/config'; | import { CoreConfig } from '@services/config'; | ||||||
| // import { CoreFilterProvider } from '@features/filter/providers/filter';
 | import { CoreFilter } from '@features/filter/services/filter'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreCourse } from '@features/course/services/course'; | import { CoreCourse } from '@features/course/services/course'; | ||||||
| import { makeSingleton, Translate } from '@singletons'; | import { makeSingleton, Translate } from '@singletons'; | ||||||
| @ -55,8 +55,6 @@ export class CoreSettingsHelperProvider { | |||||||
|     protected prefersDark?: MediaQueryList; |     protected prefersDark?: MediaQueryList; | ||||||
| 
 | 
 | ||||||
|     constructor() { |     constructor() { | ||||||
|         // protected filterProvider: CoreFilterProvider,
 |  | ||||||
| 
 |  | ||||||
|         if (!CoreConstants.CONFIG.forceColorScheme) { |         if (!CoreConstants.CONFIG.forceColorScheme) { | ||||||
|             // Update color scheme when a user enters or leaves a site, or when the site info is updated.
 |             // Update color scheme when a user enters or leaves a site, or when the site info is updated.
 | ||||||
|             const applySiteScheme = (): void => { |             const applySiteScheme = (): void => { | ||||||
| @ -87,7 +85,6 @@ export class CoreSettingsHelperProvider { | |||||||
|      * @param siteName Site Name. |      * @param siteName Site Name. | ||||||
|      * @param siteId: Site ID. |      * @param siteId: Site ID. | ||||||
|      * @return Resolved with detailed new info when done. |      * @return Resolved with detailed new info when done. | ||||||
|      * @todo filterProvider and courseProviderpart. |  | ||||||
|      */ |      */ | ||||||
|     async deleteSiteStorage(siteName: string, siteId: string): Promise<CoreSiteSpaceUsage> { |     async deleteSiteStorage(siteName: string, siteId: string): Promise<CoreSiteSpaceUsage> { | ||||||
|         const siteInfo: CoreSiteSpaceUsage = { |         const siteInfo: CoreSiteSpaceUsage = { | ||||||
| @ -95,7 +92,7 @@ export class CoreSettingsHelperProvider { | |||||||
|             spaceUsage: 0, |             spaceUsage: 0, | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         // siteName = await this.filterProvider.formatText(siteName, { clean: true, singleLine: true, filter: false }, [], siteId);
 |         siteName = await CoreFilter.instance.formatText(siteName, { clean: true, singleLine: true, filter: false }, [], siteId); | ||||||
| 
 | 
 | ||||||
|         const title = Translate.instance.instant('core.settings.deletesitefilestitle'); |         const title = Translate.instance.instant('core.settings.deletesitefilestitle'); | ||||||
|         const message = Translate.instance.instant('core.settings.deletesitefiles', { sitename: siteName }); |         const message = Translate.instance.instant('core.settings.deletesitefiles', { sitename: siteName }); | ||||||
| @ -187,16 +184,16 @@ export class CoreSettingsHelperProvider { | |||||||
|      * @param name Name of the processor to get. |      * @param name Name of the processor to get. | ||||||
|      * @param fallback True to return first processor if not found, false to not return any. Defaults to true. |      * @param fallback True to return first processor if not found, false to not return any. Defaults to true. | ||||||
|      * @return Processor. |      * @return Processor. | ||||||
|      * @todo |      * @todo typings | ||||||
|      */ |      */ | ||||||
|     getProcessor(processors: any[], name: string, fallback: boolean = true): any { |     getProcessor(processors: any[], name: string, fallback: boolean = true): any { | ||||||
|         if (!processors || !processors.length) { |         if (!processors || !processors.length) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         for (let i = 0; i < processors.length; i++) { | 
 | ||||||
|             if (processors[i].name == name) { |         const processor = processors.find((processor) => processor.name == name); | ||||||
|                 return processors[i]; |         if (processor) { | ||||||
|             } |             return processor; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Processor not found, return first if requested.
 |         // Processor not found, return first if requested.
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user