Coding

Likert Survey Web App Prompt

Generate a single-file Likert survey web app with scoring, adjustable thresholds, and responsive vanilla JS—paste into ChatGPT to get a runnable code block.

prompt engineeringweb applikert scalesurvey formvanilla jshtml css javascriptscoringaccessibilityresponsive designsingle file appassessment tool
Prompt text
You are a professional AI developer. Build a web app that is a general-purpose self-reflection quiz framework. It delivers a structured questionnaire, stores user answers locally, computes weighted scores, and shows results in banded categories.

Quiz Configuration (QUIZ object)
The quiz is defined as a constant array of sections.

Each section has:
id — short identifier.
title — displayed section heading.
help — explanatory text.
weight — multiplier for the influence of that section.
reverse (boolean, optional) — indicates items should be reverse-scored.
redFlagThreshold (optional) — sets a critical value where answers at/above this threshold trigger a safety flag.
items[] — array of questions with:
k (key) — unique identifier for the question.
t (text) — the phrasing of the item.

Answer Persistence (usePersistedAnswers)
State hook that manages the answers object.
Loads initial state from localStorage.
Saves answers back to localStorage whenever they change.
Ensures user progress persists across refreshes or browser sessions.

Scoring (computeScores)
Iterates through all questions in all sections.
For each question:
Retrieves its answer (0–4 Likert scale).
Applies section weight.
If reverse = true, computes contribution as (maxLikertValue – answer) × weight.
Else computes as (answer × weight).
Tracks total achieved score (riskIndex) and maximum possible (riskMax).
Calculates overall percentage: (riskIndex / riskMax) × 100.
Checks for safety flags: if any item exceeds its redFlagThreshold, sets safetyTriggered = true.
Maps percentage and safety flag into a band (e.g., Green, Yellow, Orange, Red).

UI Components
Likert Scale Renderer: Displays a 5-point radio button set, highlights selected, updates answers.
Badge: Displays the results “band” with visual styling (e.g., colors).
Main Quiz Renderer: Iterates over sections, displays section title/help text, renders each item with its Likert scale

Main App Flow
Initializes answers from storage.
Displays header with instructions/disclaimer.
Shows “current results” box with computed percentage and band (optionally a warning if safety triggered).
Renders questionnaire by mapping through sections and items.
Provides a “reset” button to clear answers.
Provides a “toggle results” button to show/hide detailed section breakdowns.
Renders results interpretation section explaining what the bands mean.

Privacy and Safety Features
Entirely client-side; no server calls.
Data stored only in localStorage.
Safety flags allow specific items to elevate risk regardless of total percentage.
Results are revealed only at the end to reduce priming bias.

I will provide the list of questions in the next prompt.

Prompt Author

Sam Holstein's avatar
Sam Holstein

AI consultant and software creator helping businesses and creators harness artificial intelligence through practical solutions and innovative products. Creator of BestPromptIdeas.com.

Ratings

Related prompts

Coding

Xcode Project Setup Coach

Reads your Markdown specs and coaches you step by step to create a correctly configured Xcode project with clear choices, confirmations, and a final summary.

Coding

Replit → Vercel Migration

Migrate a Replit project to Vercel: clean Replit files, update scripts, add secure SendGrid API route, audit DB, add docs, and prepare one-click production depl