Change variable based on javascript results?
Apr 08, 2016
At the end of our courses, we have a course completion certification that includes the student's name. I use a javascript to pull in the student name from the LMS. Some of our courses, however, are used outside of the LMS (by contractors) and we have fields built into the beginning of the course requiring the contractor to enter their name.
What I'd like to do is create a T/F variable "Employee" with the default set to False. Then, have it change to True if the javascript returns a user name from the LMS. Any ideas how to do this?
Having this will allow me to create a slide trigger which will all the user (employees) to by-pass the manual name entry page if the employee variable is true, so that only contractors see the manual name entry fields.
Any ideas?
Thanks,
Bobbi
3 Replies
Thinking that maybe there is a way to execute the javascript and then if the javascript results are:
null, then "employee" variable would remain falsenot null, then "employee" variable would be changed to true
Hi, Bobbi -- Thanks for reaching out and unfortunately, I am not equipped to provide support for JavaScript, so I will need to defer to the many gurus in the community to stop in and assist you further. And, in case you haven't had a chance to check it out, here is our JS Best Practices sheet, as well. :)
Bobbi, it appears that if you try to invoke the lmsapi command to get the name, and you're running outside of an LMS, then nothing happens. In that case you could probably set the name variable to a default value and then see if it changes after you try to get the name from the LMS. Does that make sense?
This discussion is closed. You can start a new discussion or contact Articulate Support.