Is there a builder-based fix for getting rating scales to work through Pavlovia

URL of experiment:

Description of the problem:

I am developing an experiment that includes the need to use a Likert rating scale to get some of the responses. I have it working fine in Builder but when run through Pavlovia the first (non-rating scale) task works but in the second task the rating scale never appears on screen and a response cant be collected.

I see others have had this problem but I don’t see a fix. One suggestion was to use the slider tool instead but when I use that the labels on the slider are too large and it appears the only suggested way to control that font size is to insert a Python code fragment in the generated code, but that is overwritten each time the programme is saved by builder. Has anyone come up with a tidier solution at this stage? I just want to show a simple 6 point scale and get a response in a way that works both locally and through Pavlovia.

I haven’t included a URL since the project is still in development but it does work fine on my local machine in psychopy v2020.1.3.

Ok, that’s something we should definitely look at separately - the online version of slider does look a little, well, y’know.

But to fix the font size, in fact almost any time that you can fix somethign with code, you can always use a Code Component instead. If you want it to modify a Slider that you’ve already created then insert it just after (below) the Slider. Or if you need to modify the creation of the slider itself then use a code component instead of the normal component. It’s really very rare that you have to hack the script in such a way that you can’t bring the changes back as a code component instead and that keeps it from overwriting and keeps things visually in all the other (non-code) components :slight_smile:

Thanks. I have converted the three uses of the rating tool to the slider tool and inserted code to modify the font size for the labels after the insertion of a call to the slider tool in Builder. Here is an example for anyone wanting to do this

A2Cslider = visual.Slider(win=win, name=‘A2Cslider’,
size=(1.0, 0.1), pos=(0, -0.1), units=None,
labels=[‘Strongly Disagree’, ‘Disagree’, ‘Somewhat Disagree’, ‘Somewhat Agree’, ‘Agree’, ‘Strongly Agree’], ticks=(1, 2, 3, 4, 5, 6),
granularity=0, style=[‘rating’],
color=‘LightGray’, font=‘HelveticaBold’,
flip=False, labelHeight = .02)

This call was in the A2C routine and I needed to change the labels in the first line to provide unique identifiers for the three different times I made this call in the different routines but it worked in a local run of the code.

When I tried to run through Pavlovia I first encountered a
ReferenceError: win is not defined
error. I can get rid of this error by inserting a code component at the beginning of the experiment e.g.
thisExp=psychoJS.experiment;
win=psychoJS.window;
(although the local version will not run with this code - it complains that psychoJS is not defined - not sure what is needed to make it run on both local builder and Pavlovia).

However, doing that means the programme will start and runs an initial routine but when it gets to the slider routine I get another error:

unknown position units: null

Then it stops. I don’t know if I would get to see the slider scale if I can pass this point. I currently have the experimental settings set to Height and all routines use experimental settings to get the units.

Thanks for any suggestions

The Pavlovia Url: https://pavlovia.org/run/DBVislab/testthis/html/

To get the experiment working both locally and online the definitions of win etc need to be JS only code rather than both.

Thanks. This my first time trying to get an experiment set up on Pavlovia. Do I set that by selecting JS as the code type in the code fragments, rather than Auto->JS, rather than Both?

Am I correct in assuming that this will need to be done for all inserted code fragments?

I appreciate the help.

I try to keep as many components as possible on Auto.

I therefore add one code component in the first routine called code_JS set to JavaScript only.

If I have a bunch of append statements that need translating to push I try to isolate them in a Both component.

Best wishes,

Wakefield

Thanks. The document was very helpful. I have now set up a code_JS fragment at the beginning containing

round = function (a) {
return Math.round(a);
}
thisExthisExp=psychoJS.experiment;
win=psychoJS.window;
event=psychoJS.eventManager;

This now allows the programme to run locally again.
I added the Math.round, which I don’t use, because adding the last 3 lines as JS code and saving, came back as Auto->JS when I checked it. Not sure if that matters but with the Math.round lines it now comes back as JS and since the purpose was to get some JS code at the beginning I decided to force it.

The programme also runs the first task on Pavlovia but when it gets to the slider routine I still get the same error:

unknown position units: null

Do you have any further suggestions about what the problem might be?

Thanks

David

At the moment the code components default back to Auto. However, that doesn’t matter so long as you don’t touch the Python side of code_JS. You should have a blank window on the left and the JS code on the right. You only need to select JS again if you want to edit it.

For the slider, it looks like you need to explicitly select the units explicitly as Height, rather than leaving it as “from Exp settings”.

Thanks again. That certainly seemed like a problem since the code fragment was saying units=None

I have set the unit to ‘height’ in each of the code fragments calling the slider tool. Things still work on the local machine but sadly they crash in exactly the same way when running through Pavlovia/WebBrowser.

it still says: unknown position units: null
on the first time I call the slider task.

I have closed down the browser (currently defaults to Microsoft Edge but we have tried some others) in the hope of clearing any cache but that also made no difference to the outcome.

Any further thoughts?

David

Actually it seems there was a synching problem. I looked at theJS code and it still had one instance of Height in it rather than height.

resynched and now I see the scale, but its lines are quite a bit thinner and no labels appear. However, I can click on it and progress until I hit the final task which uses the form tool and that crashes and indicates it is an unsupported object.

So 1) how do I make the slider labels appear when running under Pavlovia
2) can the form tool be used with Pavlovia?

Thanks

David