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.
BeforeAfter
Board lives in the browser's localStorageEvery submission is appended to a Google Sheet row (permanent log)
Nothing to install, but scores can't be sharedQuiz displays the sheet's top-10 on the results + leaderboard screens
No internet neededStill 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)

  1. Open sheets.new in your browser — it creates a brand-new empty Google Sheet. Name it Carpe Diem Leaderboard (cosmetic, any name works).
  2. Menu: Extensions → Apps Script. A script editor opens, attached to this sheet.
  3. Delete the sample function myFunction() code entirely.
  4. 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.
  5. Press Ctrl+S. Name the project e.g. CD Leaderboard.

Part 2 · Deploy it as a public web app

  1. Top-right: Deploy → New deployment.
  2. Click the gear next to "select type" and choose Web app.
  3. Set these two — they're the settings everyone gets wrong:
    SettingChooseWhy
    Execute asMe (you)Rows are written into your sheet under your account.
    Who has accessAnyoneClassmates' browsers must be able to post scores without logging in.
  4. Description can say Carpe Diem leaderboard v1. Click Deploy.
  5. 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.
  6. 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)

  1. 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":[]}).
  2. 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.
  3. Check the sheet: the Scores tab should auto-appear with a row: Timestamp | Quiz | Nickname | Score | Percent | Mode | Duration.
  4. 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

SymptomFix
Board says it can't reach the sheetCheck 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 effectCreate a new version in Manage deployments (see Part 2 warning).
Scores appear once, then stopLog has a 100,000-row safety cap in the script; unlikely — otherwise check the Sheet's own storage.
"Authorization required" on a friend's deviceAccess must be Anyone; redeploy with the right audience.
Want to reset the boardDelete rows in the Scores tab (the tab itself is auto-recreated)
Carpe Diem Engine · leaderboard_apps_script.gs is the backend source — don't edit unless you cloned it
Carpe diem. Seize the board.