coglabuzh / online-exps

Unleash the full potential of JavaScript and supercharge your web experiments with this library for experimental programming - based on jsPsych - work in progress! 🎯
2 stars 0 forks source link

General functions used to generate html code #21

Open chenyu-psy opened 11 months ago

chenyu-psy commented 11 months ago

Dear Ajit,

Thank you for your work on the circleOfSquares function. I wonder if it is possible to develop it into a series of functions that are more flexible and general.

My initial idea is that we could have two functions: displayStimuli and displayButtons. The function of these two functions is quite similar. they transform input to HTML code, which we can use in the html-button-response or html-key-response plugins. The only difference is that the objects displayed with displayStimuli cannot be clicked on, while the objects displayed with displayButtons can.

I don't know if you have a better solution. What I have done so far is using the displayButtons function in the argument of button_html, and using the displayStimuli function in the argument of stimulus. It allows me to flexibly set which objects can be clicked on and which cannot.

For the input of the functions, it should be an array that includes some objects. Each object includes the necessary information to display them on the screen. I will post other issues to describe the details about the input, but the eventual version should look like the "psychophysics" plugin.

ajit283 commented 11 months ago

Dear Chenyu, I would propose creating a single arrange function, where one can specify which layout (circle/line/matrix etc.) should be used and if the buttons are clickable (true/false), since they all share a lot of functionalities. If the buttons are clickable can be set individually per stimulus as well. Would you be fine with this?

chenyu-psy commented 11 months ago

Hi Ajit,

I separate them into several functions for two reasons:

  1. The arguments in each function are slightly different. Separating them into several functions would make it easier for the user to know which arguments they need to input.
  2. I think we will need more arranging functions in the future. It would be easier for us to simply program a location function, rather than developing your function.

So, I think it would still be a better idea to not combine them.

For your suggestion of having an argument to check whether the buttons are clickable or not, is it possible that some buttons are clickable and some are not? For example, I will display a picture and ask participants to click on the correct color from a color matrix. The image should not be clickable, but the color matrix can be.

ajit283 commented 11 months ago

Hi Chenyu,

that makes sense, I will make seperate functions then. Yes, one will be able to specify whether an element is clickable or not individually.

chenyu-psy commented 11 months ago

Another option could be to add a property for each object to determine whether they are clickable or not.