openapi: 3.0.0 info: title: Admin Exam API version: 1.0.0 description: API for managing exams and tests (admin endpoints) servers: - url: https://{host}:{port} variables: host: default: localhost description: The API host port: default: '3000' description: The port number paths: /admin/exams: post: summary: Create a new exam tags: - Admin security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - name - examType - price properties: name: type: string example: Math Exam slug: type: string example: math-exam examType: type: string example: final description: type: string example: Final math exam for grade 10 price: type: number example: 100 discountPrice: type: number example: 80 language: type: string example: en validityMonths: type: integer example: 12 coverImageUrl: type: string example: https://example.com/image.png tests: type: array items: type: object properties: name: type: string example: Algebra Test slug: type: string example: algebra-test durationMinutes: type: integer example: 60 responses: '201': description: Exam created content: application/json: schema: $ref: '#/components/schemas/SuccessExamResponse' '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' get: summary: Get all exams (courses) with their tests tags: - Admin security: - bearerAuth: [] responses: '200': description: List of all exams (courses) content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: All exams fetched successfully data: type: object properties: exams: type: array items: $ref: '#/components/schemas/Exam' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' /admin/courses: get: summary: Get all courses (exams) names tags: - Admin security: - bearerAuth: [] responses: '200': description: List of all course names content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: All courses data fetched successfully data: type: object properties: allExams: type: array items: $ref: '#/components/schemas/Exam' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' /admin/course: post: summary: Create a new course (exam) tags: - Admin security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - name - examType - price properties: name: type: string example: Math Exam slug: type: string example: math-exam examType: type: string example: JUDICIARY description: type: string example: Final math exam for grade 10 price: type: number example: 100 discountPrice: type: number example: 80 language: type: string example: en validityMonths: type: integer example: 12 coverImageUrl: type: string example: https://example.com/image.png tests: type: array items: type: object properties: name: type: string example: Algebra Test slug: type: string example: algebra-test durationMinutes: type: integer example: 60 responses: '201': description: Course created content: application/json: schema: $ref: '#/components/schemas/SuccessExamResponse' '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' /admin/tests: post: summary: Create a new test tags: - Admin security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - examId - name - durationMinutes properties: examId: type: integer example: 1 name: type: string example: Algebra Test slug: type: string example: algebra-test description: type: string example: Test on algebra topics durationMinutes: type: integer example: 60 language: type: string example: en instructions: type: string example: Read all questions carefully. responses: '201': description: Test created content: application/json: schema: $ref: '#/components/schemas/SuccessTestResponse' '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' /admin/course/{courseName}/tests: get: summary: Get all tests under a course by course name tags: - Admin security: - bearerAuth: [] parameters: - in: path name: courseName required: true schema: type: string description: The name of the course (govtExam) responses: '200': description: List of tests for the course content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: Tests fetched successfully data: type: object properties: tests: type: array items: $ref: '#/components/schemas/Test' '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Course not found content: application/json: schema: $ref: '#/components/schemas/Error' /admin/delete-test: post: summary: Delete a test from a course tags: - Admin security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - courseName - testName properties: courseName: type: string example: Math Exam testName: type: string example: Algebra Test responses: '200': description: Test deleted successfully content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: Test deleted successfully '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' /admin/test/change-status: put: summary: Change the active status of a test tags: - Admin security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - testId - isActive properties: testId: type: string example: 456e7890-e12b-34d5-c678-526614174111 isActive: type: boolean example: true responses: '200': description: Test status updated content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: Test status updated '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' /admin/update-test: put: summary: Update a test by name tags: - Admin security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - courseName - testName - updates properties: courseName: type: string example: Math Exam testName: type: string example: Algebra Test updates: type: object properties: name: type: string example: New Test Name durationMinutes: type: integer example: 90 description: type: string example: Updated description isActive: type: boolean example: true responses: '200': description: Test updated successfully content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: Test updated successfully data: type: object properties: test: $ref: '#/components/schemas/Test' '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' /admin/add-course-coupon: post: summary: Create a coupon for a specific course tags: - Admin security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - courseName - couponCode - discountType - discountValue properties: courseName: type: string example: Math Exam couponCode: type: string example: MATH50 discountType: type: string enum: [percentage, fixed] example: percentage discountValue: type: number example: 50 maxDiscount: type: number example: 100 minPurchase: type: number example: 200 startDate: type: string format: date-time example: '2024-01-01T00:00:00Z' endDate: type: string format: date-time example: '2024-02-01T00:00:00Z' maxUses: type: integer example: 100 maxUsesPerUser: type: integer example: 1 isActive: type: boolean example: true responses: '201': description: Coupon created successfully content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: Coupon created successfully data: type: object properties: coupon: type: object '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' /admin/add-coupon: post: summary: Create a global coupon tags: - Admin security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - couponCode - discountType - discountValue properties: couponCode: type: string example: GLOBAL10 discountType: type: string enum: [percentage, fixed] example: percentage discountValue: type: number example: 10 maxDiscount: type: number example: 100 minPurchase: type: number example: 200 startDate: type: string format: date-time example: '2024-01-01T00:00:00Z' endDate: type: string format: date-time example: '2024-02-01T00:00:00Z' maxUses: type: integer example: 100 maxUsesPerUser: type: integer example: 1 isActive: type: boolean example: true responses: '201': description: Global coupon created successfully content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: Global coupon created successfully data: type: object properties: coupon: type: object '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' /admin/coupons: get: summary: Get all coupons tags: - Admin security: - bearerAuth: [] responses: '200': description: List of all coupons content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: All coupons fetched successfully data: type: object properties: coupons: type: array items: type: object '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' /admin/coupon/{code}: get: summary: Get a coupon by code tags: - Admin security: - bearerAuth: [] parameters: - in: path name: code required: true schema: type: string description: The coupon code responses: '200': description: Coupon fetched successfully content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: Coupon fetched successfully data: type: object properties: coupon: type: object '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Coupon not found content: application/json: schema: $ref: '#/components/schemas/Error' delete: summary: Delete a coupon by code tags: - Admin security: - bearerAuth: [] parameters: - in: path name: code required: true schema: type: string description: The coupon code responses: '200': description: Coupon deleted successfully content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: Coupon deleted successfully data: type: object properties: code: type: string example: GLOBAL10 '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Coupon not found content: application/json: schema: $ref: '#/components/schemas/Error' /admin/course/{courseName}: get: summary: Get a course by name tags: - Admin security: - bearerAuth: [] parameters: - in: path name: courseName required: true schema: type: string description: The course name responses: '200': description: Course data fetched content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: Course Data fetched data: type: object properties: courseData: $ref: '#/components/schemas/Exam' '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' /admin/delete-course: delete: summary: Delete a course tags: - Admin security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - courseName properties: courseName: type: string example: Math Exam responses: '200': description: Course deleted successfully content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: Course deleted successfully '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Course not found content: application/json: schema: $ref: '#/components/schemas/Error' components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT schemas: Exam: type: object properties: id: type: string example: 123e4567-e89b-12d3-a456-426614174000 name: type: string example: Math Exam slug: type: string example: math-exam examType: type: string example: final description: type: string example: Final math exam for grade 10 price: type: number example: 100 discountPrice: type: number example: 80 language: type: string example: en validityMonths: type: integer example: 12 coverImageUrl: type: string example: https://example.com/image.png tests: type: array items: $ref: '#/components/schemas/Test' Test: type: object properties: id: type: string example: 456e7890-e12b-34d5-c678-526614174111 examId: type: string example: 123e4567-e89b-12d3-a456-426614174000 name: type: string example: Algebra Test slug: type: string example: algebra-test description: type: string example: Test on algebra topics durationMinutes: type: integer example: 60 language: type: string example: en instructions: type: string example: Read all questions carefully. SuccessExamResponse: type: object properties: status: type: string example: success message: type: string example: Exam created successfully data: type: object properties: exam: $ref: '#/components/schemas/Exam' SuccessTestResponse: type: object properties: status: type: string example: success message: type: string example: Test created successfully data: type: object properties: test: $ref: '#/components/schemas/Test' Error: type: object properties: status: type: string example: error message: type: string example: Missing required fields: name.