jspsych / jspsych-contrib

An open repository of jsPsych plugins and extensions, without any official support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make survey-slider plugin for multiple analog (slider) scales

DominiqueMakowski opened this issue · comments

Given that jspsych has already several useful plugins for creating questionnaires (survey-likert), it would benefit a lot for being able to use analog scales (i.e., sliders) instead of discrete choices (PS: note that this option is not available either in SurveyJS/survey-plugin afaik).

We've been using this plugin code in the past to get:

image

with:

var questionnaire = {
            type: jsPsychSurveySlider,
            questions: [
                {
                    prompt: "<b>Question 1</b>",
                    name: "question1",
                    ticks: ["Strongly disagree", "Strongly agree"],
                    required: true,
                    min: 0,
                    max: 1,
                    step: 0.01,
                    slider_start: 0.5,
                },
                {
                    prompt: "<b>Question 2</b>",
                    name: "question2",
                    ticks: ["No", "Yes"],
                    required: true,
                    min: 0,
                    max: 1,
                    step: 0.01,
                    slider_start: 0.5,
                },
            ],
            randomize_question_order: false,
            preamble: "Some instructions.",
            require_movement: false,
            slider_width: 600,
            data: {
                screen: "questionnaire",
            },
        }

        timeline.push(questionnaire)

I believe such plugin would benefit from being added here (or even as part of the official distribution IMO) but for this it would need to be updated (to typescript if I understand?) and cleaned up (and add a data simulation option). Although it's probably not a lot of work, it's still slightly beyond my javascript skill level. And I was wondering if I could get some guidance and help with that?

Hi @DominiqueMakowski,

It would be great to have this added here. The conversion from your plugin code to a TypeScript version is mainly just copy/pasting the code into the right spots in our templates. I recently added a CLI tool that helps with setting up the new plugin files. If you fork this repository, run npm install and then npm run new you should get a series of prompts to walk through creating the template code. Then you can work on copy/pasting code into the corresponding spots, which I think will be fairly clear once the templates are created. I'm happy to answer questions about the process as they come up!

Tagging @Max-Lovell as a reminder to myself to get his help

As a side comment, apparently SurveyJS will be adding analog scales within the year, so combined with jspsych/jsPsych#3204 it likely will supersede this plugin

Hi, I've made a pull request to include the code above into JSPsych contrib, see: #105

Thanks Max!

This is now implemented with @jspsych-contrib/plugin-survey-slider

Amazing thanks a lot @Max-Lovell and @jodeleeuw