Forum Discussion
MarkMair-d5b693
8 years agoCommunity Member
Getting the student name from the LMS
Hi,
I'm writing a user security awareness training course, part of which prompts the student to select whether an email is a phishing email or safe to open. I'd like to display the students actua...
KnutJackowski
8 years agoCommunity Member
Hi Mark,
to do this, you will first need to create a text variable and then change that via Javascript (create a trigger "Execute JavaScript".
This code will change an existing variable called "email" to the student_id, which might be the email (in our system it is not, but in many systems it is):
/* First you need the player to have access to the methods that will allow you to change variables in the course */
var player = GetPlayer();
/* this function looks for the lms API */
function findLMSAPI(win) {
// look in this window
if (win.hasOwnProperty("GetStudentID")) return win;
// all done if no parent
else if (win.parent == win) return null;
// climb up to parent window & look there
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
/* I am using the method "GetStudentID()", because it is the common method for an LMS to provide this. You might have to replace it with the one provided by your LMS provider. */
var email = lmsAPI.GetStudentID();
player.SetVar("email", email);
- MarkMair-d5b6938 years agoCommunity Member
Hi Knut,
thanks for this. I really appreciate it.
Mark
Related Content
- 10 months ago
- 11 months ago
- 11 months ago