Skip to content

feat(online_cms): align CMS APIs with DB models—role normalization, threaded forum, attendance, assignments, quizzes, and link-based materials#1

Merged
divyTechS merged 4 commits into
divyTechS:mainfrom
Indrapal-70:main
Mar 25, 2026

Conversation

@Indrapal-70
Copy link
Copy Markdown

🚀 Overview

This PR aligns the Online CMS backend APIs with the underlying database models and introduces several core academic features to support a complete course management workflow.


✨ Key Changes

🔐 Role Normalization

  • Standardized user roles across the system
  • Ensures consistent access control for:
    • Students
    • Instructors
    • Admins

💬 Threaded Forum System

  • Added support for:
    • Nested discussions (threaded replies)
    • Parent-child post relationships
  • Enables structured course discussions

📊 Attendance Module

  • Implemented attendance tracking:
    • Mark attendance per session
    • Store and retrieve student attendance records
  • API endpoints aligned with DB schema

📝 Assignments

  • Assignment lifecycle support:
    • Create assignments
    • Submit via link-based submissions
    • Instructor grading functionality
  • Persistent storage of submissions and grades

🧠 Quizzes

  • Quiz system enhancements:
    • Create quizzes
    • Submit responses
    • Persist results in DB
  • Ensures data consistency across attempts

📚 Course Materials (Link-Based)

  • Migrated course materials to link-based resources
  • Added:
    • DB migration for new schema
    • API endpoints for CRUD operations
  • Simplifies material access and storage

🛠️ Technical Improvements

  • Refactored API structure to match database models
  • Improved data consistency and validation
  • Reduced placeholder/mock responses
  • Enhanced scalability for future features

🔄 Migration Notes

  • Database migration required for:
    • Course materials schema update
    • Forum threading support
  • Ensure migrations are applied before deployment:
    python manage.py migrate

…hreaded forum, attendance, assignments (link submit/grade), quizzes (create/submit persistence), and link-based course materials (migration + endpoints)
Copilot AI review requested due to automatic review settings March 24, 2026 22:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the online_cms Django app from template-based views into DRF-based APIs aligned with the DB schema, adds grading models/migrations, and introduces JWT-based auth endpoints intended to support a modern course-management frontend.

Changes:

  • Replaced legacy online_cms view/URL surface with DRF API endpoints for courses, assignments (link submissions), documents (link-based), threaded forum, quizzes, attendance, and grading.
  • Added GradingScheme/StudentEvaluation models + migrations and a demo seed management command.
  • Introduced JWT auth endpoints (/api/auth/login, /api/token/refresh, /api/auth/me) and updated REST framework auth settings.

Reviewed changes

Copilot reviewed 24 out of 26 changed files in this pull request and generated 29 comments.

Show a summary per file
File Description
FusionIIIT/applications/online_cms/views.py New DRF API implementation for Online CMS features (assignments, docs, forum, quizzes, attendance, grading).
FusionIIIT/applications/online_cms/urls.py New API routing for Online CMS endpoints.
FusionIIIT/applications/online_cms/services.py Centralized enrollment/roster/instructor-link helpers.
FusionIIIT/applications/online_cms/models.py Adds grading models; expands course material URL field to TextField.
FusionIIIT/applications/online_cms/migrations/0002_*.py Migration introducing grading models.
FusionIIIT/applications/online_cms/migrations/0003_*.py Migration altering CourseDocuments.document_url.
FusionIIIT/applications/online_cms/management/commands/seed_ocms_demo.py Demo seeding command for users/courses/enrollment.
FusionIIIT/applications/online_cms/serializers.py New serializers (currently inconsistent with models in places).
FusionIIIT/applications/online_cms/selectors.py New selectors (currently inconsistent with models in places).
FusionIIIT/applications/globals/api/urls.py Adds endpoints but currently duplicates patterns.
FusionIIIT/Fusion/api_auth.py Adds JWT auth “me” endpoint with role normalization.
FusionIIIT/Fusion/urls.py Wires JWT auth endpoints and mounts Online CMS API URLs.
FusionIIIT/Fusion/settings/common.py Adds rest_framework_simplejwt and JWT config.
FusionIIIT/Fusion/settings/development.py Updates DB + REST_FRAMEWORK auth config (now hard-coded creds).
FusionIIIT/Fusion/settings/production.py Updates REST_FRAMEWORK auth config to include JWT + sessions/basic.
FusionIIIT/update_views.py New local helper script that overwrites tracked code via absolute paths.
FusionIIIT/reset_pass.py New script that resets user passwords to a hard-coded value.
FusionIIIT/fix_*.py Multiple new local helper scripts that mutate files via absolute paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread FusionIIIT/fix_globals_urls.py Outdated
Comment on lines 12 to +16
'NAME': 'fusionlab',
'HOST': os.environ.get("DB_HOST", default='localhost'),
'USER': 'fusion_admin',
'PASSWORD': 'hello123',
'USER': 'postgres',
'PASSWORD': '2304',
'HOST': 'localhost',
'PORT': '5432',
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Development DB settings now hard-code local credentials (user/password/host/port). Please revert to environment-variable based configuration (as before) to avoid leaking credentials and to keep dev setup portable across machines/CI.

