Merge pull request #1570 from dpalou/MOBILE-2502
MOBILE-2502 course: Don't pass includestealth if not supportedmain
commit
409bb0fde3
|
@ -195,7 +195,8 @@ export class CoreSite {
|
||||||
3.1: 2016052300,
|
3.1: 2016052300,
|
||||||
3.2: 2016120500,
|
3.2: 2016120500,
|
||||||
3.3: 2017051503,
|
3.3: 2017051503,
|
||||||
3.4: 2017111300
|
3.4: 2017111300,
|
||||||
|
3.5: 2018051700
|
||||||
};
|
};
|
||||||
|
|
||||||
// Rest of variables.
|
// Rest of variables.
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { CoreLoggerProvider } from '@providers/logger';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||||
import { CoreSiteWSPreSets } from '@classes/site';
|
import { CoreSiteWSPreSets, CoreSite } from '@classes/site';
|
||||||
import { CoreConstants } from '../../constants';
|
import { CoreConstants } from '../../constants';
|
||||||
import { CoreCourseOfflineProvider } from './course-offline';
|
import { CoreCourseOfflineProvider } from './course-offline';
|
||||||
|
|
||||||
|
@ -85,6 +85,18 @@ export class CoreCourseProvider {
|
||||||
this.sitesProvider.createTableFromSchema(this.courseStatusTableSchema);
|
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,
|
* 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.
|
* 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 = {
|
const params: any = {
|
||||||
courseid: courseId,
|
courseid: courseId,
|
||||||
options: [
|
options: []
|
||||||
{
|
|
||||||
name: 'includestealthmodules',
|
|
||||||
value: 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
preSets: any = {
|
preSets: any = {
|
||||||
omitExpires: preferCache
|
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 is set, retrieve all modules of that type. Otherwise get only the module.
|
||||||
if (modName) {
|
if (modName) {
|
||||||
params.options.push({
|
params.options.push({
|
||||||
|
@ -527,14 +541,17 @@ export class CoreCourseProvider {
|
||||||
{
|
{
|
||||||
name: 'excludecontents',
|
name: 'excludecontents',
|
||||||
value: excludeContents ? 1 : 0
|
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(() => {
|
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.
|
// 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.
|
// Retry without the new parameter and forcing cache.
|
||||||
|
|
Loading…
Reference in New Issue