Using lmsAPI.GetScore();

Jun 16, 2020

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!!

 

 

 

9 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)?

 

Andy Kerslake

Sam/Helen

Great thread - thanks for the advice.

I am trying to acheive something very similiar as outlined above. I want a previously scored quiz score to be displayed. When i initally run the javascript, NaN is returned (even though the quiz has previously been completed). I've tried using parseInt() to convert whatever is returned into a number, but doesnt work.

I am forced to complete the quiz again, before the score is returned which negates what i am trying to achieve (return the score from a previous attempt).

The code works, but only once the quiz has been completed within the session running. Can you think why the code doesnt recall the score from an earlier attempt?

Thank you in advance if you do have any ideas...

Andy