Basic Integration of SCORM API

May 13, 2013

Hello,

I am publishing my storyline as LMS SCORM 2004 output and run it with SCORM cloud.

I am having some issues with passing variables to scorm for reporting such as score (i am not using storylines score system so I want to manually pass it)

After reading large amount of info I come up with this Javascript but it doesnt work.

In short my question is, Should I do the Initialize, scan for API or these setups are already done for me after launching the game?

So that i can perform something like API.SetValue("cmi.score_raw", "98");

My code is:

var nFindAPITries = 0;
var API = null;
var maxTries = 500;

function ScanForAPI(win)
{
   while ((win.API_1484_11 == null) && (win.parent != null) && (win.parent != win))
   {
      nFindAPITries++;
      if (nFindAPITries > maxTries)
      {
         return null;
      }
      win = win.parent;
   }
   return win.API_1484_11;
}

function GetAPI(win)
{
   if ((win.parent != null) && (win.parent != win))
   {
      API = ScanForAPI(win.parent);
   }
   if ((API == null) && (win.opener != null))
   {
      API = ScanForAPI(win.opener);
   }
  }

var player = GetPlayer();

var returnval = GetAPI();

player.SetVar("testtest2", API);
player.SetVar("testtest", returnval );

API.Initialize("");
API.SetValue("cmi.score_raw", "98");
API.Commit("");

14 Replies
Steve Flowers

You shouldn't have to scan for the API. Everything you'd want to do on the LMS is available through the existing lmsAPI. Try this:

lmsAPI.SetScore(98,100,0);

Your LMS may nest funny. In which case you might need to break out with:

lmsAPI=parent;

lmsAPI.SetScore(98,100,0);

Many SCORM methods are available within the lmsAPI object. Simply passing...

SetStatus("completed"); 

...through a JavaScript trigger should mark your SCO complete on the LMS.

Steve Flowers

It is possible. You could access the write function directly or use the lmsAPI abstraction. The Storyline lmsAPI layer abstracts to multiple types of interactions. Interactions are relational and a bit more complicated than a single data field. It'll take some doing to unravel, but your best bet may be taking advantage of the RecordInteraction(arrArgs) function. 

Zio Fonta

thank you Phil, I'm doing some tests using the following approach. (sort of simplified interactions)

i will try to set one cmi.interactions.n.id for each slide,

setting the parameter cmi.interactions.n.description to "notviewed" by default, and setting it to "viewed" whe the timeline of that slide ends. Description is a simple text field that maybe could be good just as info to report to Moodle.

I'm using "description" since the specific cmi.interactions.n.result only supports the value "correct, incorrect,unanticipated, neutral, real"  and i suppose it has been planned to be used in different way originary.

I'll let you know, thank you for supporting.

Zio Fonta

...nothing happens. Seems like no variables are set or changed.

I used this javascript on first slide at begin of timeline:

var lmsAPI = parent;

lmsAPI.SetValue("cmi.interactions.1.id","slide1");

 lmsAPI.SetValue("cmi.interactions.2.id","slide2");

 lmsAPI.SetValue("cmi.interactions.1.description","incomplete");

 lmsAPI.SetValue("cmi.interactions.2.description","incomplete");

then at the end of timeline of slide 1 i executed:

var lmsAPI = parent;

 lmsAPI.SetValue("cmi.interactions.1.description","completed");

am i missing something?

Zio Fonta

i thougt it was not reported because i used scorm 1.2 as standard when publishin, while it seems that interactions could be specific for 2004 scorm standards, so i tried publishing for 2004 specifications, but still nothing.

the main question is: anyone of you has never developed a whole course where all slides were requested to be tracked by lms to report the progress of the user? is it possible that this feature has not been planned to be implemented, or implemented in a more easy or logical way?

do you have any other idea to report the user progress throug the course into lms tracking the slide viewed?

thank you

Phil Mayor

I have only tried setting the score through moodle so cannot help here.

perhaps the workaround here is to set variables on timeline end for each slide and do not allow progresion to the final slide until all of these are true, you could also create hidden T/F questions for each slide and force the variable value into each slide.

A reasonable amount of work

Zio Fonta

i had thought to set each slide as a "hidden" question as you suggest, Phil, but that means changing navigation standards, layouts, slide master etc. i would like to use the preferred tools for developing in the standard way,

About the score tip, maybe i could use a score value of 0 at beginnin of course and increment by 1 at each slide end, in this way if i am able to read the score value in moodle i can have a feedback about how many slides has been viewed (score=10 means 10 slides viewed and so on)

but when i set tracking based on number of slide viewed (the first option in storyline), are somewhere stored values in certain scorm variable that record the number of slides viewed? do you know which value/parameter could be?

thank you

George Ganahl

Zio,

Are you still around? I am trying to do something very similar - I want to be able to track completion of each piece of Content within a Course in Expertus, so I need some way to tell the LMS when each piece is completed. Did you ever figure out how to get the javascript to write to the LMS via the SCORM API?

manoj singh

Hi,

I am new to Scorm and LMS. I have to develop a SCORM (any version) compliant LMS. What all  I need to do to make my LMS Scorm compliant. I can see everywhere there is an API wrapper with eight common function to interact with the LMS but I can not find the scorm API anywhere. Do I need to write those API myself or only API wrapper is enough? Or is there any URL that you guys can share.... 

Ashley Terwilliger-Pollard

Hi Manoj,

Are you looking to develop and start your own LMS from scratch? You may want to look in the Building Better Courses side of the community as I don't know that I've seen a lot of discussion on that here in the Product side of the forum. You may also want to review this information about SCORM from Rustici who are leaders in the SCORM world. 

This discussion is closed. You can start a new discussion or contact Articulate Support.