Skip to content

Commit

Permalink
INTERNSHIP-329 use position to balance internships assignment reparti…
Browse files Browse the repository at this point in the history
…tion in hospitals + fix selecting non mandatory internships
  • Loading branch information
mathieuzen committed Oct 14, 2024
1 parent e04a250 commit bf768f6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions business/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def _assign_students_in_subcohorts(self):
# shuffle interships, keeps on top specialties that are not available in all cohorts to prioritize on these
internships = sorted(
available_internships,
key=lambda i: (self.internships_availability_occurence[i], random.random())
key=lambda i: (self.internships_availability_occurence[i], i.position, random.random())
)
for internship in internships:
_assign_student(self, student, internship)
Expand Down Expand Up @@ -423,7 +423,9 @@ def _assign_student(assignment, student, internship):
affectations = assign_choices_to_student(assignment, student, choices, internship)
# Deal with internship at choice
else:
if isinstance(internship, Iterable) and not _has_affected_non_mandatory_internship(student_affectations):
if not _has_affected_non_mandatory_internship(student_affectations):
if not isinstance(internship, Iterable):
internship = [internship]
for chosen_internship in internship:
if affectations is None or affectations == []:
last = chosen_internship == list(internship)[:-1]
Expand Down

0 comments on commit bf768f6

Please sign in to comment.