Forum Discussion
Capturing static course runtime
- 5 hours ago
System variables like Project.Elapsedtime are unfortunately not accessible to our triggers, I don't think, or certainly not all of the triggers.
I mocked up and attached a quick demo of a solution that relies on a JavaScript trigger placed on the top-most master slide. It's set to Execute when the timeline starts on this slide, which means it runs whenever any slide is loaded.
// Checks if a startTime variable has been created yet, and if not, makes one.
if (!window.startTime) {
window.startTime = Date.now();
};
const elapsedTime = Date.now() - window.startTime;
const minutes = Math.floor(elapsedTime / 60000);
const seconds = Math.floor((elapsedTime % 60000) / 1000);
// Use padStart to ensure seconds always has two digits
const tidyTime = `${minutes}:${seconds.toString().padStart(2, '0')}`;
setVar('tidyTime', tidyTime);Naturally for it to work, you'll need to create a Storyline text variable called tidyTime. The demo project has two slides which you can navigate back and forth between. That allows you to see the variable update only when the slide is loaded, hopefully providing less distraction to your learners than thousands of milliseconds flying by.
Fantastic! I'm nowhere near versed enough in Javascript to have made that a reality.
Thanks!
My pleasure! Let me know if it gives you any trouble or it should be tweaked.
Related Content
- 6 months ago
- 11 months ago
- 4 years ago