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

variables for attempts

Explorer ,
May 26, 2016 May 26, 2016

why is there a $$cpQuizInfoMaxAttemptsOnCurrentQuestion$$

but no $$cpQuizInfoAttemptOnCurrentQuestion$$

so I could make a reply or feedback massage saying:

"Incorrect, this was attempt 1 of 3."

or maybe a $$cpQuizInfoAttemptsLeftOnCurrentQuestion$$

so you can say:

"Incorrect, you have 2 attempst left."

And no I don't want to make custom code for it, this is more of a feature request.

TOPICS
Advanced
1.0K
Translate
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

correct answers 1 Correct answer

Explorer , Jun 01, 2016 Jun 01, 2016

If you look more closelly you can see I dit use it as a global, but somehow it dit not stick.
maybe I should have used: window.cp to get it, but I'm moving forward now.

I was allready looking into the Common JS Interface and how to get the variables without external coding 😉

if(window.cpAPIInterface)

{

    if(window.cpAPIEventEmitter)

    {

        window.cpAPIEventEmitter.addEventListener("CPAPI_QUESTIONSUBMIT",function(e)

{

window.cpAPIInterface.setVariableValue("currentAttempt",e.Data.questionAttempt

...
Translate
Community Expert ,
May 26, 2016 May 26, 2016

If this is a feature request, you need to do it through the proper channel using the feature request form on the Adobe website.

This is just a user forum and we didn't design the app.  So we cannot really give you any factual insight as to why a particular System Variable was not included in the more than 70 of them that Adobe DID provide with Captivate.

Translate
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
Explorer ,
May 26, 2016 May 26, 2016
Translate
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 ,
May 27, 2016 May 27, 2016

It's available in the Common JS Interface, put the following script in the head of your html document and create the variable in Captivate "myTries"

var interfaceObj, eventEmitterObj;

window.addEventListener( 'moduleReadyEvent', function ( e )
{
interfaceObj = e.Data;
eventEmitterObj = interfaceObj.getEventEmitter();
initializeEventListeners();
});

function initializeEventListeners()
{
if ( interfaceObj )
{
     if ( eventEmitterObj )
  {
         eventEmitterObj.addEventListener( 'CPAPI_QUESTIONSUBMIT', function ( e )
   {
   
    window.cpAPIInterface.setVariableValue( "myTries", e.Data.questionAttempts )
            });
  }
}
}

Translate
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
Explorer ,
May 27, 2016 May 27, 2016

why not add it via a javascript window in captivate?

Translate
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 ,
May 27, 2016 May 27, 2016

Because I tested and it won't work from there.

Translate
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
Explorer ,
May 30, 2016 May 30, 2016

TLCMediaDesign wrote:

Because I tested and it won't work from there.

Ah yes, I once made a workarround to load the script and not have a problem with publishing correcting my index.htm.

I used a javascript box in Captivate (first slide, load on enter):

loadScript('//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js');

loadScript('extra.js');

function loadScript(url, callback)

{

    var head = document.getElementsByTagName('head')[0];

    var script = document.createElement('script');

    script.type = 'text/javascript';

    script.src = url;

    head.appendChild(script);

}

that way I could add my own extra.js file.

which looked a bit like this and more, because I needed to generate a PDF and e-mail a hole bunce of variables.

//for debugging

var testing = true; //turn to true to show debugging information for this script

if (typeof console == "undefined" || typeof console.log == "undefined") var console = { log: function() {} };

var cp = document.Captivate;

if(testing)

    setTimeout(function(){checkJQ()},300);

function checkJQ()

{

    if (typeof jQuery != 'undefined') {

        console.log("jQuery library is loaded!");

    }else{

        console.log("jQuery library is not found!");

    }

}

function getMyData()

{

  cp = document.Captivate;

    $.each(cp.cpEIGetValue('m_VarHandle'), function(name, value)

    {

      if(testing){console.log(name + ": " + value);} //logs value of every single property of the current captivate object (long!)

    });

}

function setVar(variable, value, next)

{

    try{

        next = typeof next !== 'undefined' ? next : false;

        cp = document.Captivate;

        cp.cpEISetValue( "m_VarHandle."+variable, value);

      

        if(testing)

            console.log(variable+": "+value);

      

        if(next)

            cp.cpEISetValue('m_VarHandle.cpCmndNextSlide',1);

      

    }catch(e){

        console.log("error: "+e);

    }

}

...

back then I needed to reactivate de cp variable for every function???

I used it with Captivate 8.

Translate
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 ,
May 31, 2016 May 31, 2016

Not sure why you marked a bug/feature request as correct since Captivate supplies the variable through the Common JS Interface.

If you declare cp in a global scope you would not need to repopulate it. You need to do it in every function because that is where you are declaring it, so it is scoped to that function.

Translate
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
Explorer ,
Jun 01, 2016 Jun 01, 2016

If you look more closelly you can see I dit use it as a global, but somehow it dit not stick.
maybe I should have used: window.cp to get it, but I'm moving forward now.

I was allready looking into the Common JS Interface and how to get the variables without external coding 😉

if(window.cpAPIInterface)

{

    if(window.cpAPIEventEmitter)

    {

        window.cpAPIEventEmitter.addEventListener("CPAPI_QUESTIONSUBMIT",function(e)

{

window.cpAPIInterface.setVariableValue("currentAttempt",e.Data.questionAttempts);

});

    }

}

This does work from within captivate but unfortunatelly the variables in a retryfield do not update durring a question in flash mode, so it only works properly with html5. 

Translate
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 01, 2016 Jun 01, 2016

I rarely if ever use the Captivate JavaScript window. You should put your scripts in a JS file and include them. I don't believe the JS window is in a global scope or in the "window" object.

What version of Captivate or you using? You are mixing the cp.cpEISetValue and window.cpAPIInterface.setVariableValue.

What is this "retryfield"? Is it a TEB or a variable?

Translate
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
Explorer ,
Jun 03, 2016 Jun 03, 2016
LATEST

I'm using version 9.

Used sample code from Adobe Common JS interface​ page.

I will nolonger be using cp varibale, that was just a sample from an older code.

The feedback textfield for the retry message you can use:

03-06-2016 15-26-22.jpg

int the flash version it will only update the variables when the slide is loaded.

Translate
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