MOBILE-3109 lti: Add return types to lti
parent
3647b7bfa0
commit
a2fbe1c808
|
@ -15,7 +15,7 @@
|
||||||
import { Component, Optional, Injector } from '@angular/core';
|
import { Component, Optional, Injector } from '@angular/core';
|
||||||
import { Content } from 'ionic-angular';
|
import { Content } from 'ionic-angular';
|
||||||
import { CoreCourseModuleMainActivityComponent } from '@core/course/classes/main-activity-component';
|
import { CoreCourseModuleMainActivityComponent } from '@core/course/classes/main-activity-component';
|
||||||
import { AddonModLtiProvider } from '../../providers/lti';
|
import { AddonModLtiProvider, AddonModLtiLti } from '../../providers/lti';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays an LTI entry page.
|
* Component that displays an LTI entry page.
|
||||||
|
@ -28,7 +28,7 @@ export class AddonModLtiIndexComponent extends CoreCourseModuleMainActivityCompo
|
||||||
component = AddonModLtiProvider.COMPONENT;
|
component = AddonModLtiProvider.COMPONENT;
|
||||||
moduleName = 'lti';
|
moduleName = 'lti';
|
||||||
|
|
||||||
lti: any; // The LTI object.
|
lti: AddonModLtiLti; // The LTI object.
|
||||||
|
|
||||||
protected fetchContentDefaultError = 'addon.mod_lti.errorgetlti';
|
protected fetchContentDefaultError = 'addon.mod_lti.errorgetlti';
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ export class AddonModLtiIndexComponent extends CoreCourseModuleMainActivityCompo
|
||||||
protected fetchContent(refresh: boolean = false, sync: boolean = false, showErrors: boolean = false): Promise<any> {
|
protected fetchContent(refresh: boolean = false, sync: boolean = false, showErrors: boolean = false): Promise<any> {
|
||||||
return this.ltiProvider.getLti(this.courseId, this.module.id).then((ltiData) => {
|
return this.ltiProvider.getLti(this.courseId, this.module.id).then((ltiData) => {
|
||||||
this.lti = ltiData;
|
this.lti = ltiData;
|
||||||
this.description = this.lti.intro || this.description;
|
this.description = this.lti.intro;
|
||||||
this.dataRetrieved.emit(this.lti);
|
this.dataRetrieved.emit(this.lti);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// All data obtained, now fill the context menu.
|
// All data obtained, now fill the context menu.
|
||||||
|
|
|
@ -22,11 +22,7 @@ import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||||
import { CoreUrlUtilsProvider } from '@providers/utils/url';
|
import { CoreUrlUtilsProvider } from '@providers/utils/url';
|
||||||
import { CoreCourseLogHelperProvider } from '@core/course/providers/log-helper';
|
import { CoreCourseLogHelperProvider } from '@core/course/providers/log-helper';
|
||||||
import { CoreSite } from '@classes/site';
|
import { CoreSite } from '@classes/site';
|
||||||
|
import { CoreWSExternalWarning, CoreWSExternalFile } from '@providers/ws';
|
||||||
export interface AddonModLtiParam {
|
|
||||||
name: string;
|
|
||||||
value: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service that provides some features for LTI.
|
* Service that provides some features for LTI.
|
||||||
|
@ -104,7 +100,7 @@ export class AddonModLtiProvider {
|
||||||
* @param cmId Course module ID.
|
* @param cmId Course module ID.
|
||||||
* @return Promise resolved when the LTI is retrieved.
|
* @return Promise resolved when the LTI is retrieved.
|
||||||
*/
|
*/
|
||||||
getLti(courseId: number, cmId: number): Promise<any> {
|
getLti(courseId: number, cmId: number): Promise<AddonModLtiLti> {
|
||||||
const params: any = {
|
const params: any = {
|
||||||
courseids: [courseId]
|
courseids: [courseId]
|
||||||
};
|
};
|
||||||
|
@ -113,7 +109,9 @@ export class AddonModLtiProvider {
|
||||||
updateFrequency: CoreSite.FREQUENCY_RARELY
|
updateFrequency: CoreSite.FREQUENCY_RARELY
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.sitesProvider.getCurrentSite().read('mod_lti_get_ltis_by_courses', params, preSets).then((response) => {
|
return this.sitesProvider.getCurrentSite().read('mod_lti_get_ltis_by_courses', params, preSets)
|
||||||
|
.then((response: AddonModLtiGetLtisByCoursesResult): any => {
|
||||||
|
|
||||||
if (response.ltis) {
|
if (response.ltis) {
|
||||||
const currentLti = response.ltis.find((lti) => lti.coursemodule == cmId);
|
const currentLti = response.ltis.find((lti) => lti.coursemodule == cmId);
|
||||||
if (currentLti) {
|
if (currentLti) {
|
||||||
|
@ -141,8 +139,8 @@ export class AddonModLtiProvider {
|
||||||
* @param id LTI id.
|
* @param id LTI id.
|
||||||
* @return Promise resolved when the launch data is retrieved.
|
* @return Promise resolved when the launch data is retrieved.
|
||||||
*/
|
*/
|
||||||
getLtiLaunchData(id: number): Promise<any> {
|
getLtiLaunchData(id: number): Promise<AddonModLtiGetToolLaunchDataResult> {
|
||||||
const params: any = {
|
const params = {
|
||||||
toolid: id
|
toolid: id
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -154,7 +152,9 @@ export class AddonModLtiProvider {
|
||||||
cacheKey: this.getLtiLaunchDataCacheKey(id)
|
cacheKey: this.getLtiLaunchDataCacheKey(id)
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.sitesProvider.getCurrentSite().read('mod_lti_get_tool_launch_data', params, preSets).then((response) => {
|
return this.sitesProvider.getCurrentSite().read('mod_lti_get_tool_launch_data', params, preSets)
|
||||||
|
.then((response: AddonModLtiGetToolLaunchDataResult): any => {
|
||||||
|
|
||||||
if (response.endpoint) {
|
if (response.endpoint) {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -227,3 +227,66 @@ export class AddonModLtiProvider {
|
||||||
return this.logHelper.logSingle('mod_lti_view_lti', params, AddonModLtiProvider.COMPONENT, id, name, 'lti', {}, siteId);
|
return this.logHelper.logSingle('mod_lti_view_lti', params, AddonModLtiProvider.COMPONENT, id, name, 'lti', {}, siteId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LTI returned by mod_lti_get_ltis_by_courses.
|
||||||
|
*/
|
||||||
|
export type AddonModLtiLti = {
|
||||||
|
id: number; // External tool id.
|
||||||
|
coursemodule: number; // Course module id.
|
||||||
|
course: number; // Course id.
|
||||||
|
name: string; // LTI name.
|
||||||
|
intro?: string; // The LTI intro.
|
||||||
|
introformat?: number; // Intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN).
|
||||||
|
introfiles?: CoreWSExternalFile[]; // @since 3.2.
|
||||||
|
timecreated?: number; // Time of creation.
|
||||||
|
timemodified?: number; // Time of last modification.
|
||||||
|
typeid?: number; // Type id.
|
||||||
|
toolurl?: string; // Tool url.
|
||||||
|
securetoolurl?: string; // Secure tool url.
|
||||||
|
instructorchoicesendname?: string; // Instructor choice send name.
|
||||||
|
instructorchoicesendemailaddr?: number; // Instructor choice send mail address.
|
||||||
|
instructorchoiceallowroster?: number; // Instructor choice allow roster.
|
||||||
|
instructorchoiceallowsetting?: number; // Instructor choice allow setting.
|
||||||
|
instructorcustomparameters?: string; // Instructor custom parameters.
|
||||||
|
instructorchoiceacceptgrades?: number; // Instructor choice accept grades.
|
||||||
|
grade?: number; // Enable grades.
|
||||||
|
launchcontainer?: number; // Launch container mode.
|
||||||
|
resourcekey?: string; // Resource key.
|
||||||
|
password?: string; // Shared secret.
|
||||||
|
debuglaunch?: number; // Debug launch.
|
||||||
|
showtitlelaunch?: number; // Show title launch.
|
||||||
|
showdescriptionlaunch?: number; // Show description launch.
|
||||||
|
servicesalt?: string; // Service salt.
|
||||||
|
icon?: string; // Alternative icon URL.
|
||||||
|
secureicon?: string; // Secure icon URL.
|
||||||
|
section?: number; // Course section id.
|
||||||
|
visible?: number; // Visible.
|
||||||
|
groupmode?: number; // Group mode.
|
||||||
|
groupingid?: number; // Group id.
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Param to send to the LTI.
|
||||||
|
*/
|
||||||
|
export type AddonModLtiParam = {
|
||||||
|
name: string; // Parameter name.
|
||||||
|
value: string; // Parameter value.
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result of WS mod_lti_get_ltis_by_courses.
|
||||||
|
*/
|
||||||
|
export type AddonModLtiGetLtisByCoursesResult = {
|
||||||
|
ltis: AddonModLtiLti[];
|
||||||
|
warnings?: CoreWSExternalWarning[];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result of WS mod_lti_get_tool_launch_data.
|
||||||
|
*/
|
||||||
|
export type AddonModLtiGetToolLaunchDataResult = {
|
||||||
|
endpoint: string; // Endpoint URL.
|
||||||
|
parameters: AddonModLtiParam[];
|
||||||
|
warnings?: CoreWSExternalWarning[];
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue