Submitting a score manually via JavaScript - output is Flash with HTML5 backup

Jun 29, 2019


I'm trying to submit a score manually via JavaScript.

The problem that I'm running into is that the course has to be published using Flash/HTML5 backup. It will either submit the score in Flash or HTML5 but not both. I have code for both of them that will work (separately), but I can't seem to get both codes to work together. I tried using an "if/else" statement but based on the code below, it will only work for the HTML5 version and not the Flash version.

Has anyone been able to get something like this to work?

Here is the code:

var path = window.location.pathname;
var html5 = path.includes("html5");
                   
if (html5 == true) {
//for html5
var player = GetPlayer();
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);
lmsAPI.SetScore(90,100, 0);
} else {
//for flash
var player = GetPlayer();
var lmsAPI = parent;
lmsAPI.SetScore(90,100,0);
}
Be the first to reply

This discussion is closed. You can start a new discussion or contact Articulate Support.