Drag and Drop, Counter, Problem!

I have a drag and drop question, 18 drag items, 18 drop zones, each of the drag items can be dragged into any zone and be correct (this works).

I have a variable which 1 is added to each time a drag item is placed within one of the drop zones (this works). Text is then displayed when a submit button is clicked: 'You identified [variable] out of 18' (this works).

I now want to add drop zones which are incorrect, so for example:

18 drag items, 25 drop zones (of which 7 will be incorrect, this works).

The problem is that when a drag item is placed into an incorrect zone, 1 is still added to the variable when it shouldn't!

How do I fix this?

Attached file below.

undefined

Discussion (3)

Hi John,

The problem was with the conditions for the actions that are adding up the correctly identified spots. You sometimes have to be careful when using the "contains" comparison in conditions because it is very literal in what it finds in the variable string. For instance, when you dropped dragger 18 onto spot number 19, the string "18-19" gets added to the variable string. And one of the conditions of your action Drag_Item_18 is Question_0001 contains "18-1". A substring of "18-19" is "18-1". So that action was evaluating to true and adding 1 to the _foundSpotCount variable.

So what I did to fix it was to change the drop zone names inside the question to letters instead of numbers. And then I changed the action conditions to just look for the correct letters instead of all those "1-1, 1-2,..." number strings. This made the conditions MUCH simpler! See the attached file.

Hi Wendy,

Thanks for the reply. From the explanation you gave it makes much more sense. I ran the attached file and I encountered the same problem and it was still adding to the counter.

I renamed each drop zone to '_a', '_b' etc... and did the same for each action and it has fixed the problem, I'm guessing it has something to do with the contains relationship and how literal it is in what it finds.

Thanks.

undefined

Arrggh!! Yes, you're right. Sorry about that! I forgot to take into account the default "(na)" values that are in the string to begin with. Glad you fixed it! :)

Discussions have been disabled for this post