diff --git a/FusionIIIT/applications/examination/api/views.py b/FusionIIIT/applications/examination/api/views.py index 0a56b77ae..fb8e4896c 100644 --- a/FusionIIIT/applications/examination/api/views.py +++ b/FusionIIIT/applications/examination/api/views.py @@ -618,9 +618,9 @@ def download_template(request): student_id__in=student_ids_with_programme ) - # Optional section scope (course "allotted in sections"); electives ignore it. + # Sections apply only to UG (PG/PhD have no sections); electives ignore it. section = (request.data.get('section') or '').strip() or None - if section: + if section and (programme_type or '').strip().upper() == 'UG': course_info_query = course_info_query.filter(student_id__section=section) course_info = course_info_query.order_by("student_id_id") @@ -1878,7 +1878,10 @@ def post(self, request): # OFFERINGS: acadadmin may grade any offering of this course; faculty # only the offering(s) they are assigned to teach. An optional # `section` narrows this to a single section (electives have none). + # Sections apply only to UG; ignore any section for PG/PhD. section = (request.data.get("section") or "").strip() or None + if (programme_type or "").strip().upper() != "UG": + section = None all_offerings = list(CourseInstructor.objects.filter( course_id_id=course_id, @@ -1907,8 +1910,8 @@ def post(self, request): my_offering_ids = {o.id for o in my_offerings} my_sections = {o.section_label for o in my_offerings} # A no-section (elective) offering owns all registrants; named-section - # offerings scope the roster to students in those sections. - if None not in my_sections: + # offerings scope the roster to students in those sections (UG only). + if (programme_type or "").strip().upper() == "UG" and None not in my_sections: regs = regs.filter(student_id__section__in=my_sections) if not regs.exists(): return Response( @@ -3133,9 +3136,9 @@ def post(self, request): registrations = registrations.filter(student_id__in=student_ids_with_programme) - # Optional section scope (course "allotted in sections"); electives ignore it. + # Sections apply only to UG (PG/PhD have no sections); electives ignore it. section = (request.data.get("section") or "").strip() or None - if section: + if section and (programme_type or "").strip().upper() == "UG": registrations = registrations.filter(student_id__section=section) # Build a set of registered roll numbers for fast lookup.