👋 WELCOME to HypeXAPI
How are we doing it?
Sending a statement
8min
there are a few ways to send a statement to your lrs with hype i'm a low code developer, so i wanted to create a way for us to send statements without having to work with code directly method 1 we prepared an export script to use with the hypexapi extension an export script adds more functionality to the actions menu, designed specifically for hypexapi how do you load the hypexapi export script? to download the export script, go to this url https //github com/worldoptimizer/hypexapi https //github com/worldoptimizer/hypexapi the file is called hypexapi hype export py after you downloaded and unzipped the content open hype > go to ' preferences ' (cmd,) > select ' exporting ' > select ' show export scripts folder in finder ' > open the highlighted folder in finder > drag the ' hypexapi hype export py ' file into the opened folder > close the preferences window after you've completed loading the hypexapi export script, you have three more options in the action panel decide where and how you want to trigger an xapi statement for example, on a button click select "send statement " from the actions drop down this will give you the option to add your xapi syntax for your statement choose a verb and an object from your hypexapi dictionary adding a result and context from the dictionary is optional that's it your statement is ready to be sent preview your project when you send a statement with this method (export script), make sure that you trigger the send statement action when there isn't an animation happening in your project this method blocks js untill the statement is sent or fails method 2 the other way to send an xapi statement to your lrs, is by using the additional html attributes panel in the information panel in the image below, you can see how to bind your xapi syntax to an element in your project as you can see in the image, these attributes are tied to a button after you've done this, go to the actions tab and run javascript on an action run this code inside the function function sendstatementbydataset (hypedocument, element, event){ hypexapi sendstatementbydataset(element); } that's it your statement is ready to be sent preview your project echo in the tutorial on this page, you saw that the statement echos back in the console from the lrs that is convenient, as i don't have to go and check in my lrs whether the statements was received, or not when it appears in the console it was received by the lrs and echoed back into your browser as with method 2, you have to include the key and value data xapi debug\ echo in your statement for this to happen in your hypexapi() function that holds your xapi syntax you also need to include the following code snippet for the echo to run a good place for it to be is right before the closing curly bracket '}' of the hypexapi() function then it is out of the way, yet very helpful hypexapi setdefault('debug', true); i advise that you comment this line of code out before you do your final export less noise in the console