jsPsych icon indicating copy to clipboard operation
jsPsych copied to clipboard

allow survey plugin to accept any SurveyJS-compatible JSON model

Open becky-gilbert opened this issue 3 years ago • 6 comments

Currently the jsPsych survey plugin uses the SurveyJS library, but only implements some of the library's features. This was done to make the survey plugin as consistent as possible with all other jsPsych plugins in terms of parameter names/values. However, this approach unnecessarily limits the SurveyJS features that are available to jsPsych users. Instead, the jsPsych survey plugin could be re-written as a simple wrapper that accepts any SurveyJS JSON models, which would be passed directly to SurveyJS.

See #2639 for an example use case that isn't currently possible via the jsPsych survey plugin, but would be possible if the plugin were re-written as a simple wrapper.

becky-gilbert avatar Aug 30 '22 18:08 becky-gilbert

@jodeleeuw @bjoluc I'm back after a very long hiatus and ready to re-write the 'survey' plugin! Just double checking that (a) this is still something we want to do and a good time to do it (should I wait for v8?) and (b) no one else is working on or replaced this plugin.

I also searched for other survey-related issues and found these, so I'll try to handle these at the same time: #3131 https://github.com/jspsych/jsPsych/issues/2889 https://github.com/jspsych/jsPsych/issues/2761 https://github.com/jspsych/jsPsych/issues/2702 https://github.com/jspsych/jsPsych/issues/2691 https://github.com/jspsych/jsPsych/issues/2600

becky-gilbert avatar May 17 '23 20:05 becky-gilbert

🥳

I think it would be great to do this with v7. That way there's a functional version for v7 and, eventually, v8.

jodeleeuw avatar May 18 '23 01:05 jodeleeuw

Great, I'm starting now with v7.

becky-gilbert avatar May 18 '23 15:05 becky-gilbert

Hi @jspsych/core, sorry for the long delay getting to this. I have a working version that takes SurveyJS JSON. I just have a quick question:

Do we want to maintain backwards compatibility for this plugin, i.e. continue to accept all of the jsPsych-specific/non-SurveyJS parameters? I assume we want to make things backwards compatible whenever possible. However I think there are a few downsides to doing it in this case:

  • It would make the plugin more confusing to use, since there would be two[^1] completely separate ways of defining a survey - either the jsPsych parameters, or the SurveyJS JSON string. The latter option would allow more features.
  • It would make the plugin code more confusing.

I'm happy to keep the old parameters/code if we do want to maintain backwards compatibility. And if not, I can focus on writing good documentation for migrating from the old version to the new one.

I'm going to write some comprehensive documentation anyway, because one downside of supporting the native SurveyJS JSON is that it differs from the rest of the jsPsych plugins and their API documentation is a little overwhelming. So I'm going to flag some key properties/methods that are most likely to be used by jsPsych users, and include (or link to) a variety of examples.

[^1]: There might actually be three different ways, because I'm also thinking of including a function parameter that receives the survey object and allows the user to manipulate it with JS (rather than just with JSON configuration).

becky-gilbert avatar Dec 20 '23 18:12 becky-gilbert

Hey @becky-gilbert!

I assume we want to make things backwards compatible whenever possible.

Generally agree, but the plugin was explicitly released as "unstable" and doesn't yet have a 1.x version, so I'd say let's opt for the cleanest overall solution. In my opinion, that would be dropping the jsPsychic parameter style.

Your docs plans sound great (also the functional option as an escape hatch for script kiddies)! :tada:

bjoluc avatar Dec 20 '23 19:12 bjoluc

Great, thanks so much for the feedback @bjoluc! I'll put in a draft PR soon.

becky-gilbert avatar Dec 20 '23 19:12 becky-gilbert