Copilot uses AI. Check for mistakes.
Comment on lines +458 to +461
if timezone.is_naive(start_dt):
start_dt = timezone.make_aware(start_dt)
if timezone.is_naive(end_dt):
end_dt = timezone.make_aware(end_dt)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timezone.make_aware is applied to start_dt/end_dt, but this project has USE_TZ = False. Creating aware datetimes here can break Quiz saves/comparisons. Please keep parsed datetimes naive when USE_TZ is False, or enable time zone support consistently across settings.

Copilot uses AI. Check for mistakes.
Comment on lines +740 to +742
student = models.Student.objects.get(id__user__username=s_id)
scheme = models.GradingScheme.objects.get(pk=sc_id)
ev, _ = models.StudentEvaluation.objects.get_or_create(scheme=scheme, student=student)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

models.Student is referenced here, but there is no Student model in online_cms.models. This will raise at runtime when evaluating grades; use the imported Student model instead.

Copilot uses AI. Check for mistakes.
Comment on lines +753 to +755
curr = services.get_course_obj(course_code)
student = models.Student.objects.get(id=extra_info)
schemes = models.GradingScheme.objects.filter(course_id=curr.course_id)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

models.Student is referenced here, but Student is not defined in online_cms.models. This will raise AttributeError when a student requests grades; use the Student model imported from applications.academic_information.models.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,73 @@
from .models import CourseDocuments, Assignment, StudentAssignment, Forum, ForumReply, Quiz, QuestionBank, Topics, Question, StudentGrades
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StudentGrades is imported from .models, but no such model exists in online_cms/models.py. Importing this module will raise ImportError; please remove StudentGrades usage or replace it with the correct model (e.g., StudentEvaluation/GradingScheme).

Copilot uses AI. Check for mistakes.
if deadline_dt is None and isinstance(deadline, str):
d = parse_date(deadline)
if d is not None:
deadline_dt = timezone.make_aware(timezone.datetime(d.year, d.month, d.day, 23, 59, 0))
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timezone.make_aware(...) is used when parsing deadline, but this project has USE_TZ = False in common settings. Saving timezone-aware datetimes with time zone support disabled can raise ValueError; please keep deadline_dt naive when USE_TZ is False (or enable USE_TZ=True consistently).

Suggested change
deadline_dt = timezone.make_aware(timezone.datetime(d.year, d.month, d.day, 23, 59, 0))
deadline_dt = timezone.datetime(d.year, d.month, d.day, 23, 59, 0)

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +11
url(r'^notification/$', views.NotificationRead, name='dummy_notifs'),
url(r'^auth/me$', views.profile, name='me-api-2'),

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notification/ and auth/me are registered multiple times in this urlpatterns list, creating duplicate URL patterns. This can lead to confusing URL resolution; please keep a single canonical route for each endpoint.

Suggested change
url(r'^notification/$', views.NotificationRead, name='dummy_notifs'),
url(r'^auth/me$', views.profile, name='me-api-2'),

Copilot uses AI. Check for mistakes.
Comment thread FusionIIIT/fix_settings.py Outdated
Comment thread FusionIIIT/fix_login.py Outdated
Indrapal-70 and others added 3 commits March 25, 2026 04:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@divyTechS divyTechS merged commit f2f0345 into divyTechS:main Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants