MOBILE-3724 lti: Launch in browser by default in 3.11+
parent
b4368d8aa6
commit
a511b6d104
|
@ -61,7 +61,7 @@ export class AddonModLtiHelperProvider {
|
||||||
const modal = await CoreDomUtils.showModalLoading();
|
const modal = await CoreDomUtils.showModalLoading();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const openInBrowser = await AddonModLti.isOpenInAppBrowserDisabled(siteId);
|
const openInBrowser = await AddonModLti.shouldLaunchInBrowser(siteId);
|
||||||
|
|
||||||
if (openInBrowser) {
|
if (openInBrowser) {
|
||||||
const site = await CoreSites.getSite(siteId);
|
const site = await CoreSites.getSite(siteId);
|
||||||
|
|
|
@ -184,8 +184,35 @@ export class AddonModLtiProvider {
|
||||||
await site.invalidateWsCacheForKey(this.getLtiLaunchDataCacheKey(id));
|
await site.invalidateWsCacheForKey(this.getLtiLaunchDataCacheKey(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if open LTI in browser via site with auto-login is disabled.
|
||||||
|
* This setting was added in 3.11.
|
||||||
|
*
|
||||||
|
* @param siteId Site ID. If not defined, current site.
|
||||||
|
* @return Promise resolved with boolean: whether it's disabled.
|
||||||
|
*/
|
||||||
|
async isLaunchViaSiteDisabled(siteId?: string): Promise<boolean> {
|
||||||
|
const site = await CoreSites.getSite(siteId);
|
||||||
|
|
||||||
|
return this.isLaunchViaSiteDisabledInSite(site);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if open LTI in browser via site with auto-login is disabled.
|
||||||
|
* This setting was added in 3.11.
|
||||||
|
*
|
||||||
|
* @param site Site. If not defined, current site.
|
||||||
|
* @return Whether it's disabled.
|
||||||
|
*/
|
||||||
|
isLaunchViaSiteDisabledInSite(site?: CoreSite): boolean {
|
||||||
|
site = site || CoreSites.getCurrentSite();
|
||||||
|
|
||||||
|
return !!site?.isFeatureDisabled('CoreCourseModuleDelegate_AddonModLti:launchViaSite');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if open in InAppBrowser is disabled.
|
* Check if open in InAppBrowser is disabled.
|
||||||
|
* This setting was removed in Moodle 3.11 because the default behaviour of the app changed.
|
||||||
*
|
*
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @return Promise resolved with boolean: whether it's disabled.
|
* @return Promise resolved with boolean: whether it's disabled.
|
||||||
|
@ -198,6 +225,7 @@ export class AddonModLtiProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if open in InAppBrowser is disabled.
|
* Check if open in InAppBrowser is disabled.
|
||||||
|
* This setting was removed in Moodle 3.11 because the default behaviour of the app changed.
|
||||||
*
|
*
|
||||||
* @param site Site. If not defined, current site.
|
* @param site Site. If not defined, current site.
|
||||||
* @return Whether it's disabled.
|
* @return Whether it's disabled.
|
||||||
|
@ -239,7 +267,7 @@ export class AddonModLtiProvider {
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @return Promise resolved when the WS call is successful.
|
* @return Promise resolved when the WS call is successful.
|
||||||
*/
|
*/
|
||||||
logView(id: number, name?: string, siteId?: string): Promise<any> {
|
logView(id: number, name?: string, siteId?: string): Promise<void> {
|
||||||
const params: AddonModLtiViewLtiWSParams = {
|
const params: AddonModLtiViewLtiWSParams = {
|
||||||
ltiid: id,
|
ltiid: id,
|
||||||
};
|
};
|
||||||
|
@ -256,6 +284,24 @@ export class AddonModLtiProvider {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the LTI should be launched in browser via the site with auto-login.
|
||||||
|
*
|
||||||
|
* @param siteId Site ID.
|
||||||
|
* @return Promise resolved with boolean.
|
||||||
|
*/
|
||||||
|
async shouldLaunchInBrowser(siteId?: string): Promise<boolean> {
|
||||||
|
const site = await CoreSites.getSite(siteId);
|
||||||
|
|
||||||
|
if (site.isVersionGreaterEqualThan('3.11')) {
|
||||||
|
// In 3.11+, launch in browser by default unless it's disabled.
|
||||||
|
return !this.isLaunchViaSiteDisabledInSite(site);
|
||||||
|
} else {
|
||||||
|
// In old sites the default behaviour is to launch in InAppBrowser.
|
||||||
|
return this.isOpenInAppBrowserDisabledInSite(site);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AddonModLti = makeSingleton(AddonModLtiProvider);
|
export const AddonModLti = makeSingleton(AddonModLtiProvider);
|
||||||
|
|
|
@ -79,6 +79,7 @@ export class CoreSite {
|
||||||
'3.8': 2019111800,
|
'3.8': 2019111800,
|
||||||
'3.9': 2020061500,
|
'3.9': 2020061500,
|
||||||
'3.10': 2020110900,
|
'3.10': 2020110900,
|
||||||
|
'3.11': 2021051000, // @todo: Replace with the right version once it's released.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Possible cache update frequencies.
|
// Possible cache update frequencies.
|
||||||
|
|
Loading…
Reference in New Issue