How to grab a student's name from LMS and store it in a Captivate variable

1,692 views
Skip to first unread message

Kevin Brokamp

unread,
Jan 21, 2011, 2:14:46 PM1/21/11
to eLearning Technology and Development
Hi all. I'm trying to do something seemingly simple, but I'm having
the hardest time accomplishing it so I figured I would post here and
ask if anyone has any tips.

I'm using Captivate 5 to generate SCORM 1.2 compatible content for use
with an LMS. I'm trying to figure out a way to grab the student's
name from the LMS and assign it to a user variable in Captivate so
that I can use it throughout a training module. I'm able to grab
student name from the LMS using the
LMSGetValue('cmi.core.student_name'); command in js, but I can't for
the life of me how to get Captivate to grab that information and store
it in a variable. Any help would be greatly appreciated.

Philip Hutchison

unread,
Jan 21, 2011, 2:57:52 PM1/21/11
to elearning-technolo...@googlegroups.com
If you're using Captivate 5, try this:

In your JS:

function populateName(){

  //Get the name from SCORM 1.2
  var thename = LMSGetValue('cmi.core.student_name');

  //Send the name to Captivate via ExternalInterface
  document.getElementById("Captivate").cpEISetValue("studentname", thename);

}

invoke this JavaScript function somewhere in your CP5 file *after* it has finished loading (ExternalInterface (cpEISetValue) will take a second or two before it's ready).

some notes:

1. this code assumes your Captivate SWF is embedded with the ID "Captivate"; if not, change "Captivate" to the SWF's new ID 
2. this code assumes your user-defined variable in captivate is named $$studentname$$ -- change it to whatever variable name you actually use.


- philip





--
You received this message because you are subscribed to the Google Groups "eLearning Technology and Development" group.
To post to this group, send email to elearning-technolo...@googlegroups.com.
To unsubscribe from this group, send email to elearning-technology-and...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/elearning-technology-and-development?hl=en.


Philip Hutchison

unread,
Jan 23, 2011, 7:36:09 PM1/23/11
to elearning-technolo...@googlegroups.com
just an added FYI:  the code i provided in my previous post may not work, it's just an idea.

in order for external interface to update a variable value, that variable has to be exposed to JS via an externalinterface callback.  the cpEISetValue method is a custom method created by the Captivate product team; it uses externalinterface, but might not be configured to accept values for custom variables.

it works fine for CP5's system variables.

- philip

Kevin Brokamp

unread,
Jan 24, 2011, 9:18:06 AM1/24/11
to eLearning Technology and Development
Philip,

Thanks so much for your reply. I had previously been using a flash
object on the slide (which pretty much did the same thing by calling
ExternalInterface), but knew there had to be a better way.

I modified your code a bit so that I can use the function to call any
of the values available via SCORM and it's working perfectly. I added
the function to the scorm_support.js file located in <installdir>
\Templates\Publish\SCORM\1_2\SCORM_support so that it will available
in all of my published projects. I figured I would post it here in
case anyone else is struggling with this.

1. Added the following function to scorm_support.js file:

function scorm_get(cmivalue, whichval){

//Get the name from SCORM 1.2
var theval = g_objAPI.LMSGetValue(cmivalue);

//Send the name to Captivate via ExternalInterface
document.getElementById("Captivate").cpEISetValue(whichval,
theval);

}


2. I created a user variable in CP5 called studentname. Right now
I'm needing to grab the student's name, but in the future I may use
the same function to grab and store additional info via LMSGetValue

3. Added the following javascript call to an advanced action in CP5.
scorm_get('cmi.core.student_name', 'studentname');

You were right about waiting a few seconds for ExternalInterface to be
available. In my case I had to add a 10 second 'loading' slide at the
beginning of the project and have it run the scorm_get function on
exit (not a problem if you're not using the student's name on the very
first slide).

I've been trying to figure out a way to have the project wait until
External Interface is available, then call JS and continue, but
haven't had any luck so far.

Thanks again for your help.

Kevin


On Jan 23, 7:36 pm, Philip Hutchison <platelu...@gmail.com> wrote:
> just an added FYI:  the code i provided in my previous post may not work,
> it's just an idea.
>
> in order for external interface to update a variable value, that variable
> has to be exposed to JS via an externalinterface callback.  the cpEISetValue
> method is a custom method created by the Captivate product team; it uses
> externalinterface, but might not be configured to accept values for custom
> variables.
>
> it works fine for CP5's system variables.
>
> - philip
>
> On Fri, Jan 21, 2011 at 11:57 AM, Philip Hutchison <platelu...@gmail.com>wrote:
>
> > If you're using Captivate 5, try this:
>
> > In your JS:
>
> > function populateName(){
>
> >   //Get the name from SCORM 1.2
> >   var thename = LMSGetValue('cmi.core.student_name');
>
> >   //Send the name to Captivate via ExternalInterface
> >   document.getElementById("Captivate").cpEISetValue("studentname",
> > thename);
>
> > }
>
> > invoke this JavaScript function somewhere in your CP5 file *after* it has
> > finished loading (ExternalInterface (cpEISetValue) will take a second or two
> > before it's ready).
>
> > some notes:
>
> > 1. this code assumes your Captivate SWF is embedded with the ID
> > "Captivate"; if not, change "Captivate" to the SWF's new ID
> > 2. this code assumes your user-defined variable in captivate is named
> > $$studentname$$ -- change it to whatever variable name you actually use.
>
> > - philip
>
> > On Fri, Jan 21, 2011 at 11:14 AM, Kevin Brokamp <kevin.brok...@gmail.com>wrote:
>
> >> Hi all.  I'm trying to do something seemingly simple, but I'm having
> >> the hardest time accomplishing it so I figured I would post here and
> >> ask if anyone has any tips.
>
> >> I'm using Captivate 5 to generate SCORM 1.2 compatible content for use
> >> with an LMS.  I'm trying to figure out a way to grab the student's
> >> name from the LMS and assign it to a user variable in Captivate so
> >> that I can use it throughout a training module.  I'm able to grab
> >> student name from the LMS using the
> >> LMSGetValue('cmi.core.student_name'); command in js, but I can't for
> >> the life of me how to get Captivate to grab that information and store
> >> it in a variable.  Any help would be greatly appreciated.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "eLearning Technology and Development" group.
> >> To post to this group, send email to
> >> elearning-technolo...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> elearning-technology-and...@googlegroups.com<elearning-technology-and-development%2Bunsu...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/elearning-technology-and-development?h...
> >> .

Philip Hutchison

unread,
Jan 24, 2011, 1:12:57 PM1/24/11
to elearning-technolo...@googlegroups.com
ExternalInterface takes a little while to initialize, but it should be ready by the time your Captivate SWF is executing code. So, you could flip things around and make your SWF handle the invocation try adding a JS callback in your Captivate file.

First slide: execute JavaScript action
lookMaNoHands();


where in your JS you could have something like:

function lookMaNoHands(){
   scorm_get('cmi.core.student_name', 'studentname');
}


obligatory disclaimer: i haven't tested this, but i assume it would work as suggested.

- philip




To unsubscribe from this group, send email to elearning-technology-and...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/elearning-technology-and-development?hl=en.


Jumper

unread,
Mar 10, 2011, 2:08:31 PM3/10/11
to eLearning Technology and Development
Hi, I am having dreadful trouble making this work. The value reported
is always zero. Any ideas as to why? Your help would be really
appreciated

This is what I have done:

Placed the following code in to the js support folder:

//Get the name from SCORM 1.2
var theval = g_objAPI.LMSGetValue('cmi.core.student.name');

//Send the name to Captivate via ExternalInterface

document.getElementById("Captivate").cpEISetValue("studentname",
theval);

}

Added the following Java action to run on the entry onto the first
captivate page

scorm_get('cmi.core.student_name', 'studentname');

Created a user variable called student name
Created a text caption
Inserted the student name in the text caption

Published the file as scorm 1.2 and uploaded the zip files to moodle

I have left the document.getElementById("Captivate") as I am not sure
how to identify the ID.

I am using moodle 2.02 and Captivate 5.1

Thanks for any help you can give.

On Jan 24, 6:12 pm, Philip Hutchison <platelu...@gmail.com> wrote:
> ExternalInterface takes a little while to initialize, but it should be ready
> by the time your Captivate SWF is executing code. So, you could flip things
> around and make your SWF handle the invocation try adding a JS callback in
> your Captivate file.
>
> First slide: execute JavaScript action
> lookMaNoHands();
>
> where in your JS you could have something like:
>
> function lookMaNoHands(){
>    scorm_get('cmi.core.student_name', 'studentname');
>
> }
>
> obligatory disclaimer: i haven't tested this, but i assume it would work as
> suggested.
>
> - philip
>
> > <elearning-technology-and-development%2Bunsu...@googlegroups.com<elearning-technology-and-development%252Buns...@googlegroups.com>

John Campbell

unread,
Mar 10, 2011, 2:12:06 PM3/10/11
to elearning-technolo...@googlegroups.com
If you alert theval in JS, it's always blank or 0?  Or is it 0 when you pass it along to CP?

jpc

To unsubscribe from this group, send email to elearning-technology-and...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/elearning-technology-and-development?hl=en.




--
John Campbell

Jumper

unread,
Mar 10, 2011, 2:19:42 PM3/10/11
to eLearning Technology and Development
I am afraid my Java script knowledge is almost non existent. What I
mean is that the Caption in captivate which is supposed to show the
student name merely shows the number O

Thanks for getting back so quickly
> >http://groups.google.com/group/elearning-technology-and-development?h....
>
> --
> John Campbell

John Campbell

unread,
Mar 10, 2011, 2:22:15 PM3/10/11
to elearning-technolo...@googlegroups.com
In Javascript, do this where you had it before:

var theval = g_objAPI.LMSGetValue('cmi.core.student.name');
alert("NAME: " + theval);

What do you see?

jpc






--
John Campbell

Jumper

unread,
Mar 10, 2011, 2:30:23 PM3/10/11
to eLearning Technology and Development
Hi A small popup appears with the word Name and then a blank space.

regards

J

On Mar 10, 7:22 pm, John Campbell <j...@alumni.rice.edu> wrote:
> In Javascript, do this where you had it before:
>
> var theval = g_objAPI.LMSGetValue('cmi.core.student.name');
> alert("NAME: " + theval);
>
> What do you see?
>
> jpc
>
> ...
>
> read more »

Philip Hutchison

unread,
Mar 10, 2011, 2:33:00 PM3/10/11
to elearning-technolo...@googlegroups.com
you have a typo in your SCORM code:

cmi.core.student.name should be cmi.core.student_name

use an underscore between student and name




John Campbell

unread,
Mar 10, 2011, 2:35:41 PM3/10/11
to elearning-technolo...@googlegroups.com, Jumper
Then there is no name in the LMS.

I'm not super familiar with 1.2.   Is it student.name?    In 2004 it's cmi.learner_name.  Are you sure the data model element is correct?  

jpc




--
John Campbell

John Campbell

unread,
Mar 10, 2011, 2:36:22 PM3/10/11
to elearning-technolo...@googlegroups.com
Try cmi.core.student_name    I think that is it.

jpc
--
John Campbell

John Campbell

unread,
Mar 10, 2011, 2:40:35 PM3/10/11
to elearning-technolo...@googlegroups.com
I see Phil replied too.

BTW this is a good example of how to debug.  An understanding of all the layers is key to figuring stuff like this out.  With so many layers API->JS->Flash/CP/Whatever, you can get confused where the error actually lies.  It's best to start at the lowest level and work up so you isolate what is being tested.

jpc
--
John Campbell

Jumper

unread,
Mar 10, 2011, 2:46:35 PM3/10/11
to eLearning Technology and Development
Thanks, have corrected the typo (thanks for spotting it).
Unfortunately I still getting a value of Zero. The site has an ssl
could that be making the difference, or maybe I am using the wrong ID?


On Mar 10, 7:33 pm, Philip Hutchison <platelu...@gmail.com> wrote:
> you have a typo in your SCORM code:
>
> cmi.core.student.name should be cmi.core.student_name
>
> use an underscore between student and name
>
> ...
>
> read more »

John Campbell

unread,
Mar 10, 2011, 2:49:58 PM3/10/11
to elearning-technolo...@googlegroups.com, Jumper
Is your alert still "NAME:"  without a learner name or does it have data?

jpc

To unsubscribe from this group, send email to elearning-technology-and...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/elearning-technology-and-development?hl=en.




--
John Campbell

Jumper

unread,
Mar 10, 2011, 2:56:15 PM3/10/11
to eLearning Technology and Development
Still blank unfortunately.

regards

j

On Mar 10, 7:49 pm, John Campbell <j...@alumni.rice.edu> wrote:
> Is your alert still "NAME:"  without a learner name or does it have data?
>
> jpc
>
> ...
>
> read more »

John Campbell

unread,
Mar 10, 2011, 3:07:05 PM3/10/11
to elearning-technolo...@googlegroups.com, Jumper
Are you sure the name is in the LMS? Try it on another system (SRTE, SCORM Cloud, etc) and see what pops up.

jpc

> ...
>
> read more »

--
You received this message because you are subscribed to the Google Groups "eLearning Technology and Development" group.
To post to this group, send email to elearning-technolo...@googlegroups.com.
To unsubscribe from this group, send email to elearning-technology-and...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/elearning-technology-and-development?hl=en.




--
John Campbell

Jumper

unread,
Mar 10, 2011, 3:27:09 PM3/10/11
to eLearning Technology and Development
I have this working, not sure why> I have reverted back to Kevin's
original script:

function scorm_get(cmivalue, whichval){

//Get the name from SCORM 1.2
var theval = g_objAPI.LMSGetValue(cmivalue);

//Send the name to Captivate via ExternalInterface
document.getElementById("Captivate").cpEISetValue(whichval,
theval);

}

What is strange however is that the value is still initially returned
as O but then changes to return the value of the student's name.
Thanks for your help John, it was very much appreciated. As was your
help Phillip. Do either of you know why it takes so long for the
variable to be passed?

warm regards

J

On Mar 10, 8:07 pm, John Campbell <j...@alumni.rice.edu> wrote:
> Are you sure the name is in the LMS? Try it on another system (SRTE, SCORM
> Cloud, etc) and see what pops up.
>
> jpc
>
> ...
>
> read more »
Message has been deleted

serrioal

unread,
Jun 13, 2011, 9:47:50 AM6/13/11
to elearning-technolo...@googlegroups.com
I've been working on this for 5 days to no avail. Once I understand what's going on I'll be good to go but I've never really used Captivate or SCORM to any extent. Here's what I have going on so far. I'm using SCORM 1.2 and Captivate 5.

I have a project named "GMPAssessment.cptx".

In the scorm_support.js file I added the following:
     function scorm_get(cmivalue, whichval){ 

           //Get the name from SCORM 1.2 
           var theval = g_objAPI.LMSGetValue(cmivalue); 

           //Send the name to Captivate via ExternalInterface 
           document.getElementById("GMPAssessment").cpEISetValue(whichval,theval); 
     } 

The first slide is Executing an AdvancedAction that executes JS:  
     scorm_get('cmi.core.student_name', 'studentname');
(Does the current, new, parent, top, select box matter?)

The second slide has a textbox with the variable $$studentname$$

After I publish the project, I verify that the getElementById is indeed "GMP Assessment" then I zip all of the project files and upload them to my LMS. The variable remains empty. Please help debug!

Philip Hutchison

unread,
Jun 13, 2011, 4:34:57 PM6/13/11
to elearning-technolo...@googlegroups.com
Captivate's publishing template uses the id "Captivate" by default.  If you're using the template(s) that ship with Captivate, it should be set for you and you won't need to change it.


On Mon, Jun 13, 2011 at 6:02 AM, serrioal <ser...@gmail.com> wrote:
New to all things Captivate, where in the project do I need to make sure the name is "Captivate"? 

Referencing the line: document.getElementById("Captivate").

--
You received this message because you are subscribed to the Google Groups "eLearning Technology and Development" group.

To post to this group, send email to elearning-technolo...@googlegroups.com.
To unsubscribe from this group, send email to elearning-technology-and...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/elearning-technology-and-development?hl=en.

Lee Graham

unread,
Jun 14, 2011, 1:04:46 PM6/14/11
to eLearning Technology and Development
Hi Philip,

Do you know how I could easily do this with Flash/Captivate/AS3 and
AICC? =)

