Watts-Lab / surveys

Library of surveys for deliberation experiments
MIT License
3 stars 4 forks source link

Measure survey completion time #87

Closed JamesPHoughton closed 1 year ago

JamesPHoughton commented 1 year ago

As an experiment designer, I want to understand how long it takes on average for a participant to answer a survey, so that I can decide whether I want to adjust its length. This information should be measured for each participant for each survey, and saved with the survey record.

New code should live in the SurveyFactory: https://github.com/Watts-Lab/surveys/blob/main/src/surveyFactory.jsx

Add a useEffect to start a timer:

  useEffect(() => {
    console.log(`Discussion Room URL: ${dailyUrl}`);
  }, []);

See https://github.com/Watts-Lab/deliberation-empirica/blob/main/client/src/pages/Discussion.jsx#L34-L36 for examples

Set a timer

import dayjs from "dayjs";

start = dayjs(); \\ put in useEffect
stop = dayjs(); \\ put at top of scoreResponses function

Save a completionTime in the record object in seconds.

Use the exampleSurvey.cy.jsx cypress test to check that the time is computed properly, see examples here:

you'll need to put in a cy.wait(5000) or similar to build in some elapsed time that you measure and compare against.

JamesPHoughton commented 1 year ago

complete in https://github.com/Watts-Lab/surveys/pull/88