Using lmsAPI.GetScore();

Hi, 
We are creating a course that is in three parts, each part can be completed separately and only one part is to be attempted in the one year. On returning to the course we would like the course to get last year's score from the LMS and use that score as an ID to determine which course the learner does this time.

(BTW this is not using a quiz and results slide)

Is that possible?

I am currently able to SetScore but whatever I write for GetScore the syntax fails.

To Set the score I am using and it works a treat:

var lmsAPI = parent;
var player = GetPlayer();
var myScore= player.GetVar("certID");
lmsAPI.SetScore(myScore, 100, 0);
lmsAPI.CommitData();

I have tried variations on the following to get the score:

var lmsAPI = parent;
var myScore = lmsAPI.GetScore();
var player = GetPlayer();
player.SetVar(‘lmsCert’, myScore);

I have substituted myScore to other variables I have created but always get a fail.

PLEASE help!!

 

 

 

8 Replies
Sam Hill

Hi Helen,

If you are accessing the lmsAPI, shouldn't the first line be:

var lmsAPI = parent.lmsAPI;

 

Try outputting the values to the console.log to see if you are getting the expected values back. You view this by hitting F12 when the course loads.

var lmsAPI = parent;

console.log('-----------------> lmsAPI',lmsAPI);

var myScore = lmsAPI.GetScore();

console.log('-----------------> myScore',myScore);

BTW, you should be able to use this function call directly without using lmsAPI

var myScore = GetScore();

Helen Bundock

Hi Sam,

I tried all of your suggestions but unfortunately there was no success, the script is still flawed :(

Writing to console.log and hitting F12 produced a copious amount of information but nothing that referred to GetScore or lmsAPI.

Do you have a sample of code that is working and getting information from an LMS (Moodle or SCORM cloud)?