Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,45 @@
"schedule": "Mondays, Wednesdays, Fridays, 2:00 PM - 3:00 PM",
"max_participants": 30,
"participants": ["[email protected]", "[email protected]"]
},
# Sports 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": 22,
"participants": ["[email protected]", "[email protected]"]
},
"Basketball Club": {
"description": "Practice basketball and participate in tournaments",
"schedule": "Wednesdays, 3:30 PM - 5:00 PM",
"max_participants": 15,
"participants": ["[email protected]", "[email protected]"]
},
# Artistic activities
"Art Workshop": {
"description": "Explore painting, drawing, and sculpture techniques",
"schedule": "Mondays, 4:00 PM - 5:30 PM",
"max_participants": 18,
"participants": ["[email protected]", "[email protected]"]
},
"Drama Club": {
"description": "Act, direct, and produce school plays and performances",
"schedule": "Fridays, 3:30 PM - 5:30 PM",
"max_participants": 20,
"participants": ["[email protected]", "[email protected]"]
},
# Intellectual activities
"Math Olympiad": {
"description": "Prepare for math competitions and solve challenging problems",
"schedule": "Thursdays, 3:30 PM - 5:00 PM",
"max_participants": 16,
"participants": ["[email protected]", "[email protected]"]
},
"Debate Team": {
"description": "Develop public speaking and argumentation skills",
"schedule": "Wednesdays, 4:00 PM - 5:30 PM",
"max_participants": 14,
"participants": ["[email protected]", "[email protected]"]
}
}

Expand All @@ -62,6 +101,10 @@ def signup_for_activity(activity_name: str, email: str):
# Get the specific activity
activity = activities[activity_name]

# Check if student already signed up
if email in activity["participants"]:
raise HTTPException(status_code=400, detail="Student already signed up for this activity")

# Add student
activity["participants"].append(email)
return {"message": f"Signed up {email} for {activity_name}"}
53 changes: 41 additions & 12 deletions src/static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,7 @@ document.addEventListener("DOMContentLoaded", () => {

// Populate activities list
Object.entries(activities).forEach(([name, details]) => {
const activityCard = document.createElement("div");
activityCard.className = "activity-card";

const spotsLeft = details.max_participants - details.participants.length;

activityCard.innerHTML = `
<h4>${name}</h4>
<p>${details.description}</p>
<p><strong>Schedule:</strong> ${details.schedule}</p>
<p><strong>Availability:</strong> ${spotsLeft} spots left</p>
`;

const activityCard = renderActivityCard(name, details);
activitiesList.appendChild(activityCard);

// Add option to select dropdown
Expand All @@ -41,6 +30,46 @@ document.addEventListener("DOMContentLoaded", () => {
}
}

// Render activity card
function renderActivityCard(name, details) {
const card = document.createElement("div");
card.className = "activity-card";

const spotsLeft = details.max_participants - details.participants.length;

card.innerHTML = `
<h4>${name}</h4>
<p>${details.description}</p>
<p><strong>Schedule:</strong> ${details.schedule}</p>
<p><strong>Availability:</strong> ${spotsLeft} spots left</p>
`;

// Participants section
const participantsSection = document.createElement("div");
participantsSection.className = "participants-section";
const participantsTitle = document.createElement("h4");
participantsTitle.textContent = "Participants";
participantsSection.appendChild(participantsTitle);
const participantsList = document.createElement("ul");
participantsList.className = "participants-list";
if (details.participants && details.participants.length > 0) {
details.participants.forEach((participant) => {
const li = document.createElement("li");
li.textContent = participant;
participantsList.appendChild(li);
});
} else {
const li = document.createElement("li");
li.textContent = "No participants yet.";
li.className = "no-participants";
participantsList.appendChild(li);
}
participantsSection.appendChild(participantsList);
card.appendChild(participantsSection);

return card;
}

// Handle form submission
signupForm.addEventListener("submit", async (event) => {
event.preventDefault();
Expand Down
27 changes: 27 additions & 0 deletions src/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,30 @@ footer {
padding: 20px;
color: #666;
}

.participants-section {
background: #f8f9fa;
border-radius: 8px;
margin-top: 1em;
padding: 1em;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.participants-section h4 {
margin: 0 0 0.5em 0;
font-size: 1.1em;
color: #333;
letter-spacing: 0.5px;
}

.participants-list {
list-style: disc inside;
margin: 0;
padding-left: 1em;
color: #444;
}

.participants-list li.no-participants {
color: #aaa;
font-style: italic;
}