diff --git a/.changeset/cold-chairs-confess.md b/.changeset/cold-chairs-confess.md new file mode 100644 index 00000000..001ffbdc --- /dev/null +++ b/.changeset/cold-chairs-confess.md @@ -0,0 +1,5 @@ +--- +"@lookit/style": patch +--- + +Update consent trial style diff --git a/.changeset/strange-bottles-invent.md b/.changeset/strange-bottles-invent.md new file mode 100644 index 00000000..9774fea1 --- /dev/null +++ b/.changeset/strange-bottles-invent.md @@ -0,0 +1,6 @@ +--- +"@lookit/templates": patch +"@lookit/record": patch +--- + +Add Garden's consent template diff --git a/packages/record/scss/consent-video-trial.scss b/packages/record/scss/consent-video-trial.scss index 604a857e..25745525 100644 --- a/packages/record/scss/consent-video-trial.scss +++ b/packages/record/scss/consent-video-trial.scss @@ -35,8 +35,10 @@ div#consent-video-trial { font-size: 15px; } - ol { + ol, + ul { padding-left: 30px; + font-size: 15px; } li { diff --git a/packages/style/src/index.css b/packages/style/src/index.css index 85bc1efb..e9f20c68 100644 --- a/packages/style/src/index.css +++ b/packages/style/src/index.css @@ -8937,6 +8937,10 @@ div#consent-video-trial p { div#consent-video-trial ol { padding-left: 30px; } +div#consent-video-trial ol, div#consent-video-trial ul { + font-size: 15px; + margin-top: 0px; +} div#consent-video-trial li { padding-top: 10px; padding-bottom: 10px; diff --git a/packages/templates/hbs/consent-garden.hbs b/packages/templates/hbs/consent-garden.hbs new file mode 100644 index 00000000..84b4fa2d --- /dev/null +++ b/packages/templates/hbs/consent-garden.hbs @@ -0,0 +1,307 @@ +

