curl --request POST \
--url https://api.example.com/api/history \
--header 'Content-Type: application/json' \
--data '
{
"sessionId": "<string>",
"timestamp": "<string>",
"section": "<string>",
"questionIds": [
{}
],
"responses": {},
"score": 123,
"totalQuestions": 123,
"timeTaken": 123,
"bookmarkedQuestionIds": [
{}
]
}
'{
"practiceHistory": [
{}
],
"bookmarkedQuestions": [
{}
],
"progress": {},
"PracticeQuestions": 123,
"StudyStreak": 123,
"lastStudyDate": "<string>",
"updatedAt": "<string>",
"error": "<string>"
}Save practice session results and update user statistics including streaks, progress, and bookmarks
curl --request POST \
--url https://api.example.com/api/history \
--header 'Content-Type: application/json' \
--data '
{
"sessionId": "<string>",
"timestamp": "<string>",
"section": "<string>",
"questionIds": [
{}
],
"responses": {},
"score": 123,
"totalQuestions": 123,
"timeTaken": 123,
"bookmarkedQuestionIds": [
{}
]
}
'{
"practiceHistory": [
{}
],
"bookmarkedQuestions": [
{}
],
"progress": {},
"PracticeQuestions": 123,
"StudyStreak": 123,
"lastStudyDate": "<string>",
"updatedAt": "<string>",
"error": "<string>"
}analyticalReasoning: Number of analytical reasoning sessions completedlogicalReasoning: Number of logical reasoning sessions completedreadingComprehension: Number of reading comprehension sessions completedtestAttempts: Total number of test attemptstotalTimeSpent: Total time spent practicing (in seconds)/workspace/source/src/app/api/history/route.ts:94-104
/workspace/source/src/app/api/history/route.ts:134-156
analyticalReasoning: +1 when section === "analytical-reasoning"logicalReasoning: +1 when section === "logical-reasoning"readingComprehension: +1 when section === "reading-comprehension"testAttempts: +1 for every sessiontotalTimeSpent: Accumulates time from all sessions/workspace/source/src/app/api/history/route.ts:116-123
curl -X POST 'https://api.lsattraining.com/api/history?uuid=user123' \
-H 'Content-Type: application/json' \
-d '{
"sessionId": "session_abc123",
"timestamp": "2024-03-03T14:30:00.000Z",
"section": "logical-reasoning",
"questionIds": ["q1", "q2", "q3", "q4", "q5"],
"responses": {
"q1": "A",
"q2": "C",
"q3": "B",
"q4": "D",
"q5": "A"
},
"score": 4,
"totalQuestions": 5,
"timeTaken": 600,
"bookmarkedQuestionIds": ["q2", "q5"]
}'
{
"practiceHistory": [
{
"sessionId": "session_abc123",
"timestamp": "2024-03-03T14:30:00.000Z",
"section": "logical-reasoning",
"questionIds": ["q1", "q2", "q3", "q4", "q5"],
"responses": {
"q1": "A",
"q2": "C",
"q3": "B",
"q4": "D",
"q5": "A"
},
"score": 4,
"totalQuestions": 5,
"timeTaken": 600
},
{
"sessionId": "session_xyz789",
"timestamp": "2024-03-02T10:00:00.000Z",
"section": "analytical-reasoning",
"score": 3,
"totalQuestions": 5,
"timeTaken": 720
}
],
"bookmarkedQuestions": ["q2", "q5", "q15", "q22"],
"progress": {
"analyticalReasoning": 2,
"logicalReasoning": 5,
"readingComprehension": 3,
"testAttempts": 10,
"totalTimeSpent": 7200
},
"PracticeQuestions": 50,
"StudyStreak": 7,
"lastStudyDate": "2024-03-03",
"updatedAt": "2024-03-03T14:30:15.000Z"
}
const updatedBookmarkedQuestions = [
...new Set([...(userData.bookmarkedQuestions || []), ...bookmarkedQuestionIds])
];
/workspace/source/src/app/api/history/route.ts:109-111
This ensures:
{
"error": "UUID is required"
}
{
"error": "Invalid JSON format"
}
{
"error": "Missing required fields"
}
{
"error": "User not found"
}
{
"error": "Failed to update Firestore document"
}
{
"error": "Failed to update user data"
}
if (
!sessionId ||
!timestamp ||
!section ||
!questionIds ||
!responses ||
score === undefined || // Allows score = 0
!totalQuestions ||
timeTaken === undefined // Allows timeTaken = 0
) {
return error;
}
/workspace/source/src/app/api/history/route.ts:52-74
/workspace/source/src/app/api/history/route.ts