Skip to content

feat(examination): dynamic expected completion year in result PDF/transcript - #2017

Open
dreamweaver19 wants to merge 1 commit into
FusionIIIT:prod/acad-reactfrom
dreamweaver19:feat/exam-expected-completion-year
Open

dreamweaver19 wants to merge 1 commit into
FusionIIIT:prod/acad-reactfrom
dreamweaver19:feat/exam-expected-completion-year

Conversation

@dreamweaver19

Copy link
Copy Markdown

Context

This PR targets prod/acad-react (the correct production branch).

The previous PR #2009 was closed because it targeted the stale examination-v1 branch. The approval-sheet improvements from that PR were already merged by @vikrantwiz02 in PR #2011. This PR adds the one remaining piece: the dynamic expected completion year in student result PDFs and transcripts.


What this adds

A certificate sentence in the student result PDF / marksheet:

It is expected that 8th semester result will be declared in the month of July/August 2027.

where every value is dynamically computed — nothing hardcoded.


Source of truth (existing DB, no new models or migrations)

Data Source
Admission year Batch.year
Programme length Batch.curriculum.no_of_semester (8 for B.Tech, 4 for M.Tech)
Completion year batch.year + (no_of_semester // 2)

Examples:

  • UG2023 B.Tech → 2023 + 4 = 2027
  • UG2024 B.Tech → 2024 + 4 = 2028
  • PG2023 M.Tech → 2023 + 2 = 2025

Changes — one file only

FusionIIIT/applications/examination/api/views.py

  1. get_expected_completion_year(student) — new module-level helper after format_semester_display(). Uses Batch→Curriculum path; falls back to legacy Student.batch + 4 when curriculum FK is null; returns None gracefully (PDF still generates, sentence simply omitted).

  2. expected_completion_year added to student_info dict in:

    • GenerateTranscript (acadadmin)
    • CheckResultView (student self-service)
    • GenerateStudentResultPDFAPI DB-fetch path
  3. Certificate sentence added before the existing footer in both PDF generation code paths. Only rendered when year is non-null.


Tests — 32/32 passed ✅

Category Tests
get_expected_completion_year() helper (all programmes + fallbacks) 10
Certificate sentence construction 5
Ordinal suffix (1st/2nd/3rd/4th/8th/11th/12th/13th/21st) 12
Dynamic guarantee (4 batches → 4 distinct years, B.Tech ≠ M.Tech) 3
Sentence format matches spec exactly 2

Checklist

…nscript

Adds the certificate sentence to student result PDFs and transcript PDFs:

  'It is expected that 8th semester result will be declared in the
   month of July/August 2027.'

where the year and semester number are fully dynamic — never hardcoded.

Source of truth (existing DB fields, no new models or migrations):
  Batch.year                       → student admission year
  Batch.curriculum.no_of_semester  → programme length (8 B.Tech, 4 M.Tech)
  Formula: batch.year + (no_of_semester // 2)

Examples:
  UG2023 B.Tech (8 sems) → July/August 2027
  UG2024 B.Tech (8 sems) → July/August 2028
  PG2023 M.Tech (4 sems) → July/August 2025

Changes in FusionIIIT/applications/examination/api/views.py:

1. get_expected_completion_year(student) — new module-level helper added
   after format_semester_display(). Uses Batch→Curriculum path; falls back
   to legacy Student.batch + 4 when curriculum FK is null; returns None
   gracefully so PDFs still generate when data is missing.

2. expected_completion_year field added to student_info dict in:
   - GenerateTranscript (acadadmin transcript API)
   - CheckResultView (student self-service result API)
   - GenerateStudentResultPDFAPI DB-fetch path

3. Certificate sentence added just before the 'computer-generated
   document' footer in both PDF generation code paths
   (generate_student_result_pdf in GeneratePDFAPI and
   GenerateStudentResultPDFAPI). Sentence is rendered only when
   completion_year is non-null.

Tests: 32/32 passed
  - All B.Tech batches 2021-2024 produce correct distinct years
  - M.Tech (4 sems) produces different year than B.Tech (8 sems)
  - Fallback paths (null curriculum, null batch_id FK)
  - Sentence format matches spec exactly
  - Ordinal suffixes 1st/2nd/3rd/4th/8th/11th/12th/13th/21st

No migrations. No model changes. No frontend changes required.
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