Empty Response From Multichoice Questions
So I’m looking at the H5P API documentation for the answered multichoice question on an interactive video.
And I'm trying to figure something out. If you log event.data.statement.result.response after the user hits the check button, you’re supposed to get the user response. According to the documentation.
result.response:
The ids of the users answers where multiple alternatives are separated by “[,]“, for instance: “1[,]3” if the user answered the first and third alternatives in the way they are ordered in the editor
But for some reason I don’t understand I only get an empty string. Can anyone help me? It's been a big blocker for my project.
A rough version of what I'm trying to do is below.
H5P.externalDispatcher.on('xAPI', function (event) {
if(event.data.statement.result.completion == true){
console.log(event.data.statement.result.response);
}
}
otacke
Tue, 05/29/2018 - 19:17
Permalink
Hi Shawn!First of all, you
Hi Shawn!
First of all, you should hit a couple of errors unless you click on check right away (which in fact will return an empty string, because no option was chosen). The result property is optional and should be checked. The same is true for the response property, even if the result property is set.
And that seems to be working quite fine here on h5p.org.
Best,
Oliver
shawnbuddy
Mon, 06/04/2018 - 20:32
Permalink
Thank You
Hi Oliver. I tried your code and it worked perfectly. However, the client has a new requirement that the questions no longer be in random order, and when I disable that option that the response I get is now an empty string. Any ideas?
otacke
Tue, 06/05/2018 - 09:16
Permalink
Hi Shawn!Hard to say without
Hi Shawn!
Hard to say without knowing your code. The snippet that I posted before should work fine though, because turning off the randomize option will only change the order of the object.definition.choices array, but not the response object.
Best,
Oliver