Drag and Drop

I'd like for students to be able to correct their wrong choices.  When they go to redo, all of the answers reset, even the correct ones.  Is there a way to make it so that only the wrong ones reset and they can fix just those?

Here is an example of one that is difficult for students to have to redo the whole thing.


Continue after "Check"
Content types: 
Issue Status: 
Supporter votes Members of the Supporter Network can vote for feature requests. When the supporter network has generated sufficient funding for the top voted feature request it will normally be implemented and released. More about the H5P Supporter Network
tomaj's picture


Thanks for the great feature request. I can see where it would be useful for many authors.

- Tom

papi Jo's picture

This feature is quite easy to achieve. Here is the code:

    //Reset position and feedback.
    this.draggables.forEach(function (draggable) {
      result = draggable.results(true, this.correctDZs[draggable.id]);
      if (result == -1) {
However, it should probably be made a behaviour option of the Drag & Drop activity. I will include it in my own "enhanced" version of Drag & Drop soon to be viewable on my test site. I'll keep you posted!

otacke's picture

Thumbs up for your effort!

papi Jo's picture

You can preview the "keep correct answers" feature (along with many other new features) on my garden site quizzes page here:


Drag & Drop activities: Label the plants in the North Border and Plant families. Enjoy!

This is exactly what I want!  Where do I put that code that you put in the previous comment?? 

tomaj's picture

You're awesome Papi Jo!

papi Jo's picture

For cbuckner@spence, here is my provisional solution for the "keep correct answers" feature. This is the difference output by WinMerge between the official drag & drop dragquestion.js file and my hacks, where > means "line added" and < means "line deleted":

>   window.my_globals = {
>       correctDZs : 0
>   };
>     correctDZs = this.correctDZs;
<       draggable.resetPosition();
>       result = draggable.results(true, correctDZs[draggable.id]);
>       if (result < 0) {
>         draggable.resetPosition();
>       }
I am also attaching the modified dragquestion.js file. Usual warnings: test on a test site before using on a production site, and beware of official upgrades. Use at own risk! Before use, rename file dragquestion.txt to dragquestion.js. And empty the cachedassets directory.

papi Jo's picture

Pull request submitted on h5p github here: https://github.com/h5p/h5p-drag-question/pull/15/files

icc's picture

Thanks for sharing! We'll review you pull request and consider merging it in real soon.