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 engineering#web app#likert scale#survey form#vanilla js#html css javascript#scoring#accessibility#responsive design#single file app#assessment tool

Prompt

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.
Sam Holstein
Written by
Sam Holstein
@msamholstein_6ead51

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

Reviews

0 reviews

No reviews yet. Be the first to leave feedback.

Sign in to leave a rating or review.

Related prompts

View category →
Coding

Architecture Review & Fix Strategy

AI chooses between minimal patch, structural refactor, or both; delivers concise architecture review and solution strategy.

#software architecture#code review#refactoring#debugging+3
Sam Holstein
Sam Holstein
Coding

Collaborative Coding Agent

Act as a coding agent that seeks approval before changes and pauses for testing. Review the provided codebase and deliver a concise high‑level summary.

#coding agent#code review#software development#testing+3
Sam Holstein
Sam Holstein
Coding

Whole-Repo Architecture Review (Read-Only)

Run a read-only, whole-repo architecture review with sourced citations, risks, simplifications, target design, and a phased migration plan.

#architecture review#repository analysis#codebase audit#software architecture+9
Sam Holstein
Sam Holstein
Coding

Modernize Objective-C App to Swift & SwiftUI

Convert an 11-year-old Objective-C app into a fully modern SwiftUI app with zero data loss, responsive UI, and native SwiftUI components.

#swiftui#app modernization#objective-c to swift#ios development+2
Sam Holstein
Sam Holstein
Coding

Public Web Portfolio Audit & Cleanup

Audit a portfolio site’s public-facing code and assets for quality, security, and accessibility. Fix issues with reversible commits and produce SUMMARY.md.

#website audit#portfolio site#frontend code review#security hygiene+6
Sam Holstein
Sam Holstein
Coding

Code Performance Analyzer

Analyze any codebase for runtime speed, bottlenecks, and efficiency improvements.

#code analysis#performance optimization#efficiency audit#software engineering
Sam Holstein
Sam Holstein