Forum Discussion
XavierToyos
4 months agoCommunity Member
Problems with a javascript
Hello everyone. There are two things happening to me in the same project and I wanted to share it with you in case someone has encountered the same problem and, most import...
XavierToyos
3 months agoCommunity Member
Solved. The final solution is.....
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 newName = "Invitado";
if (lmsAPI) {
var myName = lmsAPI.GetStudentName();
var array = myName.split(' ');
var firstName = array[0];
var lastName = array[1];
}
var player = GetPlayer();
player.SetVar("Nombre", firstName);
player.SetVar("Apellido", lastName);
.... works perfectly.
Thank you all