diff --git a/src/addon/mod/data/components/index/index.ts b/src/addon/mod/data/components/index/index.ts index 1df731973..3f79e9972 100644 --- a/src/addon/mod/data/components/index/index.ts +++ b/src/addon/mod/data/components/index/index.ts @@ -260,6 +260,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp sort: Number(this.search.sortBy), order: this.search.sortDirection, page: this.search.page, + cmId: this.module.id, }).then((entries) => { const numEntries = entries.entries.length; const numOfflineEntries = entries.offlineEntries.length; diff --git a/src/addon/mod/data/providers/data.ts b/src/addon/mod/data/providers/data.ts index 553f37b54..26d55fbc3 100644 --- a/src/addon/mod/data/providers/data.ts +++ b/src/addon/mod/data/providers/data.ts @@ -608,8 +608,11 @@ export class AddonModDataProvider { */ getDatabaseAccessInformation(dataId: number, options: AddonModDataAccessInfoOptions = {}): Promise { return this.sitesProvider.getSite(options.siteId).then((site) => { + options.groupId = options.groupId || 0; + const params = { databaseid: dataId, + groupid: options.groupId, }; const preSets = { cacheKey: this.getDatabaseAccessInformationDataCacheKey(dataId, options.groupId), @@ -618,10 +621,6 @@ export class AddonModDataProvider { ...this.sitesProvider.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. }; - if (typeof options.groupId !== 'undefined') { - params['groupid'] = options.groupId; - } - return site.read('mod_data_get_data_access_information', params, preSets); }); } @@ -636,7 +635,7 @@ export class AddonModDataProvider { getEntries(dataId: number, options: AddonModDataGetEntriesOptions = {}): Promise { options.groupId = options.groupId || 0; options.sort = options.sort || 0; - options.order || options.order || 'DESC'; + options.order = options.order || 'DESC'; options.page = options.page || 0; options.perPage = options.perPage || AddonModDataProvider.PER_PAGE; diff --git a/src/addon/mod/data/providers/prefetch-handler.ts b/src/addon/mod/data/providers/prefetch-handler.ts index 4355a8fe6..a2aded865 100644 --- a/src/addon/mod/data/providers/prefetch-handler.ts +++ b/src/addon/mod/data/providers/prefetch-handler.ts @@ -22,7 +22,7 @@ import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreGroupsProvider } from '@providers/groups'; import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreCommentsProvider } from '@core/comments/providers/comments'; -import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreCourseProvider, CoreCourseCommonModWSOptions } from '@core/course/providers/course'; import { CoreCourseActivityPrefetchHandlerBase } from '@core/course/classes/activity-prefetch-handler'; import { AddonModDataProvider, AddonModDataEntry } from './data'; import { AddonModDataSyncProvider } from './sync'; @@ -100,13 +100,14 @@ export class AddonModDataPrefetchHandler extends CoreCourseActivityPrefetchHandl * @param options Other options. * @return Promise resolved with the info fetched. */ - protected getDatabaseInfoHelper(module: any, courseId: number, omitFail: boolean, options: CoreSitesCommonWSOptions = {}) + protected getDatabaseInfoHelper(module: any, courseId: number, omitFail: boolean, options: CoreCourseCommonModWSOptions = {}) : Promise { let database, groups = [], entries = [], files = []; + options.cmId = options.cmId || module.id; options.siteId = options.siteId || this.sitesProvider.getCurrentSiteId(); return this.dataProvider.getDatabase(courseId, module.id, options).then((data) => {