Search in sources :

Example 6 with FeedbackSessionsDb

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());
}
Also used : FeedbackSessionsDb(teammates.storage.api.FeedbackSessionsDb) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) RedirectResult(teammates.ui.controller.RedirectResult) InstructorFeedbackSubmissionEditSaveAction(teammates.ui.controller.InstructorFeedbackSubmissionEditSaveAction) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 7 with FeedbackSessionsDb

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);
}
Also used : FeedbackSessionsDb(teammates.storage.api.FeedbackSessionsDb) Instant(java.time.Instant)

Aggregations

FeedbackSessionsDb (teammates.storage.api.FeedbackSessionsDb)7 Test (org.testng.annotations.Test)5 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)5 RedirectResult (teammates.ui.controller.RedirectResult)5 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)3 Instant (java.time.Instant)2 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)2 NullPostParameterException (teammates.common.exception.NullPostParameterException)2 StudentFeedbackSubmissionEditSaveAction (teammates.ui.controller.StudentFeedbackSubmissionEditSaveAction)2 ArrayList (java.util.ArrayList)1 DataBundle (teammates.common.datatransfer.DataBundle)1 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)1 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)1 FeedbackNumericalScaleQuestionDetails (teammates.common.datatransfer.questions.FeedbackNumericalScaleQuestionDetails)1 EntityNotFoundException (teammates.common.exception.EntityNotFoundException)1 EmailWrapper (teammates.common.util.EmailWrapper)1 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)1 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)1 StudentsDb (teammates.storage.api.StudentsDb)1 InstructorFeedbackDeleteAction (teammates.ui.controller.InstructorFeedbackDeleteAction)1