Skip to main content

A Python wrapper for the ENSAM egrading platform

Project description

🎓 Egrading API Wrapper

A lightweight Python wrapper for the ENSAM Egrading platform. It handles authentication, exam listing, exam data retrieval, and even automatic MCQ solving using ChatGPT.

Built for students who like their grades served with an API. 🚀


✨ Features

  • ✅ Secure login using ENSAM credentials
  • 📋 Fetch all available exams
  • 📄 Get detailed data for a specific exam
  • 🤖 Auto-solve MCQs using ChatGPT
  • 🧠 Supports single & multiple correct answers
  • 🍪 Automatic handling of access & refresh tokens
  • ⚡ Fast, lightweight, and hackable

📦 Installation

If you plan to publish it as a package:

pip install egrading-api

Or clone directly:

git clone https://github.com/NacreousDawn596/egrading-api.git
cd egrading-api
pip install -r requirements.txt

🛠 Requirements

pip install requests urllib3 g4f

🚀 Quick Start

from egrading_api import Student

# Initialize client
student = Student("email@ensam.ac.ma", "password")

✅ This automatically:

  • Logs you in
  • Stores accessToken
  • Stores refreshToken
  • Prepares the ChatGPT client

📋 List All Available Exams

exams = student.listExams()
print(exams)

🔍 Returns:

  • Exam IDs
  • Subjects
  • Status
  • Time windows
  • Metadata used to launch exams

📄 Get Full Exam Data

exam_id = "123456"
exam_data = student.getExamData(exam_id)

print(exam_data)

✅ Includes:

  • Questions
  • Choices
  • Exam duration
  • Scoring details
  • Exam configuration

🤖 Auto-Solve MCQs using ChatGPT

Once you extract the questions from the exam:

questions = exam_data["questions"]

answers = student.answerQuestionsUsingChatGPT(questions)
print(answers)

✅ Output Format

{
  "Q1": [2],
  "Q2": [1, 3],
  "Q3": [4]
}
  • 🟢 Always returns lists
  • 🟢 Supports multiple correct answers
  • 🟢 Indexes are 1-based

🧠 How the AI Solving Works

  • Questions are split into smart chunks

  • Each chunk is sent to ChatGPT

  • The model is forced to return:

    • ✅ A raw Python dictionary
    • ✅ No markdown
    • ✅ No explanations
  • Output is:

    • Parsed
    • Normalized
    • Merged into a clean final result

🔐 Authentication System

The wrapper handles:

  • ✅ Access token stored in headers
  • ✅ Refresh token stored in cookies
  • ✅ Automatic session reuse
  • ✅ No manual token handling needed

⚙️ Class Overview

Student(email, password, login=True)

Parameter Type Description
email str ENSAM email
password str Account password
login bool Auto-login on init

listExams() → dict

Returns all exams available to the student.


getExamData(exam_id: str) → dict

Returns full structured exam data.


answerQuestionsUsingChatGPT(questions: list, model="gpt-4") → dict

Auto-answers all MCQs using AI.


⚠️ Security Notes

  • ❗ This project disables SSL verification (verify=False)
  • ❗ Credentials are sent in plain requests
  • ✅ Use only for educational & personal testing
  • ✅ Never expose your password in public repos

🧪 Example Full Workflow

student = Student("email@ensam.ac.ma", "password")

exams = student.listExams()
first_exam_id = exams[0]["id"]

exam_data = student.getExamData(first_exam_id)

answers = student.answerQuestionsUsingChatGPT(exam_data["questions"])

print(answers)

🛑 Disclaimer

This project is:

  • ❌ Not affiliated with ENSAM
  • ❌ Not officially supported
  • ✅ Only for educational & research purposes

Use responsibly. Don’t speedrun your academic career into chaos 💀


❤️ Author

Made with caffeine, insomnia, and bad life choices by Kamal ☕ If this saved you during exam week == you owe me monster hhhhhhhh.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

egrading_api-0.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

egrading_api-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file egrading_api-0.1.0.tar.gz.

File metadata

  • Download URL: egrading_api-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for egrading_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7c06b4d766d7f9ae1adf749eaba6190bef829418edef6b11806529ff77927ba4
MD5 31fff39f7276b3c6a3e42eb6fdff9c86
BLAKE2b-256 e96019a64a38370c87eea301a4a67e1593a871e00b8dba9fa04a863a66709057

See more details on using hashes here.

File details

Details for the file egrading_api-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: egrading_api-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for egrading_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5e066d064115d7e6ff9a4f229a1e1b5ce7da2342c51ca6ae1f502fb981d21d3
MD5 039eb6b606bc45efc8ce4db37f5497aa
BLAKE2b-256 e070450b1e9bdaf6cb854924f92ae64f4edebb97416b9bc4d8e82a3dc31dd85a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page