Pavlovia Surveys: Page-level timers and one-time random assignment without blocks/triggers?

Hi everyone,

I’m building a study in Pavlovia Surveys and am having trouble implementing two pieces of survey logic.

I’m using a survey structure that consists of a flat list of pages. My version appears to generate syntax/compilation errors when I attempt to add blocks or page-level triggers directly in the JSON editor, so I’m looking for a solution that works within the standard survey/page framework.

1. Page-specific countdown timers

My survey contains approximately 20 pages.

I would like Pages 6–10 (a series of cognitive/scenario tasks) to each have their own 60-second countdown timer that:

  • starts when the page loads,
  • resets on each new page,
  • automatically advances the participant when time expires.

I have successfully added a 60-second countdown timer to the pages I need, however I am also getting a clock that is timing the rest of the survey on all the other pages. I’m unsure how to scope the timer to a subset of pages while leaving the remainder of the survey untimed.

Additional information: I also experimented with placing the timed pages inside a separate block so the timer settings could be isolated from the rest of the survey. However, my survey editor does not appear to use the Flow interface shown in some examples. When I add a second block, participants complete the pages in the first block and then the survey ends rather than continuing to the next block. I’m not sure whether I’m misunderstanding how blocks are intended to work in my version of Pavlovia Surveys or whether additional configuration is required.

What is the recommended way to implement page-specific timers in Pavlovia Surveys?

Picture of my page interface:

2. One-time random assignment

After participants complete the timed tasks, they reach a loading/processing page.

At that point, I need to assign each participant to one of two conditions and store that assignment so it remains fixed for the remainder of the survey.

My intended flow is:

  • Page 11: loading screen
  • Generate a random value (1 or 2) once
  • Store the value
  • If value = 1 → show Page 12
  • If value = 2 → show Page 13
  • Both branches then continue to the same outcome measures

What I’ve tried

I created an Expression question using:

randInt(1, 2)

and then referenced that value in visibleIf logic.

However, it appears to be recalculated on subsequent page transitions, which causes participants to skip the condition pages or behave unpredictably.

I also tried placing randInt(1, 2) directly inside visibleIf expressions, but this appears to generate a new random value each time the condition is evaluated.

Questions

  1. Is there a way to generate a random value exactly once and store it as an embedded/survey variable?
  2. What is the recommended method for condition assignment in Pavlovia Surveys?
  3. How can I implement timers on only a subset of pages without affecting the rest of the survey?

Any examples, documentation links, or JSON snippets would be greatly appreciated.

Thanks,

Amanda

Hi all,

I’m Amanda’s supervisor, so I’m helping with the coding of this. We are combining the survey with an experiment, so I thought I would take Wakefield’s advice and combine the survey components with the experiment (the Wisconsin Card Sort) in PsychoPy. However, I cannot get the survey component to work at all, either locally or on Pavlovia! I downloaded the code for survey-test as a guide, and have inserted the survey routine json file, downloaded from Pavlovia, into my existing Wisconsin Card Sort code in PsychoPy. However, when I sync with Pavlovia, the survey does not appear at all.

There are also some weird issues with syncing - even though I’m seeing the synced code in GitLab, the version that is running when I pilot the experiment is NOT the most current one! (For instance, I’ve updated the number of blocks and changed a few words, but it’s running a previous iteration.) Any idea what is going on here?

I tried making the experiment inactive and then reactivating it, but now I am getting an error message:

This is actually slightly more informative and suggests there is a css style missing for the survey (or for one of them). Any further help is appreciated!

The code is here. I tried making a new project, but this did not seem to help. I’m now getting this error:

I am a fairly experienced coder in R and MATLAB but this has me completely stumped.

Thanks

Deborah.

Hi Deborah,

Please could you add me as a developer to the project and I’ll take a look.

Surveys don’t work locally yet.

Do you know about this tip?

Thanks Wake, I’ll do that shortly.

No I didn’t know that tip, but I’m pretty sure I have tried this at some point anyway and it didn’t seem to help.

The main issue with the experiment at the moment is that there’s a lib folder in the Gitlab repository. This shouldn’t happen (it’s included in .gitignore) and breaks the experiment if it gets uploaded by accident. Please delete it and try again.

Yeah I’m not sure why that happened. It was not included in gitignore from the outset - I did try adding it but that didn’t seem to help. I’ll try deleting the lib folder, but now I’m having issues with PsychoPy not letting me select a project at all from my desktop app (neither PsychoPy Studio nor stable PsychoPy 2026.1.3 will let me do this). It looks as if it’s trying to find a repository I have deleted from Pavlovia. I’m trying a full reinstall of PsychoPy as it keeps quitting with error messages.

The best option is to redownload from Gitlab to a new folder.

Well, OK, I’ll try this. It’s very frustrating though.

OK, I tried downloading the folder and syncing the project from there. However now I’m getting a message that the project can’t sync because the avatar is over 200kb. The avatar I’ve selected is 32kb. I’ve tried selecting other avatars with no success, and there is no way to select none. Clearly something else is wrong and this error message is misleading.

