lookit / lookit-jspsych

0 stars 0 forks source link

Jspsych Surveys #24

Closed okaycj closed 5 months ago

okaycj commented 7 months ago

Summary

This PR will introduce two packages to our mono repo. First will be the exit survey and after we've established a few patterns, we'll move on to the consent survey.

Closes #15, Closes #11

changeset-bot[bot] commented 7 months ago

⚠️ No Changeset found

Latest commit: 111ac52787ae7bc7a62453ef6c50a5d9259fa802

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

becky-gilbert commented 6 months ago

Here's what the withdrawal and feedback questions look like right now:

Screenshot 2024-03-27 at 12 19 48 PM

I don't like the alignment of the checkbox and text, so I'm going to try to add some CSS to fix that. (I figure we'll probably want to know how to make custom CSS changes anyway).

Also, in the EFP exit survey, the withdrawal statement pipes in the researcher's contact info and study name, and allows the researcher to include/omit the video privacy example:

Every video helps us, even if something went wrong! However, if you need your video deleted{include_example, select, true { (your spouse was discussing state secrets in the background, etc.)} other {}}, 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 {contact} on the study "{name}"; other video will be deleted without viewing.

For now I've just put in some static text. Later on we can (1) dynamically change this text to include the study name and researcher contact, and (2) add a plugin parameter for changing the example in this statement.

becky-gilbert commented 6 months ago

@okaycj I added support for private_level_only, which hides the multiple choice options and sets "private" as the question's value, so that the data is the same as selecting "private":

Here's private_level_only: true:

Screenshot 2024-03-28 at 12 25 20 PM

[
  {
    "rt": 8406,
    "response": {
      "feedback": null,
      "birthDate": "2024-03-12",
      "useOfMedia": "private",
      "withdrawal": null,
      "databraryShare": "no"
    },
    "trial_type": "survey",
    "trial_index": 0,
    "time_elapsed": 8611,
    "internal_node_id": "0.0-0.0"
  }
]

And here's the data when the media use choices are displayed and the user selects the "private" option:

[
  {
    "rt": 12948,
    "response": {
      "feedback": null,
      "birthDate": "2024-03-19",
      "useOfMedia": "private",
      "withdrawal": null,
      "databraryShare": "no"
    },
    "trial_type": "survey",
    "trial_index": 0,
    "time_elapsed": 13147,
    "internal_node_id": "0.0-0.0"
  }
]

I also set the two video data sharing questions to 'disabled' when the user selects the video withdrawal option. This is the way the EFP exit frame works. The questions are re-enabled if you untick the 'withdraw' box.

Screenshot 2024-03-28 at 12 24 29 PM

becky-gilbert commented 5 months ago

WRT the Jest config change in c620bae038f9083db1ad1fb879bcb1184bab689c, the data package tests were failing because of a syntax error Unexpected token 'export'. The error was occurring at import deepFreeze from "deep-freeze-es6";. I think this was because the deep-freeze package was not transpiled, which is apparently the case for certain node modules. Here's what I found in the Jest docs for transformIgnorePatterns:

Sometimes it happens (especially in React Native or TypeScript projects) that 3rd party modules are published as untranspiled code. Since all files inside node_modules are not transformed by default, Jest will not understand the code in these modules, resulting in syntax errors. To overcome this, you may use transformIgnorePatterns to allow transpiling such modules.