Py2020.2.2 "Form" on Pavlovia: Only allow exit once full form is completed

URL of experiment: No repository · Samantha Walters / TIQuestionnaires_v2 · GitLab

Description of the problem: I’m trying to find a way to end a “Form” on pavlovia, after first making sure that the form has been filled out. I have tried two approaches, and both result in being stuck at “initializing experiment” in the browser.

Psychopy2020.2.2, win10, firefox.

What I’ve tried:

  1. Using the code component from the BFI demo that creates a visualButton.stim & checks for form.Complete, changing the formName to mine (TIQues). The BFI demo is only written in PY, so I also used Auto > JS to attempt online functionality.
    Result: Stuck on “initializing experiment” when I try to run it in psychopy. I’m not sure if this is just an issue with the auto translation to js, or if this is not yet supported for Forms on pavlovia. Any insight?

#1 Auto>JS code in BeginRoutine:

continueButton = new visual.ButtonStim(win, {"labelText": "Continue", "pos": [0.35, (- 0.4)]});

#1 Auto>JS code in EachFrame:

continueButton.draw();
if (TIQues.formComplete()) {
    continueButton.buttonEnabled = true;
}
if (continueButton.buttonSelected) {
    continueRoutine = false;
}
  1. I tried adapting from this post for Slider: How to get space bar to end routine only after rating is collected - #8 by dvbridges , where the ptp can only press “space” to proceed after the slider has been used. It works successfully for me on pavlovia as a slider; I essentially changed " thisSlider.getRating()" to “thisForm.formComplete”.
    Result: After syncing to pavlovia, I again get stuck at “initializing experiment”.

#2 JS code in Each Frame:

let theseKeys = psychoJS.eventManager.getKeys({keyList:['space']});
   
// check for quit:
if (theseKeys.indexOf('escape') > -1) {
  psychoJS.experiment.experimentEnded = true;
}

if (theseKeys.length > 0) { // at least one key was pressed
  let completed_ratings = 0;
  for(var thisForm of [TIQues]) {
    if (TIQues.formComplete() !== undefined) {
      completed_ratings = completed_ratings + 1;
    }
  }
  
  if (completed_ratings === 1) {
        continueRoutine = false; // end now
    }
}

Are these issues due to Pavlovia “Form” functionality being new/still in beta for py2020.2.2? Or is there a current work-around solution to check that the entire form is filled out before allowing either a button/key press advance in a JS code component (or ideally both PY & JS if possible!)?

Thanks in advance!

1 Like

Having a similar question here… any updates? We are getting an error that formName.formComplete() is not a valid piece of syntax in JS, even in v2021 where forms are implemented.

I ended up doing what I wanted to do in a different way (not using forms)-- not sure if there’s been updates since then. Maybe @sotiri?

Thanks for flagging @sawal, OK let me take a look, x

@sawal yes I think we had a bunch of conversations about those earlier workarounds! Thanks for looping in sotiri. :slight_smile:

1 Like

we most definitely did! happy experiment building :slight_smile:

Hi @sawal, @aisa2, as it happens there is no Form.formComplete() method available in PsychoJS yet. It looks like your best bet for now would be to somehow check against myFormName._items._complete, which should be false if any responses are incomplete! x

1 Like