Duration of experiment

We want to document how long participants are doing our study. We have tried to define a GlobalClock in the beginning and get the time at the start and end of the experiment, but this unfortunately does not work. Here we get the error GlobalClock is not defined, but we defined it like this at the start of the experiment:
GlobalClock = new util.Clock();
and accessing this clock like this:
BaseStartTime = GlobalClock.getTime()

We have also tried core.MonotonicClock and this did not work either.

Is there another way to get the time participants spend on the experiment?

Update, we set the timer in the beginning of the experiment like this:

timer = new util.MonotonicClock({“start_time”: null});

At the end of the experiment we get the duration like this:
EndTime = timer.getTime();
psychoJS.experiment.addData(“EndTime”, EndTime);

Offline this works and we get a number in the EndTime column. When we run it online on Pavlovia we get no errors, but only NAN in the EndTime column. How can we solve this?

Hi, this page might help.
(Clocks and trial counters — Workshops for PsychoPy 2021 2021)

1 Like