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
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....
- Bernovan-SoestCommunity Member
Lance,
Yes, you can copy and paste the JS code in triggers.
Regarding the calculations:
var player = GetPlayer();
var start = player.GetVar("gsStart");
var end = player.GetVar("gsEnd");
var duration = end - start;
You may want to divide by 1000 because the start and end time is in millisecond.
var duration = (end - start) / 1000;
- JonXieCommunity MemberHello, Sam ! How did you achieve it ? Please kindly share your story file.
Sam Clark said:
With some additional effort, a time-remaining graphic could be added to every slide....
- JonXieCommunity Member
Hello, Berno. Could you screenr how to use your js code ?