Thanks






On Jun 13, 4:34 pm, Philip Hutchison <platelu...@gmail.com> wrote:
> Captivate's publishing template uses the id "Captivate" by default.  If
> you're using the template(s) that ship with Captivate, it should be set for
> you and you won't need to change it.
>
>
>
>
>
>
>
> On Mon, Jun 13, 2011 at 6:02 AM, serrioal <serr...@gmail.com> wrote:
> > New to all things Captivate, where in the project do I need to make sure
> > the name is "Captivate"?
>
> > Referencing the line: document.getElementById("Captivate").
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "eLearning Technology and Development" group.
> > To view this discussion on the web visit
> >https://groups.google.com/d/msg/elearning-technology-and-development/...
> > .
>
> > To post to this group, send email to
> > elearning-technolo...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > elearning-technology-and...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/elearning-technology-and-development?h....

Philip Hutchison

unread,
Jun 14, 2011, 1:06:27 PM6/14/11
to elearning-technolo...@googlegroups.com
Sorry, I don't work with AICC, so I'm not much help there.




Philip Hutchison

unread,
Oct 29, 2012, 5:16:37 PM10/29/12
to elearning-technolo...@googlegroups.com
The only difference with Captivate 6 is the JavaScript syntax for the SCORM code.  Captivate 6 uses Rustici Software's SCORM Driver to handle SCORM calls.

