Skip to content

MTahirKleem/Testsystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend (Django REST API) – Documentation

Overview

This is the backend API for your project, built with Django and Django REST Framework.
It provides a full system for user authentication, quiz/test creation and assignment, question/answer storage, student progress tracking, and notification handling for both students and teachers.


Directory Structure


backend/
│
├── backend/                 # Django project (settings, URLs)
│   ├── settings.py
│   ├── urls.py
│   └── ...
├── user\_auth/               # Main Django app for authentication & business logic
│   ├── admin.py
│   ├── models.py
│   ├── serializers.py
│   ├── views.py
│   ├── urls.py
│   └── ...
├── media/                   # Uploaded media (profile pictures etc.)
├── db.sqlite3               # SQLite database for local/dev
├── manage.py                # Django management script
└── ...


Main Components

models.py (user_auth/models.py)

Defines database models:

  • Signup: Custom user (student or teacher, with profile info)
  • Quiz: Quiz metadata
  • MCQ: Multiple Choice Questions for quizzes
  • OpenQuestion: Open-ended questions for quizzes
  • QuizTest: A named set of quizzes/tests for a book/class
  • StudentTest: Assigned tests for a class/book/date range
  • Notification: System notifications for students (e.g., new test assigned)
  • StudentTestResult: Stores a student's answers/results for a test

serializers.py (user_auth/serializers.py)

Defines serializers (convert model ↔ JSON, validate input):

  • SignupSerializer, LoginSerializer: Registration/login logic
  • MCQSerializer, OpenQuestionSerializer, QuizSerializer: For questions/quizzes
  • StudentTestSerializer, StudentTestResultSerializer: For tests/results
  • NotificationSerializer: For student notifications

views.py (user_auth/views.py)

Contains API endpoint logic:

  • Registration, login, and profile fetching
  • Quiz/question/test creation and retrieval
  • Assigning tests to classes
  • Student test submission and result handling
  • Progress, performance, and notification APIs for both roles

urls.py (user_auth/urls.py)

Maps URLs to views for the API:

  • /signup/, /login/, /user-data/
  • /quiz/, /book-quiz/, /save-quiz-test/
  • /assign-test/, /student/progress/, /student-classes/
  • /student/notifications/, /notification/mark-read/<id>/
  • /student-averages/, /assigned_subjects/, ...
  • See file for complete list!

Environment Setup

1. Clone the Repository

git clone <your-repo-url>
cd Testsystem/backend

2. Create & Activate Python Virtual Environment

Windows:

python -m venv venv
venv\Scripts\activate

Mac/Linux:

python3 -m venv venv
source venv/bin/activate

3. Install Dependencies

If you have a requirements.txt:

pip install -r requirements.txt

(If missing, install the essentials: pip install django djangorestframework djangorestframework-simplejwt and any other used packages)

4. Apply Database Migrations

python manage.py makemigrations
python manage.py migrate

5. Create Superuser (Admin)

python manage.py createsuperuser

6. Run the Development Server

python manage.py runserver

Server will be available at http://127.0.0.1:8000/.


API Summary

For full details, see user_auth/urls.py. Here are the most important endpoints:

Endpoint Method Description
/signup/ POST Register a new user
/login/ POST Log in and get token
/user-data/ GET Fetch user profile data
/quiz/ POST Generate quiz/questions from text
/book-quiz/ GET Fetch MCQs for a specific book/class
/save-quiz-test/ POST Save a new test
/assign-test/ POST Assign a test to a class
/fetch-test/ POST Fetch a specific assigned test
/submit-test-results/ POST Student submits answers/results
/get-student-test-result/ GET Fetch student test result
/student/progress/ GET Student progress per book
/student-classes/ GET List of all student classes
/student/notifications/ GET Fetch notifications for a student
/notification/mark-read/<id>/ POST Mark notification as read
/assigned_subjects/ GET Get overview of assigned books/subjects
... (See urls.py for full list)

Key Features

  • Custom User Auth: Registration/login for student & teacher, JWT/token-based sessions.
  • Quiz & Test Management: Auto-generates MCQs/open questions, compiles tests, assigns to classes.
  • Notifications: Sends notifications to students for new/updated tests.
  • Student Progress: Tracks and reports on student test results and progress.
  • Teacher Reports: Average scores and analytics for teacher dashboards.
  • Media Handling: Supports user profile pictures.

Of course! Here’s the updated Notes section for PostgreSQL:


Notes

  • By default, this backend uses PostgreSQL for the database (configured in settings.py).
  • Media uploads are stored in /media/.
  • To access the Django admin panel: /admin/ (requires superuser).

About

This Django project serves as an administration system for educational institutions, allowing easy management of departments, students, and teachers. It provides essential functionalities such as creating, editing, and deleting departments, along with viewing student and teacher details, streamlining administrative tasks efficiently.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors