Skip to content

Commit

Permalink
Student Scheduling Assistant / Student Course Requests: Available Ses…
Browse files Browse the repository at this point in the history
…sions

- Available Sessions: prefer sessions with matching student campus (in the order they are displayed)
  - if two or more academic sessions start on the same date, prefer the academic session whose initiative matches the student's campus
  • Loading branch information
tomas-muller committed Sep 23, 2024
1 parent 5724f03 commit 29904b5
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
31 changes: 29 additions & 2 deletions JavaSource/org/unitime/timetable/gwt/server/SectioningServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -807,44 +807,64 @@ public Collection<AcademicSessionProvider.AcademicSessionInfo> listAcademicSessi
if (server == null || !server.isReady()) continue;
Session session = SessionDAO.getInstance().get(Long.valueOf(s));
AcademicSessionInfo info = server.getAcademicSession();
String primaryCampus = null;
if (principal != null) {
Long studentId = principal.getStudentId(session.getUniqueId());
if (studentId == null) continue;
Student student = StudentDAO.getInstance().get(studentId);
if (student == null) continue;
StudentAreaClassificationMajor primary = student.getPrimaryAreaClasfMajor();
primaryCampus = (primary == null || primary.getCampus() == null ? null : primary.getCampus().getReference());
StudentSectioningStatus status = student.getEffectiveStatus();
if (status != null && !status.hasOption(StudentSectioningStatus.Option.enabled)
&& (!getSessionContext().hasPermissionAnySession(session, Right.StudentSchedulingAdmin) || !status.hasOption(StudentSectioningStatus.Option.admin))
&& (!getSessionContext().hasPermissionAnySession(session, Right.StudentSchedulingAdvisor) || !status.hasOption(StudentSectioningStatus.Option.advisor))
) continue;
} else {
if (!getSessionContext().hasPermissionOtherAuthority(session, Right.SchedulingAssistant, getStudentAuthority(session))) continue;
Long studentId = getStudentId(session.getUniqueId());
if (studentId != null) {
Student student = StudentDAO.getInstance().get(studentId);
StudentAreaClassificationMajor primary = (student == null ? null : student.getPrimaryAreaClasfMajor());
primaryCampus = (primary == null || primary.getCampus() == null ? null : primary.getCampus().getReference());
}
}
ret.add(new AcademicSessionProvider.AcademicSessionInfo(
session.getUniqueId(),
session.getAcademicYear(), session.getAcademicTerm(), session.getAcademicInitiative(),
MSG.sessionName(session.getAcademicYear(), session.getAcademicTerm(), session.getAcademicInitiative()),
session.getSessionBeginDateTime())
.setExternalCampus(extTerm == null ? null : extTerm.getExternalCampus(info))
.setExternalTerm(extTerm == null ? null : extTerm.getExternalTerm(info)));
.setExternalTerm(extTerm == null ? null : extTerm.getExternalTerm(info))
.setPrimary(primaryCampus != null && primaryCampus.equals(session.getAcademicInitiative()))
);
}
} else {
for (Session session: SessionDAO.getInstance().findAll()) {
if (session.getStatusType().isTestSession()) continue;
if (session.getStatusType().canPreRegisterStudents()) {
AcademicSessionInfo info = new AcademicSessionInfo(session);
String primaryCampus = null;
if (principal != null) {
Long studentId = principal.getStudentId(session.getUniqueId());
if (studentId == null) continue;
Student student = StudentDAO.getInstance().get(studentId);
if (student == null) continue;
StudentAreaClassificationMajor primary = student.getPrimaryAreaClasfMajor();
primaryCampus = (primary == null || primary.getCampus() == null ? null : primary.getCampus().getReference());
StudentSectioningStatus status = student.getEffectiveStatus();
if (status != null && !status.hasOption(StudentSectioningStatus.Option.regenabled)
&& (!getSessionContext().hasPermissionAnySession(session, Right.StudentSchedulingAdmin) || !status.hasOption(StudentSectioningStatus.Option.regadmin))
&& (!getSessionContext().hasPermissionAnySession(session, Right.StudentSchedulingAdvisor) || !status.hasOption(StudentSectioningStatus.Option.regadvisor))
) continue;
} else {
if (!getSessionContext().hasPermissionOtherAuthority(session, Right.CourseRequests, getStudentAuthority(session))) continue;
Long studentId = getStudentId(session.getUniqueId());
if (studentId != null) {
Student student = StudentDAO.getInstance().get(studentId);
StudentAreaClassificationMajor primary = (student == null ? null : student.getPrimaryAreaClasfMajor());
primaryCampus = (primary == null || primary.getCampus() == null ? null : primary.getCampus().getReference());
}
}
ret.add(new AcademicSessionProvider.AcademicSessionInfo(
session.getUniqueId(),
Expand All @@ -854,6 +874,8 @@ public Collection<AcademicSessionProvider.AcademicSessionInfo> listAcademicSessi
)
.setExternalCampus(extTerm == null ? null : extTerm.getExternalCampus(info))
.setExternalTerm(extTerm == null ? null : extTerm.getExternalTerm(info))
.setOnline(false)
.setPrimary(primaryCampus != null && primaryCampus.equals(session.getAcademicInitiative()))
);
}
}
Expand All @@ -862,7 +884,6 @@ public Collection<AcademicSessionProvider.AcademicSessionInfo> listAcademicSessi
throw new SectioningException(MSG.exceptionNoSuitableAcademicSessions());
}
Collections.sort(ret);
if (!sectioning) Collections.reverse(ret);
return ret;
}

