Skip to content

Add optional CAPTCHA feature to verify human participants#1068

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/fix-5a3b5ebe-3eb5-4c11-bf39-14fbc344c008
Draft

Add optional CAPTCHA feature to verify human participants#1068
Copilot wants to merge 5 commits intomainfrom
copilot/fix-5a3b5ebe-3eb5-4c11-bf39-14fbc344c008

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 1, 2025

Overview

This PR implements an optional CAPTCHA feature to help researchers filter out bot participants before they consume study resources. The feature addresses the need for automated screening of non-human participants while maintaining backward compatibility with existing configurations.

Implementation Details

CAPTCHA Component

A new CaptchaCheck component provides a simple math-based verification system:

  • Generates random arithmetic problems (addition, subtraction, multiplication with numbers 1-10)
  • Allows participants up to 3 attempts to solve the problem
  • Auto-advances to the next step on successful completion (500ms delay for user feedback)
  • Blocks participants after 3 failed attempts with clear messaging
  • Records detailed results including pass/fail status, number of attempts, and timestamp

Why math-based instead of reCAPTCHA?

  • No external API dependencies or API key management required
  • Self-contained and works offline/in sandboxed environments
  • Consistent experience across all deployments
  • Simple for legitimate human participants while still effective at filtering automated bots

Integration

The CAPTCHA is seamlessly integrated into the intro flow:

  1. Consent form
  2. CAPTCHA Check (if enabled via config)
  3. Attention Check
  4. Equipment Check
  5. Enter Nickname

Configuration

Enable the feature by adding to your batch config:

{
  "checkCaptcha": true
}

The feature defaults to false for backward compatibility. Config validation ensures:

  • Only boolean values are accepted
  • Warning logged when not specified
  • Error thrown for invalid values

Data Export

CAPTCHA results are automatically exported with participant data:

{
  "captchaScore": {
    "passed": true,
    "attempts": 1,
    "timestamp": 1234567890123
  }
}

This allows researchers to:

  • Filter participants who failed the CAPTCHA in post-processing
  • Analyze patterns in CAPTCHA attempts
  • Audit bot detection effectiveness

UI Preview

The CAPTCHA interface provides clear feedback across three states:

CAPTCHA UI States

  • Left: Initial state with clean interface and math problem
  • Center: Error state showing incorrect answer feedback and attempt counter
  • Right: Failed state after 3 attempts preventing further progress

Testing

Cypress Integration

Added stepCaptchaCheck command that:

  • Automatically parses the math problem from the page
  • Solves it correctly (tests the success path)
  • Verifies auto-advance behavior

New test file 15_Captcha_Check.js provides end-to-end validation of the feature.

Build Verification

  • ✅ Client builds successfully
  • ✅ Server builds successfully
  • ✅ All existing tests remain unaffected

Documentation

Updated docs/batchConfig.md with:

  • Complete checkCaptcha parameter documentation
  • Explanation of behavior and data format
  • Usage examples
  • Added to example config for consistency

Backward Compatibility

  • Feature is disabled by default (checkCaptcha defaults to false)
  • Existing batches continue to work without any changes
  • No breaking changes to existing intro flow
  • Config files without checkCaptcha work exactly as before

Future Enhancements

Possible future improvements (not in scope for this PR):

  • Configurable difficulty levels
  • Alternative CAPTCHA types (image-based, audio)
  • Configurable attempt limits
  • Integration with external CAPTCHA services as an option

Closes #[issue_number]

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)
  • o1.ingest.sentry.io
    • Triggering command: node /home/REDACTED/work/deliberation-empirica/deliberation-empirica/client/node_modules/.bin/vite build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[FEATURE]: Add an optional Captcha to test for humanity</issue_title>
<issue_description>### User Story

As a researcher, I want as much confidence as possible that I'm getting human participants, so that I can test my data.

Feature description

Include a CAPTCHA in the intro sequence, right after consent, that checks for non-bot activity. It should be its own page, and when it succeeds, it should advance the page automatically.

It should save the score assigned to the player object, and that score should be exported along with the science data.

If the CAPTCHA fails, it should not allow the participant to proceed.

What would this feature enable?

Automatic screening of bot participants (hopefully).

Is this a front end or back end feature?

  • Front end
  • Back end

Priority

None

Syntax Suggestion

We could make this optional with a config option as well.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #1067

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits October 1, 2025 16:08
Co-authored-by: JamesPHoughton <4304478+JamesPHoughton@users.noreply.github.com>
…ests

Co-authored-by: JamesPHoughton <4304478+JamesPHoughton@users.noreply.github.com>
Co-authored-by: JamesPHoughton <4304478+JamesPHoughton@users.noreply.github.com>
Co-authored-by: JamesPHoughton <4304478+JamesPHoughton@users.noreply.github.com>
Copilot AI changed the title [WIP] [FEATURE]: Add an optional Captcha to test for humanity Add optional CAPTCHA feature to verify human participants Oct 1, 2025
Copilot AI requested a review from JamesPHoughton October 1, 2025 16:20
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.

[FEATURE]: Add an optional Captcha to test for humanity

2 participants