MOBILE-3608 core: Implement missing parts of Course and filters
parent
d0af70be5a
commit
f8320f6b58
|
@ -16,7 +16,7 @@ import { CoreContentLinksAction } from '../services/contentlinks-delegate';
|
|||
import { CoreContentLinksHandlerBase } from './base-handler';
|
||||
import { CoreSites } from '@services/sites';
|
||||
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';
|
||||
|
||||
/**
|
||||
|
@ -77,7 +77,7 @@ export class CoreContentLinksModuleGradeHandler extends CoreContentLinksHandlerB
|
|||
const site = await CoreSites.instance.getSite(siteId);
|
||||
if (!params.userid || params.userid == site.getUserId()) {
|
||||
// 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);
|
||||
} else if (this.canReview) {
|
||||
// Use the goToReview function.
|
||||
|
|
|
@ -17,7 +17,7 @@ import { PopoverController } from '@ionic/angular';
|
|||
import { CoreEventCourseStatusChanged, CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreSites } from '@services/sites';
|
||||
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 { CoreCourse, CoreCourseProvider } from '@features/course/services/course';
|
||||
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.
|
||||
*
|
||||
* @param hide True to hide and false to show.
|
||||
* @todo
|
||||
* @todo CoreUser
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
protected setCourseHidden(hide: boolean): void {
|
||||
|
@ -263,7 +263,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
|
|||
* Favourite/Unfavourite the course from the course list.
|
||||
*
|
||||
* @param favourite True to favourite and false to unfavourite.
|
||||
* @todo
|
||||
* @todo CoreUser
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
protected setCourseFavourite(favourite: boolean): void {
|
||||
|
|
|
@ -24,8 +24,8 @@ import {
|
|||
CoreFilterClassifiedFilters,
|
||||
CoreFiltersGetAvailableInContextWSParamContext,
|
||||
} from './filter';
|
||||
// import { CoreCourseProvider } from '@features/course/providers/course';
|
||||
// import { CoreCoursesProvider } from '@features/courses/providers/courses';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourses } from '@features/courses/services/courses';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreEvents, CoreEventSiteData } from '@singletons/events';
|
||||
import { CoreLogger } from '@singletons/logger';
|
||||
|
@ -73,22 +73,19 @@ export class CoreFilterHelperProvider {
|
|||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the contexts.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async getBlocksContexts(courseId: number, siteId?: string): Promise<CoreFiltersGetAvailableInContextWSParamContext[]> {
|
||||
return [];
|
||||
// @todo
|
||||
// const blocks = await this.courseProvider.getCourseBlocks(courseId, siteId);
|
||||
const blocks = await CoreCourse.instance.getCourseBlocks(courseId, siteId);
|
||||
|
||||
// const contexts: CoreFiltersGetAvailableInContextWSParamContext[] = [];
|
||||
const contexts: CoreFiltersGetAvailableInContextWSParamContext[] = [];
|
||||
|
||||
// blocks.forEach((block) => {
|
||||
// contexts.push({
|
||||
// contextlevel: 'block',
|
||||
// instanceid: block.instanceid,
|
||||
// });
|
||||
// });
|
||||
blocks.forEach((block) => {
|
||||
contexts.push({
|
||||
contextlevel: 'block',
|
||||
instanceid: block.instanceid,
|
||||
});
|
||||
});
|
||||
|
||||
// return contexts;
|
||||
return contexts;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,22 +129,19 @@ export class CoreFilterHelperProvider {
|
|||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the contexts.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async getCourseContexts(courseId: number, siteId?: string): Promise<CoreFiltersGetAvailableInContextWSParamContext[]> {
|
||||
// @todo
|
||||
return [];
|
||||
// const courseIds = await this.coursesProvider.getCourseIdsIfEnrolled(courseId, siteId);
|
||||
const courseIds = await CoreCourses.instance.getCourseIdsIfEnrolled(courseId, siteId);
|
||||
|
||||
// const contexts: CoreFiltersGetAvailableInContextWSParamContext[] = [];
|
||||
const contexts: CoreFiltersGetAvailableInContextWSParamContext[] = [];
|
||||
|
||||
// courseIds.forEach((courseId) => {
|
||||
// contexts.push({
|
||||
// contextlevel: 'course',
|
||||
// instanceid: courseId
|
||||
// });
|
||||
// });
|
||||
courseIds.forEach((courseId) => {
|
||||
contexts.push({
|
||||
contextlevel: 'course',
|
||||
instanceid: courseId,
|
||||
});
|
||||
});
|
||||
|
||||
// return contexts;
|
||||
return contexts;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,29 +151,25 @@ export class CoreFilterHelperProvider {
|
|||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Promise resolved with the contexts.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async getCourseModulesContexts(courseId: number, siteId?: string): Promise<CoreFiltersGetAvailableInContextWSParamContext[]> {
|
||||
// @todo
|
||||
return [];
|
||||
const sections = await CoreCourse.instance.getSections(courseId, false, true, undefined, siteId);
|
||||
|
||||
// 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) => {
|
||||
// if (section.modules) {
|
||||
// section.modules.forEach((module) => {
|
||||
// if (module.uservisible) {
|
||||
// contexts.push({
|
||||
// contextlevel: 'module',
|
||||
// instanceid: module.id
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
// return contexts;
|
||||
return contexts;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -243,7 +233,7 @@ export class CoreFilterHelperProvider {
|
|||
const getFilters = this.getCourseContexts.bind(this, instanceId, siteId);
|
||||
|
||||
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.
|
||||
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 { CoreDomUtils } from '@services/utils/dom';
|
||||
// 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 { CoreApp } from '@services/app';
|
||||
import { CoreSiteInfo } from '@classes/site';
|
||||
|
|
|
@ -22,7 +22,7 @@ import { CoreSites } from '@services/sites';
|
|||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreConstants } from '@/core/constants';
|
||||
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 { CoreCourse } from '@features/course/services/course';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
|
@ -55,8 +55,6 @@ export class CoreSettingsHelperProvider {
|
|||
protected prefersDark?: MediaQueryList;
|
||||
|
||||
constructor() {
|
||||
// protected filterProvider: CoreFilterProvider,
|
||||
|
||||
if (!CoreConstants.CONFIG.forceColorScheme) {
|
||||
// Update color scheme when a user enters or leaves a site, or when the site info is updated.
|
||||
const applySiteScheme = (): void => {
|
||||
|
@ -87,7 +85,6 @@ export class CoreSettingsHelperProvider {
|
|||
* @param siteName Site Name.
|
||||
* @param siteId: Site ID.
|
||||
* @return Resolved with detailed new info when done.
|
||||
* @todo filterProvider and courseProviderpart.
|
||||
*/
|
||||
async deleteSiteStorage(siteName: string, siteId: string): Promise<CoreSiteSpaceUsage> {
|
||||
const siteInfo: CoreSiteSpaceUsage = {
|
||||
|
@ -95,7 +92,7 @@ export class CoreSettingsHelperProvider {
|
|||
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 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 fallback True to return first processor if not found, false to not return any. Defaults to true.
|
||||
* @return Processor.
|
||||
* @todo
|
||||
* @todo typings
|
||||
*/
|
||||
getProcessor(processors: any[], name: string, fallback: boolean = true): any {
|
||||
if (!processors || !processors.length) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < processors.length; i++) {
|
||||
if (processors[i].name == name) {
|
||||
return processors[i];
|
||||
}
|
||||
|
||||
const processor = processors.find((processor) => processor.name == name);
|
||||
if (processor) {
|
||||
return processor;
|
||||
}
|
||||
|
||||
// Processor not found, return first if requested.
|
||||
|
|
Loading…
Reference in New Issue