Forum Discussion
Need to set an expiry date for a course created in Articulate Storyline 360
Hi,
I need to set an expiry date for a course created in Articulate Storyline 360.
Is it possible?
- JudyNolletSuper Hero
That would be done via the LMS (not Storyline). And how to do it would depend on what LMS is being used. You should work with the LMS administrators to set the end date.
- ArchanaV-fb70eeCommunity Member
Thanks for the response.
It can be done using LMS but this is for a client who does need our LMS. We need to time restrict the courses to be delivered to them. So is there any way to do that?
- OwenHoltSuper Hero
You can also do it in Storyline with JavaScript.
See my response in a different thread here: https://www.crowdcast.io/m?t=c60c428655a02164d846220c96927dcd:25af8271641de4a7dae4a56b1deef6d6d53be84835324c738dde8f0010e27b0f070103a767d52dfc9f9073b8df74312c
- DavidBoyle1Community Member
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?
- SCORM Expiry.story + JavaScript files:
- OwenHoltSuper Hero
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);