Tutorial: Using Advanced actions to store and show a users answers in a quiz

16

Sometimes you would like to present a summary slide after a quiz where you present the user with their answers to the questions and give them some extra feedback.

If you run your courses in an LMS this can be achieved (with most LMS’) by reading the data stored in the LMS database. However, if you don’t deploy through an LMS you need to take a different approach.

You can achieve this by using user defined variables and advanced actions.

Basically you need to create one variable per question. I named my userQuestion1, userQuestion2, userQuestion3 etc.

These variables will be the containers for the answer the user selects on each question in your quiz. It’s not possible to run an action (or assign a value to a variable) on a question slide in Captivate. Therefore you need to insert a blank slide after each of your questions. It just needs to be 0.2 seconds long and here we will assign our user defined variables with the relevant value.

In Captivate 4 we have a system variable called cpQuizInfoAnswerChoice. This variable contains the selected answer to the question the user just answered. Note that this variable will be overwritten when the user answers a new question.

On our 0.2 second slide we go to the slide properties – navigation area and select the “On slide exit”. Here we want to assign a value to a variable so we pick Assign from the drop down list. In the Assign field we select our user variable – userQuestion1. In the “with” field we need to select what value to assign to our variable. Here we insert the cpQuizInfoAnswerChoice variable name.

assignvariable

Basically what will happen here is that when these 0.2 seconds are done Captivate will assign the value of cpQuizInfoAnswerChoice to our user defined variable userQuestion1.

On to question 2. Again we need to make a 0.2 second slide after question 2 and then assign userQuestion2 with the value from cpQuizInfoAnswerChoice. Do this for all your questions.

Now we should have a number of variables that will be populated with the values and we need to go to the next step.

The next step is to create a slide that will show some specific information based on the values of our user defined variables.

In my example I just used some text captions, but basically you can use whatever you want.

For each question we need to create a text box for each of the answer possibilities. I just have 3 answer choices to each question so I need to create 3 text captions per question.

In the text box you can write whatever you want. As an example you could write “You selected option A: 2+2 = 4. That is correct! Good job.”. You then need to go to the options tab of the text caption and assign it with a proper name. I used question1_a, question1_b etc. Also uncheck the “Visible” tick mark.

textboxes

Now this text box is invisible until it is told otherwise by Captivate.

Once you have set up all of your text boxes it’s time to create an Advanced Action to handle the showing of the relevant text captions for each question.

Hit SHIFT + F9 to open up the Advance Actions part and create a new action. I called mine “showAnswers”.

Here we will set up a number of conditions and appropriate actions to perform when these conditions are met. For each question you need 3 conditions.

Here is the script you should use for each answer possibility on each question:

Check If ( userQuestion1 is equal to A)
begin
show question1_a
end
Or Else
being
end

actionsscreenshot

Repeat this action for all of your answer possibilities and all of your questions. (don’t you just hate the fact that you can’t copy/paste in the Advanced Actions panel!!)

Now that we have our showAnswers action set up we go to the slide properties in the navigation part and select “On slide enter:” – Execute advanced action and select our showAnswers function.

slideenter

Now when you run your quiz you should have a custom slide that shows you information based on what choices the user made.

Sample project (published and CP file) can be downloaded here: www.captivate4.com/demonstrations/quizAdvancedActions.zip

Have fun ;o)

Share.

16 Comments

  1. Pingback: Using Advanced actions to store and show a users answers in a quiz | Adobe Tutorials

  2. Thank you SO MUCH for this tutorial. It is the only place that I have seen easy-to-follow step-by-step instructions for using advanced actions. Your tutorial is VERY useful!

  3. Pingback: Cp4 - Utiliser les actions avancées et les widgets « SiteDuDragon

  4. thanks,pal
    But here, that will fail if we shuffel the answer’s.
    Any solution for that???

  5. Great tutorial!

    The instructions and zip file you supplied were brilliant and work very well.

    Thanks

  6. In the “Using Advanced Actions to Store and Show a Users Answers in a Quiz…” there is an Actions Dialog box with a scripting language being used.

    Question, what is that language and is there any documentation on that language so I may learn it?

    Please respond to dr.mjthomas@att.net
    as I may not return to this group again.

    Thanks for your help.

  7. Hi Mike,

    The scripting language used is Adobe Captivates own language. It’s pretty straightforward so the way to learn it is by trial and error.

    I have never seen any official documentation on this.

    /Michael

  8. Hi,
    I am working on a projectn which requires captivate quiz scores to be emailed and saved in database. I am able to do both. One recent addition to this has been the question and chosen answer also need to be added to email. I saw captivate has a system variable that holds the current chosen answer. How do I get the corresponding quiz questions.?

    Thanks

  9. Hi CAdeveloper,

    As far as I know there is no specific variable for that purpose. However, you could create a user defined variable and then assign whatever value you want to it on each quiz question slide. That way you would be able to define the question number.

    /Michael

  10. christina jacky on

    This was great, but I already have variables throughout the tutorial that have stored responses in them. What I would like to do is to NOT ask any questions, but have those variable pass as an answer at the end anyway.

    For example:

    If variable1 = 1
    variable2 = 1
    variable3= 1 (these numbers are assigned as they select certain items during the tutorial)

    at the end, I just want a summary slide of quiz results that auto pass those without having to write a question.

    Meaning: Quiz Results 3/3 you passed.

    Is this possible?

  11. That should be possible Christina. Basically just have a variable that increments with 1 every time the correct option is selected in your course. You would then also need an action that counts the number of points and assign a new variable with the value “passed” or “failed”.

    The “quiz summary” could be a standard text caption with the varialble name and some static text – e.g. “Quiz results $$yourVar$$/3 $$varStatus$$”

    /Michael

  12. Great tutorial Michael, thank you.

    I’ve been messing with this all day and can’t get it to work for some types of questions.

    Any ideas how to pass along the cpQuizInfoAnswerChoice variable for hot spot questions?

  13. Oops, saw you were on vacation. I wanted to report that I figured out a workaround. Instead of using cpQuizInfoAnswerChoice, I used cpQuizInfoLastSlidePointScored and then built the Check If action around the score.

    I set the question to be worth 1 point. If they answer correctly, and cpQuizInfoLastSlidePointScored > 0, I show caption question1_correct. If they answer incorrectly, cpQuizInfoLastSlidePointScored = 0, and I show caption question1_incorrect.

    Hope you had a good vacation.

  14. Great discussion and thanks for the tutorial. I’m also interested in capturing the question name and correct answer from the quiz. The wrinkle I have is that I am using random slides as well. It looks like I need to dig into the quiz pool to find the current question but I’m not sure if this is possible. Is there a way to store the selected question in a user variable?

    Thanks!

  15. @ Andy – Great that you worked it out and thank you for posting the solution. Hopefully others can benefit from it as well. And yes I had a great vacation but it’s also nice to be back home again ;o)

    @Ron – I’m not sure that you will be able to do this without some major external programming (Flash). I would think that it could be achieved with a widget that can access slide objects, but in all honesty I’m not a 100% sure because I don’t know how Captivate names/ID’s random questions.