Skip to content

Commit

Permalink
rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
el-agua committed Oct 19, 2024
1 parent 495f550 commit 83005ea
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions backend/courses/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from review.management.commands.mergeinstructors import resolve_duplicates



logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -757,7 +756,6 @@ def get_section_from_course_instructor_semester(course_code, professors, semeste
)



def historical_semester_probability(current_semester: str, semesters: list[str]):
"""
:param current: The current semester represented in the 20XX(A|B|C) format.
Expand Down Expand Up @@ -806,23 +804,3 @@ def normalize_and_round(prob, i):
[semester_probabilities["A"], semester_probabilities["B"], semester_probabilities["C"]],
)
)


def get_section_from_course_instructor_semester(course_code, professors, semester):
"""
Attempts to return a course section that matches the given parameters.
ValueError is raised if the section does not exist.
"""
sections = Section.objects.prefetch_related('instructors').filter(
course__full_code=course_code,
course__semester=semester
)

professors_query = Q(instructors__name=professors[0])
for professor in professors[1:]:
professors_query &= Q(instructors__name=professor)
matching_sections = sections.filter(professors_query).distinct()

if matching_sections.count() == 1:
return matching_sections.first()
raise ValueError(f"No section exists with course code ({course_code}), professor ({professors[0]}), semester ({semester})")

0 comments on commit 83005ea

Please sign in to comment.