Display live LMS points in storyline
Jan 28, 2021
Hi, just wondering if anyone has had success displaying a learners current points when they launch a SL SCORM file.
Using Cornerstone LMS which has points and badges built in.
GOAL:
User launches a scorm file > current points for that user are retrieved from the LMS > points are displayed to user > user completes quiz > points are updated on both the lms and in the scorm on a page refresh / reload scene most likely.
POSSIBLE SOLUTION:
I have found this API Signature that retrieves a value from the LMS but don't know how to implement really.
LMSGetValue( element : CMIElement ) : string
The following code snippet does work for student name but am lost when it comes to points.
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var myID = lmsAPI.GetStudentID();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("FullName", newName);
player.SetVar("StuId", myID);
Any help greatly appreciated,
Stephen.
2 Replies
Sam Coulson assembled and posted the list of functions in the LMSAPI.js file.
https://community.articulate.com/discussions/articulate-storyline/help-with-javascript-and-pulling-data-from-an-lms
Two which should interest you are
lmsAPI.SetScore
andlmsAPI.GetScore
. We're going to work with the second. To retrieve the score and populate a custom Storyline variable, you could do something like this:var lmsAPI = window.parent;
var player = GetPlayer();
var lmsScore = (!lmsAPI.GetScore()) ? 0 : lmsAPI.GetScore();
player.SetVar("lmsScore", lmsScore);
While the 3rd line may look intimidating, it's actually an "if/else" statement condensed into a single line of script (called a "conditional (ternary) operator"). In English, it says "if the value of the variable 'score' on the LMS is 'null', set the value of 'lmsScore' to '0.' If the value of 'score' on the LMS is NOT 'null,' retrieve that value and place it into the variable 'lmsScore.'
Create a new variable in Storyline called
lmsScore
, being sure to mind the case.This is fantastic Joseph thanks very much for taking the time to reply and with such detail. I will test your suggestion and loop back to share my working project.
Many thanks,