Skip to content

Commit

Permalink
fix withdrawal question value in data and logic for enabling/disablin…
Browse files Browse the repository at this point in the history
…g the other video-related questions
  • Loading branch information
becky-gilbert committed Apr 1, 2024
1 parent 1d428f2 commit a69de96
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
23 changes: 20 additions & 3 deletions packages/surveys/src/exit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ParameterType, TrialType } from "jspsych";
import { Model } from "survey-jquery";
import SurveyPlugin from "../../../../jsPsych/packages/plugin-survey/dist";
import surveyJSON from "./survey.json";
import { LookitAPISurveyPlugin, survey_function } from "./utils";
Expand Down Expand Up @@ -55,7 +56,10 @@ function includeWithdrawalExample(trial: Trial) {
withdrawal_element &&
Object.assign(withdrawal_element, {
choices: [
`Every video helps us, even if something went wrong! However, if you need your video deleted${example}, check here to completely withdraw your video data from this session from the study. Only your consent video will be retained and it may only be viewed by Lookit project staff and researchers working with ${study.attributes.contact_info} on the study "${study.attributes.name}"; other video will be deleted without viewing.`,
{
text: `Every video helps us, even if something went wrong! However, if you need your video deleted${example}, check here to completely withdraw your video data from this session from the study. Only your consent video will be retained and it may only be viewed by Lookit project staff and researchers working with ${study.attributes.contact_info} on the study "${study.attributes.name}"; other video will be deleted without viewing.`,
value: true,
},
],
});
}
Expand Down Expand Up @@ -96,14 +100,27 @@ function surveyParameters(trial: Trial) {
return JSON.stringify(surveyJSON);
}

function exit_survey_function(survey: Model) {
survey_function(survey);
// For the withdrawal checkbox question, this takes the boolean response value out of an array
// and saves it as a single value (since there is always only one checkbox).
// We went with the checkbox question type rather than boolean with "renderAs: checkbox" because the
// latter doesn't allow both a question title and label next to the checkbox.
survey.onComplete.add(function (sender) {
const trueFalseValue =
sender.getQuestionByName("withdrawal").value.length > 0 ? true : false;
sender.setValue("withdrawal", trueFalseValue);
});
}

export class ExitSurveyPlugin extends LookitAPISurveyPlugin {
static readonly info = info;
trial(display_element: HTMLElement, trial: Trial) {
async trial(display_element: HTMLElement, trial: Trial) {
this.lookitData().then(() => {
super.trial(display_element, {
...trial,
survey_json: surveyParameters(trial),
survey_function,
survey_function: exit_survey_function,
});
});
}
Expand Down
5 changes: 3 additions & 2 deletions packages/surveys/src/survey.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"description": "Only authorized researchers will have access to information in the library. Researchers who are granted access must agree to maintain confidentiality and not use information for commercial purposes. Data sharing will lead to faster progress in research on human development and behavior. If you have any questions about the data-sharing library, please visit [Databrary](https://nyu.databrary.org/) or email [email protected].",
"enableIf": "(!{withdrawal}) or ({withdrawal} empty)",
"enableIf": "({withdrawal} empty) or ({withdrawal.length} = 0)",
"isRequired": true,
"name": "databraryShare",
"title": "Would you like to share your video and other data from this session with authorized users of the secure data library Databrary?",
Expand All @@ -36,14 +36,15 @@
}
],
"description": "",
"enableIf": "(!{withdrawal}) or ({withdrawal} empty)",
"enableIf": "({withdrawal} empty) or ({withdrawal.length} = 0)",
"isRequired": true,
"name": "useOfMedia",
"title": "Use of video clips and images:",
"type": "radiogroup"
},
{
"choices": [],
"defaultValue": [],
"isRequired": false,
"name": "withdrawal",
"title": "Withdrawal of video data",
Expand Down

0 comments on commit a69de96

Please sign in to comment.