Forum Discussion
Capturing static course runtime
As I'm doing user testing, I want to display the total elapsed time on the last slide. I don't want to rely on the estimated time in the Publish menu (it's waaaay off) and I want to keep it as simple as possible for my testers to say "this is the time the computer told me."
I threw Project.Elapsedtime into a text box on the screen, but that is a continually running time; I am trying to figure out how to capture the static elapsed time when the slide loads.
I attempted to set variables equal to Project.Elapsedtime when the timeline starts, but Project.Elapsedtime is not an option that Articulate allows me to select. How can I freeze time?
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.
3 Replies
- AndrewBlemings-Community Member
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.
- BenKaye-SkinnerCommunity Member
Fantastic! I'm nowhere near versed enough in Javascript to have made that a reality.
Thanks!
- AndrewBlemings-Community Member
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