MOBILE-2502 course: Don't pass includestealth if not supported
parent
f233dbf5b4
commit
c74b8bbcb3
|
@ -195,7 +195,8 @@ export class CoreSite {
|
|||
3.1: 2016052300,
|
||||
3.2: 2016120500,
|
||||
3.3: 2017051503,
|
||||
3.4: 2017111300
|
||||
3.4: 2017111300,
|
||||
3.5: 2018051700
|
||||
};
|
||||
|
||||
// Rest of variables.
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreLoggerProvider } from '@providers/logger';
|
|||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreSiteWSPreSets } from '@classes/site';
|
||||
import { CoreSiteWSPreSets, CoreSite } from '@classes/site';
|
||||
import { CoreConstants } from '../../constants';
|
||||
import { CoreCourseOfflineProvider } from './course-offline';
|
||||
|
||||
|
@ -85,6 +85,18 @@ export class CoreCourseProvider {
|
|||
this.sitesProvider.createTableFromSchema(this.courseStatusTableSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the site supports requesting stealth modules.
|
||||
*
|
||||
* @param {CoreSite} [site] Site. If not defined, current site.
|
||||
* @return {boolean} Whether the site supports requesting stealth modules.
|
||||
*/
|
||||
canRequestStealthModules(site?: CoreSite): boolean {
|
||||
site = site || this.sitesProvider.getCurrentSite();
|
||||
|
||||
return site.isVersionGreaterEqualThan(['3.4.6', '3.5.3']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if module completion could have changed. If it could have, trigger event. This function must be used,
|
||||
* for example, after calling a "module_view" WS since it can change the module completion.
|
||||
|
@ -269,17 +281,19 @@ export class CoreCourseProvider {
|
|||
|
||||
const params: any = {
|
||||
courseid: courseId,
|
||||
options: [
|
||||
{
|
||||
name: 'includestealthmodules',
|
||||
value: 1
|
||||
}
|
||||
]
|
||||
options: []
|
||||
},
|
||||
preSets: any = {
|
||||
omitExpires: preferCache
|
||||
};
|
||||
|
||||
if (this.canRequestStealthModules(site)) {
|
||||
params.options.push({
|
||||
name: 'includestealthmodules',
|
||||
value: 1
|
||||
});
|
||||
}
|
||||
|
||||
// If modName is set, retrieve all modules of that type. Otherwise get only the module.
|
||||
if (modName) {
|
||||
params.options.push({
|
||||
|
@ -527,14 +541,17 @@ export class CoreCourseProvider {
|
|||
{
|
||||
name: 'excludecontents',
|
||||
value: excludeContents ? 1 : 0
|
||||
},
|
||||
{
|
||||
name: 'includestealthmodules',
|
||||
value: includeStealthModules ? 1 : 0
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
if (this.canRequestStealthModules(site)) {
|
||||
params.options.push({
|
||||
name: 'includestealthmodules',
|
||||
value: includeStealthModules ? 1 : 0
|
||||
});
|
||||
}
|
||||
|
||||
return site.read('core_course_get_contents', params, preSets).catch(() => {
|
||||
// Error getting the data, it could fail because we added a new parameter and the call isn't cached.
|
||||
// Retry without the new parameter and forcing cache.
|
||||
|
|
Loading…
Reference in New Issue