Overview
Challenge routes handle listing, viewing, and submitting answers to math challenges. Routes are filtered based on user account type (regular vs competition participants).List Challenges
List all challenges with pagination
Current page number for pagination
- Admin users: See ALL challenges (regular + summer, including unreleased)
- Summer competition participants: Only see summer challenges for their key stage
- Regular users: Only see released regular challenges (where
release_at <= now) - Unauthenticated users: Redirected to login
- Rendered
main/challenges.htmltemplate - Pagination: 6 challenges per page
View Challenge
Display a specific challenge and handle answer submissions
ID of the challenge to view
- Summer competition participants (except admins) cannot access regular challenges
- Non-admin users cannot view unreleased challenges (where
release_at > now) - Locked challenges display but don’t accept submissions (except from admins)
- Challenge content and metadata
- Answer boxes and forms
- User’s previous submissions per answer box
- Completion status (
all_correct) - Remaining attempts per box (max 3)
ID of the answer box being answered
User’s submitted answer
- Validates form and checks if challenge is locked
- Checks if user already has correct submission for this box
- Creates new
AnswerSubmissionrecord - Checks answer correctness via
answer_box.check_answer() - If all boxes correct and first to complete:
- Awards 3 points to leaderboard
- Updates
challenge.first_correct_submissiontimestamp
- If all boxes correct but not first: Awards 1 point
- Partial completion: No points, encouragement message
- GET: Rendered
main/challenge.htmltemplate - POST: Redirects back to challenge page with flash message
View Autumn Challenge
Display summer competition challenge and handle submissions
ID of the summer challenge to view
- Only summer competition participants and admins can access
- User’s key stage must match challenge key stage (except admins)
- Challenge must not be locked for submissions
- Challenge content specific to user’s key stage
- Answer boxes and submission forms
- User’s previous submissions (from
SummerSubmissionmodel) - Completion status
can_submitflag based on permissions
ID of the summer challenge answer box
User’s submitted answer
- Checks submission count (max 3 attempts per box)
- Validates answer against
SummerChallengeAnswerBox.check_answer() - Calculates points:
- First to complete entire challenge: 3 points
- Others who complete: 1 point
- Partial completion: 0 points
- Creates
SummerSubmissionwithpoints_awarded - Updates
SummerLeaderboardif points awarded
- GET: Rendered
main/summer_challenge.htmltemplate - POST: Redirects back to challenge with flash message
About Page
Display general about page
main/about.html template
Autumn Competition About
Display autumn competition about page
main/summer_about.html template with competition information
Challenge Submission Flow
Regular Challenges
- User submits answer to answer box
- System checks if max attempts (3) exceeded
- Answer validated and
AnswerSubmissioncreated - If all boxes correct:
- Check if first to complete challenge
- Award 3 points (first) or 1 point (others)
- Update
LeaderboardEntryfor user’s key stage
- Flash appropriate message
Summer Challenges
- User submits answer to summer challenge box
- System validates user’s key stage matches challenge
- Checks remaining attempts (max 3 per box)
SummerSubmissioncreated with correctness flag- Points calculated only on full challenge completion:
- First to complete: 3 points
- Subsequent completions: 1 point
SummerLeaderboardupdated with points- School rankings automatically updated
Key Stage Filtering
Challenges are filtered by key stage:- KS3: Years 7-8
- KS4: Years 9-11
- KS5: Years 12-13