Forum Discussion

HelenBundock-d2's avatar
HelenBundock-d2
Community Member
5 years ago

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

 

 

 

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

  • Thanks Sam, I'm new to JS and implementing whatever I can find via Dr Google searches! Thanks for your offerings and so quickly! 
    I'll get into testing them tomorrow and let you know how I go! 

     

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

     

  • Hi Helen, would you mind providing your Storyline file. I can take a look for you and see if I can figure out what is going on.

  • Thanks Sam, please see attached. Really appreciate your help with this. As I said earlier, I can get the learner name from the LMS and set the score in the LMS OK UNTIL I add the GetScore script and then everything falls apart!

     

  • Hi Helen, it was just a small problem with some JavaScript. The quotes that you have around lmsCert are not supported by JavaScript. See the attached screen shot that illustrates the correct quotes to use. Also attached the fixed file.

  • AndyKerslake's avatar
    AndyKerslake
    Community Member

    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