In related news, I tried piloting it from the web interface after deleting the lib files, but now I just get a blank white screen - no error message. This is after clearing the browser cache.

I just got that. Since it works for me when I fork it (with no further changes) so please set it to inactive and then Piloting again.

Hi Wake,

OK, thanks, that WORKED! However, something strange… one of the scenarios from the Part 2 survey appeared right before the Wisconsin Card Sort Task, although it’s definitely NOT in the survey. However I fixed this by re-downloading the json file and then manually uploading it to the repository.

However, the problem with syncing remains. At first I’m getting the message that the avatar is too big (even though there is now no avatar at all). Then when I try to sync anyway, I get this message when I try to specify the local directory to sync to:

If I click “No”, it does not sync. If I click “Yes”, it keeps on creating sub-directories recursively, like this:

This definitely seems like some kind of bug…

Thanks again for all your help. I’ll also need to assign participants to one of two options in Survey 2 - hoping to use your counterbalancing example from the Survey Example, but knowing my luck this will not work either…

Thanks!

Deborah.

I would not recommend saving the project to a Dropbox folder (or other cloud folders, though I don’t have issues with Google Drive folders).

Try a new local folder

OK, I’ve had troubles with GitHub and Dropbox in the past, but I’m not sure that is the problem. Nevertheless I tried it; made a new folder in Documents, tried downloading fresh from GitLab (it still won’t download from the directory you’re associated with because of the image error, so I tried another one where I have the same code, because I have tried this multiple times now).

Got a fresh new error message!

Traceback (most recent call last):
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/app/pavlovia_ui/project.py”, line 587, in sync
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/app/pavlovia_ui/project.py”, line 854, in syncProject
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/projects/pavlovia.py”, line 960, in sync
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/projects/pavlovia.py”, line 1017, in pull
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/projects/pavlovia.py”, line 1007, in pull
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/git/cmd.py”, line 1003, in <lambda>
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/git/cmd.py”, line 1616, in _call_process
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/git/cmd.py”, line 1406, in execute
git.exc.GitCommandError: Cmd(‘/Applications/PsychoPy.app/Contents/Resources/git-core/git’) failed due to: exit code(128)
  cmdline: /Applications/PsychoPy.app/Contents/Resources/git-core/git pull https://*****:*****@gitlab.pavlovia.org/DeborahA/reading-the-room master
  stderr: ‘git: ‘credential-osxkeychain’ is not a git command. See ‘git —help’.
warning: redirecting to https://gitlab.pavlovia.org/DeborahA/reading-the-room.git/
From https://gitlab.pavlovia.org/DeborahA/reading-the-room
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories’

I tried this both starting with an empty folder (so I could pull all the files from the repository) and after copying across the files from the original folder.

I am going to try downloading some of your original Survey code and making a new project with that, to see if it is something related to my own files.

OK, that did not help and I cannot manage to sync any projects.

I would like to add that I have successfully done this in the past, and used PsychoPy/Pavlovia in a student project last year with minimal problems. It is not that I don’t know what I’m doing. I am having absolutely NO success even doing basic things like setting a project directory. If I open the .psyexp file that I used for last year’s project, it automatically opens in the project for that file. But I cannot manage to set a project directory for a new project and sync it successfully. I am wondering whether this is an unintended consequence of whatever you’ve been doing to fix the bot problem?

A side note - last year’s project was synced from Dropbox with no issues. So I don’t think that is the problem.

To confirm, are you downloading from GitLab or syncing from PsychoPy?

I will bring this thread to the attention of @apitiot

There doesn’t seem to by anything wrong with the project. I just synced it myself and if you unprotected the master branch* then I could push edits if that would be helpful.

*To allow Developers to make changes, the Maintainer should go to Settings - Repository - Protected Branches and allow Developers and Maintainers to push and merge.

OK, thanks so much for confirming that there’s nothing wrong with the project, I thought I was going crazy. I’m trying to sync from PsychoPy but getting all the error messages and PsychoPy crashes a lot. I’ve also tried downloading from Gitlab to PsychoPy but that’s not working either.

I will unprotect the master branch now. Thanks again for your help.

FYI I have also tried downloading the latest version of PsychoPy (although I already had the latest version) and reinstalling. I have also tried PsychoPy Studio with similar results. Could it possibly be some sort of conflict with a local installation of Python? I have Python 3.11 installed. But this has never been a problem in the past.

Best

Deborah.

Hi again,

Is there any news on this? I’m still getting this error (as above) when I try to sync anything from any project.

I’m thinking the key lines are these:

git.exc.GitCommandError: Cmd(‘/Applications/PsychoPy.app/Contents/Resources/git-core/git’) failed due to: exit code(128)
  cmdline: /Applications/PsychoPy.app/Contents/Resources/git-core/git pull https://*****:*****@gitlab.pavlovia.org/DeborahA/amanda-honours master
  stderr: ‘git: ‘credential-osxkeychain’ is not a git command. See ‘git —help’.
