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

Lookit's jsPsych Video Extensions and Plugins #25

Merged
merged 25 commits into from
Jul 23, 2024
Merged

Lookit's jsPsych Video Extensions and Plugins #25

merged 25 commits into from
Jul 23, 2024

Conversation

okaycj
Copy link
Collaborator

@okaycj okaycj commented Apr 18, 2024

Summary

To start, we're going to write up a trial recording extension.

Test Samples

Trial recording

const jsPsych = initJsPsych({
  extensions: [{ type: chsRecord.TrialRecordExtension }],
});

const init_camera = { type: jsPsychInitializeCamera };

const trial = {
  type: jsPsychHtmlButtonResponse,
  stimulus: `<div id="target" style="width:250px; height: 250px; background-color: #333; position: relative; margin: 2em auto;"> <div class="orbit" style="width:25px; height:25px; border-radius:25px;background-color: #f00; position: absolute; top:calc(50% - 12px); left:calc(50% - 12px);"></div> </div> <style> .orbit { transform: translateX(100px); animation: orbit 4s infinite; } @keyframes orbit { 0% { transform: rotate(0deg) translateX(100px); } 100% { transform: rotate(360deg) translateX(100px); } } </style>`,
  choices: ["Done"],
  prompt: "<p>Video is recording. Click done after a few seconds.</p>",
  extensions: [{ type: chsRecord.TrialRecordExtension }],
};

jsPsych.run([init_camera, trial, stop_rec]);

Session Recording

const jsPsych = initJsPsych();

const init_camera = { type: jsPsychInitializeCamera };

const init_microphone = { type: jsPsychInitializeMicrophone };

const hello_trial = {
  type: jsPsychHtmlKeyboardResponse,
  stimulus: "Hello world!",
};

const morning = {
  type: jsPsychHtmlKeyboardResponse,
  stimulus: "Good morning!",
};

const evening = {
  type: jsPsychHtmlKeyboardResponse,
  stimulus: "Good evening!",
};

const night = { type: jsPsychHtmlKeyboardResponse, stimulus: "Good night!" };

const start_rec = { type: chsRecord.StartRecordPlugin };

const stop_rec = { type: chsRecord.StopRecordPlugin };

jsPsych.run([
  init_camera,
  start_rec,
  hello_trial,
  morning,
  evening,
  night,
  stop_rec,
]);

Copy link

changeset-bot bot commented Apr 18, 2024

⚠️ No Changeset found

Latest commit: 81dd78d

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

Base automatically changed from jspsych-surveys to main May 6, 2024 15:25
@okaycj okaycj force-pushed the video branch 3 times, most recently from 4bfb9ac to dc6dd44 Compare May 6, 2024 18:35
@becky-gilbert becky-gilbert changed the title Lookit's jsPysch Video Extensions and Plugins Lookit's jsPsych Video Extensions and Plugins May 6, 2024
@becky-gilbert
Copy link
Contributor

FYI I changed chsVideo to chsRecord in the code in the PR description.

okaycj and others added 20 commits May 22, 2024 13:35
* Update eslint package to fix warning message

* Add exit survey pacakge

* exit survey

* se survey_function to format survey text

* edit exit survey question titles and descriptions

* change question names and MC values to match EFP names

* add withdrawal and feedback questions

* Change package name, exit survey parameters

* Added privacy and databrary params

* Get study to add to withdraw copu

* disable the video sharing questions if video withdrawal is true

* Add MD link

* Add global data store

* fix withdrawal question value in data and logic for enabling/disabling the other video-related questions

* add validation for child birthdate: cannot be a future date

* Update root package

* Update survey to use new data structure

* First pass at tests

* Add data finish function

* Update tests

* Update versions of deps

* freeze loaded data

* Add s3 from EFP

* Add s3 class

* Update linters to support jsdoc comments

* First pass at code documentation

* Change functions to arrow functions

* Fix tests

* fix typos

* minor edits to JSdoc comments

* Format and comment changes

* Test updates

* Moved user function to run first

* A few rebase errors

---------

Co-authored-by: Becky Gilbert <[email protected]>
* Update eslint package to fix warning message

* Add exit survey pacakge

* exit survey

* Use survey_function to format survey text

* edit exit survey question titles and descriptions

* change question names and MC values to match EFP names

* add withdrawal and feedback questions

* Change package name, exit survey parameters

* Added privacy and databrary params

* Get study to add to withdraw copu

* disable the video sharing questions if video withdrawal is true

* Add MD link

* Add global data store

* fix withdrawal question value in data and logic for enabling/disabling the other video-related questions

* add validation for child birthdate: cannot be a future date

* Update root package

* First pass at tests

* Add data finish function

* Update tests

* Update versions of deps

* freeze loaded data

* Add s3 from EFP

* Add s3 class

* First pass at code documentation

* add auto bind dependency

* Add trial recorder

* Session recording

* More package updates

* Add comments to code

---------

Co-authored-by: Becky Gilbert <[email protected]>
This commit will do two things.  First, this will only bundle iife configs. Second, it adds the data package as an external dependency.
okaycj and others added 3 commits June 6, 2024 12:00
* Set up mkdocs

* Add markdown files

* move to mocros plugin

* Format changes

* Finish parameters table for surveys

* Add strict to build

* Add validation, git repo url, and exclude docs to config

* Link to change log wasn't working

* Grammar mistake in record docs
* Rebase fixes

* Fix a few mistakes found from rebasing

* adapt EFP S3 class for AWS SDK v3

* rename S3 class/file to LookitS3

* add AWS S3 region to Env type

* import S3 class into Recorder and add S3 upload (keep local download option for now)

* move creation of Recorder instance from trial constructor to on_start

* set strictPropertyInitialization:false to give the Recorder an s3 property that is not always set in constructor (can remove this if we remove local download option)

* fix formatting error

* call jsPsych finishTrial in stop plugin, give the recorder a second to stop before finishing

* add optional filename param to Recorder constructor and util to create filename

* remove strictPropertyInitialization: false

* mark vars as optional so that they do not need to be defined in constructor

* make s3 optional so that it does not need to be definitely assigned in constructor

* remove the getFilename util and replace with class create filename method and filename getter

* store recorder instance on window, call stop on that existing recorder, and throw errors based on existence/absence of recorder

* S3 tests

* fix file path for recorder import

* make the recorder stop method async and have stop plugin wait for upload to finish

* Change type of sessionRecorder to "unknown"

To facilitate the typing for our window storage, I've added an interface that extends Window.  Additionally, there's a new script in the root of this repo that will clean out "dist" directories.

* fix JSDoc and linting errors

* formatting fix

* Fix broken tests after data went external

* Remove prettier ignore file

* Add typing for env values and update how s3 uses them

* Add local down env value to record

---------

Co-authored-by: CJ Green <[email protected]>
packages/index.md Outdated Show resolved Hide resolved
packages/surveys/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@becky-gilbert becky-gilbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@okaycj okaycj merged commit 3f4ceeb into main Jul 23, 2024
2 checks passed
@okaycj okaycj deleted the video branch July 23, 2024 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants