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?
34 Replies
- 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...
- KyleYates1Community 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. 😀
- JonXieCommunity Member
Many thanks, Berno! Good job. Another problem--how could I go about achieving remaining time by using JS in this case as Sam did to add it to each slide? Sorry to trouble you !
- RebeccaFleischCCommunity Member
Hi All,
I'm venturing - no really I'm tip-toeing - into Execution of JavaScript. And since I no NOTHING about it, I'm simply using what y'all offer here and C/P into the JavaScript box.So, I really appreciate the Q/A.
I know enough to understand that the trigger names must match the characters inside the Javascript window, e.g., in the case of the gsStart trigger, it matches the characters inside the first set of quotation marks in the player.SetVar line:
player.SetVar("gsStart", d.getTime());
So, I successfully implemented a trigger that shows how much time was spent on a previous slide when the Learner clicks the next button - and to display the time on the next slide. Essentially, I copied what you did, Berno, but using the next button instead of Submit.
What I really want to do is to have a counter that displays a number of seconds count on the current slide. So, nothing would be clicked, it would just count up in seconds. And I'd reference the count inside a text box.
I'd searched the forums a while back for this but didn't find exactly what I was looking for. Perhaps I missed it. Does anyone know how to do this?
And thanks again.
- SteveFlowersCommunity Member
Hi, Rebecca -
You'd need to do this with an interval to repeatedly update the second value. I'll test one out to make sure there's no funny business or side effects and post in a bit.
In the mean time, here are some DYNAMITE references for learning more about JavaScript. The codacademy site is instructional candy. So good. All practice and feedback. Appendto isn't bad either, more demonstration if that's your preference.
- SamClarkCommunity Member
Rebecca Fleisch Cordeiro said:
I know enough to understand that the trigger names must match the characters inside the Javascript window, e.g., in the case of the gsStart trigger, it matches the characters inside the first set of quotation marks in the player.SetVar line:
Probably a typeo, but gsStart is a Storyline variable, not a trigger. If there is a way to fire a trigger in Storyline, it would be by setting a value in a variable to which a trigger is set to fire on that value.Steve's suggestion of an interval timer is the right idea. I look forward to seeing it implemented.
- RebeccaFleischCCommunity Member
Sam, yep was a typo. And I DO understand the difference between triggers and variables ... really
Tx for proofing/editing. Don't want to lead people down the wrong path, nor do I want them to think I don't know my whatchamacallit from my elbow.
Steve, tx so much. As I mentioned in another thread to Nancy, I'll need to add this to my ToDo list. In the meantime, looking forward to your post. Oh, there's no rush. Just something I had in mind. And I know you're busy.
- 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.
- SteveFlowersCommunity Member
The value in the setInterval call "1000" is milliseconds. So that's a 1 second tick.
- JonXieCommunity Member
Thanks a lot, Steve, It's wonderful !
- Bernovan-SoestCommunity Member
Steve,
The global functions idea is great.
I've placed my Javascript in a seperate .js file.
It allows you to experiment / test the JS code after publishing. Just alter the code and refresh your browser.
Saves a lot of time compared to publishing after every code change.
And you could edit the code in a JS savvy editor.
You have to alter your story.html file and perform some post-publish copy actions
in the story.html find the place where other JS code is included:
and add your own:
After each publish copy the altered story.html over the newly published one and copy your .js file to the story_content folder.
Have a nice weekend!