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

New plugin: Survey #2265

Merged
merged 40 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
347e7f6
Setup initial survey plugin draft
bjoluc Oct 6, 2021
9af1b54
Update package-lock.json
bjoluc Oct 6, 2021
a073b07
first pass at survey plugin with SurveyJS, with docs and example (WIP)
becky-gilbert Oct 8, 2021
c45cd24
add different question types/params, survey-level params, expand exam…
becky-gilbert Oct 22, 2021
d9dc250
add changeset
becky-gilbert Oct 22, 2021
eb5c67a
update docs, add CSS file
becky-gilbert Oct 22, 2021
df80575
respond to reviews: change text question columns/rows params to textb…
becky-gilbert Oct 26, 2021
b577852
tweak html param description
becky-gilbert Oct 29, 2021
bf7d18f
change textbox row/col values to test params and defaults
becky-gilbert Oct 29, 2021
cdb8346
refactor, move question set-up to private methods, add question param…
becky-gilbert Oct 29, 2021
c15cb0a
add non-responses to data, add custom question names
becky-gilbert Nov 1, 2021
7470b07
minor edits to docs text, change default page/question names to upper…
becky-gilbert Nov 1, 2021
a1fd34a
add "other" radio/checkbox option with associated text response field"
becky-gilbert Nov 1, 2021
6964a6e
add drop-down and likert questions, tweak CSS, add params for require…
becky-gilbert Nov 2, 2021
cc523da
finish moving dropdown set-up into separate function
becky-gilbert Nov 2, 2021
2cb14e4
add/fix tests
becky-gilbert Nov 2, 2021
e8ac058
tweak demos
becky-gilbert Nov 2, 2021
ff26459
add correct_response question parameter (WIP)
becky-gilbert Nov 2, 2021
bb37073
add ranking question type (WIP)
becky-gilbert Nov 4, 2021
112f0a3
add parameter for custom required error text
becky-gilbert Nov 4, 2021
1d900f7
add likert (rating) question type, rename matrix question type from l…
becky-gilbert Nov 9, 2021
9ad3310
respond to GH reviews
becky-gilbert Nov 9, 2021
f867846
more const -> let changes
becky-gilbert Nov 10, 2021
64293b8
add response scoring when correctResponse is specified
becky-gilbert Nov 18, 2021
d273259
some refactoring to get started
bjoluc Nov 23, 2021
3219ce7
fully construct questions in setup functions
bjoluc Nov 23, 2021
77d2e31
update SurveyJS
bjoluc Nov 23, 2021
5a0ce4e
fix ranking question
bjoluc Nov 24, 2021
fac55ac
fix typo in error message
bjoluc Nov 24, 2021
25a4732
switch to default theme and include surveyjs stylesheet
bjoluc Nov 24, 2021
fc92e40
add Sass support to include and override SurveyJS styles
bjoluc Nov 28, 2021
2b8d4f0
Merge branch 'main' into plugin-survey
jodeleeuw Nov 29, 2021
ab14d01
add docs demos
jodeleeuw Nov 29, 2021
686efbf
update docs with warning, remove refs about randomization
jodeleeuw Nov 30, 2021
b7700f0
mention CSS file in docs
jodeleeuw Nov 30, 2021
e7252f0
fix existing tests for survey plugin
jodeleeuw Nov 30, 2021
0d61743
update CSS for survey plugin
jodeleeuw Nov 30, 2021
5143363
change version number in prep for minor bump
jodeleeuw Nov 30, 2021
8509d16
add examples to docs for survey plugin
jodeleeuw Nov 30, 2021
dee2287
switch to minor release
jodeleeuw Nov 30, 2021
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
7 changes: 7 additions & 0 deletions .changeset/blue-seahorses-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@jspsych/plugin-survey": major
---

A plugin for presenting one or more pages with survey-type questions, such as multiple choice, multiple selection, free text responses, drop-down selection, and likert scale matrices.
Provides options for response validation and question/option randomization.
Uses the SurveyJS library: https://surveyjs.io/.
266 changes: 266 additions & 0 deletions docs/plugins/survey.md

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions packages/plugin-survey/css/plugin-survey.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* navigation buttons */
.jspsych-survey-btn {
margin-bottom: 20px;
margin-top: 10px;
}

/* question prompt text */
.jspsych-survey-question-prompt {
font-family: "Open Sans", "Arial", sans-serif;
font-size: 18px;
line-height: 1em;
}

/* question spacing */
.jspsych-display-element div.jspsych-survey-question {
padding-top: 0;
padding-bottom: 0;
margin-bottom: 0.5em;
}
becky-gilbert marked this conversation as resolved.
Show resolved Hide resolved

/* html prompts */
.jspsych-survey-html {
font-size: 18px;
}

/* textbox inputs, dropdown menu */
.jspsych-display-element input[type="text"], .jspsych-display-element textarea, .jspsych-display-element select.jspsych-survey-dropdown {
font-family: "Open Sans", "Arial", sans-serif;
font-size: 14px;
padding: 4px;
}

