Forum Discussion
LMS Course Name JavaScript Action
Morning all,
I am hoping someone will be able to support me here, I am trying to have a JavaScript action that will set my "CourseName" the code i am using is as follows;
var player=GetPlayer();
var course=player.GetVar("CourseName");
player.SetVar("CourseName");
I use an LMS and this story-line certificate is embedded in to a Rise package, i have managed to get the Student Name and Date to all pull through from the LMS but i cannot get the Course Name to do the same (example of student name is below incase this is needed)
var player = GetPlayer();
function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var LMSName = array[1] + ' ' + array[0];
player.SetVar("newName", LMSName);
26 Replies
- CraigBunyea-23dCommunity Member
So much like lmsAPI.GetStudentName(); fetches the variable myName, there should be a function within lmsAPI that can retrieve the className. Use your console and type "lmsAPI." and scroll to all the Get functions, there are likely many. Just guessing, it could be lmsAPI.GetClassroomName(); but everything's case-sensitive of course.
That is what you'll add to the right of =- PhilMayorSuper Hero
LMSSPI doesn’t normally have course name suspect there is a ERS API as well
Sent from my iPhone
- PhilMayorSuper Hero
But if it resolves directly in the console you should be able to use as is.
Sent from my iPhone
- JoeLloyd-17dcfeCommunity Member
very very strange..... i am just not sure if i have set it up correctly but if the code is there and is being instructed and initiated the exact same as the other codes then it should be working in theory but for some reason it just isnt.....
- CraigBunyea-23dCommunity Member
Well it's entirely possible that multiple APIs are running in your environment, so the method you're using to invoke GetStudentName() in fact might not include any reference to what you'd think is a GetClassName(). When desperate I've gone to the Console's sources tab and explored what look like API scripts and searched for some variable reference I know exists. Storyline includes scormdriver.js when publishing for a SCORM LMS.
- Jürgen_Schoene_Community Member
the LMS stores Scorm data and Scorm data are ONLY learner data - name, state ...
the "name of the course" does not belong to it
- JoeFrancisCommunity Member
Sam Coulson listed all of the available functions in LMSAPI.js several years ago. These functions correspond to their AICC/SCORM data elements. While AICC did have a data element reserved for course title called course.title, SCORM did not carry that data element over.
Since that element doesn't exist, you can't even query the LMS through the API using the SCORM function GetValue(element:CMIElement) : string, because, again, course.title doesn't exist in the SCORM dataset.