Forum Discussion
How to access xAPI/Tin Can LMS variables in JavaScript
Hi, can anyone help me? Nandhakumar S code doesn't work quite right.
The Tin Can code works on Scorm Cloud but not on our custom system. We get mailto
Is there any workaround?
This might be occuring because of mbox.
function getParameterByName(name, url)
{
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var a =[];var a1 = [];
var foo = getParameterByName('actor');
a = foo.split(",");
var x=a[0];
a1 = x.split(":");
var str = a1[1];
var UName = str.replace(/[^a-zA-Z ]/g, "");
var player = GetPlayer();
player.SetVar("Username",UName);
Appreciated!
- Nandhakumar_S6 years agoCommunity Member
HI Steven Pascoe,
Can you share your working story file?
- rosycolelli6 years agoCommunity Member
Hello, I need to pass my score to LMS. I have to publish the course as Tincan. I tried the below Java but doesn't work.... LMS shows Score unknown
var player = GetPlayer(); var passingScore = "75"; 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); lmsAPI.SetScore(player.GetVar("Score"), 75, 0); if (player.GetVar("Score")>= passingScore) { SetStatus("passed"); } else { SetStatus("failed"); }
Could you help me, please?
- SocratesAnas2613 years agoCommunity Member
Why do I get the feeling that without coding skills nobody can really utilize xAPI statements?
- ChrisBurke-48fc3 years agoCommunity Member
Steven did you end up get a working result? I'm having a similar issue.