Just finally kicking the tires with PsychoJS, and wondering about a few things. This is all basic conversion of some standard Builder practices:
Resource management:
For this basic test experiment, I’m cycling through pre-made png’s with a standard trick - define the image filename in a variable (in a code component, not in the new “variable” component since it looks like that’s py only at the moment? Aims to change that?) at Start Routine and set the image’s path e.g. with Image Component: $imgPath -> set every repeat. However, doing this doesn’t register the images as resources, so they’re not compiled into the html, committed and uploaded, so I get resource not found errors. I see the ServerManager is responsible for resources, but it claims to not be exposed to the experiment and I only see methods for listing and downloading resources, not adding them.
In this case, when the list of resources is known but not explicit from the builder, what’s the best way to register them? Also, how are resources expired? When I tested a single image it was manually added, but not removed when I switched to using code for the file path. Should I add an issue to psyshojs to add a check to remove resources that are no longer required?
Running locally / squashing noisy git commits at the end of the day
I see lots of dependencies (jquery, psychojs itself) are packaged in /lib/vendor - is this being handled by a of package manager (npm) on pavlovia? If so, is there an easy way to vendor this all locally so that I don’t have to commit and push for literally every change and error I make while building the task? And if not, should we should consider adding an option to squash all the recent commits (by day?) to use meaningful git logs? Or would most users not care and that would just needlessly complicate the UI?
Interesting experience converting these so far! Glad to see it!
put all required resources into html/resources which will then be automatically be fetched/loaded by the client. This is what Builder is currently doing
@apitiot has added the option to provide a list of resource files (which can then be in any location) but I haven’t directly used that feature myself yet and can’t tell you how!
For running a test version locally:
I absolutely agree. We need this
As a first port of call we could export a local html script and set the paths to be https://run.pavlovia.org/lib/... so that the user doesn’t need a copy installed locally? (I was previously providing the option to “package” current libs but then people get out-dated versions etc.
Next thing that will be an issue is what happens locally given that there won’t be a local server-side script to handle data-save. Maybe PsychpJS could detect this and offer to save file locally at end of experiment?
Solution 1 (manually dropping things into resources) will work for today and let me keep going. Would love to hear more about the manifest from @apitiot whenever, and would be happy to PR a doc page if somone points me in the right direction. Do you recall the method name?
For a local, I can just do a sed find and replace easy enough, again for right now. Would be interested in toggling around a bit to add some detection of environment for saving locally. IIRC serving locally would require some server (either the node or python standards, python -m http.server, but that shouldn’t be too terrible to start once. I’ll think about it a little more.
GH Issue would probably be a better spot to discuss this, but I don’t see one. Should I add it? Thanks!
I need some help from someone who is using PsychoJS as this is my first time with JS and online experiments. My entire experiment is made in builder except for this small code component that I am using. I wrote in python code component and it is working offline. I converted it to JS but it is not working in the online version. There is an issue with the “Correct” variable here. The variable is present in the conditions excel sheet but I don’t know how to call Correct in PsychoJS. Any help would be appreciated.
// update component parameters for each repeat
Dummy1= slider_2.getRating();
if (Correct ==1 and Dummy1>1.5){
code1="Feedback_incorrect_training.png";
}
else if (Correct ==1 and Dummy1<1.5){
code1="Feedback_correct_training.png";
}
else if (Correct ==2 and Dummy1<1.5){
code1="Feedback_incorrect_training.png";
}
else if (Correct ==2 and Dummy1>1.5){
code1="Feedback_correct_training.png";
}
Hey Please look at the image. My friend tried looking throught he console and found error in this line:
if (Correct ==1 and Dummy1>1.5){
So I realized I need some way to call Correct. The other variables in the excel are image paths and Builder is directly calling it through setImage (). I only have this one code component.
Hi @dvbridges do you think my problem is straight forward or I need to have more expertise on JS? I am only going to have if-else loops in my experiments and only learning the syntax for that.
Thanks for your quick response. I am new to whole coding thing and realized that it was a very silly mistake. “and” operator in JS is “&&”. I changed this and everything is working now.
However, I have one issue with slider marker. The triangle in my scale is too huge. Is there a way to reduce that size from code component as there is no option in builder for doing that? Also, the color for clicking on radio button is different in online (gray) and offline (red).
Hi, yes this is a problem that needs to be resolved in the PsychoJS library - I will log an issue on GitHub to get this resolved. If you do not use the triangle rating, the maker size is a normal size, but lacks the point accuracy of the triangle. On the other hand, if you are making a discrete scale, change the granularity of the Slider to 1, and point accuracy of the triangle may not be needed because the circular marker will fall exactly on the point selected.