Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking survey 2.0.0 plugin: title cannot be a function #3356

Open
DominiqueMakowski opened this issue Jul 20, 2024 · 6 comments
Open

breaking survey 2.0.0 plugin: title cannot be a function #3356

DominiqueMakowski opened this issue Jul 20, 2024 · 6 comments
Assignees

Comments

@DominiqueMakowski
Copy link

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.

@DominiqueMakowski
Copy link
Author

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

@jodeleeuw
Copy link
Member

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?

@DominiqueMakowski
Copy link
Author

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?

@bjoluc
Copy link
Member

bjoluc commented Aug 23, 2024

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.

@jodeleeuw
Copy link
Member

I'm on board with that 👍

@becky-gilbert
Copy link
Collaborator

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.

@becky-gilbert becky-gilbert self-assigned this Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants