3838        "schedule" : "Mondays, Wednesdays, Fridays, 2:00 PM - 3:00 PM" ,
3939        "max_participants" : 30 ,
404041+     },
42+     # Sports activities 
43+     "Soccer Team" : {
44+         "description" : "Join the school soccer team and compete in local leagues" ,
45+         "schedule" : "Tuesdays and Thursdays, 4:00 PM - 5:30 PM" ,
46+         "max_participants" : 22 ,
47+ 48+     },
49+     "Basketball Club" : {
50+         "description" : "Practice basketball skills and play friendly matches" ,
51+         "schedule" : "Wednesdays, 3:30 PM - 5:00 PM" ,
52+         "max_participants" : 15 ,
53+ 54+     },
55+     # Artistic activities 
56+     "Art Club" : {
57+         "description" : "Explore painting, drawing, and other visual arts" ,
58+         "schedule" : "Mondays, 3:30 PM - 5:00 PM" ,
59+         "max_participants" : 18 ,
60+ 61+     },
62+     "Drama Society" : {
63+         "description" : "Participate in theater productions and acting workshops" ,
64+         "schedule" : "Thursdays, 4:00 PM - 5:30 PM" ,
65+         "max_participants" : 25 ,
66+ 67+     },
68+     # Intellectual activities 
69+     "Math Olympiad" : {
70+         "description" : "Prepare for math competitions and solve challenging problems" ,
71+         "schedule" : "Fridays, 2:00 PM - 3:30 PM" ,
72+         "max_participants" : 16 ,
73+ 74+     },
75+     "Science Club" : {
76+         "description" : "Conduct experiments and explore scientific concepts" ,
77+         "schedule" : "Wednesdays, 4:00 PM - 5:00 PM" ,
78+         "max_participants" : 20 ,
79+ 4180    }
4281}
4382
@@ -62,6 +101,14 @@ def signup_for_activity(activity_name: str, email: str):
62101    # Get the specific activity 
63102    activity  =  activities [activity_name ]
64103
65-     # Add student 
104+ # Validate student is not already signed up 
105+     if  email  in  activity ["participants" ]:
106+         raise  HTTPException (status_code = 400 , detail = "Already signed up for this activity" )
107+ 
108+     # Check if max participants reached 
109+     if  len (activity ["participants" ]) >  activity ["max_participants" ]:
110+         raise  HTTPException (status_code = 400 , detail = "Activity is full" )
111+ 
112+     # Add student to participants 
66113    activity ["participants" ].append (email )
67-     return  {"message" : f"Signed up { email }   for { activity_name }  " }
114+     return  {"message" : f"Signed up { email }   for { activity_name }  " }     
0 commit comments