I haven't worked with SCORM Driver, but according to the documentation, all you need to do is call GetStudentName()

Same example from previous email, updated with SCORM Driver code:

function populateName(){

  //Get the name from SCORM 1.2
  var thename = GetStudentName();

  //Send the name to Captivate via ExternalInterface
  document.getElementById("Captivate").cpEISetValue("studentname", thename);

}


Haven't tested it, but in theory it should work fine.

- philip



On Mon, Oct 29, 2012 at 2:06 PM, Jason Smith <jasonco...@gmail.com> wrote:
Has anyone done this same set up for Captivate 6?
________________________________________________
--
You received this message because you are subscribed to the Google Groups "eLearning Technology and Development" group.

Vladislav Volokhov

unread,
Dec 7, 2012, 2:46:31 AM12/7/12
to elearning-technolo...@googlegroups.com
And then I delete my custom JS-code - course start to work correctly! :( 

On Thursday, December 6, 2012 7:25:44 PM UTC+4, Vladislav Volokhov wrote:
Hi, Guys!


I need your help!

After reading of this topic I try to take  username from Moodle to Captivate course. I create User Variable "studentname" in Captivate and put it to my course in Text caption.

I find recommendation here that I need to get value "cmi.core.student_name" from Moodle.

After that I published my project. Course and published swf file has a name "Captivate".

Then I open file "scorm_support.js" from "\SCORM_support" folder and add this:

function scorm_get(cmi.core.student_name, studentname){


       //Get the name from SCORM 1.2
       var theval = g_objAPI.LMSGetValue(cmi.core.student_name);


       //Send the name to Captivate via ExternalInterface
       document.getElementById("Captivate").cpEISetValue(studentname, theval);

     }

Then I save file, create new zip-package and add it to Moodle.

But course does not open in Moodle - it shows only grey background without any activity for course (attached picture)!

What I do  wrong?

BTW - Is it important to put my custom JS-code in same special string in file "scorm_support.js"? I can put it in any string?

 

Philip Hutchison

unread,
Dec 7, 2012, 7:15:20 PM12/7/12
to elearning-technolo...@googlegroups.com
The custom code should work fine in scorm_support.js, but watch out for typos, and be careful not to mess up the existing javascript


--
 
 

Najeeb Haider

unread,
Jan 19, 2014, 12:48:35 AM1/19/14
to elearning-technolo...@googlegroups.com
Hi;
any progress on this so far?

I have tried this in one of my trainings, js is working fine; I used the function;
function scorm_get(cmivalue, whichval){


       //Get the name from SCORM 1.2
       var theval = g_objAPI.LMSGetValue(cmivalue);


       //Send the name to Captivate via ExternalInterface
       document.getElementById("Captivate").cpEISetValue(whichval,
theval);

     } 
in scorm support js and
scorm_get('cmi.learner_name', 'StudentName');
scorm_get('cmi.learner_id', 'StudentID');
in captivate;

Uploaded the training in SCORM Cloud; but the variables returned 0 value;

When I investigated through SandBox registration in Scorm Cloud for the training; it shows the variable cmi.learner_name and its value is set there as registrant name. in debug log report; it says

 

+ [07:46:28.414] LMSGetValue('cmi.learner_name') returned ''  in 0.001 seconds 

[07:46:28.414] CheckForGetValueError (cmi.learner_name, cmi.learner_name, , )

 

[07:46:28.415] SCORM ERROR FOUND - Set Error State: 201 - The parameter 'cmi.learner_name' is not recognized.

 

so the function was called correctly from the Captivate and scorm_support.js but was not answered correctly by Scorm cloud;

ERR 201 as per SCORM RTE Reff is

General Argument Error (201) An invalid argument was passed to an API method (usually indicates that Initialize, Commit or Terminate did not receive the expected empty string argument.

 

Any help in this regard will be appreciated;

Philip Hutchison

unread,
Jan 19, 2014, 1:01:40 AM1/19/14
to elearning-technolo...@googlegroups.com
cmi.learner_name is SCORM 2004 syntax. You said your course is SCORM 1.2.  For SCORM 1.2, use cmi.core.student_name



--
You received this message because you are subscribed to the Google Groups "eLearning Technology and Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elearning-technology-and...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Najeeb Haider

unread,
Jan 19, 2014, 1:19:18 AM1/19/14
to elearning-technolo...@googlegroups.com

Yes Just figured it out; its working correctly now

thanks for your help.
To unsubscribe from this group and stop receiving emails from it, send an email to elearning-technology-and-development+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages