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

Accessing cpInfoPercentage system variable value from the published code

New Here ,
May 23, 2018 May 23, 2018

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

944
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
New Here ,
May 23, 2018 May 23, 2018

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

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
Community Expert ,
May 23, 2018 May 23, 2018

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

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 23, 2018 May 23, 2018

All you need is window.cpInfoPercentage

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
New Here ,
May 23, 2018 May 23, 2018

Do you  have any examples of this being  used?

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 24, 2018 May 24, 2018

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.

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
New Here ,
May 24, 2018 May 24, 2018

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.

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 24, 2018 May 24, 2018

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.

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
New Here ,
May 24, 2018 May 24, 2018

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?

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 24, 2018 May 24, 2018

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?

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
New Here ,
May 24, 2018 May 24, 2018

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?

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 24, 2018 May 24, 2018

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.

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
New Here ,
May 24, 2018 May 24, 2018
LATEST

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.

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