Skip to content

Commit 688801f

Browse files
committedDec 21, 2023
Instructional Offering Detail: Instructor Requirements
- include instructor surveys for assigned instructors that did not fill in course requirements for the course
1 parent 14d441f commit 688801f

File tree

3 files changed

+71
-5
lines changed

3 files changed

+71
-5
lines changed
 

‎JavaSource/org/unitime/timetable/model/InstructorCourseRequirement.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,22 @@ public static List<InstructorCourseRequirement> getRequirementsForOffering(Instr
9696
}
9797

9898
public static boolean hasRequirementsForOffering(InstructionalOffering io) {
99-
return InstructorCourseRequirementDAO.getInstance().getSession().createQuery(
99+
int reqs = InstructorCourseRequirementDAO.getInstance().getSession().createQuery(
100100
"select count(r) from InstructorCourseRequirement r, CourseOffering co " +
101101
"where co.instructionalOffering.uniqueId = :offeringId and " +
102102
"r.instructorSurvey.session = co.instructionalOffering.session and " +
103103
"(r.courseOffering = co or r.course = (co.subjectAreaAbbv || ' ' || co.courseNbr)) and " +
104104
"r.instructorSurvey.submitted is not null", Number.class
105105
).setParameter("offeringId", io.getUniqueId())
106-
.setCacheable(true).uniqueResult().intValue() > 0;
106+
.setCacheable(true).uniqueResult().intValue();
107+
if (reqs > 0) return true;
108+
int survs = InstructorCourseRequirementDAO.getInstance().getSession().createQuery(
109+
"select count(s) from InstructorSurvey s where s.submitted is not null and s.externalUniqueId in " +
110+
"(select ci.instructor.externalUniqueId from ClassInstructor ci where ci.classInstructing.schedulingSubpart.instrOfferingConfig.instructionalOffering.uniqueId = :offeringId and ci.instructor.externalUniqueId is not null)" +
111+
" and s.session.uniqueId = :sessionId and (s.preferences is not empty or length(s.note) > 0)", Number.class
112+
).setParameter("sessionId", io.getSessionId()).setParameter("offeringId", io.getUniqueId())
113+
.setCacheable(true).uniqueResult().intValue();
114+
if (survs > 0) return true;
115+
return false;
107116
}
108117
}

‎JavaSource/org/unitime/timetable/server/instructor/survey/InstructorRequirementsBackend.java

+59-3
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@
3939
import org.unitime.timetable.model.InstructorCourseRequirement;
4040
import org.unitime.timetable.model.InstructorCourseRequirementNote;
4141
import org.unitime.timetable.model.InstructorCourseRequirementType;
42+
import org.unitime.timetable.model.InstructorSurvey;
4243
import org.unitime.timetable.model.Preference;
4344
import org.unitime.timetable.model.TimePatternModel;
4445
import org.unitime.timetable.model.TimePref;
4546
import org.unitime.timetable.model.dao.InstructionalOfferingDAO;
4647
import org.unitime.timetable.model.dao.InstructorCourseRequirementTypeDAO;
48+
import org.unitime.timetable.model.dao.InstructorSurveyDAO;
4749
import org.unitime.timetable.security.SessionContext;
4850
import org.unitime.timetable.security.rights.Right;
4951
import org.unitime.timetable.webutil.RequiredTimeTable;
@@ -73,11 +75,11 @@ public InstructorRequirementData execute(InstructorRequirementsRequest request,
7375
}
7476

7577