/* required astrisk and error text */
.jspsych-display-element .jspsych-survey-required {
color: red;
}
80 changes: 80 additions & 0 deletions packages/plugin-survey/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html>
<head>
<script src="../jspsych/dist/index.browser.js"></script>
<script src="./dist/index.browser.js"></script>
<link rel="stylesheet" href="../jspsych/css/jspsych.css">
<link rel="stylesheet" href="css/plugin-survey.css">
</head>
<body></body>
<script type="text/javascript">

var jsPsych = initJsPsych({
on_finish: function() {
jsPsych.data.displayData();
}
});

var options = ['Option 1', 'Option 2', 'Option 3', 'Option 4', 'Option 5', 'Option 6'];

var survey_trial = {
type: jsPsychSurvey,
pages: [
[
{type: 'html', prompt: '<p>Here is some arbitrary text via an "html" question type.<br>Similar to preamble but can be inserted anywhere in the question set.</p><p>This trial uses automatic question numbering (continued across pages).</p>'},
{type: 'text', prompt: 'This is a single-line text question. The correct answer is "hello".', required: true, correct_response: "hello"},
{type: 'text', prompt: 'This is a multi-line text question.', placeholder: 'This is a placeholder.', textbox_rows: 10, textbox_columns: 40},
],
// [
// {
// type: 'likert',
// prompt: 'Please indicate how much you agree with the following statements:',
// statements: [{prompt: 'I like cats.', name: 'cat'},{prompt: 'I like giraffes.', name: 'giraffe'},{prompt: 'I like antelopes.', name: 'antelope'},{prompt: 'I like lizards.', name: 'lizard'}],
// options: ['A lot', 'Somewhat', 'Not very much'],
// name: 'animals',
// required: true,
// randomize_statement_order: true,
// }
// ],
[
{
type: 'drop-down', prompt: 'Which shape do you like the best?', options: ['Triangle','Circle','Square'], add_other_option: true, option_reorder: 'asc', dropdown_select_prompt: 'Select one:', required: true
},
{
type: 'ranking', prompt: 'Please order the shapes from your most to least favorite.', options: ['Triangle','Circle','Square'], option_reorder: 'random'
},
],
[
{type: 'multi-choice', prompt: 'This is a multi-choice question with options in one column (the default).', options: options},
{type: 'multi-choice', prompt: 'This is a multi-choice question with options in one row. The correct response is option 5.', options: options, columns: 0, correct_response: "Option 5"},
{type: 'multi-choice', prompt: 'This is a multi-choice question with options in two columns, with an "other" option.', options: options, columns: 2, add_other_option: true},
{type: 'multi-select', prompt: 'This is a multi-select question.', options: options},
{type: 'multi-select', prompt: 'This is a multi-select question with three columns and random option ordering.', options: options, columns: 3, option_reorder: 'random'},
]
],
button_label_next: "Next >",
button_label_back: "< Back",
button_label_finish: "Finish!",
show_question_numbers: 'on',
required_question_label: "",
required_error_text: "You forgot to answer this question!"
};

var survey_trial_random = {
type: jsPsychSurvey,
pages: [[
{type: 'text', prompt: 'Question 1.', textbox_rows: 2, textbox_columns: 20},
{type: 'text', prompt: 'Question 2.'},
{type: 'text', prompt: 'Question 3.', textbox_columns: 50},
{type: 'text', prompt: 'Question 4.', textbox_rows: 2},
{type: 'text', prompt: 'Question 5.'},
{type: 'text', prompt: 'Question 6.', textbox_rows: 10, textbox_columns: 20},
]],
title: 'This is a separate survey trial. The order of questions should be randomized.',
randomize_question_order: true
};

jsPsych.run([survey_trial, survey_trial_random]);

</script>
</html>
1 change: 1 addition & 0 deletions packages/plugin-survey/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@jspsych/config/jest").makePackageConfig(__dirname);
46 changes: 46 additions & 0 deletions packages/plugin-survey/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@jspsych/plugin-survey",
"version": "0.1.0",
"description": "A jsPsych plugin for complex surveys",
"type": "module",
"main": "dist/index.cjs",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"typings": "dist/index.d.ts",
"unpkg": "dist/index.browser.min.js",
"files": [
"src",
"dist"
],
"source": "src/index.ts",
"scripts": {
"test": "jest",
"test:watch": "npm test -- --watch",
"tsc": "tsc",
"build": "rollup --config",
"build:watch": "npm run build -- --watch"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jspsych/jsPsych.git",
"directory": "packages/plugin-survey"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/jspsych/jsPsych/issues"
},
"homepage": "https://www.jspsych.org/latest/plugins/survey",
"peerDependencies": {
"jspsych": ">=7.0.0"
},
"devDependencies": {
"@jspsych/config": "^1.0.0",
"@jspsych/test-utils": "^1.0.0"
},
"dependencies": {
"survey-knockout": "^1.8.70"
}
}
3 changes: 3 additions & 0 deletions packages/plugin-survey/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { makeRollupConfig } from "@jspsych/config/rollup";

export default makeRollupConfig("jsPsychSurvey");