Captivate SCORM in Moodle – JavaScript Error

I’m using Adobe Captivate Classic (2019).
I have created a SCORM project and it works great in Preview mode (Preview > Project menu).
I have created a variable named slideNum and a number of advanced actions. Again everything works well in preview mode. It also works well in my test in scorm.cloud.com as can be seen in the image where teh green tick appears after clicking the next button.

Works in scorm.cloud.com

I have JavaScript code as follows which is executed when I click the “next” button:

var currSlide = window.cpAPIInterface.getCurrentSlideIndex();
$("#icon_tick_slide" + currSlide + "c").css("visibility", "visible");

This displays an otherwise hidden tick mark when I click the next button.
The problem is that while this works in preview mode and in scorm.cloud.com, no matter what I try I cant get this to work on a moodle SCORM package. The tick simply wont show.

I’ve tried all sorts of combinations of SCORM exports from Moodle and code variations using window.onload and jQyery(document).ready even though none of the examples I’ve seen require this.

I’m using the documentation at https://helpx.adobe.com/captivate/classic/common-js-interface.html

Thanks for any help.