+ {{#if header}} {{exp-format header}} {{else}} + {{{t "consent-garden.header" experiment=experiment.name}}} + {{/if}} +

+ +{{! intro sentence }} +

{{#if intro_sentence}} {{exp-format intro_sentence}} {{else}} + {{t + "consent-garden.intro-sentence" + name=PIName + institution=institution + experiment=experiment.name + htmlSafe=true + }} + {{/if}} + {{exp-format summary_statement}} +

+ +{{! overview }} +

+ {{#if overview_header}} {{exp-format overview_header}} {{else}} + {{t "consent-garden.overview-header" htmlSafe=true}} + {{/if}} +

+ +

+ {{#if overview_content}} {{exp-format overview_content}} {{else}} + {{t + "consent-garden.overview-content" + contact=PIContact + experiment=experiment.name + htmlSafe=true + }} + {{/if}} +

+ +{{! study info }} +

+ {{#if study_info_header}} {{exp-format study_info_header}} {{else}} + {{t "consent-garden.study-info-header" htmlSafe=true}} + {{/if}} +

+

+ {{#if study_info_content}} {{exp-format study_info_content}} {{else}} + {{t + "consent-garden.study-info-content" + description=study_info_description + lab=lab + institution=institution + experiment=experiment.name + htmlSafe=true + }} + {{/if}} +

+ +{{! purpose }} +

+ {{#if purpose_header}} {{exp-format purpose_header}} {{else}} + {{t "consent-garden.purpose-header" htmlSafe=true}} + {{/if}} +

+

+ {{exp-format purpose_content}} +

+ +{{! eligibility }} +

+ {{#if eligibility_header}} {{exp-format eligibility_header}} {{else}} + {{t "consent-garden.eligibility-header" htmlSafe=true}} + {{/if}}

+

{{exp-format eligibility_content}}

+ +{{! procedures }} +

{{#if procedures_header}} {{exp-format procedures_header}} {{else}} + {{t "consent-garden.procedures-header" htmlSafe=true}} + {{/if}}

+

+ {{#if include_duration_in_procedures}} + {{#if duration_statment}} {{exp-format duration_statment}} {{else}} + {{t + "consent-garden.duration-statement" + duration=experiment.duration + htmlSafe=true + }} + {{exp-format procedures_content}} + {{/if}} + {{else}} + {{exp-format procedures_content}} + {{/if}} +

+ +{{! payment }} +

{{#if payment_header}} {{exp-format payment_header}} {{else}} + {{t "consent-garden.payment-header" htmlSafe=true}} + {{/if}}

+

{{#if payment_content}} {{exp-format payment_content}} {{else}} + {{t "consent-garden.payment-content" htmlSafe=true}} + {{/if}}

+ +{{! benefits }} +

{{#if benefits_header}} {{exp-format benefits_header}} {{else}} + {{t "consent-garden.benefits-header" htmlSafe=true}} + {{/if}}

+

{{exp-format benefits_content}}

+ +{{! risks }} +

{{#if risk_header}} {{exp-format risk_header}} {{else}} + {{t "consent-garden.risk-header" htmlSafe=true}} + {{/if}}

+

+ {{#if risk_content}} + {{exp-format risk_content}} + {{else}} + {{t + "consent-garden.risk-content-1" + duration=experiment.duration + experiment=experiment.name + htmlSafe=true + }} + {{#if risk_content_additional}} + {{exp-format risk_content_additional}} + {{/if}} + {{t + "consent-garden.risk-content-2" + risk_content_discontinue_options=risk_content_discontinue_options + htmlSafe=true + }} + {{#if risk_content_breach_of_confidentiality}} + {{exp-format risk_content_breach_of_confidentiality}} + {{/if}} + {{t "consent-garden.risk-content-3" htmlSafe=true}} + {{/if}} +

+ +{{! data collection }} +

{{#if data_collection_header}} + {{exp-format data_collection_header}} + {{else}} + {{t "consent-garden.data-collection-header" htmlSafe=true}} + {{/if}}

+

{{#if data_collection_content}} + {{exp-format data_collection_content}} + {{else}} + {{t + "consent-garden.data-collection-content" + institution=institution + omit_video=data_collection_omit_video + htmlSafe=true + }} + {{/if}}

+ +{{! data use }} +

{{#if data_use_header}} {{exp-format data_use_header}} {{else}} + {{t "consent-garden.data-use-researchers-header" htmlSafe=true}} + {{/if}}

+

{{#if data_use_content}} {{exp-format data_use_content}} {{else}} + {{t "consent-garden.data-use-researchers-content" htmlSafe=true}} + {{/if}}

+ +{{! data access }} +

{{#if data_access_header}} {{exp-format data_access_header}} {{else}} + {{t "consent-garden.data-access-header" htmlSafe=true}} + {{/if}}

+

{{#if data_access_content}} {{exp-format data_access_content}} {{else}} + {{t + "consent-garden.data-access-content" + institution=institution + htmlSafe=true + }} + {{/if}}

+ +{{! data management }} +

{{#if data_management_header}} + {{exp-format data_management_header}} + {{else}} + {{t "consent-garden.data-management-header" htmlSafe=true}} + {{/if}}

+

{{#if data_management_content}} + {{exp-format data_management_content}} + {{else}} + {{t "consent-garden.data-management-content" htmlSafe=true}} + {{/if}}

+ +{{! data sharing }} +

{{#if data_sharing_header}} {{exp-format data_sharing_header}} {{else}} + {{t "consent-garden.data-sharing-header" htmlSafe=true}} + {{/if}}

+

{{#if data_sharing_content}} {{exp-format data_sharing_content}} {{else}} + {{t + "consent-garden.data-sharing-content" + data_sharing_learn=data_sharing_learn + experiment=experiment.name + htmlSafe=true + }} + {{/if}}

+ +{{! research rights and irb info }} +

{{#if research_rights_irb_header}} + {{exp-format research_rights_irb_header}} + {{else}} + {{t + "consent-garden.research-rights-irb-header" + institution=institution + htmlSafe=true + }} + {{/if}}

+

{{#if research_rights_irb_content}} + {{exp-format research_rights_irb_content}} + {{else}} + {{t + "consent-garden.research-rights-irb-content" + institution=institution + include_irb_contact_statement=include_irb_contact_statement + irb_contact=irb_contact + irb_extra=irb_extra + htmlSafe=true + }} + {{/if}}

+ +{{! lookit info }} +

{{#if lookit_info_header}} {{exp-format lookit_info_header}} {{else}} + {{t "consent-garden.lookit-info-header" htmlSafe=true}} + {{/if}}

+

{{#if lookit_info_content}} {{exp-format lookit_info_content}} {{else}} + {{t "consent-garden.lookit-info-content" htmlSafe=true}} + {{/if}}

+ +{{! voluntary participation }} +

{{#if voluntary_participation_header}} + {{exp-format voluntary_participation_header}} + {{else}} + {{t "consent-garden.voluntary-participation-header" htmlSafe=true}} + {{/if}}

+

{{#if voluntary_participation_content}} + {{exp-format voluntary_participation_content}} + {{else}} + {{t "consent-garden.voluntary-participation-content" htmlSafe=true}} + {{/if}}

+ +{{! video sharing }} +

{{#if video_sharing_header}} {{exp-format video_sharing_header}} {{else}} + {{t "consent-garden.video-sharing-header" htmlSafe=true}} + {{/if}}

+

+ {{#if video_sharing_consent}} {{exp-format video_sharing_consent}} {{else}} + {{t "consent-garden.video-sharing-consent" htmlSafe=true}} + {{/if}} + {{#unless data_collection_omit_video}} + + {{#if video_sharing_study}} + {{exp-format video_sharing_study}} + {{else}} + {{#if private_level_only}} + {{t "consent-garden.video-sharing-study-private" htmlSafe=true}} + {{else}} + {{t "consent-garden.video-sharing-study-all-1" htmlSafe=true}} + {{#if include_databrary}} + {{t "consent-garden.video-sharing-study-all-databrary" htmlSafe=true}} + {{/if}} + {{t "consent-garden.video-sharing-study-all-2" htmlSafe=true}} + {{/if}} + {{/if}} + {{/unless}} + + {{! additional video privacy statement }} + {{#if additional_video_privacy_statement}} + {{exp-format additional_video_privacy_statement}} + {{/if}} +

+ +{{! databrary sharing }} +{{#if include_databrary}} +

{{#if databrary_header}} {{exp-format databrary_header}} {{else}} + {{t "consent-garden.databrary-header" htmlSafe=true}} + {{/if}}

+

+ {{#if databrary_content}} {{exp-format databrary_content}} {{else}} + {{t "consent-garden.databrary-content" htmlSafe=true}} + {{/if}} +

+{{/if}} + +{{! additional segments }} +{{#if additional_segments}} + {{#each additional_segments as |segment|}} +

{{exp-format segment.title}}

+

{{exp-format segment.text}}

+ {{/each}} +{{/if}} + +{{! contact }} +

+ {{#if contact_header}} {{exp-format contact_header}} {{else}} + {{{t "consent-garden.contact-header" htmlSafe=true}}} + {{/if}}

+

+ {{#if contact_content}} {{exp-format contact_content}} {{else}} + {{t + "consent-garden.contact-content" + name=PIName + institution=institution + contact=PIContact + htmlSafe=true + }} + {{/if}} +

\ No newline at end of file diff --git a/packages/templates/src/consentVideoTemplate.ts b/packages/templates/src/consentVideoTemplate.ts index 63870f04..1166261d 100644 --- a/packages/templates/src/consentVideoTemplate.ts +++ b/packages/templates/src/consentVideoTemplate.ts @@ -1,6 +1,7 @@ import { LookitWindow } from "@lookit/data/dist/types"; import Handlebars from "handlebars"; import { PluginInfo, TrialType } from "jspsych"; +import consent_garden from "../hbs/consent-garden.hbs"; import consent_template_5 from "../hbs/consent-template-5.hbs"; import consentVideoTrialTemplate from "../hbs/consent-video-trial.hbs"; import { ConsentTemplateNotFound } from "./errors"; @@ -48,6 +49,8 @@ const consentDocument = (trial: TrialType) => { switch (trial.template) { case "consent-template-5": return consent_template_5; + case "consent-garden": + return consent_garden; default: throw new ConsentTemplateNotFound(trial.template); } diff --git a/packages/templates/src/index.spec.ts b/packages/templates/src/index.spec.ts index 1aaa6459..6dc70064 100644 --- a/packages/templates/src/index.spec.ts +++ b/packages/templates/src/index.spec.ts @@ -5,11 +5,22 @@ import chsTemplate from "./index"; declare const window: LookitWindow; -test("consent video", () => { - const trial = { +/** + * Test helper function to create trial object. + * + * @param values - Object to replace default trial values + * @returns Trial object + */ +const getTrial = (values: Record = {}) => { + return { locale: "en-us", template: "consent-template-5", + ...values, } as unknown as TrialType; +}; + +test("consent video", () => { + const trial = getTrial(); const name = "some name"; window.chs = { study: { @@ -29,10 +40,7 @@ test("consent video", () => { }); test("consent video in French", () => { - const trial = { - locale: "fr", - template: "consent-template-5", - } as unknown as TrialType; + const trial = getTrial({ locale: "fr" }); const name = "some name"; window.chs = { study: { @@ -52,11 +60,15 @@ test("consent video in French", () => { }); test("consent video with unknown template", () => { - const trial = { - locale: "en-us", + const trial = getTrial({ template: "not a real template name", - } as unknown as TrialType; + }); expect(() => chsTemplate.consentVideo(trial)).toThrow( ConsentTemplateNotFound, ); }); + +test("consent garden template", () => { + const trial = getTrial({ template: "consent-garden" }); + expect(chsTemplate.consentVideo(trial)).toContain("Project GARDEN"); +}); diff --git a/packages/templates/src/utils.ts b/packages/templates/src/utils.ts index fb4a6913..e8842558 100644 --- a/packages/templates/src/utils.ts +++ b/packages/templates/src/utils.ts @@ -88,4 +88,7 @@ i18next.use(ICU).init({ // Setup Handlebars' helpers Handlebars.registerHelper("exp-format", (context) => expFormat(context)); -Handlebars.registerHelper("t", (context, { hash }) => i18next.t(context, hash)); +Handlebars.registerHelper("t", (context, { hash }) => { + const txt = String(i18next.t(context, hash)); + return hash.htmlSafe ? new Handlebars.SafeString(txt) : txt; +});