Import variable from SCROM to moodle LMS

Apr 07, 2023

I have made an e-learning course in articulate storyline 360, which is having a variable name score, that is updated on viewing each slide, so I want to get the value of the variable score and export it to Moodle LMS. I have the following javascript code but didn't work for me. Does anyone have a solution for this problem?

var lmsAPI = parent;
var player = GetPlayer();
var myScore = player.GetVar("LMS");
lmsAPI.SetScore(myScore,100,80);

2 Replies
Jürgen Schoenemeyer

here is a more universal method to find the lms

https://community.articulate.com/discussions/articulate-storyline/lmsapi-setscore-is-not-working

try this

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);

console.log( "lmsAPI", lmsAPI );

var player = GetPlayer();
var myScore = player.GetVar("LMS");

console.log( "myScore", myScore );

lmsAPI.SetScore(myScore,100,80);

with the two lines "console.log" you get debug info for the browser console -> F12