warning: redirecting to https://gitlab.pavlovia.org/DeborahA/amanda-honours.git/
From https://gitlab.pavlovia.org/DeborahA/amanda-honours
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories’

I think there is something to do with the Mac OSX keychain? I tried googling the error message and couldn’t find anything PsychoPy specific, but I did find this on Stack Overflow. Where would I find the .gitconfig file?

Thanks!

Deborah.

Hello @deborah.apthorp

The problem

Two separate issues are showing up in your PsychoPy sync output, but only one of them actually blocks the sync.

1. The blocking error: fatal: refusing to merge unrelated histories

This means your local project folder and the Pavlovia GitLab repository don’t share a common commit history, so git can’t merge them automatically. This typically happens when the project was initialized independently both locally and on Pavlovia — e.g., the local .git folder was deleted/recreated, or the project existed locally first and was then separately created on Pavlovia.

2. The secondary warning: git: 'credential-osxkeychain' is not a git command

This is just a warning, not a failure. PsychoPy ships its own bundled copy of git (at /Applications/PsychoPy.app/Contents/Resources/git-core/git), and this bundled binary doesn’t have access to the git-credential-osxkeychain helper, which normally lives in the PATH of a system-installed git (e.g., from Xcode Command Line Tools or Homebrew). PsychoPy’s git is sandboxed inside the app bundle, so it doesn’t see helpers installed elsewhere on your Mac. It doesn’t block the sync — it just means credentials won’t be cached in the macOS Keychain through this particular git binary, so you may be prompted for credentials more often.

Step 1 — Check repo status before doing anything else

Open Terminal, navigate to your project folder (the one with the .psyexp file), and run:

git status

What to expect:

  • fatal: not a git repository... → the folder isn’t properly linked as a git repo. This itself would explain your sync issue — re-link the project from within PsychoPy (Experiment Settings → Online tab → project link) rather than trying to patch git manually.

  • On branch master with “nothing to commit, working tree clean” → repo is fine and has no pending local changes; you can go straight to Step 2.

  • On branch master with modified/untracked files listed → commit or stash these first, since uncommitted changes can cause the --allow-unrelated-histories pull to fail or create messy conflicts:

    git add -A
    git commit -m "local changes before sync fix"
    
  • Also confirm you’re on branch master, not main — Pavlovia expects master.


Step 2 — Fix the unrelated-histories error

git pull https://gitlab.pavlovia.org/DeborahA/amanda-honours master --allow-unrelated-histories

If conflicts appear (e.g., duplicate files like index.html or *.psyexp), keep your local version unless you have reason to prefer the Pavlovia version:

git checkout --ours <filename>
git add <filename>

Then finish the merge:

git commit

After this, click “Sync” again in PsychoPy — the histories are now linked, so it should proceed without the unrelated-histories error.

Alternative (simpler, but discards local history): delete the local .git folder and re-link the project to Pavlovia through PsychoPy, letting it clone fresh. Only do this if the Pavlovia version is the authoritative one.


Step 3 (optional) — Resolve the Keychain warning

Point PsychoPy’s bundled git to the system credential helper:

/Applications/PsychoPy.app/Contents/Resources/git-core/git config --global credential.helper /usr/bin/git-credential-osxkeychain

(Requires Xcode Command Line Tools, which provides /usr/bin/git-credential-osxkeychain.) Alternatively, just ignore this warning, or perform manual git operations using a system-installed git instead of PsychoPy’s bundled one.

I hope this will help

Best wishes Jens

Hi Jens,

Thanks, that was helpful, and worked in as much as it stopped PsychoPy from crashing, but I still was unable to sync the directory on my computer with the GitLab directory (it claimed the folder was not associated with a project and made me create a new project). In the meantime I had given up on that repository and created another one with the same name as the original repository, which seemed to work, and I was able to sync files and continue piloting.

I have two remaining issues:

  1. The study is actually a social psych experiment, so participants need to be randomised to one of two conditions where they get fake feedback on their performance in a survey, then fill out some more questions. I assume it is easiest to do this randomisation in PsychoPy, but is it easier to use the output of this code in the survey to control which “page” or “question” they see, or to create two separate surveys and send participants to one or the other?
  2. I am trying to make a fake “progress bar” to give the impression that the program is analysing their data. However, the “progress bar” element does not seem to produce anything if I just put it in a routine - it’s just a blank screen. I feel as if I’m missing something really obvious? Thanks for any help on this!

The code is here: https://gitlab.pavlovia.org/DeborahA/WisconsinCardSort

Thanks!

Deborah.

Hello @deborah.apthorp

There are a couple of ways to implement a between-group design. You could use the counterbalance feature on the shelf, assign groups based on odd/even participant numbers, or use Wakecarter’s Vespr app. The first two options may not result in an even distribution of participants to groups. However, you can adjust the distribution while collecting data.

Whether you have two separate surveys or control which page/question is displayed probably depends on the differences between the two surveys. Both approaches are feasible.

I get a 404 error when I access your repository. I have never used a progress bar before. In a survey, you could perhaps use quiz mode to simulate an evaluation.

Best wishes Jens