use of teammates.common.datatransfer.FeedbackSessionStats in project teammates by TEAMMATES.
the class FeedbackSessionsLogicTest method testGetFeedbackSessionDetailsForInstructor.
private void testGetFeedbackSessionDetailsForInstructor() throws Exception {
// This file contains a session with a private session + a standard
// session + a special session with all questions without recipients.
DataBundle newDataBundle = loadDataBundle("/FeedbackSessionDetailsTest.json");
removeAndRestoreDataBundle(newDataBundle);
Map<String, FeedbackSessionDetailsBundle> detailsMap = new HashMap<>();
String instrGoogleId = newDataBundle.instructors.get("instructor1OfCourse1").googleId;
List<FeedbackSessionDetailsBundle> detailsList = fsLogic.getFeedbackSessionDetailsForInstructor(instrGoogleId);
List<String> expectedSessions = new ArrayList<>();
expectedSessions.add(newDataBundle.feedbackSessions.get("standard.session").toString());
expectedSessions.add(newDataBundle.feedbackSessions.get("no.responses.session").toString());
expectedSessions.add(newDataBundle.feedbackSessions.get("no.recipients.session").toString());
expectedSessions.add(newDataBundle.feedbackSessions.get("private.session").toString());
StringBuilder actualSessionsBuilder = new StringBuilder();
for (FeedbackSessionDetailsBundle details : detailsList) {
actualSessionsBuilder.append(details.feedbackSession.toString());
detailsMap.put(details.feedbackSession.getFeedbackSessionName() + "%" + details.feedbackSession.getCourseId(), details);
}
String actualSessions = actualSessionsBuilder.toString();
______TS("standard session");
assertEquals(4, detailsList.size());
AssertHelper.assertContains(expectedSessions, actualSessions);
FeedbackSessionStats stats = detailsMap.get(newDataBundle.feedbackSessions.get("standard.session").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("standard.session").getCourseId()).stats;
// 2 instructors, 6 students = 8
assertEquals(8, stats.expectedTotal);
// 1 instructor, 1 student, did not respond => 8-2=6
assertEquals(6, stats.submittedTotal);
______TS("No recipients session");
stats = detailsMap.get(newDataBundle.feedbackSessions.get("no.recipients.session").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("no.recipients.session").getCourseId()).stats;
// 2 instructors, 6 students = 8
assertEquals(8, stats.expectedTotal);
// only 1 student responded
assertEquals(1, stats.submittedTotal);
______TS("No responses session");
stats = detailsMap.get(newDataBundle.feedbackSessions.get("no.responses.session").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("no.responses.session").getCourseId()).stats;
// 1 instructors, 1 students = 2
assertEquals(2, stats.expectedTotal);
// no responses
assertEquals(0, stats.submittedTotal);
______TS("private session with questions");
stats = detailsMap.get(newDataBundle.feedbackSessions.get("private.session").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("private.session").getCourseId()).stats;
assertEquals(1, stats.expectedTotal);
// For private sessions, we mark as completed only when creator has finished all questions.
assertEquals(0, stats.submittedTotal);
______TS("change private session to non-private");
FeedbackSessionAttributes privateSession = newDataBundle.feedbackSessions.get("private.session");
privateSession.setSessionVisibleFromTime(privateSession.getStartTime());
privateSession.setEndTime(TimeHelper.parseInstant("2015-04-01 2:00 PM +0000"));
privateSession.setFeedbackSessionType(FeedbackSessionType.STANDARD);
fsLogic.updateFeedbackSession(privateSession);
// Re-read details
detailsList = fsLogic.getFeedbackSessionDetailsForInstructor(newDataBundle.instructors.get("instructor1OfCourse1").googleId);
for (FeedbackSessionDetailsBundle details : detailsList) {
if (details.feedbackSession.getFeedbackSessionName().equals(newDataBundle.feedbackSessions.get("private.session").getFeedbackSessionName())) {
stats = details.stats;
break;
}
}
// 1 instructor (creator only), 6 students = 8
assertEquals(7, stats.expectedTotal);
// 1 instructor, 1 student responded
assertEquals(2, stats.submittedTotal);
______TS("private session without questions");
expectedSessions.clear();
expectedSessions.add(newDataBundle.feedbackSessions.get("private.session.noquestions").toString());
expectedSessions.add(newDataBundle.feedbackSessions.get("private.session.done").toString());
detailsList = fsLogic.getFeedbackSessionDetailsForInstructor(newDataBundle.instructors.get("instructor2OfCourse1").googleId);
detailsMap.clear();
actualSessionsBuilder = new StringBuilder();
for (FeedbackSessionDetailsBundle details : detailsList) {
actualSessionsBuilder.append(details.feedbackSession.toString());
detailsMap.put(details.feedbackSession.getFeedbackSessionName() + "%" + details.feedbackSession.getCourseId(), details);
}
actualSessions = actualSessionsBuilder.toString();
AssertHelper.assertContains(expectedSessions, actualSessions);
stats = detailsMap.get(newDataBundle.feedbackSessions.get("private.session.noquestions").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("private.session.noquestions").getCourseId()).stats;
assertEquals(0, stats.expectedTotal);
assertEquals(0, stats.submittedTotal);
______TS("completed private session");
stats = detailsMap.get(newDataBundle.feedbackSessions.get("private.session.done").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("private.session.done").getCourseId()).stats;
assertEquals(1, stats.expectedTotal);
assertEquals(1, stats.submittedTotal);
______TS("private session with questions with no recipients");
expectedSessions.clear();
expectedSessions.add(newDataBundle.feedbackSessions.get("private.session.norecipients").toString());
detailsList = fsLogic.getFeedbackSessionDetailsForInstructor(newDataBundle.instructors.get("instructor1OfCourse3").googleId);
detailsMap.clear();
actualSessions = "";
actualSessionsBuilder = new StringBuilder();
for (FeedbackSessionDetailsBundle details : detailsList) {
actualSessionsBuilder.append(details.feedbackSession.toString());
detailsMap.put(details.feedbackSession.getFeedbackSessionName() + "%" + details.feedbackSession.getCourseId(), details);
}
actualSessions = actualSessionsBuilder.toString();
AssertHelper.assertContains(expectedSessions, actualSessions);
stats = detailsMap.get(newDataBundle.feedbackSessions.get("private.session.norecipients").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("private.session.norecipients").getCourseId()).stats;
assertEquals(0, stats.expectedTotal);
assertEquals(0, stats.submittedTotal);
______TS("instructor does not exist");
assertTrue(fsLogic.getFeedbackSessionDetailsForInstructor("non-existent.google.id").isEmpty());
}
Aggregations