Expand Down Expand Up @@ -3917,6 +3938,8 @@ public Collection<AcademicSessionProvider.AcademicSessionInfo> getStudentSession
if (session.getStatusType().canPreRegisterStudents() || session.getStatusType().canOnlineSectionStudents()) {
if (!getSessionContext().hasPermissionAnySession(session, Right.AdvisorCourseRequests)) continue;
AcademicSessionInfo info = new AcademicSessionInfo(session);
StudentAreaClassificationMajor primary = student.getPrimaryAreaClasfMajor();
String primaryCampus = (primary == null || primary.getCampus() == null ? null : primary.getCampus().getReference());
ret.add(new AcademicSessionProvider.AcademicSessionInfo(
session.getUniqueId(),
session.getAcademicYear(), session.getAcademicTerm(), session.getAcademicInitiative(),
Expand All @@ -3925,6 +3948,7 @@ public Collection<AcademicSessionProvider.AcademicSessionInfo> getStudentSession
)
.setExternalCampus(extTerm == null ? null : extTerm.getExternalCampus(info))
.setExternalTerm(extTerm == null ? null : extTerm.getExternalTerm(info))
.setPrimary(primaryCampus != null && primaryCampus.equals(session.getAcademicInitiative()))
);
sessionIds.add(session.getUniqueId());
}
Expand All @@ -3938,6 +3962,8 @@ public Collection<AcademicSessionProvider.AcademicSessionInfo> getStudentSession
if (sessionIds.contains(session.getUniqueId())) continue;
if (!getSessionContext().hasPermissionAnySession(session, Right.AdvisorCourseRequests)) continue;
AcademicSessionInfo info = new AcademicSessionInfo(session);
StudentAreaClassificationMajor primary = student.getPrimaryAreaClasfMajor();
String primaryCampus = (primary == null || primary.getCampus() == null ? null : primary.getCampus().getReference());
ret.add(new AcademicSessionProvider.AcademicSessionInfo(
session.getUniqueId(),
session.getAcademicYear(), session.getAcademicTerm(), session.getAcademicInitiative(),
Expand All @@ -3946,6 +3972,7 @@ public Collection<AcademicSessionProvider.AcademicSessionInfo> getStudentSession
)
.setExternalCampus(extTerm == null ? null : extTerm.getExternalCampus(info))
.setExternalTerm(extTerm == null ? null : extTerm.getExternalTerm(info))
.setPrimary(primaryCampus != null && primaryCampus.equals(session.getAcademicInitiative()))
);
}
Collections.sort(ret);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public static class AcademicSessionInfo implements IsSerializable, Comparable<Ac
private String iYear, iTerm, iCampus, iName;
private String iExternalTerm, iExternalCampus;
private Date iStartDate;
private Boolean iPrimary = null;
private Boolean iOnline = null;

public AcademicSessionInfo() {}

Expand Down Expand Up @@ -90,6 +92,18 @@ public AcademicSessionInfo(Long sessionId, String year, String term, String camp
public Date getStartDate() { return iStartDate; }
public void setStartDate(Date startDate) { iStartDate = startDate; }

public boolean isPrimary() { return Boolean.TRUE.equals(iPrimary); }
public AcademicSessionInfo setPrimary(boolean primary) {
iPrimary = primary;
return this;
}

public boolean isOnline() { return !Boolean.FALSE.equals(iOnline); }
public AcademicSessionInfo setOnline(boolean online) {
iOnline = online;
return this;
}

@Override
public String toString() {
return getName();
Expand All @@ -103,8 +117,12 @@ public boolean equals(Object o) {

@Override
public int compareTo(AcademicSessionInfo s) {
if (isOnline() != s.isOnline())
return isOnline() ? -1 : 1;
int cmp = s.getStartDate().compareTo(getStartDate());
if (cmp != 0) return cmp;
if (cmp != 0) return (isOnline() ? cmp : -cmp);
if (isPrimary() != s.isPrimary())
return isPrimary() ? -1 : 1;
cmp = getName().compareTo(s.getName());
if (cmp != 0) return cmp;
return getSessionId().compareTo(s.getSessionId());
Expand Down
8 changes: 8 additions & 0 deletions WebContent/help/Release-Notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@
<line>Show recommendations from the other academic session(s) if a student is advised in two or more parallel sessions.</line>
</description>
</item>
<item>
<name>Student Scheduling Assistant / Student Course Requests</name>
<description>
<line>Available Sessions: Prefer sessions with matching student campus (in the order they are displayed).
<line>If two or more academic sessions start on the same date, prefer the academic session whose initiative matches the student's campus.</line>
</line>
</description>
</item>
</category>
<category>
<title>Examination Timetabling</title>
Expand Down

0 comments on commit 29904b5

Please sign in to comment.