Giter Site home page Giter Site logo

lms-backend's Introduction

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Donate us Support us Follow us on Twitter

Description

Nest framework TypeScript starter repository.

Project setup

$ npm install

Compile and run the project

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Run tests

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

baseurl: http://localhost:5000

  1. Introduction This document provides details on how to test the various API endpoints for the project. Each section includes the endpoint, method, request parameters, and expected responses.

  2. Authentication APIs

2.1 Register User Endpoint: /auth/register Method: POST Description: Register a new user. Request Body: json Copy code { "username": "testuser", "password": "password123" } Expected Response: Status: 201 Created Body: json Copy code { "message": "User registered successfully" }

2.2 Login User Endpoint: /auth/login Method: POST Description: Login an existing user. Request Body: json Copy code { "username": "testuser", "password": "password123" } Expected Response: Status: 200 OK Body: json Copy code { "access_token": "JWT_TOKEN" }

2.3 Logout User Endpoint: /auth/logout Method: POST Description: Logout the current user. Request Headers: Authorization: Bearer JWT_TOKEN Expected Response: Status: 200 OK Body: json Copy code { "message": "Logged out successfully" }

  1. Question Management APIs (Admin Only)

3.1 Create Question Endpoint: /questions Method: POST Description: Create a new question with a specified difficulty. Request Headers: Authorization: Bearer JWT_TOKEN Request Body: json Copy code { "text": "What is the capital of France?", "difficulty": 5, "options": ["Paris", "Berlin", "Rome", "Madrid"], "correctAnswer": "Paris" } Expected Response: Status: 201 Created Body: json Copy code { "message": "Question created successfully", "questionId": "QUESTION_ID" }

3.2 Get All Questions Endpoint: /questions Method: GET Description: Retrieve all questions. Request Headers: Authorization: Bearer JWT_TOKEN Expected Response: Status: 200 OK Body: json Copy code [ { "id": "QUESTION_ID", "text": "What is the capital of France?", "difficulty": 5, "options": ["Paris", "Berlin", "Rome", "Madrid"], "correctAnswer": "Paris" }, ... ]

3.3 Get Question by ID Endpoint: /questions/:id Method: GET Description: Retrieve a single question by its ID. Request Headers: Authorization: Bearer JWT_TOKEN Expected Response: Status: 200 OK Body: json Copy code { "id": "QUESTION_ID", "text": "What is the capital of France?", "difficulty": 5, "options": ["Paris", "Berlin", "Rome", "Madrid"], "correctAnswer": "Paris" }

3.4 Update Question Endpoint: /questions/:id Method: PUT Description: Update an existing question by its ID. Request Headers: Authorization: Bearer JWT_TOKEN Request Body: json Copy code { "text": "What is the capital of Germany?", "difficulty": 5, "options": ["Berlin", "Paris", "Rome", "Madrid"], "correctAnswer": "Berlin" } Expected Response: Status: 200 OK Body: json Copy code { "message": "Question updated successfully" }

3.5 Delete Question Endpoint: /questions/:id Method: DELETE Description: Delete a question by its ID. Request Headers: Authorization: Bearer JWT_TOKEN Expected Response: Status: 200 OK Body: json Copy code { "message": "Question deleted successfully" }

  1. Test Management APIs (End User)

4.1 Get Test by Unique URL Endpoint: /tests/unique/:uniqueURL Method: GET Description: Retrieve test details using a unique URL. Expected Response: Status: 200 OK Body: json Copy code { "id": "TEST_ID", "title": "Sample Test", "questions": [...] }

4.2 Start Adaptive Test Endpoint: /tests/:testId/start Method: POST Description: Start a new adaptive test for a user. Request Headers: Authorization: Bearer JWT_TOKEN Expected Response: Status: 200 OK Body: json Copy code { "message": "Test started successfully", "firstQuestion": { "id": "QUESTION_ID", "text": "What is the capital of France?", "difficulty": 5, "options": ["Paris", "Berlin", "Rome", "Madrid"] } }

4.3 Submit Answer Endpoint: /tests/:testId/questions/:questionId/answer Method: POST Description: Submit an answer for a question and get the next question based on the response. Request Headers: Authorization: Bearer JWT_TOKEN Request Body: json Copy code { "answer": "Paris" } Expected Response: Status: 200 OK Body: json Copy code { "correct": true, "nextQuestion": { "id": "NEXT_QUESTION_ID", "text": "What is the capital of Germany?", "difficulty": 6, "options": ["Berlin", "Paris", "Rome", "Madrid"] } }

  1. Test Results APIs (Admin Only)

5.1 Get Test Results Endpoint: /tests/:testId Method: GET Description: Retrieve the test results (admin only). Request Headers: Authorization: Bearer JWT_TOKEN Expected Response: Status: 200 OK Body: json Copy code { "testId": "TEST_ID", "results": [ { "userId": "USER_ID", "score": 80, "attempts": 20, ... }, ... ] }

lms-backend's People

Contributors

soumenlinux avatar

Watchers

SOUMEN MAITY avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.