From 67cd965a469958978e330635e025143013432538 Mon Sep 17 00:00:00 2001 From: sunil-archt <77359197+sunil-archt@users.noreply.github.com> Date: Wed, 16 Jul 2025 20:04:58 +0000 Subject: [PATCH 1/2] Add extracurricular activities and signup validation to the API --- src/app.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/app.py b/src/app.py index 4ebb1d9..0310435 100644 --- a/src/app.py +++ b/src/app.py @@ -38,6 +38,45 @@ "schedule": "Mondays, Wednesdays, Fridays, 2:00 PM - 3:00 PM", "max_participants": 30, "participants": ["john@mergington.edu", "olivia@mergington.edu"] + }, + # Sports related activities + "Soccer Team": { + "description": "Join the school soccer team and compete in local leagues", + "schedule": "Tuesdays and Thursdays, 4:00 PM - 5:30 PM", + "max_participants": 18, + "participants": ["lucas@mergington.edu", "mia@mergington.edu"] + }, + "Basketball Club": { + "description": "Practice basketball skills and play friendly matches", + "schedule": "Wednesdays, 3:30 PM - 5:00 PM", + "max_participants": 15, + "participants": ["liam@mergington.edu", "ava@mergington.edu"] + }, + # Artistic activities + "Art Club": { + "description": "Explore painting, drawing, and other visual arts", + "schedule": "Mondays, 3:30 PM - 5:00 PM", + "max_participants": 16, + "participants": ["noah@mergington.edu", "isabella@mergington.edu"] + }, + "Drama Society": { + "description": "Participate in school plays and drama workshops", + "schedule": "Thursdays, 4:00 PM - 5:30 PM", + "max_participants": 20, + "participants": ["amelia@mergington.edu", "benjamin@mergington.edu"] + }, + # Intellectual activities + "Math Olympiad": { + "description": "Prepare for math competitions and solve challenging problems", + "schedule": "Fridays, 2:00 PM - 3:30 PM", + "max_participants": 10, + "participants": ["charlotte@mergington.edu", "elijah@mergington.edu"] + }, + "Science Club": { + "description": "Conduct experiments and explore scientific concepts", + "schedule": "Wednesdays, 4:00 PM - 5:00 PM", + "max_participants": 14, + "participants": ["harper@mergington.edu", "james@mergington.edu"] } } @@ -62,6 +101,11 @@ def signup_for_activity(activity_name: str, email: str): # Get the specific activity activity = activities[activity_name] + # Check if student is already signed up + if email in activity["participants"]: + raise HTTPException(status_code=400, detail="Student is already signed up for this activity") + + # Add student activity["participants"].append(email) return {"message": f"Signed up {email} for {activity_name}"} From 4e71b67019c4a0a8489efbb9528aaf7856cc7ca9 Mon Sep 17 00:00:00 2001 From: sunil-archt <77359197+sunil-archt@users.noreply.github.com> Date: Wed, 16 Jul 2025 20:09:32 +0000 Subject: [PATCH 2/2] Add participants list and styling to activity cards --- src/static/app.js | 8 ++++++++ src/static/styles.css | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/static/app.js b/src/static/app.js index dcc1e38..d23ab96 100644 --- a/src/static/app.js +++ b/src/static/app.js @@ -20,11 +20,19 @@ document.addEventListener("DOMContentLoaded", () => { const spotsLeft = details.max_participants - details.participants.length; + const participantsList = details.participants.length > 0 + ? `` + : '

No participants yet

'; + activityCard.innerHTML = `

${name}

${details.description}

Schedule: ${details.schedule}

Availability: ${spotsLeft} spots left

+
+

Participants:

+ ${participantsList} +
`; activitiesList.appendChild(activityCard); diff --git a/src/static/styles.css b/src/static/styles.css index a533b32..c8ee032 100644 --- a/src/static/styles.css +++ b/src/static/styles.css @@ -74,6 +74,30 @@ section h3 { margin-bottom: 8px; } +.participants-section { + margin-top: 15px; + padding-top: 10px; + border-top: 1px solid #e0e0e0; +} + +.participants-list { + margin: 8px 0 0 20px; + padding: 0; +} + +.participants-list li { + margin-bottom: 4px; + color: #666; + font-size: 14px; +} + +.no-participants { + margin: 8px 0 0 0 !important; + color: #999; + font-style: italic; + font-size: 14px; +} + .form-group { margin-bottom: 15px; }