Skip to content

Commit 41116d0

Browse files
committed
Add Quiz & Documentation pages with Supabase leaderboard - Created Documentation page with PDF placeholders and hardware gallery - Created Quiz page with 15 BB84 questions and real-time leaderboard - Integrated Supabase for global leaderboard storage - Added username input and score submission with rate limiting - Added time tracking and answer review - Updated Home page with new navigation buttons - Created placeholder directories for docs and hardware photos
1 parent c03c15d commit 41116d0

File tree

9 files changed

+1387
-6
lines changed

9 files changed

+1387
-6
lines changed

package-lock.json

Lines changed: 119 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"@radix-ui/react-tooltip": "^1.2.7",
4444
"@react-three/drei": "^9.122.0",
4545
"@react-three/fiber": "^8.18.0",
46+
"@supabase/supabase-js": "^2.81.1",
4647
"@tanstack/react-query": "^5.83.0",
4748
"class-variance-authority": "^0.7.1",
4849
"clsx": "^2.1.1",

public/docs/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Project Documents
2+
3+
## 📄 Add Your Files Here
4+
5+
### Files Needed:
6+
7+
1. **report.pdf** - Project report (upload here)
8+
2. **presentation.pdf** - Project presentation slides (upload here)
9+
10+
### After Uploading:
11+
12+
1. Place PDF files in this folder
13+
2. Update `src/pages/Documentation.tsx`:
14+
- Find the report/presentation download buttons
15+
- Remove `disabled` attribute
16+
- Update the `href` or `onClick` to point to:
17+
- `/docs/report.pdf`
18+
- `/docs/presentation.pdf`
19+
20+
### Example:
21+
```tsx
22+
// Change from:
23+
<Button disabled>Download Report (Coming Soon)</Button>
24+
25+
// To:
26+
<a href="/docs/report.pdf" download>
27+
<Button>Download Report</Button>
28+
</a>
29+
```

public/images/hardware/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Hardware Gallery Images
2+
3+
## 📸 Add Your Hardware Photos Here
4+
5+
### Required Images:
6+
7+
1. **setup.jpg** - Complete hardware setup
8+
2. **laser.jpg** - Laser system
9+
3. **filters.jpg** - Polarization filters
10+
4. **detector.jpg** - Detection unit
11+
5. **electronics.jpg** - Control electronics
12+
6. **team.jpg** - Team working on hardware
13+
14+
### Image Requirements:
15+
16+
- **Format:** JPG or PNG
17+
- **Resolution:** At least 1920x1080 (Full HD)
18+
- **Orientation:** Landscape (horizontal) preferred
19+
- **File Size:** Under 5MB each
20+
21+
### After Uploading:
22+
23+
1. Place images in this folder with exact names above
24+
2. Update `src/pages/Documentation.tsx`:
25+
- Find the `hardwareImages` array
26+
- Change `placeholder: true` to `placeholder: false` for each image
27+
28+
### Example:
29+
```tsx
30+
{
31+
id: 1,
32+
title: 'Complete Setup',
33+
description: 'Full quantum key distribution hardware setup',
34+
url: '/images/hardware/setup.jpg',
35+
placeholder: false // Change this from true to false
36+
}
37+
```
38+
39+
### Tips:
40+
41+
- Use good lighting for clear photos
42+
- Clean up the workspace before photos
43+
- Include captions/labels in photos if possible
44+
- Take multiple angles and choose the best ones

src/App.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { SimulationProvider } from "./contexts/SimulationContext";
77
import Home from "./pages/Home";
88
import Theory from "./pages/Theory";
99
import Simulation from "./pages/Simulation";
10+
import Documentation from "./pages/Documentation";
11+
import Quiz from "./pages/Quiz";
1012
import NotFound from "./pages/NotFound";
1113
import Starfield from "@/components/ui/Starfield";
1214

@@ -27,6 +29,8 @@ const App = () => (
2729
<Route path="/" element={<Home />} />
2830
<Route path="/theory" element={<Theory />} />
2931
<Route path="/simulation" element={<Simulation />} />
32+
<Route path="/documentation" element={<Documentation />} />
33+
<Route path="/quiz" element={<Quiz />} />
3034
{/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
3135
<Route path="*" element={<NotFound />} />
3236
</Routes>

src/lib/supabase.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { createClient } from '@supabase/supabase-js';
2+
3+
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
4+
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
5+
6+
if (!supabaseUrl || !supabaseAnonKey) {
7+
throw new Error('Missing Supabase environment variables');
8+
}
9+
10+
export const supabase = createClient(supabaseUrl, supabaseAnonKey);
11+
12+
// Types for our leaderboard
13+
export interface LeaderboardEntry {
14+
id?: number;
15+
username: string;
16+
score: number;
17+
total_questions: number;
18+
time_taken: number;
19+
created_at?: string;
20+
}
21+
22+
// Rate limiting check - prevent spam submissions
23+
const SUBMISSION_COOLDOWN = 30000; // 30 seconds
24+
let lastSubmission = 0;
25+
26+
export const canSubmitScore = (): boolean => {
27+
const now = Date.now();
28+
if (now - lastSubmission < SUBMISSION_COOLDOWN) {
29+
return false;
30+
}
31+
return true;
32+
};
33+
34+
export const updateLastSubmission = () => {
35+
lastSubmission = Date.now();
36+
};

0 commit comments

Comments
 (0)