Copy link to clipboard
Copied
I have gotten better at Advanced Actions in Cap, and as a result... I wish to submit my custom quiz results to the LMS and not the Captivate "quiz slide" method.
I realize i need JavaScript to communicate with the LMS... but how do i set "my_result" to the Captivate quiz score submission?
Thanks!!
~ Sean
They definitely are read only if you try to set them from within Captivate. Not so sure if everything is exposed in JavaScript. Don't really have time right now to test all of that. Getting to your script, try this:
Put this function in the head of the HTML page.
function submit_score()
{
var cp = document.Captivate;
var sendScore = cp.cpEIGetValue("m_VarHandle.quiz_score");
SCORM_SetValue("cmi.core.score.raw", Number(sendScore));
SCORM_SetValue('cmi.core.lesson_status', 'passed');
SCORM_Finish('EXIT_TY
...Copy link to clipboard
Copied
The only results that ar transferred to a LMS are the ones in the quizzing system variables. And those variables are read-only, you cannot control/change them.
If you explained more in detail how the 'my_result' variable is getting its value, maybe I could offer some suggestions. Here are two older articles, where you'll find some information about reporting the results of custom questions. I think you are pointing to that kind of questions, my apologies if it is not the case.
Copy link to clipboard
Copied
I have a basic practice quiz setup, using SCORM 1.2.
== Description ============================================
10 questions
10 slides + a results slide
Advanced Action validates a drop-down widget choice
If widget = correct {
quiz score is incremented from it's initial value of "0"
}
I then divide total questions / correct answers to get a score, which i called "my_result".
...which i would then like to submit to the LMS in place of Captivate's native quizzing.. if possible that is. 🙂
========================================================
== Question ============================================
Your comment above said the native quiz values are read-only.
Any chance we could get around the read-only-ness via JavaScript?
========================================================
Thank you for your thoughts!
~ Sean
One of the advanced actions in Cap -->>

Copy link to clipboard
Copied
You can try using the JavaScript depending on when Captivate actually writes the score. Your may get overridden unless you hijack the function that writes the score.
JavaScript Window:
var cp = document.Captivate;
var sendScore = cp.cpEIGetValue("m_VarHandle.my_result");
SCORM_SetValue("cmi.core.score.raw", sendScore);
Copy link to clipboard
Copied
Hello TLC,
I have the following JavaScript executed to exit the course and submit the quiz values to the LMS.
The "rdcmndExit = 1" does not fire, presumably because there is an error in the included JavaScript.
Thoughts?
===============================================================
function submit_score()
{
var objCP = document.Captivate;
var sendScore = objCP.cpEIGetValue("m_VarHandle.quiz_score");
objCP.cpEISetValue("cpQuizInfoPointsscored", sendScore);
SCORM_objAPI.LMSSetValue('cmi.core.score.max', 100);
SCORM_objAPI.LMSSetValue('cmi.core.score.raw', sendScore);
SCORM_objAPI.LMSSetValue('cmi.core.lesson_status', 'passed');
SCORM_objAPI.LMSCommit('');
SCORM_objAPI.LMSFinish('');
objCP.cpEISetValue('rdcmndExit', 1);
}
submit_score();
===============================================================
Copy link to clipboard
Copied
What version of Captivate are you using? I'm wondering where you got the "SCORM_objAPI."?
Also, you don't need the rdcmndExit, the LMSFinish should close the course.
Also you cannot set cpQuizInfoPointsscored as it's read only.
Copy link to clipboard
Copied
System:
Captivate 8 x64
Windows 7 x64
SCORM 1.2
I "thought" SCORM_objAPI was the correct API to call the cmi.core features.
So cpQuizInfoPointsscored is readonly
and cpQuizInfoTotalPointsscored is read only too?
That sounds an awful lot like "what you want isn't possible."
But that's just my thoughts... Thank you for yours!
~ Sean
Copy link to clipboard
Copied
They definitely are read only if you try to set them from within Captivate. Not so sure if everything is exposed in JavaScript. Don't really have time right now to test all of that. Getting to your script, try this:
Put this function in the head of the HTML page.
function submit_score()
{
var cp = document.Captivate;
var sendScore = cp.cpEIGetValue("m_VarHandle.quiz_score");
SCORM_SetValue("cmi.core.score.raw", Number(sendScore));
SCORM_SetValue('cmi.core.lesson_status', 'passed');
SCORM_Finish('EXIT_TYPE_FINISH', 'true');
}
On you last page, click a button and execute the JavaScript
submit_score();
Copy link to clipboard
Copied
The above JavaScript did not trigger any activity once added to the HTML file and triggered by a button w/ JavaScript.
I have seen several different ways in which to reference a Captivate quizzing item.
Most documentation i've seen has the LMSSetValue call, but i'm not sure what the API prefix is for my system.
=================================================================
var cp = document.Captivate;
var sendScore = cp.cpEIGetValue("m_VarHandle.quiz_score");
SCORM_objAPI.LMSSetValue('cmi.core.score.max', 100);
SCORM_objAPI.LMSSetValue('cmi.core.score.raw', sendScore);
SCORM_objAPI.LMSSetValue('cmi.core.lesson_status', 'passed');
SCORM_objAPI.LMSCommit('');
SCORM_objAPI.LMSFinish('');
== OR ==
var cp = document.Captivate;
var sendScore = cp.cpEIGetValue("m_VarHandle.quiz_score");
SCORM_SetValue("cmi.core.score.raw", Number(sendScore));
SCORM_SetValue('cmi.core.lesson_status', 'passed');
SCORM_Finish('EXIT_TYPE_FINISH', 'true');
=================================================================
Copy link to clipboard
Copied
Are you using SWF or HTML5 or both?
Once your file is running in an LMS you don't need the API prefix with the Captivate scormdiver.js.
I think I was looking at a different file, it's SCORM_CallLMSSetValue. I'll throw one together this weekend and see how to overwrite the score.
var cp = document.Captivate;
var sendScore = cp.cpEIGetValue("m_VarHandle.quiz_score");
SCORM_CallLMSSetValue("cmi.core.score.raw", Number(sendScore));
SCORM_CallLMSSetValue('cmi.core.lesson_status', 'passed');
SCORM_Finish('EXIT_TYPE_FINISH', 'true');
Copy link to clipboard
Copied
I did this test for SCORM 1.2 with the settings in the image.
I created a function in the html page:
<script>
function setScore(myScore)
{
SCORM_SetScore(myScore,30,0)
}
</script>
Note that there were 3 questions so I kept max score at 30.
In CP I executed the following JS, newScore is the user variable to write to the LMS.:
var cp = document.GetElementById("Captivate");
var getScore = cp.cpEIGetValue('m_VarHandle.' + newScore);
setScore("getScore");
It overwrote the Score.

Copy link to clipboard
Copied
Here is the script i am attempting to execute when exiting the course.
The script runs correctly if executed by an action within Captivate.
If the script is triggered from the onunload or unbeforeunload, there is no result.
Thoughts?
==========================================
<script>
function closeOut()
{
var passing_percentage = window.cpAPIInterface.getVariableValue("cpQuizInfoQuizPassPercent");
var valid = window.cpAPIInterface.getVariableValue("quiz_score");
if (valid > 0)
{
var final_score = window.cpAPIInterface.getVariableValue("quiz_score");
alert("Your score was " + final_score);
window.cpAPIInterface.setVariableValue("cpQuizInfoTotalQuizPoints", final_score);
if (final_score >= passing_percentage)
{
alert("You passed with a score of " + final_score);
SCORM_CallLMSSetValue("cmi.core.lesson_status","completed");
SCORM_CallLMSSetValue("cmi.core.exit","logout");
SCORM_SetScore(final_score,100,0)
SCORM_CallLMSCommit();
SCORM_CallLMSFinish();
}
else
{
alert("You have not passed.");
SCORM_CallLMSSetValue("cmi.core.lesson_status","incomplete");
SCORM_CallLMSSetValue("cmi.core.exit","logout");
SCORM_SetScore(final_score,100,0)
SCORM_CallLMSCommit();
SCORM_CallLMSFinish();
}
}
else
{
alert("This course is incomplete.");
window.cpAPIInterface.setVariableValue("cpQuizInfoTotalQuizPoints", 0);
SCORM_SetScore(0,100,0);
SCORM_CallLMSSetValue("cmi.core.lesson_status","incomplete");
SCORM_CallLMSSetValue("cmi.core.exit","");
SCORM_CallLMSCommit();
SCORM_CallLMSFinish();
}
}
</script>
==========================================
Copy link to clipboard
Copied
I updated my previous post with my current code to make things easier.
Any thoughts?!
![]()
Copy link to clipboard
Copied
Yes, never rely on the onuload or onbeforeunload when trying to write to the LMS. The LMS usually knows it's happening and terminates the session.
Execute from the onEnter of the last slide or have the users click a button to register the score.
Copy link to clipboard
Copied
I do have a follow-up question:
When native Captivate courses are opened and closed without taking a quiz, they're marked as "incomplete."
When MY course and custom quiz is opened and closed without quizzing, it's marked as "Completed".
Something is different in the way that exit behavior is handled between the two of them... but i'm unsure what.
Copy link to clipboard
Copied
I'm not sure what all of your quiz preferences are, but I think you are trying to manipulate things that Captivate is doing internally.
The best way to do this would be to create your own SCORM wrapper, there are quite a few you can download. Do NOT publish to SCORM and make the SCORM calls yourself so Captivate isn't doing it also.
Captivate will still have the quizzing info, but it won't write to the LMS.
Copy link to clipboard
Copied
Here are some of the SORM values for 2004 and 1.2:
SCORM 2004 Score
| Yes | Yes | CMIDecimal/CMIBlank | a normalized value between 0 and 100, initially blank |
| Yes | Yes | CMIDecimal/CMIBlank | a normalized value between 0 and 100, initially blank |
| Yes | Yes | CMIDecimal/CMIBlank | a normalized value between 0 and 100, initially blank |
This may work to set these values if they are not already set. It may also affect the lesson status and success as the roll-up[ rules are different for each SCORM version.
To make the calls, use the following JavaScript examples.
SCORM2004_SetValue(“cmi.score.scaled”,yourVar)
SCORM_SetValue(“cmi.core.score.raw”,yourVar)
Note that you'll need to get the CP var for whatever version of CP and may have to be in quotes in the script window.
Copy link to clipboard
Copied
We are using xapi rather than scorm. Will these approaches still work, or are they scorm specific?
Copy link to clipboard
Copied
The following strategy enables creating a custom score without requiring direct SCORM interaction. It modifies the internal scoring process in Captivate:
https://medium.com/@hdecisions/custom-quiz-scoring-in-adobe-captivate-245b60ef49d3#.apbzqvl8m
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more