Retrieving cmi.mode

Feb 28, 2020

Hi

I have used the following script to retrieve a users name from our LMS and have no problems, using the tool in a range of e-products I've produced.

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 getName = lmsAPI.GetStudentName();
var newName = getName.split(" ");


player.SetVar("firstName", newName[0]);
player.SetVar("lastName", newName[1]);

 

I now wish to retrieve the details of the cmi.mode that the user launches the course in, in order to distinguish between live, browse or preview modes.  I need to be able to do this in order to restrict what the user sees/accesses in 'preview' mode, as currently this mode gives them access to a range of live assessments that should only be visible and available to complete when working in the 'live' environment.

I was hoping the above script would do the job, by simply amending the variable names and using the var getMode = lmsAPI.GetMode(); line of code to retrieve what I need.  Once retrieved and the result passed to a Storyline variable I can then limit access based on the way the course has been launched i.e. live or preview.

Amending the script above does not seem to be having the positive effect that retrieving the users name from the LMS does and at the moment I can't seem to get any Mode value returned to work with.

Can anyone please assist?

Regards

Rob  

2 Replies
Rob Wilson

Russell

You star 😉

That works a treat and for testing purposes it's displaying the value of 'Normal' in the Storyline variable text box  when the course is launched as normal and 'Review' in the text box when completed and re-worked in review mode.

What a star. I think I was close, but was going round in circles and don't think I'd have got there without your help.

I can now restrict course access based on whether the user is in normal or review mode.

Thanks again.

Rob

 

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