25 Replies Latest reply: Sep 11, 2012 9:01 AM by osbornsm RSS

    Reading SCORM variables

    merobertsjr Community Member

      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?

        • 1. Re: Reading SCORM variables
          www.cpguru.com Community Member

          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.

          • 2. Re: Reading SCORM variables
            merobertsjr Community Member

            Thanks,

            I was pretty sure I would have to use a different script for 1.2 vs 2004.  Thanks for confirming.  I have also noticed that many LMS deal better with 1.2.  The current one we are using is setup for 1.2 for the most part, but the LMS has a web based aggrigator that only uses 2004 content???  Strange.

             

            I was hoping that the javascript to captivate would be possible, since I am not great with Flash.  But, I guess I just need to get in there and figure it out.  I have Flash CS4 and I know some basics, but it is not my forte.  Would this need to be a full blown widget?

            • 3. Re: Reading SCORM variables
              www.cpguru.com Community Member

              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.

              • 4. Re: Reading SCORM variables
                www.cpguru.com Community Member

                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.

                • 5. Re: Reading SCORM variables
                  salvador_sorianojr Community Member

                  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.

                  • 6. Re: Reading SCORM variables
                    www.cpguru.com Community Member

                    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.

                    • 7. Re: Reading SCORM variables
                      sigmundc

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

                      • 8. Re: Reading SCORM variables
                        www.cpguru.com Community Member

                        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.

                        • 9. Re: Reading SCORM variables
                          salvador_sorianojr Community Member

                          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.

                          • 10. Re: Reading SCORM variables
                            www.cpguru.com Community Member

                            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.

                            • 11. Re: Reading SCORM variables
                              merobertsjr Community Member

                              I am still having trouble with the first part, but once I can get the value to display in flash, then I will work on "transfering" it to captivate.

                               

                              I have decided to test in SCORM1.2,  because that is what works best on our LMS... So, I have modified the standard.js file in my captivate templates folder so that the javascript below is included in all published projects:

                               

                              function returnName(str)
                              {
                              return doGetValue('cmi.core.student_name');
                              }

                               

                              I will later create a function that works with SCORM 2004 and just name that function something like returnNameST

                               

                              Then I created the flash object and embeded it in my captivate project.  No changes to the code you suggested.  The problem is that nothing displays.  I tested the animation by supplying some text to it (then inserting into captivate), and that displays, but it does not work with the javascript function.  I get nothing displayed at all???

                               

                              Kind of fustrating because I have to publish all the way to the LMS to test, and then see no results...

                               

                              I'm not sure if it is just not executing the javascript call, or if it is not pulling any data from the LMS, or if there is something else going on...  Shouldn't it be giving me at least the appended "test" message as the string value if nothing is actually returned from the javascript function?

                              • 12. Re: Reading SCORM variables
                                merobertsjr Community Member

                                I finally figured it out.  Below is a link to a tutorial for anyone that is interested in reading SCORM variables in Captivate 5.

                                 

                                Click to see a Tutorial

                                • 13. Re: Reading SCORM variables
                                  yjia70 Community Member

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

                                   

                                  Thanks for sharing.

                                  • 14. Re: Reading SCORM variables
                                    swmangold Community Member

                                    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
                                    }

                                    • 15. Re: Reading SCORM variables
                                      markdins

                                      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

                                      • 16. Re: Reading SCORM variables
                                        merobertsjr Community Member

                                        I will post a link to my Moodle site this weekend and share a link when it

                                        is updated.  Sorry, I was only testing out ConnectPro.

                                         

                                        Thanks,

                                        • 18. Re: Reading SCORM variables
                                          Jumper06

                                          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

                                          • 19. Re: Reading SCORM variables
                                            sporschi82 Community Member

                                            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

                                            • 20. Re: Reading SCORM variables
                                              merobertsjr Community Member

                                              Hello,

                                               

                                              The function does not need to be in a specific place per say, but you have a typo on the javascript function.  The name of the function should be "returnName(str)" not "returName(str)".  Missing an "n".  Give that a try and let me know if that works.

                                               

                                              Michael

                                               

                                              www.vtrainingroom.com

                                              • 21. Re: Reading SCORM variables
                                                sporschi82 Community Member

                                                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.

                                                • 22. Re: Reading SCORM variables
                                                  jswift1234

                                                  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.student_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

                                                  • 23. Re: Reading SCORM variables
                                                    jswift1234 Community Member

                                                    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

                                                    • 24. Re: Reading SCORM variables
                                                      Frubisher Bold

                                                      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

                                                      • 25. Re: Reading SCORM variables
                                                        osbornsm Community Member

                                                        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