How to use the setFeedback() function
Submitted by papi Jo on Mon, 07/08/2019 - 23:49
Forums:
Hi!
I am working on a H5P content which is not a question type. At the end of the activity I need to display a score. I can use the scorebar without any problem, like this:
scoreBar = JoubelUI.createScoreBar(maxScore); scoreBar.setScore(actualScore); scoreBar.appendTo($feedback);
But I would like to add a score explanation to the score bar. I think that I need to use the setFeedback() function which resides in the H5P.Question-1.4 library. I have added it to my own library in the preloadedDependencies section.
But when I call the setFeedback() function (with the relevant parametres) I get this error message:
TypeError: this.setFeedback is not a function
What can I do? Thanks in advance.
otacke
Wed, 07/10/2019 - 10:47
Permalink
Hi Papi Jo!H5P.Question is
Hi Papi Jo!
H5P.Question is just a bunch of handy functions bundling common tasks (defining buttons, etc.) that you'd otherwise have to do manually - like setting up the score bar. It's not needed however. If I am not mistaken, the 4th parameter of JoubelUI.createScoreBar is what you are looking for and essentially only passes the arguments to the constructor of JoubelScoreBar.
If you want to switch to H5P.Question anyway: Your class (what this is referencing to) will have to extend H5P.Question so your class will inherit H5P.Question's functions. The basics are described in the readme.
Cheers,
Oliver
papi Jo
Wed, 07/10/2019 - 15:20
Permalink
Hi Oliver!
Thanks for your reply. Just what I needed! No need to use H5P.Question.
Joseph
otacke
Wed, 07/10/2019 - 18:08
Permalink
You're welcome!
You're welcome!
Degrange
Wed, 03/10/2021 - 02:16
Permalink
Note to future people reading
Note to future people reading this topic after a google search : It's H5P.JoubelUI not just JoubelUI :)