Picture of Tom Baum
Get Feedback in custom-component
by Tom Baum - Thursday, 10 November 2016, 4:08 PM
 

Hello,

i am creating my first custom-component, but i stuck to get the feedback texts out of the component.json show up in the feedback-modal. I had a look at adapt-contrib-matching.js and core/js/views/questionView.js to figure out how it works, but failed. All i get is an empty modal. I published my code at http://pastebin.com/06g64gK4. Maybe someone could help?

 

Thanks in advance,

Tom

Picture of Dan Storey
Re: Get Feedback in custom-component
by Dan Storey - Thursday, 10 November 2016, 5:05 PM
 

Hi Tom,

You can retrieve the feedback object by doing something like this:

var feedback = this.model.get("_feedback");

The modal can then be triggered using the command

var popupObject = {
    title: "Correct Answer",
    body: feedback.correct
};

Adapt.trigger('notify:popup', popupObject);

The code above is taken from this page which you might find useful:

https://github.com/adaptlearning/adapt_framework/wiki/Core-modules#notify

 

Picture of Matt Leathes
Re: Get Feedback in custom-component
by Matt Leathes - Thursday, 10 November 2016, 5:24 PM
 

That would certainly work but if you're inheriting from questionView you shouldn't need to do that.

You also shouldn't need to have an onSubmit function in your code - questionView should handle that.

What you DO need to have is a function called isCorrect that returns either true or false.

You might also want to add a canSubmit function - assuming you want to prevent the user from submitting until they have selected an answer (not always required e.g. in Slider you can just hit submit without moving the slider)

Finally, if you want your question to have partly correct feedback, you'll want to include an isPartlyCorrect function.

BTW feel free to ask for further support over in the Framework Gitter chat if you need.

Equally you might want to have a look at adapt-contrib-question - although I notice it hasn't been updated in ages.. :-(

Picture of Tom Baum
Re: Get Feedback in custom-component
by Tom Baum - Thursday, 10 November 2016, 6:55 PM
 

@ matt

works like a charm. Thank you very much!

@ dan

thank you for the link - it's realy useful.

Cheers

Tom