Skip to content

Add survey creation, submission, results analytics and response management#78

Merged
A1L13N merged 3 commits into
alphaonelabs:mainfrom
ghanshyam2005singh:feature/survey-system
Jul 21, 2026
Merged

Add survey creation, submission, results analytics and response management#78
A1L13N merged 3 commits into
alphaonelabs:mainfrom
ghanshyam2005singh:feature/survey-system

Conversation

@ghanshyam2005singh

@ghanshyam2005singh ghanshyam2005singh commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

This PR implements a complete Survey System, including survey creation, participation, response collection, and analytics.

Backend

Implemented API endpoints:

Survey Management

  • GET /api/surveys
  • POST /api/surveys
  • GET /api/surveys/
  • DELETE /api/surveys/

Survey Participation

  • POST /api/surveys//submit

Survey Analytics

  • GET /api/surveys//results

Features

  • Support for multiple question types:

    • Multiple Choice (MCQ)
    • Checkbox
    • Text Response
    • True / False
    • Scale
  • Required question validation

  • Duplicate submission prevention (409 response)

  • Creator-only survey deletion

  • Survey response aggregation

  • Response rate calculation

  • Engagement score calculation

  • Top and bottom choice insights

Security

  • Free-text survey answers are AES encrypted before storage.
  • Encryption approach is consistent with existing feedback message handling.

Frontend

Rebuilt public/surveys.html as a self-contained page supporting:

  • Survey listing (/surveys)
  • Survey creation (?create=1)
  • Survey participation (?id=<survey_id>)
  • Survey analytics (?id=<survey_id>&results=1)

Screenshot:

Screencast.from.2026-07-19.21-12-48.mp4

Summary

  • Added a complete survey backend with creation, retrieval, listing, participation, submission, creator-only deletion, and duplicate-submission prevention.
  • Added support for multiple question types, required-question validation, choice validation, and encrypted free-text responses.
  • Added survey analytics with response aggregation, response rates, engagement scores, and top/bottom choice insights.
  • Rebuilt the surveys page as a self-contained client-side interface supporting survey management, participation, results visualization, and CSV export.

Impact

Users can now create and complete surveys, while creators can review aggregated results through a dedicated interface. Survey response privacy is improved through AES encryption of free-text answers.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@A1L13N, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository: alphaonelabs/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 57441707-543e-4604-aa38-f36b1722d2a2

📥 Commits

Reviewing files that changed from the base of the PR and between 6b5aa3a and 670d04b.

📒 Files selected for processing (2)
  • public/surveys.html
  • src/worker.py

Walkthrough

Changes

Surveys feature

Layer / File(s) Summary
Survey schema and API
src/worker.py
Adds survey tables, indexes, validation, CRUD endpoints, answer submission, encryption for free-text answers, and aggregated results.
Survey API routing
src/worker.py
Routes survey collection, detail, submission, deletion, and results requests.
Survey listing and creation
public/surveys.html
Adds authenticated client-side rendering for survey lists and dynamic survey creation.
Survey participation and results
public/surveys.html
Adds detail/take forms, answer submission, result charts, metrics, deletion controls, CSV export, and query-parameter routing.

Estimated code review effort: 4 (Complex) | ~60 minutes

Suggested reviewers: a1l13n, ananya44444, shubhashish-chakraborty

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant Worker
  participant Database
  Browser->>Worker: Request survey list or detail
  Worker->>Database: Query survey data and submission status
  Database-->>Worker: Survey records
  Worker-->>Browser: JSON survey data
  Browser->>Worker: Submit survey answers
  Worker->>Database: Validate and persist response
  Database-->>Worker: Stored response
  Worker-->>Browser: Submission response
  Browser->>Worker: Request survey results
  Worker->>Database: Aggregate responses and answers
  Database-->>Worker: Result statistics
  Worker-->>Browser: JSON results
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main survey system changes, including creation, submission, analytics, and response handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@public/surveys.html`:
- Around line 395-405: Update the CSV construction in the export-data click
handler to sanitize user-authored res.text and label values before quoting them:
prefix any cell whose content begins with =, +, -, or @ so spreadsheet
applications treat it as text. Apply the same sanitizer to both fields while
preserving existing quote escaping and CSV output behavior.
- Around line 139-149: Add aria-label attributes describing the purpose of the
question type select and question-text input in the question-rendering template.
Update the controls identified by data-field="type" and data-field="text" while
preserving their existing values, styling, and behavior.

In `@src/worker.py`:
- Around line 3206-3236: The api_survey_results handler currently exposes
decrypted text answers without authentication. Update api_survey_results to
reuse the existing verify_token authentication guard, and only include raw text
answers when the authenticated user is the survey creator; otherwise remove
text_answers from the response payload.
- Around line 3147-3156: The survey submission writes at src/worker.py lines
3147-3156 must be made atomic: in api_submit_survey, precompute encrypted text
values, build the response and survey_answers statements, and execute them
through env.DB.batch(...). Also batch the surveys, survey_questions, and
survey_choices inserts at src/worker.py lines 3013-3025 so survey creation
cannot partially persist.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: alphaonelabs/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 62e22da1-6e67-4985-8755-aee908dc61d2

📥 Commits

Reviewing files that changed from the base of the PR and between c7bc322 and 6b5aa3a.

📒 Files selected for processing (2)
  • public/surveys.html
  • src/worker.py

Comment thread public/surveys.html Outdated
Comment thread public/surveys.html
Comment thread src/worker.py Outdated
Comment thread src/worker.py
@A1L13N
A1L13N merged commit 6f9efa4 into alphaonelabs:main Jul 21, 2026
1 of 2 checks passed
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