{ "openapi": "3.0.2", "info": { "title": "Activity Engine API", "version": "1.0.0", "description": "The Activity Engine manages all user-generated data such as student assessment attempts, answers, and metrics (video metrics and violations)." }, "servers": [ { "url": "http://localhost:9000/v1", "description": "Local development server" } ], "tags": [ { "name": "Attempts", "description": "Endpoints related to handling assessment attempts and answers." }, { "name": "Metrics", "description": "Endpoints related to student activity metrics (video metrics, violations)." } ], "paths": { "/attempts": { "post": { "summary": "Start a new assessment attempt", "tags": ["Attempts"], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["studentId", "courseInstanceId", "assessmentId"], "properties": { "studentId": { "type": "string", "description": "The ID of the student" }, "courseInstanceId": { "type": "string", "description": "The course instance identifier" }, "assessmentId": { "type": "string", "description": "The assessment identifier" } }, "example": { "studentId": "stu123", "courseInstanceId": "courseABC", "assessmentId": "assess456" } } } } }, "responses": { "201": { "description": "Created a new attempt", "content": { "application/json": { "schema": { "type": "object", "properties": { "attemptId": { "type": "integer" }, "studentId": { "type": "string" }, "assessmentId": { "type": "string" }, "courseInstanceId": { "type": "string" }, "status": { "type": "string", "enum": ["IN_PROGRESS", "SUBMITTED"] }, "attemptTime": { "type": "string", "format": "date-time" } } }, "example": { "attemptId": 1001, "studentId": "stu123", "assessmentId": "assess456", "courseInstanceId": "courseABC", "status": "IN_PROGRESS", "attemptTime": "2024-12-12T10:00:00Z" } } } }, "400": { "description": "Bad Request" }, "500": { "description": "Internal Server Error" } } } }, "/attempts/{attemptId}": { "get": { "summary": "Get attempt details by attemptId", "tags": ["Attempts"], "parameters": [ { "name": "attemptId", "in": "path", "required": true, "description": "The unique ID of the attempt", "schema": { "type": "integer" } } ], "responses": { "200": { "description": "Attempt details retrieved successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "attemptId": { "type": "integer" }, "studentId": { "type": "string" }, "assessmentId": { "type": "string" }, "courseInstanceId": { "type": "string" }, "status": { "type": "string", "enum": ["IN_PROGRESS", "SUBMITTED"] }, "attemptTime": { "type": "string", "format": "date-time" }, "submissionTime": { "type": "string", "format": "date-time" }, "natAnswers": { "type": "array", "items": { "$ref": "#/components/schemas/StudentNATAnswer" } }, "descriptiveAnswers": { "type": "array", "items": { "$ref": "#/components/schemas/StudentDescriptiveAnswer" } }, "mcqAnswers": { "type": "array", "items": { "$ref": "#/components/schemas/StudentMCQAnswer" } }, "msqAnswers": { "type": "array", "items": { "$ref": "#/components/schemas/StudentMSQAnswer" } } } }, "example": { "attemptId": 1001, "studentId": "stu123", "assessmentId": "assess456", "courseInstanceId": "courseABC", "status": "IN_PROGRESS", "attemptTime": "2024-12-12T10:00:00Z", "natAnswers": [], "descriptiveAnswers": [], "mcqAnswers": [], "msqAnswers": [] } } } }, "404": { "description": "Attempt not found" }, "500": { "description": "Internal Server Error" } } } }, "/attempts/{attemptId}/submit": { "post": { "summary": "Submit the attempt for grading", "tags": ["Attempts"], "parameters": [ { "name": "attemptId", "in": "path", "required": true, "schema": { "type": "integer" }, "description": "The attempt ID to submit" } ], "responses": { "200": { "description": "Attempt submitted successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string" } } }, "example": { "status": "SUBMITTED" } } } }, "404": { "description": "Attempt not found" }, "409": { "description": "Attempt already submitted or cannot be submitted" }, "500": { "description": "Internal Server Error" } } } }, "/attempts/{attemptId}/answers": { "post": { "summary": "Submit answers for a given attempt", "tags": ["Attempts"], "parameters": [ { "name": "attemptId", "in": "path", "required": true, "schema": { "type": "integer" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["studentId", "courseInstanceId", "answers"], "properties": { "studentId": { "type": "string" }, "courseInstanceId": { "type": "string" }, "answers": { "type": "array", "items": { "type": "object", "required": ["questionId", "type"], "properties": { "questionId": { "type": "string" }, "type": { "type": "string", "enum": ["NAT", "DESCRIPTIVE", "MCQ", "MSQ"] }, "value": { "type": "string" }, "answerText": { "type": "string" }, "choiceId": { "type": "string" }, "choiceIds": { "type": "array", "items": { "type": "string" } } } } } }, "example": { "studentId": "stu123", "courseInstanceId": "courseABC", "answers": [ { "questionId": "Q1", "type": "NAT", "value": "42" }, { "questionId": "Q2", "type": "MCQ", "choiceId": "C1" } ] } } } } }, "responses": { "200": { "description": "Answers submitted successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string" } } }, "example": { "status": "answers_submitted" } } } }, "404": { "description": "Attempt not found" }, "500": { "description": "Internal Server Error" } } } }, "/metrics/video": { "get": { "summary": "Get video metrics for a student", "tags": ["Metrics"], "parameters": [ { "name": "studentId", "in": "query", "required": true, "schema": { "type": "string" } }, { "name": "courseInstanceId", "in": "query", "required": true, "schema": { "type": "string" } }, { "name": "videoId", "in": "query", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Video metrics retrieved successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "studentId": { "type": "string" }, "courseInstanceId": { "type": "string" }, "videoId": { "type": "string" }, "replays": { "type": "integer" } } }, "example": { "studentId": "stu123", "courseInstanceId": "courseABC", "videoId": "video789", "replays": 5 } } } } } }, "post": { "summary": "Update video metrics for a student", "tags": ["Metrics"], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["studentId", "courseInstanceId", "videoId", "replays"], "properties": { "studentId": { "type": "string" }, "courseInstanceId": { "type": "string" }, "videoId": { "type": "string" }, "replays": { "type": "integer" } }, "example": { "studentId": "stu123", "courseInstanceId": "courseABC", "videoId": "video789", "replays": 6 } } } } }, "responses": { "200": { "description": "Metrics updated", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string" }, "data": { "type": "object" } } }, "example": { "status": "updated", "data": { "studentId": "stu123", "courseInstanceId": "courseABC", "videoId": "video789", "replays": 6 } } } } }, "500": { "description": "Internal Server Error" } } } }, "/metrics/violations": { "get": { "summary": "Get recorded violations", "tags": ["Metrics"], "parameters": [ { "name": "studentId", "in": "query", "required": true, "schema": { "type": "string" } }, { "name": "contentTypeId", "in": "query", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Violations retrieved successfully", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/StudentViolationMetrics" } }, "example": [ { "id": 501, "studentId": "stu123", "contentType": "VIDEO", "contentTypeId": "video789", "violationType": "OUT_OF_FRAME", "createdAt": "2024-12-12T10:00:00Z" } ] } } } } }, "post": { "summary": "Record a new violation", "tags": ["Metrics"], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["studentId", "contentType", "contentTypeId", "violationType"], "properties": { "studentId": { "type": "string" }, "contentType": { "type": "string", "enum": ["VIDEO", "ARTICLE", "ASSESSMENT"] }, "contentTypeId": { "type": "string" }, "violationType": { "type": "string" } }, "example": { "studentId": "stu123", "contentType": "VIDEO", "contentTypeId": "video789", "violationType": "OUT_OF_FRAME" } } } } }, "responses": { "200": { "description": "Violation recorded", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string" }, "violationId": { "type": "integer" } } }, "example": { "status": "recorded", "violationId": 501 } } } }, "500": { "description": "Internal Server Error" } } } } }, "components": { "schemas": { "StudentNATAnswer": { "type": "object", "properties": { "id": { "type": "integer" }, "questionId": { "type": "string" }, "studentId": { "type": "string" }, "courseInstanceId": { "type": "string" }, "value": { "type": "string" }, "assessmentAttemptId": { "type": "integer" }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" } } }, "StudentDescriptiveAnswer": { "type": "object", "properties": { "id": { "type": "integer" }, "questionId": { "type": "string" }, "studentId": { "type": "string" }, "courseInstanceId": { "type": "string" }, "answerText": { "type": "string" }, "assessmentAttemptId": { "type": "integer" }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" } } }, "StudentMCQAnswer": { "type": "object", "properties": { "id": { "type": "integer" }, "questionId": { "type": "string" }, "studentId": { "type": "string" }, "courseInstanceId": { "type": "string" }, "choiceId": { "type": "string" }, "assessmentAttemptId": { "type": "integer" }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" } } }, "StudentMSQAnswer": { "type": "object", "properties": { "id": { "type": "integer" }, "questionId": { "type": "string" }, "studentId": { "type": "string" }, "courseInstanceId": { "type": "string" }, "choiceId": { "type": "string" }, "assessmentAttemptId": { "type": "integer" }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" } } }, "StudentViolationMetrics": { "type": "object", "properties": { "id": { "type": "integer" }, "studentId": { "type": "string" }, "contentType": { "type": "string", "enum": ["VIDEO", "ARTICLE", "ASSESSMENT"] }, "contentTypeId": { "type": "string" }, "violationType": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" } } } } } }