Search in sources :

Example 11 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionOpeningRemindersActionTest method allTests.

@Test
public void allTests() throws Exception {
    ______TS("default state of typical data bundle: no sessions opened");
    FeedbackSessionOpeningRemindersAction action = getAction();
    action.execute();
    verifyNoTasksAdded(action);
    ______TS("1 session opened, 1 session opened with disabled opening reminder");
    // Close the session and re-open with the opening time 1 day before
    FeedbackSessionAttributes session1 = dataBundle.feedbackSessions.get("session1InCourse1");
    session1.setStartTime(TimeHelper.getInstantDaysOffsetFromNow(2));
    session1.setEndTime(TimeHelper.getInstantDaysOffsetFromNow(3));
    fsLogic.updateFeedbackSession(session1);
    session1.setStartTime(TimeHelperExtension.getInstantHoursOffsetFromNow(-23));
    fsLogic.updateFeedbackSession(session1);
    // Ditto, but disable the opening reminder, but currently open emails will still be sent regardless
    FeedbackSessionAttributes session2 = dataBundle.feedbackSessions.get("session2InCourse1");
    session2.setStartTime(TimeHelper.getInstantDaysOffsetFromNow(2));
    session2.setEndTime(TimeHelper.getInstantDaysOffsetFromNow(3));
    session2.setOpeningEmailEnabled(false);
    fsLogic.updateFeedbackSession(session2);
    session2.setStartTime(TimeHelperExtension.getInstantHoursOffsetFromNow(-23));
    fsLogic.updateFeedbackSession(session2);
    action = getAction();
    action.execute();
    // 5 students and 5 instructors in course1
    verifySpecifiedTasksAdded(action, Const.TaskQueue.SEND_EMAIL_QUEUE_NAME, 20);
    String courseName = coursesLogic.getCourse(session1.getCourseId()).getName();
    List<TaskWrapper> tasksAdded = action.getTaskQueuer().getTasksAdded();
    for (TaskWrapper task : tasksAdded) {
        Map<String, String[]> paramMap = task.getParamMap();
        try {
            assertEquals(String.format(EmailType.FEEDBACK_OPENING.getSubject(), courseName, session1.getSessionName()), paramMap.get(ParamsNames.EMAIL_SUBJECT)[0]);
        } catch (AssertionError ae) {
            assertEquals(String.format(EmailType.FEEDBACK_OPENING.getSubject(), courseName, session2.getSessionName()), paramMap.get(ParamsNames.EMAIL_SUBJECT)[0]);
        }
    }
    ______TS("2 sessions opened with emails sent");
    session1.setSentOpenEmail(true);
    fsLogic.updateFeedbackSession(session1);
    session2.setSentOpenEmail(true);
    fsLogic.updateFeedbackSession(session2);
    action = getAction();
    action.execute();
    verifyNoTasksAdded(action);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) TaskWrapper(teammates.common.util.TaskWrapper) FeedbackSessionOpeningRemindersAction(teammates.ui.automated.FeedbackSessionOpeningRemindersAction) Test(org.testng.annotations.Test)

Example 12 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class AutomatedSessionRemindersTest method prepareTestData.

@Override
protected void prepareTestData() {
    testData = loadDataBundle("/AutomatedSessionRemindersTest.json");
    /*
         * In this test, we set the email address of the accounts to be the same as the
         * support email address. When running the test against a production server,
         * email alerts will be sent to the specified support email address.
         * The tester should manually check the email box after running the test suite.
         */
    testData.accounts.get("instructorWithEvals").email = Config.SUPPORT_EMAIL;
    testData.instructors.get("AutSessRem.instructor").email = Config.SUPPORT_EMAIL;
    testData.students.get("alice.tmms@AutSessRem.course").email = Config.SUPPORT_EMAIL;
    testData.feedbackSessions.get("closedSession").setCreatorEmail(Config.SUPPORT_EMAIL);
    testData.feedbackSessions.get("closingSession").setCreatorEmail(Config.SUPPORT_EMAIL);
    testData.feedbackSessions.get("openingSession").setCreatorEmail(Config.SUPPORT_EMAIL);
    testData.feedbackSessions.get("publishedSession").setCreatorEmail(Config.SUPPORT_EMAIL);
    testData.feedbackQuestions.get("questionForOpeningSession").creatorEmail = Config.SUPPORT_EMAIL;
    testData.feedbackQuestions.get("questionForClosingSession").creatorEmail = Config.SUPPORT_EMAIL;
    testData.feedbackQuestions.get("questionForPublishedSession").creatorEmail = Config.SUPPORT_EMAIL;
    // Set closing time of one feedback session to tomorrow
    FeedbackSessionAttributes closingFeedbackSession = testData.feedbackSessions.get("closingSession");
    closingFeedbackSession.setEndTime(TimeHelper.getInstantDaysOffsetFromNow(1));
    // Set closing time of one feedback session to 30 mins ago
    FeedbackSessionAttributes closedFeedbackSession = testData.feedbackSessions.get("closedSession");
    closedFeedbackSession.setEndTime(TimeHelperExtension.getInstantMinutesOffsetFromNow(-30));
    // Set opening time for one feedback session to yesterday
    FeedbackSessionAttributes openingFeedbackSession = testData.feedbackSessions.get("openingSession");
    openingFeedbackSession.setStartTime(TimeHelper.getInstantDaysOffsetFromNow(-1));
    // Published time for one feedback session already set to some time in the past.
    removeAndRestoreDataBundle(testData);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes)

