Skip to main content
osbornsm
Inspiring
July 14, 2015
Question

How to: Submit custom score to LMS from Captivate

  • July 14, 2015
  • 1 reply
  • 1358 views

Hello all and good afternoon,

I have spent the better part of my free time these last few weeks working with SCORM, JavaScript, and our LMS.

I have included the HTML w/ JavaScript to show how you too can do this.

Quiz Preferences

  • For this to work the "Enable reporting for this project" must be disabled in quiz preferences.
  • Because of this, a SCORM .js file must be included.
  • I used the APIWrapper.js file available from ADL.
  • SCORM 1.2
  • LMS = IBM / Kenexa / Outstart / SCORMcloud.com

The rest is up to your creativity!!

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title></title>

    <script src="standard.js" type="text/javascript"></script>

    <script src="SCORM_12_APIWrapper.js" type="text/javascript"></script>

   

    <script>

        function startUp()

        {

            doLMSInitialize();

            var lsnStatusStart = doLMSGetValue("cmi.core.lesson_status");

            if (lsnStatusStart == "not attempted")

            {   

                doLMSSetValue("cmi.core.lesson_status", "incomplete");   

            }

        }

    </script>

       

    <script>

        function closeOut()

        {

            var Passing_percentage = window.cpAPIInterface.getVariableValue("cpQuizInfoQuizPassPercent");

            var currentQuiz = window.cpAPIInterface.getVariableValue("quiz_score");

            var prevScore = doLMSGetValue("cmi.core.score.raw");

            var lsnStatus = doLMSGetValue("cmi.core.lesson_status");

           

            if ((prevScore == "unknown")||(prevScore == null)||(prevScore == "undefined")||(prevScore == ""))

            {   

                prevScore = 0;   

            }

           

            if (currentQuiz > 0)

            {                   

                if(currentQuiz >= Passing_percentage)

                {

                    doLMSSetValue("cmi.core.lesson_status", "passed")

                    doLMSSetValue("cmi.core.exit", "logout");

                    doLMSSetValue("cmi.suspend_data", "");

                   

                    doLMSSetValue("cmi.core.score.raw",currentQuiz);

                    doLMSSetValue("cmi.core.score.max", 100);

                    doLMSSetValue("cmi.core.score.min",0)

                   

                    doLMSCommit();

                    doLMSFinish();

                    window.close();

                }

                else if (currentQuiz > prevScore)

                {

                    doLMSSetValue("cmi.core.lesson_status", "incomplete");

                    doLMSSetValue("cmi.core.exit", "logout");

                    doLMSSetValue("cmi.suspend_data", "");

                   

                    doLMSSetValue("cmi.core.score.raw",currentQuiz);

                    doLMSSetValue("cmi.core.score.max", 100);

                    doLMSSetValue("cmi.core.score.min",0);

                   

                    doLMSCommit();

                    doLMSFinish();

                    window.close();

                }

                else

                {

                    doLMSSetValue("cmi.core.lesson_status", lsnStatus);

                    doLMSSetValue("cmi.core.exit", "logout");

                    doLMSSetValue("cmi.suspend_data", "");

                   

                    doLMSSetValue("cmi.core.score.raw",prevScore);

                    doLMSSetValue("cmi.core.score.max", 100);

                    doLMSSetValue("cmi.core.score.min",0);

                   

                    doLMSCommit();

                    doLMSFinish();

                    window.close();

                }

            }

            else

            {

                doLMSSetValue("cmi.core.exit", "");

                doLMSSetValue("cmi.suspend_data", "");

               

                if (prevScore > 0)

                {

                    doLMSSetValue("cmi.core.score.raw",prevScore);

                    doLMSSetValue("cmi.core.score.max", 100);

                    doLMSSetValue("cmi.core.score.min", 0);

                    doLMSSetValue("cmi.core.lesson_status", lsnStatus);

                }

                else

                {

                    doLMSSetValue("cmi.core.score.raw",0);

                    doLMSSetValue("cmi.core.score.max", 100);

                    doLMSSetValue("cmi.core.score.min",0);

                    doLMSSetValue("cmi.core.lesson_status", "incomplete");

                }

                doLMSCommit();

                doLMSFinish();

                window.close();

            }

        }

    </script>  

   

    <script language="JavaScript1.2">

        window.onkeypress      = CheckForDebugCommand;

        window.onload             = startUp;

        window.onunload          = closeOut;

        blnDebug                    = false;

    </script>

</head>

<link rel="stylesheet" type="text/css" href="captivate.css" />

<body onunload="closeOut()" bgcolor="#333333">     

    <div id="CaptivateContent"> </div>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

You may have noticed in a noob @ JavaScripting, however i got it to work!!!

Thoughts?

This topic has been closed for replies.

1 reply

osbornsm
osbornsmAuthor
Inspiring
July 14, 2015

Yes, i cut off the 2nd half of the HTML file.

All that's left to do after this is make sure the variable names line up to the ones listed in your Captivate file.

Also, don't forget to embed the SWF within the <body> tag.

NOTE: The function closeOut() is called from body unload and from the event listener onunload.

Participating Frequently
November 11, 2015

Hi osbornsm,

You write that the variable names have to line up to the ones in the Captivate file, but which variables do you mean? Because I see you are making use of the "cpQuizInfoQuizPassPercent" variable in one of your variable definitions, which looks like a CP system variable to me. Which variables are your custom score variables?

Regards, Andre