Carpe Diem — Global Leaderboard Setup
one-time setup · ~15 minutes · powered by kingfahd pappoe
Backend: Google Apps Script (free, uses your own Google account)
Applies to: CarpeDiem_Genetics_MegaQuiz.html
What you're building
Right now scores are saved only on this device (browser localStorage). This walkthrough connects the quiz to a free Google Sheet backend, so anyone with the quiz file — anywhere — posts their scores to one shared, permanent log and sees one shared top-10 per module.
| Before | After |
| Board lives in the browser's localStorage | Every submission is appended to a Google Sheet row (permanent log) |
| Nothing to install, but scores can't be shared | Quiz displays the sheet's top-10 on the results + leaderboard screens |
| No internet needed | Still works offline — the board just says it can't reach the sheet without internet |
Prerequisites: a Google account, internet, and the files in The carpe Diem Engine folder. Nothing is paid; Apps Script + Sheets are free.
Part 1 · Create the backend (Google Sheet + script)
- Open sheets.new in your browser — it creates a brand-new empty Google Sheet. Name it Carpe Diem Leaderboard (cosmetic, any name works).
- Menu: Extensions → Apps Script. A script editor opens, attached to this sheet.
- Delete the sample
function myFunction() code entirely.
- Open leaderboard_apps_script.gs (in your Engine folder), select everything (Ctrl+A), copy (Ctrl+C), and paste it into the editor (Ctrl+V). The file contains the POST handler (writes rows) and a JSONP GET handler (reads top-10) — leave it untouched.
- Press Ctrl+S. Name the project e.g. CD Leaderboard.
Part 2 · Deploy it as a public web app
- Top-right: Deploy → New deployment.
- Click the gear next to "select type" and choose Web app.
- Set these two — they're the settings everyone gets wrong:
| Setting | Choose | Why |
| Execute as | Me (you) | Rows are written into your sheet under your account. |
| Who has access | Anyone | Classmates' browsers must be able to post scores without logging in. |
- Description can say Carpe Diem leaderboard v1. Click Deploy.
- Authorise your account when asked. The "Google hasn't verified this app" warning is normal for your own private script — click Advanced → Go to Carpe Diem Leaderboard (unsafe) → Allow.
- Deploy done → copy the Web app URL. It ends in
/exec. That URL is your LEADERBOARD_URL. Keep it; share it — classmates don't need the sheet, just the quiz.
If you ever edit the .gs code later, you must Deploy → Manage deployments → Edit → New version, otherwise changes don't take effect.
Part 3 · Wire the URL into the quiz
In build_genetics_megaquiz.py, find the config block (around line 326) and paste your URL:
bank = {
"config": {
"title": "The Carpe Diem Genetics - Modules 1-9",
"leaderboard_url": "PASTE-YOUR-/exec-URL-HERE", # was ""
...
Then rebuild (from the Engine folder, in a terminal):
python build_genetics_megaquiz.py build then node check_genetics_megaquiz.js
This bakes the URL into the quiz's data. Remember: the quiz HTML already chosen/being shared must be the rebuilt one.
Part 4 · Test it (epoch of truth)
- Smoke the API alone: paste in a browser:
YOUR-URL?do=top&quiz=BIOL%20153&callback=cdLB — you should get something like cdLB({"ok":true,"top":[]}).
- Play one short section of the quiz to the end (16-question sections are quick), finish it, and enter a nickname on the results screen.
- Check the sheet: the Scores tab should auto-appear with a row: Timestamp | Quiz | Nickname | Score | Percent | Mode | Duration.
- Check the quiz: the results screen now shows the global board card with your name on it; the Leaderboard screen gains the shared ranking.
Troubleshooting
| Symptom | Fix |
| Board says it can't reach the sheet | Check the /exec URL is pasted exactly (ends in /exec, not /dev), saved, and the quiz rebuilt. |
| Popup says "Google hasn't verified this app" | Normal for personal scripts. Advanced → Go to … (unsafe) → Allow. |
| Edits to the script don't take effect | Create a new version in Manage deployments (see Part 2 warning). |
| Scores appear once, then stop | Log has a 100,000-row safety cap in the script; unlikely — otherwise check the Sheet's own storage. |
| "Authorization required" on a friend's device | Access must be Anyone; redeploy with the right audience. |
| Want to reset the board | Delete rows in the Scores tab (the tab itself is auto-recreated) |