Forum Discussion

Bjarne's avatar
Bjarne
Community Member
11 years ago

Scorm 1.2 LMS communication and feedback using javascript and lmsAPI

Dear community,

I'm testing LMS (scorm 1.2) integration, using the sample story attached.
I'm fetching the students name from the LMS using the few lines of javascript below, as sampled elsewhere in this great forum, and I submit feedback using a TextEntry field.

var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
player.SetVar("studentName", myName);

My comments ARE being submittet to scorm cloud, encoded in the cmi.suspend_data, so communication does take place - but I'd rather store my comments somewhere else.

The scorm 1.2 runtime reference  mentions "cmi.comments (CMIString (SPM: 4096), RW) Textual input from the learner about the SCO"

I'm curious about the lmsAPI.GetStudentName(); used in the javascript above, it looks like a function made available by storyline?

Is there more to lmsAPI and where can I find information about it?

How do you handle feedback to your LMS?

Any ideas are greatly appreciated :)

Bjarne

  • Bjarne's avatar
    Bjarne
    Community Member

    An update to this challenge... I've managed to achieve most of what I want, fetching student data from scorm and submitting comments to cmi.comments, where they belong - using javascript-snippets like the following (please see attached story for full demo)...

     

    JS snippet to get studentname from lms

    var player = GetPlayer();
    var lmsStudentName = lmsAPI.GetStudentName();
    player.SetVar("lmsStudentName", lmsStudentName);

    JS to write comments to lms

    var player = GetPlayer();
    var lmsComments = player.GetVar("TextEntry");
    lmsAPI.WriteComment(lmsComments);

    There are many more interesting lmsAPI functions, including .GetStudentID, GetStatus, SetScore - dig into the LMSAPI.js that storyline creates to find more...

    I'm testing in scorm cloud and reload scorm player, with flash disabled, as I need this to work in HTML5 on tablets.

    Largely it works - but - if I click the "fetch variables from lms" button, and thus executes the javascript that gets my studentname etc from scorm, the "submit comments" button stops working?

    If I just click the js test popup buttons, there is no problem... So - I suspect, that something regarding GetPlayer og lmsAPI is not utilized or cleaned up correctly?

    Any good ideas are greatly appreciated!

    Bjarne

     

  • Hi Bjarne and thanks for this great input of information.

    Is there possible to create your own varibles and send to SCORM?

    I´ve been trying to create a input user name and password page in Storyline and send this info to the LMS and then when the user restart the project I want to check if this is the user that made the input and make him open the course and no need for rewrite ta new login information.

     

    Danne/

  • Hi Dan!

    This thread is a bit dated and I'm not sure that Bjarne is still subscribed here, but you are welcome to reach out to the user directly via the 'Contact Me' option on the user profile.

  • Hi.

    I use

    var player = GetPlayer();
    var lmsComments = player.GetVar("TextEntry");
    lmsAPI.WriteComment(lmsComments);

    but the variable when I try to read it give me

    [object Object]

    Do you know Why?

    Thanks

  • Is there any lmsAPI to get the Current Date or Registered date. I want to capture date when the user registered for that particular WBT on LMS.

    • JamesMartin-49f's avatar
      JamesMartin-49f
      Community Member

      This is an old thread, and I'm sure you've found a solution. But, for the benefit of others, you can always pull the current date from the JS Date() object. Here's a line I use in a Storyline project. I'm converting it to US format, but you can sub the language code for whatever you like. 

       const todaysDate = (new Date()).toLocaleDateString('en-US');

      In the rest of your Storyline project, you can now pull the date from the constant, todaysDate

      Here are some references for language codes: 

      https://www.andiamo.co.uk/resources/iso-language-codes/

      https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes