As I found in several posts, in order for the slider to be drawn in online experiments, we need to define another component (say a mouse and a box with the label of “NEXT”) so participants first respond to the slider and then click on the box. The problem with this method is that if someone clicks on the box, it will go to the next trial, without responding to the slider.
I used the following code to stop this and it works. However, now if someone clicks on the screen before the mouse and box appear (which they appear after 5 secs), then the map undefined error would show.
// continue if both slider and mouse is clicked
if (mouse_confidence.getPressed()[0] === 1) {
clickable = [save_box];
for (const obj of clickable) { // for each clickable stim, check if it contains the mouse
if (obj.contains(mouse_confidence)) {
if (obj === save_box && slider_confidence.getRating()) {
continueRoutine = false;
} else {
continueRoutine = true;
}
}
}
}
@Omidrezaa, you could check the status of the mouse, and only continue with your block of code if the mouse has started i.e., after 5 seconds, when the mouse start time has passed. E.g.,
If you’re in Builder, you can maybe set your mouse component to start on “condition” (instead of time) and set this condition to slider.rating (change “slider” to the name of your slider). I used a key component and it worked perfectly.
Hi @dvbridges. Your suggestion solved the cannot read sth of undefined error, However, the beginning problem is still there. I mean, if I set the mouse as Never End Routine, clicking the box would not end the routine and if I set it as End Valid Click, it will end the routine without checking for slider ratings.
Here is the edited code in the Each Frame Tab:
// continue if both slider and mouse is clicked
if (mouse_confidence.status === PsychoJS.Status.STARTED && mouse_confidence.getPressed()[0] === 1) {
clickable = [save_box];
for (const obj of clickable) {
if (obj.contains(mouse_confidence)) {
if (obj === save_box && slider_confidence.getRating()) {
continueRoutine = false;
} else {
continueRoutine = true;
}
}
}
}
Hi @lcrible. Thank you for your response. I am afraid that I need to set my mouse to start at a specific time, not a condition. However, I really interested to hear about your solution a bit more. What do you mean by a mouse starts on a condition? And, could you please share the code that you used to set the condition to the slider? I am sure that I can use your solution in other parts of my experiment.
Sure, but I’m only using Builder, not Coder, so I don’t know what the exact code is. But in Builder view, you can change the “start” parameter of a key (and possibly mouse) component to “condition”, and in the box set this condition to “slider.rating”, see in this screen capture. Hope this helps.
@lcrible, your solution was fantastic. I was not aware of setting Start to a condition. Your suggestion solved my problem. i just did a minor change to make it compatible with psychoJS, instead of psychopy, so I used slider.getRating() instead of slider.rating as the condition.
I won’t close the forum now and wait for David’s reply. I am sure I can learn a different approach there.
Thank you for your suggestion! It really helped me. However, I have one question.
I have 20 questions that I ask my participants. Questions are presented one by one and participants need to choose one of the 7 ratings and then click the button that is below with their mouse component to go to the next question.
So, actually, everything works until here however some questions are pretty small and can be answered in a few seconds, however, if I choose one of the ratings and try to click the “next” button it seems like it not clickable. It feels like I need to wait around 5 seconds after I choose one of the ratings before clicking the next button.
Do you know if you can change that?
Hi @emregurbuz
The only reason I can think of (but I’m no expert) is that you accidentally set a Start time (cf the screen shot in one of my previous replies) for your next button. You could try sharing your set up so that people can have a look at the parameters.
Your solution helped me a lot, thanks for that! But do you know if there is a way that I can add more than one start condition. Because in my experiments participants should be able to continue after rating 10 sliders and I want to add all as conditions.
Thanks in advance.