Need to set an expiry date for a course created in Articulate Storyline 360

Jun 17, 2021

Hi,

I need to set an expiry date for a course created in Articulate Storyline 360.

Is it possible? 

5 Replies
Dave Engage

Hi Owen and Matthew,

In testing the file you provided in your initial feed (Date_2bRestricted-CA expired) with the attached code example, it worked fine on the first attempt, but when resuming I have been receiving a blank white screen in the player.

In my attached example:

  • SCORM Expiry.story + JavaScript files:
    • checkExpiry_external.js
    • sendData2Player.js

I have used your base code in these 2 external JavaScript files to check the expiry of a course when the course is loaded. 2 script tags have been added to the header of index.html and story.html to reference the scripts in the DOM.

The variable "Loaded" is used to stop the script being executed more than once. It is reset each time you load the course.

The variable "expired" is set to "false" if the device's date is less than or equal to the expiry date which is manually coded.

After checking expiry, the second script send the values of the above variables to the Storyline player to execute a Jump to expired slide action.

The JavaScript is executing without an error when initially loading and when resuming, as confirmed through the JavaScript console.

Unfortunately I am still receiving a white screen when resuming the course (see attached). I have been testing it in SCORM cloud. The course resume behavior seems to be different to the initial course load behavior.

Can you advise what is causing the white screen

OWEN HOLT

The issue is most likely in your use of external files instead of using triggers inside of Storyline to execute specific JavaScript written in your Storyline project.

I added some variables for you to record a creation date and an expiration date. I use JavaScript to calculate the number of days that have passed since the creation date and the number of days that the course is open for. I also updated your trigger to show the "expired course" slide when the elapsed days is greater than the valid days.

Here is the JavaScript I used, which you can see on the Slide Masters used in your file.

let player = GetPlayer();

var date1 = new Date(player.GetVar("License_CreationDate"));
var date2 = new Date();
var date3 = new Date(player.GetVar("License_ExpirationDate"));
var elapsedTime = date2.getTime() - date1.getTime();
var elapsedDays = elapsedTime/(1000 * 3600 * 24);
var totalTime = date3.getTime() - date1.getTime();
var totalDays = totalTime/(1000 * 3600 * 24);


player.SetVar("License_DaysUsed", elapsedDays);
player.SetVar("License_ValidDays", totalDays);