2.0.27855 • Published 2 years ago
strongmind-lti_provider_client v2.0.27855
#Introduction The LTI Provider Client provides a client api that is used to communicate with the LTI Provider endpoint.
#Getting Started 1. Installation process npm install lti_provider_client 2. API references configureClient(onLaunchFunction) -> Invoked on lti consumer launch passing the lti parameters PostScore(score) -> Passes a score back to the lti consumer.
#Usage Example for Aurelia First we want to initialize the lti client.
import { inject } from 'aurelia-framework';
import {LtiProviderClientService} from 'lti-client'
@inject(LtiProviderClientService)
export class App {
constructor(token, ltiClient) {
this.ltiClient = ltiClient;
}
//We use the attached lifecycle to configure the lti client and to pass the function to call when the consumer launches the tool.
<b>
attached() {
this.ltiClient.configureClient(launchParams => {
let toast = launchParams;
});
}
</b>
}
Then to post scores back...
import { inject } from 'aurelia-framework';
import {LtiProviderClientService} from 'lti-client'
@inject(LtiProviderClientService)
export class Player
{
constructor(lti){
this.lti = lti;
}
<b>
postScore(score){
//The PostScore function takes a double and will call the outcomes url on the Consumer.
this.lti.PostScore(score);
}
</b>
}
Custom Messages
import { inject } from 'aurelia-framework';
import {LtiProviderClientService} from 'lti-client'
@inject(LtiProviderClientService)
export class Player
{
constructor(lti){
this.lti = lti;
}
<b>
sendMessage(score){
//The SendCustomMessage will send data through to the lti provider parent window
this.lti.SendCustomMessage(<any json or string>);
}
</b>
}
2.0.27855
2 years ago