How to use the setFeedback() function

papi Jo's picture
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's picture

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's picture

Thanks for your reply. Just what I needed! No need to use H5P.Question.

Joseph

otacke's picture

You're welcome!

Note to future people reading this topic after a google search : It's H5P.JoubelUI not just JoubelUI :)