Copy link to clipboard
Copied
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.
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
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I just did via: Feature Request/Bug Report Form
Copy link to clipboard
Copied
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 )
});
}
}
}
Copy link to clipboard
Copied
why not add it via a javascript window in captivate?
Copy link to clipboard
Copied
Because I tested and it won't work from there.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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:
int the flash version it will only update the variables when the slide is loaded.