78+
String instructorNameFormat = context.getUser().getProperty(UserProperty.NameFormat);
79+
boolean timeVertical = false;//RequiredTimeTable.getTimeGridVertical(context.getUser());
80+
boolean gridAsText = false;//RequiredTimeTable.getTimeGridAsText(context.getUser());
7681
List<InstructorCourseRequirement> requirements = InstructorCourseRequirement.getRequirementsForOffering(io);
7782
if (!requirements.isEmpty()) {
78-
String instructorNameFormat = context.getUser().getProperty(UserProperty.NameFormat);
79-
boolean timeVertical = false;//RequiredTimeTable.getTimeGridVertical(context.getUser());
80-
boolean gridAsText = false;//RequiredTimeTable.getTimeGridAsText(context.getUser());
8183
for (InstructorCourseRequirement req: new TreeSet<InstructorCourseRequirement>(requirements)) {
8284
DepartmentalInstructor di = req.getInstructorSurvey().getInstructor(io);
8385
CourseRequirement line = new CourseRequirement();
@@ -124,6 +126,60 @@ public InstructorRequirementData execute(InstructorRequirementsRequest request,
124126
response.addInstructorRequirement(line);
125127
}
126128
}
129+
130+
List<InstructorSurvey> surveys = InstructorSurveyDAO.getInstance().getSession().createQuery(
131+
"select s from InstructorSurvey s where s.submitted is not null and s.externalUniqueId in " +
132+
"(select ci.instructor.externalUniqueId from ClassInstructor ci where ci.classInstructing.schedulingSubpart.instrOfferingConfig.instructionalOffering.uniqueId = :offeringId and ci.instructor.externalUniqueId is not null)" +
133+
" and s.session.uniqueId = :sessionId and (s.preferences is not empty or length(s.note) > 0)", InstructorSurvey.class)
134+
.setParameter("sessionId", io.getSessionId()).setParameter("offeringId", io.getUniqueId()).setCacheable(true).list();
135+
survey: for (InstructorSurvey survey: surveys) {
136+
if (response.hasInstructorRequirements())
137+
for (CourseRequirement line: response.getInstructorRequirements()) {
138+
if (survey.getExternalUniqueId().equals(line.getExternalId())) continue survey;
139+
}
140+
DepartmentalInstructor di = survey.getInstructor(io);
141+
CourseRequirement line = new CourseRequirement();
142+
line.setExternalId(survey.getExternalUniqueId());
143+
if (di != null)
144+
line.setInstructorId(di.getUniqueId());
145+
line.setInstructorName(survey.getExternalUniqueId());
146+
if (di != null)
147+
line.setInstructorName(di.getName(instructorNameFormat));
148+
149+
line.setCourseName(io.getControllingCourseOffering().getCourseName());
150+
line.setId(io.getControllingCourseOffering().getUniqueId());
151+
line.setCourseTitle(io.getControllingCourseOffering().getTitle());
152+
153+
line.setNote(survey.getNote());
154+
155+
for (Preference p: survey.getPreferences()) {
156+
if (p instanceof TimePref) {
157+
TimePref tp = (TimePref)p;
158+
RequiredTimeTable rtt = tp.getRequiredTimeTable();
159+
if (gridAsText) {
160+
line.setTimeHtml(rtt.getModel().toString().replaceAll(", ","\n"));
161+
} else {
162+
((TimePatternModel)rtt.getModel()).setMode("|" + propertyValue(io.getDepartment(), ApplicationProperty.InstructorSurveyTimePreferencesDept, ApplicationProperty.InstructorSurveyTimePreferences));
163+
line.setTimeHtml("<img border='0' " +
164+
"onmouseover=\"showGwtInstructorAvailabilityHint(this, 'IS#" + survey.getUniqueId() +
165+
"#" + io.getDepartment().getDeptCode() + "');\" onmouseout=\"hideGwtInstructorAvailabilityHint();\" " +
166+
"src='pattern?v=" + (timeVertical ? 1 : 0) + "&d=" + io.getDepartment().getUniqueId() + "&p=" + rtt.getModel().getPreferences() + "' title='"+rtt.getModel().toString()+"' >&nbsp;"
167+
);
168+
}
169+
//line.setTime(rtt.getModel().toString());
170+
} else if (p instanceof DistributionPref) {
171+
if (((DistributionPref)p).getDistributionType().effectiveSurvey()) {
172+
line.addDist(p.preferenceText(instructorNameFormat));
173+
line.addDistHtml(p.preferenceHtml(instructorNameFormat));
174+
}
175+
} else {
176+
line.addRoom(p.preferenceText(instructorNameFormat));
177+
line.addRoomHtml(p.preferenceHtml(instructorNameFormat));
178+
}
179+
}
180+
response.addInstructorRequirement(line);
181+
}
182+
127183
return response;
128184
}
129185

‎WebContent/help/Release-Notes.xml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<name>Instructional Offering Detail: Instructor Requirements</name>
3434
<description>
3535
<line>Ensure that only requirements (instructor surveys) from the correct academic session are listed.</line>
36+
<line>Include instructor surveys for assigned instructors that did not fill in course requirements for the course.</line>
3637
</description>
3738
</item>
3839
<item>

0 commit comments

Comments
 (0)
Please sign in to comment.