Adding a countdown timer to the screen

882 views
Skip to first unread message

osgoodp...@gmail.com

unread,
Jun 6, 2017, 1:03:08 PM6/6/17
to jsPsych
Hi everyone,

I have a couple of questions regarding elements I would like to add to my experiment. Any advice would be great,y appreciated, thank you in advance!

1. How can I add a countdown timer to my experiment? I want participants to answer as many questions as they can in a limited amount of time and for the remaining time to be displayed in a countdown timer in on the screen.

2. How can I force my experiment to stop when the time limit described above has expired?

Thank you!

Best,
Jeff

Josh de Leeuw

unread,
Jun 6, 2017, 11:46:51 PM6/6/17
to osgoodp...@gmail.com, jsPsych
Hi,

I just happened to have recently created an experiment that does something very similar. Here's a link to the experiment code:


Or, the live version, here:


The key technical points:

1) We use the option to specify a display_element in jsPsych.init to embed the jsPsych content in a div element and then create the timer element outside of jsPsych's domain.
2) We use a call-function plugin trial to display the timer when appropriate.
3) We use a timeline with a loop function to continue the trials until the timer expires. This requires using functions as parameters for the parts of the trial that change, so that we can have a single trial that repeats while the timer is running.

Hope that helps. Feel free to follow up with any questions.

Josh

--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/80571df1-ed79-42c2-818c-2844683f0a2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages