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

Survey plugin rewrite (fixes #2758) #3204

Merged
merged 65 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
036c40a
initial survey plugin rewrite with survey-jquery and updated versions
becky-gilbert Jan 3, 2024
2d13cd0
update example file for new survey plugin version
becky-gilbert Jan 3, 2024
12ccb6f
remove continue button alignment class (moved to CSS to make it the d…
becky-gilbert Jan 3, 2024
5aba572
remove console logs
becky-gilbert Jan 3, 2024
00b8f8a
fix tests
becky-gilbert Jan 4, 2024
18ec8cb
remove comment about right-aligning buttons (moved to default css)
becky-gilbert Jan 4, 2024
4481baf
add survey_function parameter, parameter comments and pretty names to…
becky-gilbert Jan 4, 2024
fde6c10
default survey_json should be (JSON) string, not JS object
becky-gilbert Jan 4, 2024
335031c
implement survey_function parameter and add basic test
becky-gilbert Jan 4, 2024
ab6cb2a
add test for combining survey_json and survey_function parameters
becky-gilbert Jan 4, 2024
4e5f140
add changeset
becky-gilbert Jan 4, 2024
63e83d3
fix typo
becky-gilbert Jan 4, 2024
fff335d
edit survey demo1 to work with new plugin
becky-gilbert Jan 5, 2024
bb55167
update survey demo 2
becky-gilbert Jan 5, 2024
dc80201
center the question content and titles, and make an exception for dro…
becky-gilbert Jan 5, 2024
60a1ace
update survey demo 3
becky-gilbert Jan 5, 2024
12b13d5
update survey demo 4
becky-gilbert Jan 5, 2024
ebd14f2
update survey demo 5, switched from timeline variables to constructin…
becky-gilbert Jan 5, 2024
bfe07e6
fix css selector for centering title elements
becky-gilbert Jan 5, 2024
bd66318
add css to prevent multiple choice option labels from wrapping
becky-gilbert Jan 5, 2024
9fc9b79
move suvey plugin example.html to an examples folder
becky-gilbert Jan 5, 2024
c62c327
move examples into separate files
becky-gilbert Feb 2, 2024
c41e0b4
remove unused css class
becky-gilbert Feb 2, 2024
dbc9e85
update survey plugin docs for surveyjs wrapper rewrite
becky-gilbert Mar 12, 2024
5b57978
update survey demos for docs page
becky-gilbert Mar 13, 2024
7558000
Merge branch 'main' into survey-plugin-rewrite
becky-gilbert Mar 14, 2024
c0d9969
add panels to survey theme
becky-gilbert Mar 19, 2024
8d8aeeb
add CSS variables for panel borders
becky-gilbert Mar 19, 2024
d6fa734
left align text and fix content width/centering
becky-gilbert Mar 19, 2024
d1c48b4
add survey dist (for temp access until package is published)
becky-gilbert Mar 19, 2024
eee6272
add built CSS (for temp access until package is published)
becky-gilbert Mar 19, 2024
f956fc1
prevent radio/checkbox labels from overflowing container
becky-gilbert Mar 21, 2024
2b7c593
update built CSS files (will be removed later)
becky-gilbert Mar 21, 2024
6b7820d
switch to the surveyjs class name map for custom css, remove unnecess…
becky-gilbert Apr 15, 2024
2a1649f
update surveyjs core and jquery versions
becky-gilbert Apr 15, 2024
5aa930a
update built dist/css files (will be removed later)
becky-gilbert Apr 15, 2024
37a9a17
add a new building surveys docs page in overview
becky-gilbert Apr 17, 2024
9aa6a99
stop question content from overflowing panel
becky-gilbert Apr 17, 2024
46a0d66
increase max width of body
becky-gilbert Apr 17, 2024
1606c81
move matrix question onto a separate page
becky-gilbert Apr 17, 2024
cab79b8
update demo 4 to show/hide nav buttons based on page
becky-gilbert Apr 17, 2024
c7c4729
add demo for images, video, audio and custom css
becky-gilbert Apr 17, 2024
12bcd4d
reduce body max width to 80%
becky-gilbert Apr 17, 2024
44fdab4
change text input box width from 100% to auto
becky-gilbert Apr 18, 2024
fc3fbdf
fix tests
becky-gilbert Apr 18, 2024
e5729d5
text edits
becky-gilbert Apr 18, 2024
3e678a6
add demo for text input masking
becky-gilbert Apr 18, 2024
5e92ba3
formatting changes
becky-gilbert Apr 18, 2024
073f3cb
reorganize sections, move some content to new building-surveys page, …
becky-gilbert Apr 18, 2024
df408ac
update dist and css files (will be removed later)
becky-gilbert Apr 18, 2024
41f5cd5
add link to timeline vars
becky-gilbert Apr 22, 2024
8ec5189
edit descriptions of checkbox and radio group types
becky-gilbert Apr 22, 2024
115209a
add surveyJS verison
becky-gilbert Apr 22, 2024
b21ae7b
replace SSN question with 9-digit number
becky-gilbert Apr 22, 2024
0f31dc2
fix nav button spacing when complete button is hidden
becky-gilbert Apr 22, 2024
d557c48
add css to fix incorrect min-width for questions in same row
becky-gilbert Apr 22, 2024
98dcaca
remove unnecessary jquery
becky-gilbert Apr 23, 2024
9fda752
swtich from survey-jquery to survey-knockout-ui, remove outdated imports
becky-gilbert Apr 23, 2024
730ce05
switch from JSON string to object, update docs and examples/demos
becky-gilbert Apr 29, 2024
109755c
add timeline vars example
becky-gilbert Apr 29, 2024
f0e9f79
add tests for functions-as-params and timeline vars
becky-gilbert Apr 29, 2024
9cdf62c
update built files (will remove later)
becky-gilbert Apr 29, 2024
d8c1f9a
Merge branch 'main' into survey-plugin-rewrite
becky-gilbert Apr 30, 2024
e09a54e
fix markdown syntax error
becky-gilbert Apr 30, 2024
e807de4
fix typo
becky-gilbert Apr 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bright-pillows-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@jspsych/plugin-survey": major
---

To take advantage of all of the SurveyJS features, we have re-written the survey plugin so that it now takes a SurveyJS-compatible JSON string ('survey_json') and/or a SurveyJS-compatible function ('survey_function') that manipulates a SurveyJS model. This is a breaking change. See the jsPsych Survey Plugin page for documentation and examples: https://www.jspsych.org/latest/plugins/survey/. More details about creating the SurveyJS JSON strings and functions can be found on their website: https://surveyjs.io/form-library/documentation/design-survey/create-a-simple-survey#create-a-survey-model.
47 changes: 24 additions & 23 deletions docs/demos/jspsych-survey-demo1.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<script src="docs-demo-timeline.js"></script>
<script src="https://unpkg.com/jspsych@7.3.4"></script>
<script src="https://unpkg.com/@jspsych/plugin-html-button-response@1.1.3"></script>
<script src="https://unpkg.com/@jspsych/plugin-survey@0.2.2"></script>
<script src="../../packages/plugin-survey/dist/index.browser.js"></script>
<link rel="stylesheet" href="https://unpkg.com/jspsych@7.3.4/css/jspsych.css" />
<link rel="stylesheet" href="https://unpkg.com/@jspsych/plugin-survey@0.2.2/css/survey.css">
<link rel="stylesheet" href="../../packages/plugin-survey/css/survey.css">
<link rel="stylesheet" href="docs-demo.css" type="text/css">
</head>
<body></body>
Expand All @@ -16,28 +16,29 @@

const trial = {
type: jsPsychSurvey,
pages: [
[
{
type: 'html',
prompt: 'Please answer the following questions:',
},
{
type: 'multi-choice',
prompt: "Which of the following do you like the most?",
name: 'VegetablesLike',
options: ['Tomato', 'Cucumber', 'Eggplant', 'Corn', 'Peas'],
required: true
},
{
type: 'multi-select',
prompt: "Which of the following do you like?",
name: 'FruitLike',
options: ['Apple', 'Banana', 'Orange', 'Grape', 'Strawberry'],
required: false,
}
survey_json: {
showQuestionNumbers: false,
elements:
[
{
type: 'radiogroup',
title: "Which of the following do you like the most?",
name: 'vegetablesLike',
choices: ['Tomato', 'Cucumber', 'Eggplant', 'Corn', 'Peas', 'Broccoli']
},
{
type: 'checkbox',
title: "Which of the following do you like?",
name: 'fruitLike',
description: "You can select as many as you want.",
choices: ['Apple', 'Banana', 'Orange', 'Grape', 'Strawberry', 'Kiwi', 'Mango'],
showOtherItem: true,
showSelectAllItem: true,
showNoneItem: true,
required: true,
},
]
],
},
};

const timeline = [trial];
Expand Down
89 changes: 52 additions & 37 deletions docs/demos/jspsych-survey-demo2.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<script src="docs-demo-timeline.js"></script>
<script src="https://unpkg.com/jspsych@7.3.4"></script>
<script src="https://unpkg.com/@jspsych/plugin-html-button-response@1.1.3"></script>
<script src="https://unpkg.com/@jspsych/plugin-survey@0.2.2"></script>
<script src="../../packages/plugin-survey/dist/index.browser.js"></script>
<link rel="stylesheet" href="https://unpkg.com/jspsych@7.3.4/css/jspsych.css" />
<link rel="stylesheet" href="https://unpkg.com/@jspsych/plugin-survey@0.2.2/css/survey.css">
<link rel="stylesheet" href="../../packages/plugin-survey/css/survey.css">
<link rel="stylesheet" href="docs-demo.css" type="text/css">
</head>
<body></body>
Expand All @@ -17,45 +17,60 @@

const trial = {
type: jsPsychSurvey,
pages: [
[
survey_json: {
showQuestionNumbers: false,
title: 'My questionnaire',
completeText: 'Done!',
pageNextText: 'Continue',
pagePrevText: 'Previous',
pages: [
{
type: 'text',
prompt: "Where were you born?",
placeholder: 'City, State, Country',
name: 'birthplace',
required: true,
},
name: 'page1',
elements: [
{
type: 'text',
title: 'Where were you born?',
placeholder: 'City, State/Region, Country',
name: 'birthplace',
size: 30,
isRequired: true,
},
{
type: 'text',
title: 'How old are you?',
name: 'age',
isRequired: false,
inputType: 'number',
min: 0,
max: 100,
defaultValue: 0
}
]
},
{
type: 'text',
prompt: "How old are you?",
name: 'age',
textbox_columns: 5,
required: false,
}
],
[
{
type: 'multi-choice',
prompt: "What's your favorite color?",
options: ['blue','yellow','pink','teal','orange','lime green','other','none of these'],
name: 'FavColor',
},
{
type: 'multi-select',
prompt: "Which of these animals do you like? Select all that apply.",
options: ['lion','squirrel','badger','whale'],
option_reorder: 'random',
columns: 0,
name: 'AnimalLike',
name: 'page2',
elements: [
{
type: 'radiogroup',
title: "What's your favorite color?",
choices: ['Blue','Yellow','Pink','Teal','Orange','Lime green'],
showNoneItem: true,
showOtherItem: true,
colCount: 0,
name: 'FavColor',
},
{
type: 'checkbox',
title: 'Which of these animals do you like? Select all that apply.',
choices: ['Lion','Squirrel','Badger','Whale', 'Turtle'],
choicesOrder: 'random',
colCount: 0,
name: 'FavAnimals',
}
]
}
]
],
title: 'My questionnaire',
button_label_next: 'Continue',
button_label_back: 'Previous',
button_label_finish: 'Submit',
show_question_numbers: 'onPage'
}
};

const timeline = [trial];
Expand Down
123 changes: 70 additions & 53 deletions docs/demos/jspsych-survey-demo3.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<script src="docs-demo-timeline.js"></script>
<script src="https://unpkg.com/jspsych@7.3.4"></script>
<script src="https://unpkg.com/@jspsych/plugin-html-button-response@1.1.3"></script>
<script src="https://unpkg.com/@jspsych/plugin-survey@0.2.2"></script>
<script src="../../packages/plugin-survey/dist/index.browser.js"></script>
<link rel="stylesheet" href="https://unpkg.com/jspsych@7.3.4/css/jspsych.css" />
<link rel="stylesheet" href="https://unpkg.com/@jspsych/plugin-survey@0.2.2/css/survey.css">
<link rel="stylesheet" href="../../packages/plugin-survey/css/survey.css">
<link rel="stylesheet" href="docs-demo.css" type="text/css">
</head>
<body></body>
Expand All @@ -17,62 +17,79 @@

const trial = {
type: jsPsychSurvey,
pages: [
[
survey_json: {
showQuestionNumbers: false,
title: 'Likert scale examples',
pages: [
{
type: 'likert',
prompt: 'I like to eat vegetables.',
likert_scale_min_label: 'Strongly Disagree',
likert_scale_max_label: 'Strongly Agree',
likert_scale_values: [
{value: 1},
{value: 2},
{value: 3},
{value: 4},
{value: 5}
elements: [
{
type: 'rating',
name: 'like-vegetables',
title: 'I like to eat vegetables.',
description: 'Button rating scale with min/max descriptions',
minRateDescription: 'Strongly Disagree',
maxRateDescription: 'Strongly Agree',
displayMode: 'buttons',
rateValues: [1,2,3,4,5]
},
{
type: 'rating',
name: 'like-cake',
title: 'I like to eat cake.',
description: 'Star rating scale with min/max descriptions',
minRateDescription: 'Strongly Disagree',
maxRateDescription: 'Strongly Agree',
rateType: 'stars',
rateCount: 10,
rateMax: 10,
},
{
type: 'rating',
name: 'like-cooking',
title: 'How much do you enjoy cooking?',
description: 'Smiley rating scale without min/max descriptions',
rateType: 'smileys',
rateCount: 10,
rateMax: 10,
scaleColorMode: 'colored',
}
]
},
{
type: 'likert',
prompt: 'I like to eat fruit.',
likert_scale_min_label: 'Strongly Disagree',
likert_scale_max_label: 'Strongly Agree',
likert_scale_values: [
{value: 1},
{value: 2},
{value: 3},
{value: 4},
{value: 5}
]
},
{
type: 'likert',
prompt: 'I like to eat meat.',
likert_scale_min_label: 'Strongly Disagree',
likert_scale_max_label: 'Strongly Agree',
likert_scale_values: [
{value: 1},
{value: 2},
{value: 3},
{value: 4},
{value: 5}
}, {
elements: [
{
type: 'matrix',
name: 'like-food-matrix',
title: 'Matrix question for rating mutliple statements on the same scale.',
alternateRows: true,
isAllRowRequired: true,
rows: [
{text: 'I like to eat vegetables.', value: 'VeggiesTable'},
{text: 'I like to eat fruit.', value: 'FruitTable'},
{text: 'I like to eat cake.', value: 'CakeTable'},
{text: 'I like to cook.', value: 'CookTable'},
],
columns: [{
"value": 5,
"text": "Strongly agree"
}, {
"value": 4,
"text": "Agree"
}, {
"value": 3,
"text": "Neutral"
}, {
"value": 2,
"text": "Disagree"
}, {
"value": 1,
"text": "Strongly disagree"
}]
}
]
},

],
[
{
type: 'likert-table',
prompt: ' ',
statements: [
{prompt: 'I like to eat vegetables', name: 'VeggiesTable'},
{prompt: 'I like to eat fruit', name: 'FruitTable'},
{prompt: 'I like to eat meat', name: 'MeatTable'},
],
options: ['Strongly Disagree', 'Disagree', 'Neutral', 'Agree', 'Strongly Agree'],
}
]
],
}
};

const timeline = [trial];
Expand Down