Skip to content

Refactor grade calculation and improve course audit logging#1930

Merged
vikrantwiz02 merged 3 commits into
FusionIIIT:prod/acad-reactfrom
vikrantwiz02:prod/acad-react
Jul 13, 2026
Merged

Refactor grade calculation and improve course audit logging#1930
vikrantwiz02 merged 3 commits into
FusionIIIT:prod/acad-reactfrom
vikrantwiz02:prod/acad-react

Conversation

@vikrantwiz02

Copy link
Copy Markdown
Member

This pull request introduces several important improvements and fixes across the academic procedures, examination, and programme curriculum modules. The main highlights are the addition of a safe demotion endpoint for students, significant corrections to cumulative credit calculations (ensuring credits are only counted once per course and semester), and improved handling of JSON serialization in course audit logs.

Academic Procedures:

  • New demotion endpoint: Added apply_demotion API and URL, allowing academic admins to safely move students back one semester if they were over-promoted. The demotion does not remove any course registrations, making it a safe corrective action. [1] [2]

Examination Module:

  • Cumulative credit calculation fixes: Refactored how cumulative credits are calculated and reported in student semester histories. Credits are now deduped (counted once per course, even with retakes or improvements), and cumulative credits in APIs and reports now reconcile with transcript totals. [1] [2] [3] [4] [5] [6]
  • Credit earning logic correction: Updated logic so that any grade with a non-negative grade point (including 'F') earns credit, while only 'X', 'I', 'AU', and 'CD' do not earn credit. [1] [2]
  • Course replacement and best grade selection: Improved CPI calculation by collapsing duplicate/retake grades and handling course replacements more robustly, ensuring only the best attempt counts toward CPI and credits.

Programme Curriculum Module:

  • Audit log JSON serialization: Fixed a bug where saving audit logs for course changes could fail due to non-JSON-serializable types (like Decimal or datetime). Now, all audit log fields are safely encoded using Django's JSON encoder. [1] [2] [3]

These changes improve data integrity, user experience for academic admins, and reliability of student records and reporting.

apply_demotion endpoint moves selected students one semester back (floored at
sem 1); safe inverse of an accidental promotion — decrements curr_semester_no
only, without deleting course registrations.
create_course_audit_log stored old/new data and versions into JSONField columns
whose default encoder can't serialize Decimal (Course.version is a DecimalField).
The course row saved first, then the audit log insert raised -> 500, leaving the
course added in the DB while the UI showed failure (and "already exists" on retry).
Coerce audit values to JSON-native types via DjangoJSONEncoder before saving.
@vikrantwiz02
vikrantwiz02 merged commit 1ff7009 into FusionIIIT:prod/acad-react Jul 13, 2026
1 check passed
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.

1 participant