From d0e72d0bfeac0d25e427e161e96223ab4be4d5e0 Mon Sep 17 00:00:00 2001 From: "nate@necloud.us" Date: Mon, 7 Jul 2025 08:23:02 -0400 Subject: [PATCH] Sessions --- data/results.json | 78 ++++++++++++++++++++++------------------- migrateResults.js | 16 +++++++++ public/index.html | 14 ++++++++ public/js/admin.js | 86 +++++++++++++++++++++++++++++++++++++++++----- server.js | 14 ++++---- 5 files changed, 158 insertions(+), 50 deletions(-) create mode 100644 migrateResults.js diff --git a/data/results.json b/data/results.json index 39d572a..ec3db51 100644 --- a/data/results.json +++ b/data/results.json @@ -1,38 +1,44 @@ { - "student1": { - "score": 8, - "completed": true, - "answers": [ - { - "word": "apple", - "correct": true - }, - { - "word": "banana", - "correct": false - }, - { - "word": "grape", - "correct": true - } - ] - }, - "nate": { - "score": 1, - "completed": true, - "answers": [ - { - "word": "not", - "correct": false - }, - { - "word": "bot", - "correct": false - }, - { - "word": "snot", - "correct": true - } - ] - } + "student1": [ + { + "score": 8, + "completed": true, + "answers": [ + { + "word": "apple", + "correct": true + }, + { + "word": "banana", + "correct": false + }, + { + "word": "grape", + "correct": true + } + ], + "timestamp": "2025-07-07T12:14:21.057Z" + } + ], + "nate": [ + { + "score": 1, + "completed": true, + "answers": [ + { + "word": "not", + "correct": false + }, + { + "word": "bot", + "correct": false + }, + { + "word": "snot", + "correct": true + } + ], + "timestamp": "2025-07-07T12:14:21.058Z" + } + ] } \ No newline at end of file diff --git a/migrateResults.js b/migrateResults.js new file mode 100644 index 0000000..62b082b --- /dev/null +++ b/migrateResults.js @@ -0,0 +1,16 @@ +const fs = require('fs'); +const path = require('path'); + +const resultsPath = path.join(__dirname, 'data', 'results.json'); +const existingData = JSON.parse(fs.readFileSync(resultsPath)); + +for (const username in existingData) { + const singleResult = existingData[username]; + existingData[username] = [{ + ...singleResult, + timestamp: new Date().toISOString() + }]; +} + +fs.writeFileSync(resultsPath, JSON.stringify(existingData, null, 2)); +console.log("✅ Migration complete. Results are now session arrays."); \ No newline at end of file diff --git a/public/index.html b/public/index.html index dd9551c..82e527f 100644 --- a/public/index.html +++ b/public/index.html @@ -52,6 +52,7 @@ + @@ -121,6 +122,7 @@ + + + + +