Skip to main content
Inspiring
April 30, 2018
Question

Execute JS when a drag object is rejected -- is this possible?

  • April 30, 2018
  • 2 replies
  • 763 views

Hello,

With Captivate, I can execute Javascript or an advanced action when drag object is accepted.  (See below) This is good.  How can I do the same when a drag object is rejected?  Is that possible? 

Thanks for any help!!

I am using Captivate 2017.

This topic has been closed for replies.

2 replies

TLCMediaDesign
Inspiring
April 30, 2018

This will tell you if the failure caption is showing. Just execute onSlide enter of the DD slide and change the name in the first line to the name of the failure caption/shape:

var elem = document.getElementById("Failure_Shape_1");

   

    setInterval(function()

    {

     if ( elem.style.visibility === "visible")

     {

      console.log("SHOWING");

     }

    

    }, 500);

Lilybiri
Legend
April 30, 2018

David, I don't think this is what OP wants. Failure message appears after submitting the D&D slide. He wants to use the event when a drag source is rejected in one drag action, it is an object action. But there is no object action if the accepted drag source is limited to the correct one, at least not to trigger an advanced/shared action.

TLCMediaDesign
Inspiring
April 30, 2018

Goctha, thanks, slight misread.

Lilybiri
Legend
April 30, 2018

German!  Is logical when I see your name.

If you want object actions for both correct and wrong drag actions you cannot restrict them to allow only the correct ones. What do you want to do? I know JS is hype at this moment, even for very simple workflows (I prefer the KISS principle). Are you aware of the InBuilt states for drag sources and drop targets? You don't tell what you want to do with JS. Have a look at:

Built in States for Drag&Drop objects - eLearning

An example of a D&D where I used the (simple) advanced/shared actions:

Drag&Drop: Using Shared or Advanced Actions - eLearning

Inspiring
April 30, 2018

I need to send one kind of xAPI (Tin Can) Statement to an LRS when the object was accepted, and a different kind when it is rejected. 

To be more specific, I am taking an old project and giving it xapi capabilities -- or more capabilities than you get when you publish the project as Tin Can.  I don't really want to make huge Captivate changes because it was already accepted by the customer long ago.

Right now, when the answer is rejected, it flies back to its original position, and there is a quick "incorrect" feedback that dissappears after a few seconds seconds. When the answer is correct, the drag object "sticks" and there is a quick "correct" feedback.  Essentially, it is impossible to get a wrong answer, but I still would like to track a wrong answer attempt with xapi.

I think if I make all three answers "acceptable", they would "stick" on the drop object, and the short "rejected" feedback will not be shown, right?

Lilybiri
Legend
April 30, 2018

Is that feedback an InBuilt state, which would indeed appear for a short time? Indeed, you should allow wrong drag actions in order to have them trigger any command. That would mean the wrong drag sources are not rejected anymore, but you can allow to have them replace if only one drag source per drop target is allowed.