diff --git a/src/addon/mod/lti/components/index/index.html b/src/addon/mod/lti/components/index/index.html
index e80a89554..049830e41 100644
--- a/src/addon/mod/lti/components/index/index.html
+++ b/src/addon/mod/lti/components/index/index.html
@@ -3,7 +3,7 @@
-
+
@@ -12,12 +12,10 @@
-
+
-
-
{{ 'addon.mod_lti.errorinvalidlaunchurl' | translate }}
diff --git a/src/addon/mod/lti/components/index/index.ts b/src/addon/mod/lti/components/index/index.ts
index 4c81f8786..8f0168a99 100644
--- a/src/addon/mod/lti/components/index/index.ts
+++ b/src/addon/mod/lti/components/index/index.ts
@@ -14,7 +14,6 @@
import { Component, Optional, Injector } from '@angular/core';
import { Content } from 'ionic-angular';
-import { CoreUrlUtilsProvider } from '@providers/utils/url';
import { CoreCourseModuleMainActivityComponent } from '@core/course/classes/main-activity-component';
import { AddonModLtiProvider } from '../../providers/lti';
@@ -30,14 +29,12 @@ export class AddonModLtiIndexComponent extends CoreCourseModuleMainActivityCompo
moduleName = 'lti';
lti: any; // The LTI object.
- isValidUrl: boolean;
protected fetchContentDefaultError = 'addon.mod_lti.errorgetlti';
constructor(injector: Injector,
@Optional() protected content: Content,
- private ltiProvider: AddonModLtiProvider,
- private urlUtils: CoreUrlUtilsProvider) {
+ private ltiProvider: AddonModLtiProvider) {
super(injector, content);
}
@@ -47,7 +44,7 @@ export class AddonModLtiIndexComponent extends CoreCourseModuleMainActivityCompo
ngOnInit(): void {
super.ngOnInit();
- this.loadContent(false, true);
+ this.loadContent();
}
/**
@@ -68,13 +65,8 @@ export class AddonModLtiIndexComponent extends CoreCourseModuleMainActivityCompo
protected fetchContent(refresh: boolean = false, sync: boolean = false, showErrors: boolean = false): Promise
{
return this.ltiProvider.getLti(this.courseId, this.module.id).then((ltiData) => {
this.lti = ltiData;
-
- return this.ltiProvider.getLtiLaunchData(ltiData.id).then((launchData) => {
- this.lti.launchdata = launchData;
- this.description = this.lti.intro || this.description;
- this.isValidUrl = this.urlUtils.isHttpURL(launchData.endpoint);
- this.dataRetrieved.emit(this.lti);
- });
+ this.description = this.lti.intro || this.description;
+ this.dataRetrieved.emit(this.lti);
}).then(() => {
// All data obtained, now fill the context menu.
this.fillContextMenu(refresh);
@@ -101,18 +93,18 @@ export class AddonModLtiIndexComponent extends CoreCourseModuleMainActivityCompo
* Launch the LTI.
*/
launch(): void {
- // "View" LTI.
- this.ltiProvider.logView(this.lti.id).then(() => {
- this.checkCompletion();
- }).catch((error) => {
- // Ignore errors.
- });
+ this.ltiProvider.getLtiLaunchData(this.lti.id).then((launchData) => {
+ // "View" LTI.
+ this.ltiProvider.logView(this.lti.id).then(() => {
+ this.checkCompletion();
+ }).catch((error) => {
+ // Ignore errors.
+ });
- // Launch LTI.
- this.ltiProvider.launch(this.lti.launchdata.endpoint, this.lti.launchdata.parameters).catch((message) => {
- if (message) {
- this.domUtils.showErrorModal(message);
- }
+ // Launch LTI.
+ return this.ltiProvider.launch(launchData.endpoint, launchData.parameters);
+ }).catch((message) => {
+ this.domUtils.showErrorModalDefault(message, 'core.error', true);
});
}
}
diff --git a/src/addon/mod/lti/pages/index/index.html b/src/addon/mod/lti/pages/index/index.html
index 456646402..ffcf3f1f0 100644
--- a/src/addon/mod/lti/pages/index/index.html
+++ b/src/addon/mod/lti/pages/index/index.html
@@ -8,5 +8,9 @@
+
+
+
+
diff --git a/src/addon/mod/lti/providers/lti.ts b/src/addon/mod/lti/providers/lti.ts
index be87ee4ac..f2a453ce6 100644
--- a/src/addon/mod/lti/providers/lti.ts
+++ b/src/addon/mod/lti/providers/lti.ts
@@ -135,7 +135,12 @@ export class AddonModLtiProvider {
const params: any = {
toolid: id
};
+
+ // Try to avoid using cache since the "nonce" parameter is set to a timestamp.
const preSets = {
+ getFromCache: false,
+ saveToCache: true,
+ emergencyCache: true,
cacheKey: this.getLtiLaunchDataCacheKey(id)
};
@@ -192,7 +197,7 @@ export class AddonModLtiProvider {
// Generate launcher and open it.
return this.generateLauncher(url, params).then((url) => {
- this.utils.openInApp(url).show();
+ this.utils.openInApp(url);
});
}
@@ -203,14 +208,10 @@ export class AddonModLtiProvider {
* @return {Promise} Promise resolved when the WS call is successful.
*/
logView(id: string): Promise {
- if (id) {
- const params: any = {
- ltiid: id
- };
+ const params: any = {
+ ltiid: id
+ };
- return this.sitesProvider.getCurrentSite().write('mod_lti_view_lti', params);
- }
-
- return Promise.reject(null);
+ return this.sitesProvider.getCurrentSite().write('mod_lti_view_lti', params);
}
}