Sending a pass or fail to LMS
Feb 07, 2022
By
Donald John
Hello everyone.
I am probably overthinking this massively so apologies if this wins the stupidest question ever award.
I have a simple course that has a var called total_score (original I know!). All I am trying to do is let the moodle LMS know if someone passed or failed the course.
I understand that I must use Javascript to make this happen? So in this example I have 5 steps in a process, for every step the user gets right they score a point. They need 4 out of 5 to pass.
So at the end of this example the total_score var is used to tell them if they passed or failed, but I am trying to let the LMS know this. I found this code
/*get LMS API*/
var lmsAPI = parent;
/*set score; the first number is the score. The second is the max score and third min score*/
lmsAPI.SetScore(x, 5, 0);
Does anyone know how to get "x" to be the same value as total_score? and then send it to the LMS?
Many thanks
I am probably overthinking this massively so apologies if this wins the stupidest question ever award.
I have a simple course that has a var called total_score (original I know!). All I am trying to do is let the moodle LMS know if someone passed or failed the course.
I understand that I must use Javascript to make this happen? So in this example I have 5 steps in a process, for every step the user gets right they score a point. They need 4 out of 5 to pass.
So at the end of this example the total_score var is used to tell them if they passed or failed, but I am trying to let the LMS know this. I found this code
/*get LMS API*/
var lmsAPI = parent;
/*set score; the first number is the score. The second is the max score and third min score*/
lmsAPI.SetScore(x, 5, 0);
Does anyone know how to get "x" to be the same value as total_score? and then send it to the LMS?
Many thanks
1 Reply
var player = GetPlayer();
var lmsAPI = parent;
lmsAPI.SetScore(player.GetVar(“total_score”), 5, 0);
if(player.GetVar(“total_score”)>=4)
SetStatus = "Passed";
if(player.GetVar(“total_score”)<4)
SetStatus = "Failed";