POST /activities/:activityId/submit
POST /activities/:activityId/submit
Validation schema for quiz submission questionId -> selectedAnswer POST /api/activities/[activityId]/submit Verify user is authenticated with Clerk Get user's profile to get Supabase id Apply rate limiting for API mutations Parse and validate request body Fetch activity to get quiz content Verify activity is a quiz Get or create activity_progress Check max attempts Grade the quiz Points for questions that can be auto-graded Grade based on question type Essay questions require manual grading Not graded yet Case-insensitive matching for short answer Exact match for true/false and multiple choice Fallback for unknown types Calculate percentage based on auto-gradable questions only Essay questions don't count toward automatic passing/failing Overall percentage (including essay questions that will be manually graded) For quizzes with essay questions, only auto-graded portion determines pass/fail Essay questions will be manually graded later Get course_id from module Determine status: if essay questions exist and not all auto-graded questions passed, mark as in_progress Otherwise use passed/failed If there are essay questions and auto-graded portion didn't pass, keep as in_progress If auto-graded portion passed, mark as completed (essays will be graded separately) Update or create activity_progress Update enrollment progress if quiz passed (only if no essay questions or all auto-graded questions passed) Return quiz result Add rate limit headers First get all modules for the course Get all required activities for these modules Get completed activities for this course Update enrollment Don't throw - this is not critical
Endpoint
POST /activities/:activityId/submit
Authentication
This endpoint requires authentication. Include your authentication token in the request headers.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
activityId | string | Path parameter |
Error Responses
| Status Code | Error Code | Description |
|---|---|---|
| 401 | HTTP_401 | Unauthorized |
| 404 | HTTP_404 | Not Found |
| 429 | HTTP_429 | Error |
| 400 | HTTP_400 | Bad Request |
| 404 | HTTP_404 | Not Found |
| 400 | HTTP_400 | Bad Request |
| 403 | HTTP_403 | Forbidden |
| 500 | HTTP_500 | Internal Server Error |
| 500 | HTTP_500 | Internal Server Error |
| 500 | HTTP_500 | Internal Server Error |
Example Request
curl -X POST "https://api.allurelms.com/activities/activityId-value/submit" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{}'