Online Learning Management System with Source Code

Online Learning Management System with Source Code

Online Learning Management System

In an era where online education is booming, an Online Learning Management System (LMS) plays a pivotal role in delivering education to students across the globe. From universities to corporate training, LMS platforms are vital tools for facilitating learning, managing content, and tracking student progress.


Key Features

In this project, we’ll implement some of the fundamental features of an LMS, such as:

  1. User Authentication – For students and educators to securely log in and access their courses.
  2. Course Creation – letting instructors design and oversee their own courses.
  3. Content Upload – Facilitating uploading of course materials such as PDFs, videos, and assignments.
  4. Progress Tracking – Allowing pupils to see their development.
  5. Quizzes and Assignments – Interactive tasks to assess student learning.


Technologies Used

  • Python – For backend logic.
  • Django – As the web framework to manage routing, views, and templates.
  • SQLite – For the database (Django’s default).
  • HTML/CSS – For the front end to render user interfaces.

Online Learning Management System
Online Learning Management System with Source Code

Step-by-Step Guide to


1. settings.py – Project Configuration

In online_lms/settings.py, include the courses app in the list of installed apps:

INSTALLED_APPS = [
    # other apps like admin, auth, etc.
    'courses',
]

New Project :-https://www.youtube.com/@Decodeit2

See also  How to Create a CSS Page Loading Spinner - A Step-by-Step Tutorial

2. models.py – Define Models

In courses/models.py, define the models for Course, Enrollment, Quiz, and Question:

from django.db import models
from django.contrib.auth.models import User

# Course Model
class Course(models.Model):
    title = models.CharField(max_length=100)
    description = models.TextField()
    instructor = models.ForeignKey(User, on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title

# Enrollment Model
class Enrollment(models.Model):
    student = models.ForeignKey(User, on_delete=models.CASCADE)
    course = models.ForeignKey(Course, on_delete=models.CASCADE)
    enrolled_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{self.student.username} enrolled in {self.course.title}"

# Quiz Model
class Quiz(models.Model):
    course = models.ForeignKey(Course, on_delete=models.CASCADE)
    title = models.CharField(max_length=100)
    created_at = models.DateTimeField(auto_now_add=True)

# Question Model
class Question(models.Model):
    quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE)
    text = models.TextField()
    answer = models.CharField(max_length=100)

3. views.py – Define Views

In courses/views.py, create views for course creation, course list, and enrollment:

from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required
from .models import Course, Enrollment

@login_required
def create_course(request):
    if request.method == 'POST':
        title = request.POST['title']
        description = request.POST['description']
        Course.objects.create(title=title, description=description, instructor=request.user)
        return redirect('course_list')
    return render(request, 'courses/create_course.html')

@login_required
def course_list(request):
    courses = Course.objects.all()
    return render(request, 'courses/course_list.html', {'courses': courses})

@login_required
def enroll_course(request, course_id):
    course = Course.objects.get(id=course_id)
    Enrollment.objects.create(student=request.user, course=course)
    return redirect('course_list')

4. urls.py – Define URL Patterns

In courses/urls.py, map the views to their respective URLs:

from django.urls import path
from . import views

urlpatterns = [
    path('create/', views.create_course, name='create_course'),
    path('', views.course_list, name='course_list'),
    path('enroll/<int:course_id>/', views.enroll_course, name='enroll_course'),
]

In the main online_lms/urls.py, include the courses app:

from django.contrib import admin
from django.urls import path, include
from django.contrib.auth import views as auth_views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('courses/', include('courses.urls')),
    path('login/', auth_views.LoginView.as_view(), name='login'),
    path('logout/', auth_views.LogoutView.as_view(), name='logout'),
]

5. Templates – HTML Files

Create the templates in courses/templates/courses/.

create_course.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Create Course</title>
</head>
<body>
    <h1>Create a New Course</h1>
    <form method="post">
        {% csrf_token %}
        <label for="title">Course Title:</label>
        <input type="text" name="title" id="title"><br>
        <label for="description">Course Description:</label>
        <textarea name="description" id="description"></textarea><br>
        <button type="submit">Create Course</button>
    </form>
</body>
</html>

course_list.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Course List</title>
</head>
<body>
    <h1>Available Courses</h1>
    <ul>
        {% for course in courses %}
        <li>
            {{ course.title }} by {{ course.instructor.username }} 
            <a href="{% url 'enroll_course' course.id %}">Enroll</a>
        </li>
        {% endfor %}
    </ul>
</body>
</html>

Online Learning Management System with Source Code
Online Learning Management System with Source Code

6. Authentication – Login and Logout Views

Django’s built-in authentication is used for login and logout. This functionality is included in the main online_lms/urls.py.

  • Login URL: /login/
  • Logout URL: /logout/

7. Running the Project

  1. Migrate the Models: Run the migrations to create the database tables. python manage.py makemigrations python manage.py migrate
  2. Create a Superuser: Create a superuser to access the Django admin panel and manage courses. python manage.py createsuperuser
  3. Run the Server: Start the Django development server. python manage.py runserver

You can now access the LMS at http://localhost:8000/courses/, where instructors can create courses and students can enroll.

See also  eLearning Application :Free & Best 1 Project

PHP PROJECT:- CLICK HERE

  • Online Learning Management System with Source Code
  • Online Learning Management System
Show 1 Comment

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *