breaking survey 2.0.0 plugin: `title` cannot be a function
It seems like version 2.0.0 doesn't allow for the title field to be dynamically set via a function anymore
var rating = {
type: jsPsychSurvey,
survey_json: {
title: "MY TITLE",
// title: function () {
// return "MY TITLE"
// },
description: "Some description",
pages: [
{
elements: [
{
type: "rating",
name: "Something",
title: "My question",
rateMin: 0,
rateMax: 6,
},
],
},
],
},
}
It just doesn't show any title or description when title is a function.
Actually, reversing survey only to 1.0.1 didn't fix it, I had to revert the whole JsPsych to v7 It's probably an upstream issue
Hi @DominiqueMakowski,
In version 8 the process for checking plugin parameters and converting functions to values is more strict, and this does indeed break the survey plugin. The workaround would be to make the entire survey_json a function, and just dynamically set the title in that.
@bjoluc what do you think about some kind of parameter or flag that would tell the core library to recursively check an object, without manually specifying all allowable values?
After trying to adapt to the new system, I must admit it's quite cumbersome, especially for long surveys spanning multiple pages where it would be much more straightforward to have each element dynamically set rather than having to code a megafunction to set the whole survey dynamically.
Is there any potential avenue for relaxing some of the restrictions in this survey to make it more user-friendly?
Thanks for bumping, @DominiqueMakowski! @jspsych/core What do you think about baking this into the survey plugin and releasing it in a patch version? I don't think the pattern is common enough to support it in the core library (?) and joining multiple distinct parameters into one "complex" parameter has the slight smell of an anti-pattern IMO. Nevertheless, in this situation it makes perfect sense, so I think it should be handled by the survey plugin itself.
I'm on board with that 👍
Yes! I agree it's too unusual to be flagged and handled by the core library. In most cases the 'jsPsych approach' would be to break the JSON out into separate parameters, but here we're intentionally not doing that to remain compatible with SurveyJS. I don't know why I hadn't thought of just adding this functionality into the plugin itself 🤦♀️ I'd be happy to do this.