• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

branching issues in captivate 6

New Here ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

Hello,

I am trying to create a project in which users first have to answer a questionnaire (survey quiz) with two options each and based on their answers (e.g. if option As chosen is greater than option Bs), they are transferred to a different part of the project.

I tried to achieve this by creating custom variables. I created a variable for A (answerA) and another for B (answerB) and then wrote the script below for it.

if (cpQuizInfoAnswerChoice == A) {

   answerA++;

}

else {

   answerB++;

}

I then executed this script on the "on Enter" event for each slide in the quiz.

On the "Quiz Results" page, I executed an advanced action

captivate.pngcaptivate2.png

The problem is that this does not seem to be working. I previewed it on my browser and after answering the questions, it directed me to slide 2. I assumed it was working since i purposely selected more option Bs and had specified "jump to slide 2 if answerB is greater than answerA". But then I took the quiz again but this time, I selected more option  As but still it jumped to slide 2 instead of slide 1 as i specified.

Please can anyone tell me what I am doing wrong?

Thank you.

Views

297

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

First you need to get the Captivate object to access the variables, and turn the variable into a number:

var cpObj = document.getElementById('Captivate');

var myChoice = cpObj.cpEIGetValue('m_VarHandle.cpQuizInfoAnswerChoice');

var ansA = parseInt(cpObj.cpEIGetValue('m_VarHandle.answerA'));

var ansB = parseInt(cpObj.cpEIGetValue('m_VarHandle.answerB'));

if (myChoice == A) {

     ansA++;

     cpObj.cpEISetValue('m_VarHandle.answerA', ansA);

}

else { 

     ansB++;

     cpObj.cpEISetValue('m_VarHandle.answerB', ansB);

}

Also, if you execute the script on slide enter, it will return the answer of the last question answered.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

Thanks for replying.

Am I to insert all the code above in each question slide like this?

captivate2.png

And since my "On slide exit" option is greyed out, I opted for "on slide enter". Is my method of using the advanced action on the quiz results page adequate? Or can you please suggest a better way for me to achieve this?

Thanks again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

Your advanced action should be fine.

I didn't test the code I wrote but it should work.

If your decision to jump to different slides is on the first slide after the last quiz I think you'll need to execute the JavaScript from the advanced action and then make the decision based on the variable values.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

I tried everything as you suggested but it does not seem to be working. It still takes me back to slide 2 regardless of what option is chosen more.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

The variable cpQuizInfoAnswerChoice is only available for a split second, then it is reset.

I think you are going to need to find a way to evaluate points scored.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

Really? I have the experience that cpQuizInfoAnswerChoice keeps its value until the next question is submitted. I have been using it in many use cases.

Secrets of cpQuizInfoAnswerChoice and.... - Captivate blog

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

Yep, I was alerting the values and it came up empty, then I put the variable in a Smart Shape and you could see it reset a split second into the next slide.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

I'm always capturing that value On Enter for the next slide. And then it is still there. Because you are starting a new question, it will be reset soon.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

You'd think it would still be there since it is not set until slide enter anyway. Might be a bug of some kind. I've had the same issue trying to capture it in a widget.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

About which version are you talking? It worked perfectly in previous versions, but checked just now in 7.0.1 and you are right. Have to check in CP8. Bummer, what has changed there?

Moreover, when I capture the answer with the Success/Failure actions, the user variable is populated, but it is cleared together with cpQuizInfoAnswerChoice.

Another blog post that I have to take off line. Time to stop totally with blogging, I'm afraid.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

Latest version of 7, I haven't checked 8 yet either. Makes the variable kind of useless.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

Indeed, I used to check most of my blog posts with each release, but didn't do it last time. This was a blog post that was visited quite a few times, now it is again unusable. Will check on CP8, but suspect it will be the same. It has no sense whatsoever to expose a system variable that you cannot use.

Same situation in Captivate 8. I will log a bug.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

I just checked v6 and it's doing the same thing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

LATEST

I don't have 6 anymore... thanks. Just logged a bug. And there are more articles where I used this system variable

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources