Copy link to clipboard
Copied
Hello!
I am publishing a Captivate assessment as HTML5 (not SCORM packaged and no SWF) and need to be able to access the cpInfoPercentage system value (holds the quiz score as a percentage) in the published HTML/JavaScript code. Going through the published code, I am seeing where this variable is used to create the SVG image of the score number for the slide to be viewed in HTML in a browser. However, I am not sure I can grab this as a value.
Has anyone done this and can offer any guidance or code they used to make it happen / test it?
The reason I need to do this is because we are creating our e-learning courses in a way where we are either writing them in straight HTML / JavaScript or creating portions of them in Animate or Captivate and using the published code as modules inside an HTML player (basically the completed courses are a website that we package as a whole with a scorm packager). We currently are not able to use any of the assessment capability of Captivate because of the way we are creating our courses... I would like to be able to use this functionality than the what we are currently doing to create quizzes, and I could if I could capture this variable to be able to pull into our assessment results and certificate pages (which are created in HTML/JavaScript.
Thank you so much in advance for your help!
Ali
Copy link to clipboard
Copied
I found this code in a different forum:
var Fbk=window.cpAPIInterface.getVariableValue("cpInfoPercentage");
and am wondering if this is what I need.... Does anyone know if this will work using the published files from Captivate or this is meant to be used inside Captivate?
This is the forum I got this from:
Email quiz results variables in body of an email with JavaScript in Captivate 9
Copy link to clipboard
Copied
That is how I transfer values of variables from Captivate when I want to use them in JS. You can find more explanation about the common API for JS in Captivate in:
Learn about the Common JavaScript interface for Adobe Captivate
But I think window.cpInfoPercentae will work as well.
If you want to learn more about quizzing system variables: Using Quizzing System Variables - Captivate blog
Copy link to clipboard
Copied
All you need is window.cpInfoPercentage
Copy link to clipboard
Copied
Do you have any examples of this being used?
Copy link to clipboard
Copied
I don't know what you mean by examples of it being used.
I have never used the variable myself, but to get the value of that variable you just need the code I posted. I don't know where you are when you are accessing the value or how you are going to use it.
Copy link to clipboard
Copied
Thank you. I just want to verify that this is how to access it from the published HTML5/JavaScript code and that I do not have to do anything in Captivate before I publish it besides having an assessment.
What I am trying to do is be able to access the score to use in another module in my course that is written in HTML5/JavaScript and for other functionality. window.cpInfoPercentage is not a variable, it is a function call... so I was just looking for a little code snipped.. as in
var LearnerScore = window.cpInfoPercentage();
to verify if I am thinking about this correctly in how it is used... thank you for all your help though.
I think using this reference: Learn about the Common JavaScript interface for Adobe Captivate -- I can figure it out.
I do want to leave this question open though because I would love to hear from somebody that has actually done what I am trying to do:
Access system variables from the published code to use in a separate file.. for example to display the score on a subsequent page (custom results page) and ultimately be deployed to an LMS where we will be passing the score.
Copy link to clipboard
Copied
It is not a function call, it is a variable, so you would just use:
var LearnerScore = window.cpInfoPercentage;
If the results page is not a Captivate page or you want to pass it to a custom LMS you'll obviously need to do something else.
Using cpAPIInterface.getVariableValue() is to get variables from SWF and HTML5, but if you are just using HTML5 there is no need for it since all of Captivates variables are in the window object.
Copy link to clipboard
Copied
OK
So, it sounds like this is not the answer to my question then. I need to be able to get the score outputted from Captivate into the published HTML/JavaScript code so that I can use it from there. Searching through the code of a published assessment, the window.cpInfoPercentage variable is not automatically outputted.
Inside Captivate, I could just as easily use cpInfoPercentage (without the window. ) to assign it to another variable, display it, etc..
Basically, I need to know how I force a value to be written into the HTML or JavaScript code so I can access it after it is published?
Copy link to clipboard
Copied
I don't know what you mean by outputted?
Captivates output is just a single page that redraws itself for each slide.
You need a trigger I guess that get's the value at a certain point. So my thought is that if you put your code in a slideenter listener you can check what slide you are on and get the value of the variable.
How is it that you want it displayed?
Copy link to clipboard
Copied
I am sorry that I am probably not making much sense. What I am trying to do is complicated, and I am having a hard time wrapping my head around how to accomplish it and how to explain it correctly. But, I know it can be done.
A trigger may work. We currently have an HTML player that is able to read the published HTML5/JavaScript files and display them. We then add other content as needed and our assessment, a results page, and packaged it with SSP to put up on our LMS.
Because of they way we are doing this, we can not currently use Captivate to create our assessments. I am trying to find a way to capture the score so that we can use it on a results page and send the value on to the LMS. If we can find a way to do that, we can use Captivate to create our assessment modules.
So, I need a way to be able to capture that score variable value to be able to use at a later time in different code. Does that make sense?
Copy link to clipboard
Copied
It kind of makes sense.
If you have a HTML player that is able to read the published files, then that variable would be available to read right along with them.
Not sure if you really mean "read" though. If it's just in an iFrame of another html page that is used to "display" the Captivate published content, then you need code to read the content of the iFrame.
Or you could have variables in that page and have Captivate populate them using window.parent.
Copy link to clipboard
Copied
The code is using an iFrame to display the content.
Thank you!
I think you just range the bell I needed. The code I think I need is something like:
window.parent.LearnerScore = cpInfoPercentage;
where LearnerScore is a variable in our HTML player code....And this is put in a script window in Captivate. We are doing something similar to this to disable and enable the 'next' button in the HTML player.