MOBILE-2346 lti: PR fixes
parent
519256b0bb
commit
11b1a55e04
|
@ -3,7 +3,7 @@
|
|||
<core-context-menu>
|
||||
<core-context-menu-item *ngIf="externalUrl" [priority]="900" [content]="'core.openinbrowser' | translate" [href]="externalUrl" [iconAction]="'open'"></core-context-menu-item>
|
||||
<core-context-menu-item *ngIf="description" [priority]="800" [content]="'core.moduleintro' | translate" (action)="expandDescription()" [iconAction]="'arrow-forward'"></core-context-menu-item>
|
||||
<core-context-menu-item *ngIf="loaded && !hasOffline && isOnline" [priority]="700" [content]="'core.refresh' | translate" (action)="doRefresh(null, $event)" [iconAction]="refreshIcon" [closeOnClick]="false"></core-context-menu-item>
|
||||
<core-context-menu-item *ngIf="loaded && isOnline" [priority]="700" [content]="'core.refresh' | translate" (action)="doRefresh(null, $event)" [iconAction]="refreshIcon" [closeOnClick]="false"></core-context-menu-item>
|
||||
</core-context-menu>
|
||||
</core-navbar-buttons>
|
||||
|
||||
|
@ -12,12 +12,10 @@
|
|||
|
||||
<core-course-module-description [description]="description" [component]="component" [componentId]="componentId"></core-course-module-description>
|
||||
|
||||
<div padding-horizontal *ngIf="isValidUrl">
|
||||
<div padding-horizontal>
|
||||
<button ion-button block icon-left (click)="launch()">
|
||||
<ion-icon name="link"></ion-icon>
|
||||
{{ 'addon.mod_lti.launchactivity' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<ion-card class="core-info-card" *ngIf="!isValidUrl">{{ 'addon.mod_lti.errorinvalidlaunchurl' | translate }}</ion-card>
|
||||
</core-loading>
|
||||
|
|
|
@ -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<any> {
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,5 +8,9 @@
|
|||
</ion-navbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
<ion-refresher [enabled]="ltiComponent.loaded" (ionRefresh)="ltiComponent.doRefresh($event)">
|
||||
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
||||
</ion-refresher>
|
||||
|
||||
<addon-mod-lti-index [module]="module" [courseId]="courseId" (dataRetrieved)="updateData($event)"></addon-mod-lti-index>
|
||||
</ion-content>
|
||||
|
|
|
@ -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<any>} Promise resolved when the WS call is successful.
|
||||
*/
|
||||
logView(id: string): Promise<any> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue