use of teammates.storage.api.FeedbackSessionsDb in project teammates by TEAMMATES.
the class InstructorFeedbackSubmissionEditSaveActionTest method testGracePeriodExecuteAndPostProcess.
@Test
public void testGracePeriodExecuteAndPostProcess() throws Exception {
dataBundle = loadDataBundle("/InstructorFeedbackSubmissionEditSaveActionTest.json");
FeedbackSessionsDb feedbackSessionDb = new FeedbackSessionsDb();
FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("Grace Period Session");
InstructorAttributes instructor = dataBundle.instructors.get("instructor1InCourse1");
gaeSimulation.loginAsInstructor(instructor.googleId);
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName() };
______TS("opened");
fs.setEndTime(TimeHelper.getInstantDaysOffsetFromNow(1));
feedbackSessionDb.updateFeedbackSession(fs);
assertTrue(fs.isOpened());
assertFalse(fs.isInGracePeriod());
InstructorFeedbackSubmissionEditSaveAction a = getAction(submissionParams);
RedirectResult r = getRedirectResult(a);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, false, "instructor1InCourse1"), r.getDestinationWithParams());
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
assertFalse(r.isError);
______TS("during grace period");
fs.setEndTime(Instant.now());
feedbackSessionDb.updateFeedbackSession(fs);
assertFalse(fs.isOpened());
assertTrue(fs.isInGracePeriod());
a = getAction(submissionParams);
r = getRedirectResult(a);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, false, "instructor1InCourse1"), r.getDestinationWithParams());
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
assertFalse(r.isError);
______TS("after grace period");
fs.setEndTime(TimeHelper.getInstantDaysOffsetFromNow(-10));
feedbackSessionDb.updateFeedbackSession(fs);
assertFalse(fs.isOpened());
assertFalse(fs.isInGracePeriod());
a = getAction(submissionParams);
r = getRedirectResult(a);
assertEquals(Const.StatusMessages.FEEDBACK_SUBMISSIONS_NOT_OPEN, r.getStatusMessage());
}
use of teammates.storage.api.FeedbackSessionsDb in project teammates by TEAMMATES.
the class InstructorFeedbackUnpublishActionTest method modifyFeedbackSessionPublishState.
private void modifyFeedbackSessionPublishState(FeedbackSessionAttributes session, boolean isPublished) throws Exception {
// startTime < endTime <= resultsVisibleFromTime
Instant startTime = TimeHelper.getInstantDaysOffsetFromNow(-2);
Instant endTime = TimeHelper.getInstantDaysOffsetFromNow(-1);
Instant resultsVisibleFromTimeForPublishedSession = TimeHelper.getInstantDaysOffsetFromNow(-1);
session.setStartTime(startTime);
session.setEndTime(endTime);
if (isPublished) {
session.setResultsVisibleFromTime(resultsVisibleFromTimeForPublishedSession);
assertTrue(session.isPublished());
} else {
session.setResultsVisibleFromTime(Const.TIME_REPRESENTS_LATER);
assertFalse(session.isPublished());
}
session.setSentPublishedEmail(true);
new FeedbackSessionsDb().updateFeedbackSession(session);
}
Aggregations