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": ["john@mergington.edu", "olivia@mergington.edu"]
},
# 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": ["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": 18,
"participants": ["isabella@mergington.edu", "noah@mergington.edu"]
},
"Drama Society": {
"description": "Participate in acting, stage production, and school plays",
"schedule": "Thursdays, 4:00 PM - 5:30 PM",
"max_participants": 25,
"participants": ["amelia@mergington.edu", "jack@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": 16,
"participants": ["ethan@mergington.edu", "charlotte@mergington.edu"]
},
"Debate Club": {
"description": "Develop public speaking and argumentation skills",
"schedule": "Wednesdays, 4:00 PM - 5:30 PM",
"max_participants": 20,
"participants": ["benjamin@mergington.edu", "harper@mergington.edu"]
}
}

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

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

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

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

Copilot AI Jun 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Previously the UI displayed available spots; consider also computing and showing remaining slots (max_participants minus current participants) to maintain consistency in availability info.

Suggested change
<p><strong>Max Participants:</strong> ${details.max_participants}</p>
<p><strong>Max Participants:</strong> ${details.max_participants}</p>
<p><strong>Remaining Slots:</strong> ${spotsLeft}</p>

Copilot uses AI. Check for mistakes.
<div class="participants-section">
<strong>Participants:</strong>
<ul class="participants-list">
${details.participants && details.participants.length > 0
? details.participants.map(p => `<li>${p}</li>`).join('')
: '<li><em>No participants yet</em></li>'}
Comment on lines +32 to +33

Copilot AI Jun 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rendering participant names directly via innerHTML opens a risk for XSS if the data isn't sanitized. Consider using DOM methods or sanitizing input before insertion.

Suggested change
? details.participants.map(p => `<li>${p}</li>`).join('')
: '<li><em>No participants yet</em></li>'}
? (() => {
const participantsList = document.createDocumentFragment();
details.participants.forEach(p => {
const listItem = document.createElement("li");
listItem.textContent = p;
participantsList.appendChild(listItem);
});
return participantsList;
})()
: (() => {
const noParticipantsItem = document.createElement("li");
noParticipantsItem.innerHTML = "<em>No participants yet</em>";
return noParticipantsItem.outerHTML;
})()}

Copilot uses AI. Check for mistakes.
</ul>
</div>
`;

activitiesList.appendChild(activityCard);
Expand Down
23 changes: 23 additions & 0 deletions src/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,26 @@ footer {
padding: 20px;
color: #666;
}

.participants-section {
margin-top: 10px;
padding: 10px;
background-color: #eef3fb;
border-radius: 4px;
}

.participants-section strong {
color: #1a237e;
}

.participants-list {
margin: 8px 0 0 18px;
padding-left: 0;
list-style-type: disc;
}

.participants-list li {
margin-bottom: 4px;
font-size: 15px;
color: #333;
}