Example 13 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionPublishedRemindersActionTest method allTests.

@Test
public void allTests() throws Exception {
    ______TS("default state of typical data bundle: 1 session published with email unsent");
    FeedbackSessionPublishedRemindersAction action = getAction();
    action.execute();
    verifySpecifiedTasksAdded(action, Const.TaskQueue.FEEDBACK_SESSION_PUBLISHED_EMAIL_QUEUE_NAME, 1);
    ______TS("1 session published by moving automated publish time, " + "1 session published similarly with disabled published reminder, " + "1 session published manually");
    // Publish session by moving automated publish time
    FeedbackSessionAttributes session1 = dataBundle.feedbackSessions.get("session1InCourse1");
    session1.setResultsVisibleFromTime(TimeHelper.getInstantDaysOffsetFromNow(-1));
    fsLogic.updateFeedbackSession(session1);
    verifyPresentInDatastore(session1);
    // Publish session by moving automated publish time and disable publish reminder
    FeedbackSessionAttributes session2 = dataBundle.feedbackSessions.get("session2InCourse1");
    session2.setResultsVisibleFromTime(TimeHelper.getInstantDaysOffsetFromNow(-1));
    session2.setPublishedEmailEnabled(false);
    fsLogic.updateFeedbackSession(session2);
    verifyPresentInDatastore(session2);
    // Do a manual publish
    FeedbackSessionAttributes session3 = dataBundle.feedbackSessions.get("gracePeriodSession");
    session3.setResultsVisibleFromTime(Const.TIME_REPRESENTS_LATER);
    fsLogic.updateFeedbackSession(session3);
    fsLogic.publishFeedbackSession(session3);
    verifyPresentInDatastore(session3);
    action = getAction();
    action.execute();
    verifySpecifiedTasksAdded(action, Const.TaskQueue.FEEDBACK_SESSION_PUBLISHED_EMAIL_QUEUE_NAME, 3);
    ______TS("1 session unpublished manually");
    fsLogic.unpublishFeedbackSession(session3);
    action = getAction();
    action.execute();
    verifySpecifiedTasksAdded(action, Const.TaskQueue.FEEDBACK_SESSION_PUBLISHED_EMAIL_QUEUE_NAME, 2);
    ______TS("1 session published with emails sent");
    session1.setSentPublishedEmail(true);
    fsLogic.updateFeedbackSession(session1);
    action = getAction();
    action.execute();
    verifySpecifiedTasksAdded(action, Const.TaskQueue.FEEDBACK_SESSION_PUBLISHED_EMAIL_QUEUE_NAME, 1);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackSessionPublishedRemindersAction(teammates.ui.automated.FeedbackSessionPublishedRemindersAction) Test(org.testng.annotations.Test)

Example 14 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionRemindEmailWorkerActionTest method allTests.

@Test
public void allTests() throws Exception {
    ______TS("Send feedback session reminder email");
    FeedbackSessionAttributes session1 = dataBundle.feedbackSessions.get("session1InCourse1");
    InstructorAttributes instructor1 = dataBundle.instructors.get("instructor1OfCourse1");
    // re-read from Datastore to update the respondents list
    session1 = fsLogic.getFeedbackSession(session1.getFeedbackSessionName(), session1.getCourseId());
    String[] submissionParams = new String[] { ParamsNames.SUBMISSION_FEEDBACK, session1.getFeedbackSessionName(), ParamsNames.SUBMISSION_COURSE, session1.getCourseId(), ParamsNames.USER_ID, instructor1.getGoogleId() };
    FeedbackSessionRemindEmailWorkerAction action = getAction(submissionParams);
    action.execute();
    // 2 students and 4 instructors sent reminder, 1 instructor notified
    verifySpecifiedTasksAdded(action, Const.TaskQueue.SEND_EMAIL_QUEUE_NAME, 7);
    List<String> studentRecipientList = new ArrayList<>();
    for (StudentAttributes student : studentsLogic.getStudentsForCourse(session1.getCourseId())) {
        if (!fsLogic.isFeedbackSessionCompletedByStudent(session1, student.email)) {
            studentRecipientList.add(student.email);
        }
    }
    List<String> instructorRecipientList = new ArrayList<>();
    List<String> instructorNotifiedList = new ArrayList<>();
    for (InstructorAttributes instructor : instructorsLogic.getInstructorsForCourse(session1.getCourseId())) {
        if (!fsLogic.isFeedbackSessionCompletedByInstructor(session1, instructor.email)) {
            instructorRecipientList.add(instructor.email);
        }
    }
    instructorNotifiedList.add(instructorsLogic.getInstructorForGoogleId(session1.getCourseId(), instructor1.getGoogleId()).email);
    String courseName = coursesLogic.getCourse(session1.getCourseId()).getName();
    List<TaskWrapper> tasksAdded = action.getTaskQueuer().getTasksAdded();
    for (TaskWrapper task : tasksAdded) {
        Map<String, String[]> paramMap = task.getParamMap();
        assertEquals(String.format(EmailType.FEEDBACK_SESSION_REMINDER.getSubject(), courseName, session1.getSessionName()), paramMap.get(ParamsNames.EMAIL_SUBJECT)[0]);
        String header = "The email below has been sent to students of course: [" + session1.getCourseId() + "]";
        String content = paramMap.get(ParamsNames.EMAIL_CONTENT)[0];
        String recipient = paramMap.get(ParamsNames.EMAIL_RECEIVER)[0];
        if (content.contains(header)) {
            // notification to only requesting instructors
            assertTrue(instructorNotifiedList.contains(recipient));
            instructorNotifiedList.remove(recipient);
            continue;
        }
        if (studentRecipientList.contains(recipient)) {
            studentRecipientList.remove(recipient);
            continue;
        }
        if (instructorRecipientList.contains(recipient)) {
            instructorRecipientList.remove(recipient);
            continue;
        }
        fail("Email recipient " + recipient + " is not in the list!");
    }
    // Ensure that every email recipient is accounted for
    assertTrue(String.valueOf(studentRecipientList.size()), studentRecipientList.isEmpty());
    assertTrue(String.valueOf(instructorRecipientList.size()), instructorRecipientList.isEmpty());
    assertTrue(instructorNotifiedList.isEmpty());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) TaskWrapper(teammates.common.util.TaskWrapper) FeedbackSessionRemindEmailWorkerAction(teammates.ui.automated.FeedbackSessionRemindEmailWorkerAction) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 15 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionUnpublishedEmailWorkerActionTest method allTests.

@Test
public void allTests() {
    FeedbackSessionAttributes session1 = dataBundle.feedbackSessions.get("session1InCourse1");
    String[] submissionParams = new String[] { ParamsNames.EMAIL_COURSE, session1.getCourseId(), ParamsNames.EMAIL_FEEDBACK, session1.getFeedbackSessionName() };
    FeedbackSessionUnpublishedEmailWorkerAction action = getAction(submissionParams);
    action.execute();
    // 5 students and 5 instructors in course1
    verifySpecifiedTasksAdded(action, Const.TaskQueue.SEND_EMAIL_QUEUE_NAME, 10);
    String courseName = coursesLogic.getCourse(session1.getCourseId()).getName();
    List<TaskWrapper> tasksAdded = action.getTaskQueuer().getTasksAdded();
    for (TaskWrapper task : tasksAdded) {
        Map<String, String[]> paramMap = task.getParamMap();
        assertEquals(String.format(EmailType.FEEDBACK_UNPUBLISHED.getSubject(), courseName, session1.getSessionName()), paramMap.get(ParamsNames.EMAIL_SUBJECT)[0]);
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) TaskWrapper(teammates.common.util.TaskWrapper) FeedbackSessionUnpublishedEmailWorkerAction(teammates.ui.automated.FeedbackSessionUnpublishedEmailWorkerAction) Test(org.testng.annotations.Test)

Aggregations

FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)205 Test (org.testng.annotations.Test)85 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)78 ArrayList (java.util.ArrayList)47 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)35 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)32 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)30 RedirectResult (teammates.ui.controller.RedirectResult)27 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)21 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)19 StatusMessage (teammates.common.util.StatusMessage)19 HashMap (java.util.HashMap)17 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)13 EmailWrapper (teammates.common.util.EmailWrapper)12 Text (com.google.appengine.api.datastore.Text)11 DataBundle (teammates.common.datatransfer.DataBundle)11 EmailGenerator (teammates.logic.api.EmailGenerator)10 List (java.util.List)9 TaskWrapper (teammates.common.util.TaskWrapper)9