From 5bb883e9e891e6c21ef5c79b4f826ed5c13777d0 Mon Sep 17 00:00:00 2001 From: Becky Gilbert Date: Tue, 15 Oct 2024 11:30:21 -0700 Subject: [PATCH] update response with completed_consent_frame: true --- packages/record/src/consentVideo.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/record/src/consentVideo.ts b/packages/record/src/consentVideo.ts index 0fbbb85c..f6f0d979 100644 --- a/packages/record/src/consentVideo.ts +++ b/packages/record/src/consentVideo.ts @@ -1,3 +1,4 @@ +import Data from "@lookit/data"; import { LookitWindow } from "@lookit/data/dist/types"; import Handlebars from "handlebars"; import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "jspsych"; @@ -279,13 +280,24 @@ export class VideoConsentPlugin implements JsPsychPlugin { */ private nextButton(display: HTMLElement) { const next = this.getButton(display, "next"); - next.addEventListener("click", () => this.jsPsych.finishTrial()); + next.addEventListener("click", () => this.endTrial()); + } + + /** + * Mark the response in the lookit-api database as having completed the consent frame, + * then finish the trial. + */ + private async endTrial() { + await Data.updateResponse(window.chs.response.id, { + completed_consent_frame: true, + }); + this.jsPsych.finishTrial(); } /** * Add CHS type to experiment data. This will enable Lookit API to run the * "consent" Frame Action Dispatcher method after the experiment has - * completed. It looks like jsPsych uses snake case for these data. + * completed. * * @returns Object containing CHS type. */