Skip navigation
Currently Being Moderated

Reading SCORM variables

Oct 20, 2009 2:36 PM

I was curious if anyone has any insight on how to read SCORM variables into captivate once a project is published on an LMS.  Here is my problem.  I would like to use captivate to pull the current user data during runtime from the cmi.learner_name variable, and store the data in a captivate variable, so I can then display the users name (or otherwise use the data).

 

Does anyone have experience implimenting this?  I was considering using javascript to assign the value to a captivate variable, but I am a bit lost as to how to make javascript pass the variable to captivate.  As well as when to have this happen, since I am sure there are some initialization issues.  I would also like to be able to use captivate to make a simple debugger project to use when working with a new LMS using this same principle.  Any suggestions?

 
Replies
  • Currently Being Moderated
    Oct 21, 2009 12:36 AM   in reply to merobertsjr

    I have done this through a combination of JavaScript and Flash. You need JavaScript to get the value from the LMS and then I used a Flash file embedded in Captivate to show / process the value. Once you have the value in Flash you can assign the value to a Captivate User defined variable.

     

    The "issue" with these SCORM things is the difference between SCORM 1.2 and SCORM 2004. For some reason a lot of major LMS' are still using the old SCORM 1.2 standard while some are using the "new" SCORM 2004 standard. There are some fundamental changes in these two SCORM versions, so basically you would need to make a SCORM 1.2 file and a SCORM 2004 file.

     

    If you don't know Flash then you could probably (just guessing here) assign the value from your SCORM variable to a Captivate user defined variable through JavaScript, but I have no idea how to do that.

     

    /Michael

     


    Visit my Captivate blog with tips & tricks, tutorials and Widgets.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 21, 2009 10:33 AM   in reply to merobertsjr

    The main difference between the SCORM calls in 1.2 and 2004 is that the SCORM fields have different names. I can't remember if that applies for learner_name though.

     

    To answer your question - No your wouldn't need a full blown widget to do this. That would be total overkill as the code in Flash is maximum 10 lines.

     

    I'll see if I can dig up some code in Flash to get you started once I get in the office tomorrow.

     

    /Michael

     


    Visit my Captivate blog with tips & tricks, tutorials and Widgets.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 22, 2009 12:01 AM   in reply to www.cpguru.com

    Alright here is some code.. You probably need to adapt if for your own needs, but this will get you started.

     

    In JavaScript create a function like this:

     

    function returnName(str) {

          return doGetValue('cmi.learner_name');
        }

     

    In Flash create code like this:

     

    // stop the Flash timeline

    this.stop();

    // import external interface to handle JavaScript communication

    import flash.external.*;

    // The name of the JavaScript function to call
    var callJS:String = "returnName";

    //parameter to send to the JavaScript function. This is not needed now
    var msg:String = "test";
    // Execute the function call and store the result in the variable returnValue
    var returnValue:String = ExternalInterface.call(callJS, msg).toString();

    // Put the value into a textfield on the Flash stage
    this.return_txt.text = returnValue;

     

    Also create a dynamic text field on the stage with the instance name "return_txt"

     

    That should more or less be it. Let me know if it works out for you.

     

    /Michael

     


    Visit my Captivate blog with tips & tricks, tutorials and Widgets.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 15, 2009 5:48 PM   in reply to www.cpguru.com

    This is pretty cool. Just have some clarification.. where specifically shall I place these codes below:

     

    In JavaScript create a function like this:

    function returnName(str) {

          return doGetValue('cmi.learner_name');
        }

     

    Thanks.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 16, 2009 1:02 AM   in reply to salvador_sorianojr

    You can put that in the "standard.js" file that Captivate creates or insert it in the HTM file that launches the Captivate SWF.

     

    /Michael

     


    Visit my Captivate blog with tips & tricks, tutorials and Widgets.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 16, 2009 8:17 AM   in reply to www.cpguru.com

    Does this solution work if the LMS is not SCORM compliant?

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 16, 2009 10:07 AM   in reply to sigmundc

    If your LMS stores data in a different type of database you could adapt the JavaScript to get the data from that instead but of course you wouldn't be able to use the SCORM calls and functions.

     

    /Michael


    Visit my Captivate blog with tips & tricks, tutorials and Widgets.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 16, 2009 11:07 PM   in reply to www.cpguru.com

    Is it only the Flash Component as imported into Captivate and the Javascript which will have its way of connecting here?Is there anything that I need to define in my Captivate? Variables perhaps...

     

    Thanks.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 18, 2009 5:33 AM   in reply to salvador_sorianojr

    Yes if you want to use the data in Captivate then you need to "transfer" it from Flash to Captivate.

     

    Create one or more user defined variables in Captivate. From Flash send the values to these variables like _root.v_myCaptivateVariable = FlashVariableYouWantToTransfer;

     

    /Michael

     


     

    Visit my Captivate blog with tips & tricks, tutorials and Widgets.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 4, 2010 6:28 PM   in reply to merobertsjr

    We haven't upgraded to CP 5 yet. I wonder if anyone has AS2 version of the Flash code.

     

    Thanks for sharing.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 16, 2010 4:03 PM   in reply to merobertsjr

    Thank you all very much for the information.  FYI to get this to work in Captivate 5 and SCORM 1.2, you'll want to modify the javascript returnName function to the following:

     

    function returnName(str) {
          return g_objAPI.LMSGetValue("cmi.core.student_name"); //returns a string
    }

     
    |
    Mark as:
  • Currently Being Moderated
    Calculating status...
    Dec 9, 2010 1:53 PM   in reply to merobertsjr

    Hello Merobertsjr!

     

    I was looking at this thread in the Adobe Forums and would like to look at your tutorial, unfortunately the link seems to have expired.

     

    Is it possible to see this anywhere else? I would like to take a look.

     

    Thank you!

     

    Mark

     
    |
    Mark as:
  • Currently Being Moderated
    Calculating status...
    Mar 10, 2011 9:31 AM   in reply to merobertsjr

    Thanks for putting up the tutorial, it was very helpful. Unfortunately I am still having problems getting the variables out of my LMS (moodle). When I play the Captivate 5 slide, all I am seeing is the variable name v_myUserName appearing in the slide, rather than the desired student name. Any ideas what I might be doing wrong?

     

    Many thanks

     

    J

     
    |
    Mark as:
  • Currently Being Moderated
    May 5, 2011 10:04 PM   in reply to merobertsjr

    hi. i have the same problem as jumper. i followed your tutorial but for

    some reason all that is displayed on the slide is the variable name. Reading the information from the file works, I've tested that so the problem is with the flash getting the information from the LMS/Java Script. Any ideas?

     

    I added this function to the SCROM_support java script file in the Captivate Publish templates for SCORM. We are using SCORM 1.2:

     

    function returName(str)

    {

         return (g_objAPI.cmi.core.student_name);

    }

     

    Does this need to be placed in a specific position in the file?

     

    And I used the action script code you provided in your tutorial:

     

    import flash.external.*;

     

    this.stop();

     

    var returnValue:String = ExternalInterface.call("returnName",returnValue);

     

    var myRoot:MovieClip = MovieClip(root);

    var mainmov:MovieClip = MovieClip(myRoot.parent.root);

    mainmov.v_myUserName = returnValue;

     

    Do I need to change the * ater import flash.external.* to something else?

     

    Any ideas?

     

    Thanks

     
    |
    Mark as:
  • Currently Being Moderated
    May 6, 2011 1:37 AM   in reply to merobertsjr

    Thanks for the quick reply. I only made the typo here in the forum.

    It's actually working now, but I had to use this function:

     

    function returnName(str) {
          return g_objAPI.LMSGetValue("cmi.core.student_name"); //returns a string
    }

     

    Now I'm wondering how I can get the last and first name seperated because the LMS gives it back as a string (lastname, first name).

     

    Sorry. I'm not very familiar with flash and java script.

     
    |
    Mark as:
  • Currently Being Moderated
    Calculating status...
    May 26, 2011 3:36 PM   in reply to merobertsjr

    You can actually take it a step further, and not use any JavaScript at all...

     

    This script will get you where you need to go....

     

    import flash.external.ExternalInterface;


    try{

         //Assigns the LMS value to a string

         var UserName:String = String(ExternalInterface.call('g_objAPI.LMSGetValue','cmi.core.studen t_name'));

     

        //Assigns the string to a textfeild

         nameTxt.text = UserName;

    }catch(err:Error){

         trace("Not in an LMS Currently");

    }

     

    The nice thing about the above script is that you don't need to remember to add the JavaScript function anywhere which is nice if you're making widgets that you plan to distribute (ie people wont know to add the JavaScript snippit.)

     

    I usually wrap SCORM related content in a 'try catch' so that if flash chokes on the LMS API call, it wont kill the program.

     

    I hope this helps

    ~Jsswift

     
    |
    Mark as:
  • Currently Being Moderated
    May 26, 2011 3:43 PM   in reply to sporschi82

    To get the first and last name separated.

     

    In Flash...

     

     

    import flash.external.ExternalInterface;

     

     

     

     

     

    try{

         //Assigns the LMS value to a string

         var UserName:String = String(ExternalInterface.call('g_objAPI.LMSGetValue','cmi.core.studen t_name'));

     

         //To Separate the first and last name...

     

         var LastName:String = UserName.slice(0, userName.indexOf(","));

     

         var FirstName:String = UserName.slice(Number(userName.indexOf(",")+2), userName.length);

     

     

     

    }catch(err:Error){

         trace("Not in an LMS Currently");

     

    }

     

     

     

    ~Jsswift

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 27, 2011 8:08 AM   in reply to jswift1234

    Jsswift (or anyone else!),

     

    For a complete Flash novice, would you be able to expand on how to get your solution working. I've tried creating a flash project using your code above and then inserting it as an animation within a captivate project, adding a text caption displaying user variables student_name, firstname and lastname but they all come out blank once published. I'm working with Captivate 5.5, Flash CS4 and Moodle 2.0.

     

    Alternatively, if anyone knows an easier way to display the student name (taken from Moodle) to appear on the results page of the course, please advise.

     

    Alistair

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 11, 2012 9:01 AM   in reply to Frubisher Bold

    Hello all,

     

    I am attempting to solve this issue as well.

     

    Has there been a tutorial that is still active that we can look at to get this all solved?  I am piecing together different bits of information but cannot get this to work.

     

    Any steps to complete this would be greatly useful.

     

    For example... for the Flash code... does it have to be within a widget?  Or just added to captivate as an animation?

     

    Thank you so much,

    ~ Sean

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points