How to check for empty drop zone in drag and drop
November 20, 2017 12:00 AM
I've got an interaction set up. I use an action group to provide feedback to the learner. I am building an error message to display as the feedback. I have 4 drop zones. I need to check to see if each or all drop zone(s) is/are empty, to provide a message. How do I do this?
Discussion (4)
Hi SB,
The variable for an empty drag-and-drop question looks like this:
saveVariable for VarQuestion_0003 to [1-(na),2-(na),3-(na),4-(na)]
As the learner drags items into each drop zone, the variable is edited like this:
saveVariable for VarQuestion_0003 to [1-3,2-(na),3-(na),4-(na)]
Until all items have been placed in the drop zones:
saveVariable for VarQuestion_0003 to [1-3,2-1,3-2,4-4]
You can check if any (or all) drop zones are empty by checking if the question variable contains 'na' at all. For example, your submit button might look like this:
On Mouse Click
Display Message ';One or more drop zones is empty!';
IF VarQuestion_0003 contains na
Hope this helps!
I created a sample that uses straight Lectora actions and the feedback settings on the question. This all depends on whether you have a submit button used for the question.
It's setup so that clicking the submit button verifies that the question does not contain "na" OR "is not empty" before processing it. You want to make sure the user doesn't get the feedback if they haven't moved any of the drop items.
In this sample, the Feedback on the question is used to run an action group for both correct/incorrect, since it sounds like you provide the correct/incorrect feedback along with other actions as part of that group. Hope this helps, too!
Ok, so I don't check to see if something is in the drop zone, I check to see if one of the Drag Items has been moved. Makes sense!! Thank you!
Thanks, Jason. I am having to do a lot of non-straight lectora for this particular drag-and-drop. However, between the two responses, I was able to use the information in them to get what I needed.
Discussions have been disabled for this post