Sorry this is a bit uninutitive, but the prodigyanswer
event is fired once the task is already answered, so you couldn't use that to update the current task.
Instead, it's better to attach the updating to the onChange
event of the slider, so the current task is updated whenever the slider changes.
document.addEventListener('prodigymount', () => {
// This runs once the page is set up
document.querySelector('#score_slider').addEventListener('change', event => {
window.prodigy.update({ score: event.target.value })
})
})
Apparently there are some browser-related inconsistencies with the implementation of <input type="range" />
so if the change
event doesn't fire in your browser, try listening to input
. See this blog post for background – but it might already be fixed in more modern browser versions.