Forum Discussion
Timing how long an interaction takes.
So my courses have to be timed for credit. I have an interaction which include several slides and pathways. I want to be able to make sure that the participants spend a certain amount of time going through the interaction or repeating the interaction to see different results. Is there a way to make sure an interaction takes a desired amount of time?
- Bernovan-SoestCommunity Member
- LauraIngleCommunity Member
Hi Berno. Your javascript worked well. However, I'm trying to figure out how to stop and resume if there is bookmarking on a course. Any ideas?
- onEnterFrameCommunity Member
You could create a Storyline var and store the elapsed time in it. That should be saved along with the other resume data. And then pull that back into your JS when the learner returns. It might be off a second as there will be a difference of when it was saved vs the actual time...
- GiselleYatesCommunity Member
Amazing work Berno! I know this was 7 years ago but it helped me out a ton!
One of the many reasons we keep these older discussions around! Glad you're able to use this in your course building, Kyle! And, welcome to the E-Learning Heroes community! We're glad you're here. 😀
- SteveFlowersCommunity Member
Here's a quick and dirty example. I'm using a text variable to catch the value but you could just as easily use a number for logic inside of Storyline. Some cool concepts at work here. Noteable are the establishment of global functions that make it easier to start and stop the timer. It also continues to run between slides if you don't stop it.
- SamClarkCommunity Member
I've extended Steve's code to add another variable that records elapsed seconds using the JavaScript Date() in addition to counting timer intervals. There shouldn't be much difference in the two unless other Storyline JavaScipts block the timer interval here and there. Maybe this would add up to something, maybe not, maybe accuracy doesn't matter in most situations. But using Date() doesn't cost anything additional, and you will get more accurate results.
This demo shows both counting along. You can simulate another JavaScript blocking the interval timer by clicking the "Busy" button once to view the cumulative difference.
- Bernovan-SoestCommunity Member
Hi Lance,
I'm not sure if this is what you're looking for but this is how I implemented it.
when the timeline starts I fire this JS:
var d = new Date();
var player = GetPlayer();
var start = player.SetVar("gsStart", d.getTime());
when the interaction has finished:
var d = new Date();
var player = GetPlayer();
var start = player.SetVar("gsEnd", d.getTime());
Using start and time you can perform the calculation you need.
- LanceSwigertCommunity Member
I'm new to Storyline, and not familiar with JS. How would I go about doing that?
- Bernovan-SoestCommunity Member
Add triggers to your interaction.
Specify Execute Javascript as the action.
Click the Script button
Enter Javascript code
- JonXieCommunity Member
Hello, Berno, your solution is quite cutting edge, could you share the story file ? I tried to add js trigger on my slide, but failed.
- Bernovan-SoestCommunity Member
Hello Jon,
I had some JavaScript startup trouble as well.
http://community.articulate.com/forums/t/22924.aspx
Maybe this will help.
- LanceSwigertCommunity Member
Thanks Berno. So can I just copy and past what you put in the first post into triggers at the beginning and the end of the interaction? How would I go about doing the calculations.... Sorry for so many questions. I really have no experience with JS.
- SamClarkCommunity Member
With some additional effort, a time-remaining graphic could be added to every slide....