Browser-based psychology assessments · 浏览器端心理测试框架
Quick Start · Widget · 8 Frameworks · API · Live Demos →
[English] A lightweight, dependency-free JavaScript library for creating browser-based psychology assessments.
[中文] 一个轻量级、零依赖的 JavaScript 库,用于创建浏览器端的心理测试和评估。
All tests are anonymous, free, and science-based. No data is sent to any server — everything runs in the browser.
所有测试均匿名、免费、基于科学理论。所有数据仅在浏览器端运行,不会发送到任何服务器。
👉 Live Demos / 在线体验: countrycode.xyz/psy/
| Metric | Value |
|---|---|
| 🧪 Frameworks | 8 (Attachment, CBT, Big Five, Decision, Flow, Stress Coping, Social Energy, Mental Age) |
| 🌐 Languages | English + Chinese (built-in i18n) |
| 📦 Size | ~8KB minified, ~2KB widget (gzipped) |
| 🎯 Dependencies | Zero — no jQuery, no React, no build tools |
| 🔌 Integration | 2-line HTML embed — works on any page |
| 📡 API | REST API with rate limit of 60 req/min (free, no key needed) |
| 🔗 Sharing | URL hash-based result sharing for all frameworks |
Adding a free psychology quiz to your site drives engagement, time-on-site, and return visits:
💡 Traffic strategy: When a visitor takes a quiz and shares their result on social media, the shared link points to YOUR page (where the widget is embedded), not to PsyQuiz. You get the referral traffic.
<script src="https://cdn.jsdelivr.net/gh/ZHIJAC/psyquiz@main/dist/psyquiz.min.js"></script>
<script>
const quiz = PsyQuiz.createQuiz('attachment', { lang: 'zh' });
console.log(quiz.meta);
const q = quiz.current();
quiz.answer('a1_3');
quiz.next();
const result = quiz.calculate();
console.log(result.primary, result.scores);
</script>
<div class="psyquiz-widget" data-framework="attachment" data-lang="zh"></div>
<script src="https://cdn.jsdelivr.net/gh/ZHIJAC/psyquiz@main/dist/psyquiz-widget.js"></script>
That’s it! A complete, interactive psychology quiz rendered in place.
| data-framework | Assessment |
|---|---|
attachment |
Attachment Style Test |
cbt |
Cognitive Distortions Test |
big-five |
Big Five Personality Test |
decision |
Decision Style (Maximizer vs Satisficer) |
flow |
Flow State Test |
stress-coping |
Stress Coping Style Test |
social-energy |
Social Energy Type Test |
mental-age |
Mental Age Fun Test |
| Version | URL |
|---|---|
| Latest (main branch) | https://cdn.jsdelivr.net/gh/ZHIJAC/psyquiz@main/dist/psyquiz.min.js |
| Latest widget | https://cdn.jsdelivr.net/gh/ZHIJAC/psyquiz@main/dist/psyquiz-widget.js |
| v1.1.0 (stable) | https://cdn.jsdelivr.net/gh/ZHIJAC/psyquiz@v1.1.0/dist/psyquiz.min.js |
| Full source | https://cdn.jsdelivr.net/gh/ZHIJAC/psyquiz@main/src/psyquiz.js |
🚀 Want this quiz on YOUR site? Add
psyquiz-widget.jsand a<div>— 2 lines, no signup, no API key.
The PsyQuiz Widget lets you add a complete psychology quiz to ANY website with just 2 lines of HTML.
<!-- 1. Container with data attributes -->
<div class="psyquiz-widget" data-framework="big-five" data-lang="en"></div>
<!-- 2. Script tag -->
<script src="https://cdn.jsdelivr.net/gh/ZHIJAC/psyquiz@main/dist/psyquiz-widget.js"></script>
| Attribute | Values | Default | Description |
|---|---|---|---|
data-framework |
See frameworks table | (required) | Which assessment to show |
data-lang |
en, zh |
en |
Interface language |
data-theme |
light, dark |
light |
Color theme |
Works on GitHub Pages, WordPress, static HTML sites, React/Vue apps, and more. No build step needed.
PsyQuiz is running in production on CountryCode.xyz — a psychology + emergency preparedness resource site:
| Feature | Status |
|---|---|
| 🧪 All 8 frameworks deployed | ✅ Live at /psy/ |
| 🌐 Bilingual (EN/ZH) | ✅ Both languages active |
| 👥 Daily users | Growing — organic traffic from quiz shares |
| 🔗 Open source | ✅ PsyQuiz on GitHub |
| 📡 REST API | ✅ countrycode.xyz/api |
Want your site listed here? Embed the PsyQuiz widget and open a PR to add your site. This section will feature community deployments.
| ID | Name (EN) | 名称 (中文) | Based On | Questions | Status |
|---|---|---|---|---|---|
attachment |
Attachment Style | 依恋类型 | Bowlby & Ainsworth | 7 | ✅ |
cbt |
Cognitive Distortions | 认知扭曲 | Beck’s CBT | 7 | ✅ |
big-five |
Big Five Personality | 大五人格 | Goldberg | 25 | ✅ |
decision |
Decision Style | 决策风格 | Schwartz | 7 | ✅ |
flow |
Flow State | 心流状态 | Csikszentmihalyi | 9 | ✅ |
stress-coping |
Stress Coping | 压力应对 | Folkman & Lazarus | 6 | ✅ |
social-energy |
Social Energy Type | 社交能量 | Introversion-Extraversion | 6 | ✅ |
mental-age |
Mental Age | 心理年龄 | Entertainment | 5 | ✅ |
All 8 frameworks are fully implemented with scoring, result interpretation, and bilingual (EN/ZH) support.
PsyQuiz.createQuiz(framework, options)| Option | Type | Default | Description |
|---|---|---|---|
lang |
'en' \| 'zh' |
'en' |
Language |
shuffle |
boolean |
false |
Randomize question order |
requiredAll |
boolean |
true |
Require all questions to be answered |
Returns a QuizInstance with:
.meta — Quiz metadata (title, description, question count).current() — Current question object.total() — Total question count.answer(value) — Record answer for current question.next() — Advance to next question.previous() — Go back to previous question.isComplete() — Check if all questions answered.calculate() — Compute results object with .primary, .scores, .interpretation.results() — Human-readable result stringPsyQuiz.listFrameworks()Returns array of all available framework IDs.
PsyQuiz now has a REST API for developers and AI agents! Submit answers via HTTP POST and get scored results back as JSON.
Base URL: https://countrycode.xyz/api
| Endpoint | Method | Description |
|---|---|---|
/api/frameworks |
GET | List all available frameworks |
/api/frameworks/:id |
GET | Get framework details + questions |
/api/assess/:framework |
POST | Submit answers, get scored results |
Rate limit: 60 requests/minute/IP (free, no API key needed)
curl -X POST https://countrycode.xyz/api/assess/attachment \
-H "Content-Type: application/json" \
-d '{"answers":{"a1":"a1_1","a2":"a2_1","a3":"a3_1"},"lang":"zh"}'
Response:
{
"framework": "attachment",
"name": "依恋类型测试",
"result": {
"primary": { "en": "Secure Attachment", "zh": "安全型依恋" },
"dimensions": { "secure": 6, "anxious": 0, "avoidant": 0, "disorganized": 0 }
}
}
import requests
r = requests.post("https://countrycode.xyz/api/assess/big-five", json={
"answers": {"b1": "b1_3", "b2": "b2_1"},
"lang": "en"
})
print(r.json()["result"]["primary"])
📖 Full API docs: countrycode.xyz/psy-api/
All 8 assessments are live at countrycode.xyz/psy/:
| Assessment | Type | URL |
|---|---|---|
| 🧠 Mental Age Fun Test | Entertainment | Try it |
| 🔗 Attachment Style Test | Psychology | Try it |
| 🔄 Cognitive Distortions | CBT | Try it |
| ⚖️ Decision Style | Maximizer vs Satisficer | Try it |
| 🌊 Flow State | Optimal Experience | Try it |
| 🧬 Big Five Personality | OCEAN Model | Try it |
| 💪 Stress Coping | Coping Strategies | Try it |
| 🔋 Social Energy Type | Introvert/Extrovert | Try it |
psyquiz/
├── src/
│ ├── psyquiz.js # Core library
│ ├── share-hash.js # URL hash sharing module
│ └── frameworks/ # Individual framework definitions
├── dist/
│ ├── psyquiz.min.js # Minified core (8KB)
│ └── psyquiz-widget.js # Embeddable widget script
├── examples/ # Example HTML files
└── docs/ # Documentation
If you use PsyQuiz in your project and find it valuable, consider supporting development:
USDT (Solana): 8M7jBNmCMUpoJx4bpG4YZKjGGEZQDAanXGEVfnVd78Wz
USDT (ERC-20): 0xf94a90Ed0A177CAf7954D77B1677dD59c8347D3d
Or contribute via pull request. All contributions welcome!
MIT — see LICENSE.
Built with ❤️ | ⭐ Star on GitHub | 🎯 Live Demos