XavierToyos
2 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 importantly, if anyone knows how to solve it.
The project has, at the beginning, a javascript that gets the name of the student from the LMS (I have extracted it from different forums, but I liked the PUNTOMOV one better). The javascript works perfectly, it's as follows....
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[1];
var lastName = array[0];
}
var player = GetPlayer();
player.SetVar("Nombre", firstName);
player.SetVar("Apellido", lastName);
Working with SCORM 2004 4ed, in Moodle Workplace 4.1.11, in Spanish, in Firefox.
The first thing that happens to me is that it can't work with the variables ("Nombre", "Apellido") separated. If I put only the "Nombre" variable somewhere in the project, it doesn't work. I have to put the "Apellido" variable next to it for it to work. I've tried to separate javascript into two, to get only one of the variables, but it doesn't work either. The two variables have to go together for them to work. Is there a way to get just one of the variables and have it work?
The second thing that happens to me is that when Javascript is executed, some triggers do not work, specifically those that pass to other slides in other scenarios. Without running javascript they do work. Does anyone know what is happening and how it can be solved?
Thanks a lot