TypeError: (intermediate value).CountdownTimer is not a constructor

URL of experiment: FluencyTaskMasterarbeit [PsychoPy]

Description of the problem:
I use a countdown timer to control the loops in my experiment (participants have 2 minutes to write as many words as they can think of to a given topic).
My code works perfectly fine when I run it on my computer. However, when trying to run it online, I encounter the following error message:
“TypeError: (intermediate value).CountdownTimer is not a constructor”

I use the following code for the countdown:

  • Begin Experiment
    countdownStarted = False

  • Begin Routine
    if not countdownStarted:
    countdownClock = core.CountdownTimer(120)
    countdownStarted = True

  • Each Frame
    timeRemaining = countdownClock.getTime()
    if timeRemaining <= 0.0:
    continueRoutine = False
    trial_VF_test.finished = True
    countdownStarted = False
    else:
    minutes = int(timeRemaining/60.0)
    seconds = int(timeRemaining - (minutes * 60.0))
    timeText = str(minutes) + ‘:’ + str(seconds)

  • End Routine
    if timeRemaining == 0.0:
    continueRoutine = False
    trial_VF_test.finished = True
    countdownStarted = False

I hope you can help me!
Thanks in advance!

Hello,

ok, the code I provided was not tested online. I made some changes and tested I locally in a browser. O, set the Code type of the code-component in which you code the countdown timer to both. All changes are Javascript-changes only. In the Begin Experiment tab add

minutes = 0;
seconds = 0;
timeText = "";

to the Javascript side on the right. In the Begin routine tab, change new core.CountdownTimer(300) to new util.CountdownTimer(300), see below. You need to use the number of seconds that suits your experiment.

if ((! countdownStarted)) {
    countdownClock = new util.CountdownTimer(300);
    countdownStarted = true;
}

That should do the trick.

Best wishes Jens

1 Like

Thank you so much, it worked now!!!