Skip to main content
Inspiring
June 23, 2016
Answered

Advanced Action not following "else" direction

  • June 23, 2016
  • 1 reply
  • 434 views

Hi,

I am using Captivate 8, and trying to create an advanced action involving a hotspot question.

Currently, I have:

If (all conditions are true):

     If cpQuizInfoAnswerChoice [is equal to] 0   ((literal -- as generated by Captivate)

Then:

     Execute Javascript: window.cpAPIInterface.setVariableValue("cpQuizInfoAnswerChoice", "Correct");

Else:

     Execute Javascript: window.cpAPIInterface.setVariableValue("cpQuizInfoAnswerChoice", "Incorrect");

(FWIW, I am confident in the "Then" Javascript, having used this script in other, similar conditional advanced actions.)

However, regardless of whether cpQuizInfoAnswerChoice is 0 (i.e., correct) or appears blank (i.e., incorrect), the advanced action always returns the If condition (whether or not the parameters are met).

I suppose one way of solving this would be to figure out what is generated by Captivate for cpQuizInfoAnswer when the question is incorrect, but cannot seem to find it; another way would be to create a conditional advanced action based on whether the question was marked as Correct or Incorrect, but this does not seem to be a readily available option.

I would appreciate any suggestions on how to get around this issue!

    This topic has been closed for replies.
    Correct answer laura_sie

    Did you never try to use a custom hotspot question? I use shape buttons for hotspots, they can have a free form, they can have a score attached to them (which allows partial scoring for hotspot slides).


    When you have multiple hotspots, the value of cpQuizInfoAnswerChoice changes to

    x,y,z,...    where x, y, z stand for the number of the hotspot. First indicated hotspot = 0, second = 1 etc. It is not incrementing. In that case you should need the 'contain' operator.


    I haven't tried custom hotspots, but will for future projects -- this has been more trouble than it's been worth.

    I did end up creating multiple hotspots, with the first one (=0) being a "dummy" and the second one (=1) being the correct answer. Then, I created my conditional Advanced Action to return "Incorrect" if the answer is 0 or null (since the system finds them equivalent), and "correct" if the answer is 1.

    Thank you for all of your assistance with this, Lilybiri!

    1 reply

    Lilybiri
    Legend
    June 23, 2016

    Could you explain in normal sentences what you want to achieve? Quizzing system variables are normally read only, I doubt very much that you were ever able to change the value of such a variable using conditional advanced actions. I didn't check if it is possible with JS however. The variable cpQuizInfoAnswerChoice is reused after each question slide.  I blogged once about this variable:

    Secrets of cpQuizInfoAnswerChoice and.... - Captivate blog

    Sorry, I didn't treat it for Hotspot question slides, because personally I will never use the default Hotspot type included with Captivate, but create a custom hotspot slide. The default one is too limited for my taste.

    Tried to find out how that system variable is populated when using a hotspot question slide: it remains empty for an incorrect answer, and indeed gets the number '0' for a correct answer (pretty weird). I suspect you are bumping on the fact that Captivate doesn't see the difference between an empty value and the number 0. Did you try to create a dummy empty variable v_null to check instead of checking the number '0'? It is a workaround that I often use when I have this type of issues. Look at this very old post:

    Where is Null? - Captivate blog

    laura_sieAuthor
    Inspiring
    June 23, 2016

    Hi, and thanks for your ongoing help!

    I left out some details in my post above - there is another step, that you have already helped me with greatly! - in which cpQuizInfoAnswerChoice is assigned to a user-made variable before proceeding to the next question. So it really is my user variables that I'm trying to recast in the Advanced Action. (Mentioning this didn't seem relevant to the question about 0 being "misunderstood" in the conditional Advanced Action...though maybe it was?) Anyway, so far I have been successful in other question types in using Javascript to recast the system generated answers associated with these new variables (e.g., 0,1, etc.) in terms that are more useful to my learners.

    I think you are correct with the Null issue, this is the root of the problem. However, I made a null variable (v_null, with nothing in the Value line), but the system is still interpreting it as identical to literal 0 or even a variable v_0, with 0 in the Value line...am I overlooking the obvious?

    Thank you!

    Lilybiri
    Legend
    June 23, 2016

    Did you look at the article? Instead of checking the condition 'is equal to 0', you should reverse the condition and check if 'is equal to v_null'. That way you check if the variable is left empty, which means in this case that the answer was incorrect.

    Sorry, cannot remember all the names and the answers I offered in the past.