A Django-based web application designed for managing and participating in DataTalks.Club courses. This platform allows instructors to create and manage courses, assignments, and peer reviews.
Students can enroll in courses, submit homework, projects and engage in peer evaluations.
- User Authentication: Registration and login functionality for students and instructors.
- Course Management: Instructors can create and manage courses.
- Homework and Projects: Students can submit homework and projects; instructors can manage assignments.
- Peer Reviews: Facilitates peer review process for project evaluations.
- Leaderboard: Displays student rankings based on performance in courses.
├── accounts/ # Handles user accounts and authentication
├── course_management/ # Main project folder with settings and root configurations
├── courses/ # Main logic is here (courses, homeworks, etc)
├── templates/ # Global templates directory for the project
This project uses uv for dependency management and requires Python 3.13.
Install uv if you don't have it yet:
pip install uv
Install Python 3.13 and dependencies:
uv python install 3.13
uv sync --dev
Set the database to local:
export DATABASE_URL="sqlite:///db/db.sqlite3"
Make migrations:
make migrations
# uv run python manage.py migrate
Add an admin user:
make admin
# uv run python manage.py createsuperuser
Add some data:
make data
make run
# uv run python manage.py runserver 0.0.0.0:8000
Build it:
docker build -t course_management .
Run it:
DBDIR=`cygpath -w ${PWD}/db`
docker run -it --rm \
-p 8000:80 \
--name course_management \
-e DATABASE_URL="sqlite:////data/db.sqlite3" \
-e SITE_ID="${SITE_ID}" \
-v ${DBDIR}:/data \
course_management
remove the container later
docker rm course_management
get to the container
docker exec -it course_management bash
There are /data
endpoints for getting the data
Using them:
TOKEN="TEST_TOKEN"
HOST="http://localhost:8000"
COURSE="fake-course"
HOMEWORK="hw1"
curl \
-H "Authorization: ${TOKEN}" \
"${HOST}/data/${COURSE}/homework/${HOMEWORK}"
Make sure to run make data
to create the admin user and
data (including authentication token)
If you want to authenticate with OAuth locally (not requeired for testing), do the following
- Go to the admin panel (http://localhost:8000/admin)
- Add a record to "Sites"
- "localhost:8000" for display and domain names
- note the ID of the site (probably it's "2")
- Add records to "Social applications":
- GoogleDTC. Provider: Google
- Ask Alexey for the keys. Don't share them publicly
- For the site, choose the localhost one
Export SITE_ID
(should be the ID of the localhost site):
export SITE_ID=2
Restart the app:
python manage.py runserver 0.0.0.0:8000
Now log out as admin and log in with Google
Prep work
Host bastion-tunnel
HostName <IP>
User ubuntu
IdentityFile c:/Users/alexe/.ssh/<KEY>.pem
LocalForward 5433 dev-course-management-cluster.cluster-cpj5uw8ck6vb.eu-west-1.rds.amazonaws.com:5432
ServerAliveInterval 60
Connect to the bastion
ssh bastion-tunnel
And then
pgcli -h localhost -p 5433 -u pgusr -d coursemanagement
When connecting for the first time, create dev and prod schemas
CREATE DATABASE dev;
CREATE DATABASE prod;
Django shell
export DATABASE_URL="postgresql://pgusr:${DB_PASSWORD}@localhost:5433/dev"
export SECRET_KEY="${DJANGO_SECRET}"
pipenv run python manage.py shell
or
export DATABASE_URL="postgresql://pgusr:${DB_PASSWORD}@localhost:5433/prod"
export SECRET_KEY="${DJANGO_SECRET}"
Finding user with email:
from django.contrib.auth import get_user_model
User = get_user_model()
user = User.objects.get(email='[email protected]')
All API endpoints require authentication using a valid token in the Authorization header: Token <token_key>
Endpoint: GET /data/{course_slug}/homework/{homework_slug}
Description: Retrieves comprehensive homework data including course information, homework details, and all student submissions with their answers.
Response: Returns course data, homework details, and an array of submissions with:
- Student information
- Homework submission details (links, time spent, scores)
- Individual question answers with correctness
- Learning in public contributions
- FAQ contributions
Endpoint: GET /data/{course_slug}/project/{project_slug}
Description: Retrieves comprehensive project data including course information, project details, and all student submissions with their scores and peer review information.
Response: Returns course data, project details, and an array of submissions with:
- Student information and GitHub links
- Project scores (project, FAQ, learning in public, peer review)
- Peer review status and scores
- Pass/fail status
- Time spent and learning in public links
Endpoint: GET /data/{course_slug}/graduates
Description: Retrieves a list of students who have successfully completed the course by passing the minimum required number of projects.
Response: Returns an array of graduates with:
- Student email
- Certificate name (or display name if certificate name not set)
Endpoint: POST /data/{course_slug}/update-certificate
Description: Updates the certificate URL for a user's enrollment in a specific course.
Request Body:
{
"email": "[email protected]",
"certificate_path": "/path/to/certificate.pdf"
}
Response:
{
"success": true,
"message": "Certificate URL updated for [email protected] in course course-slug",
"enrollment_id": 123,
"certificate_url": "/path/to/certificate.pdf"
}
Error Responses:
400 Bad Request
: Missing required fields or invalid JSON401 Unauthorized
: Missing or invalid authentication token404 Not Found
: User not found or not enrolled in the course405 Method Not Allowed
: Wrong HTTP method (only POST allowed)500 Internal Server Error
: Server error
Example Usage:
curl -X POST \
-H "Authorization: Token your_token_here" \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "certificate_path": "/certificates/student-cert.pdf"}' \
http://localhost:8000/data/python-for-data-science/update-certificate