Search in sources :

Example 6 with FeedbackSessionAttributes

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

the class FeedbackSessionAttributesTest method testValidate.

@Test
public void testValidate() {
    ______TS("invalid parameter error messages");
    FeedbackSessionAttributes feedbackSessionAttributes = FeedbackSessionAttributes.builder("", "", "").withStartTime(Instant.now()).withEndTime(Instant.now()).withCreatedTime(Instant.now()).withResultsVisibleFromTime(Instant.now()).withSessionVisibleFromTime(Instant.now()).withGracePeriodMinutes(-100).build();
    assertEquals(feedbackSessionAttributes.getInvalidityInfo(), buildExpectedErrorMessages());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) Test(org.testng.annotations.Test)

Example 7 with FeedbackSessionAttributes

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

the class StudentHomePageUiTest method prepareTestData.

@Override
protected void prepareTestData() {
    testData = loadDataBundle("/StudentHomePageUiTest.json");
    // use the 1st student account injected for this test
    String student1GoogleId = TestProperties.TEST_STUDENT1_ACCOUNT;
    String student1Email = student1GoogleId + "@gmail.com";
    testData.accounts.get("alice.tmms").googleId = student1GoogleId;
    testData.accounts.get("alice.tmms").email = student1Email;
    testData.students.get("alice.tmms@SHomeUiT.CS2104").email = student1Email;
    testData.students.get("alice.tmms@SHomeUiT.CS1101").googleId = student1GoogleId;
    testData.students.get("alice.tmms@SHomeUiT.CS1101").email = student1Email;
    testData.students.get("alice.tmms@SHomeUiT.CS4215").googleId = student1GoogleId;
    testData.students.get("alice.tmms@SHomeUiT.CS4215").email = student1Email;
    testData.students.get("alice.tmms@SHomeUiT.CS4221").googleId = student1GoogleId;
    testData.students.get("alice.tmms@SHomeUiT.CS4221").email = student1Email;
    removeAndRestoreDataBundle(testData);
    FeedbackSessionAttributes gracedFeedbackSession = BackDoor.getFeedbackSession("SHomeUiT.CS2104", "Graced Feedback Session");
    gracedFeedbackSession.setEndTime(Instant.now());
    BackDoor.editFeedbackSession(gracedFeedbackSession);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes)

Example 8 with FeedbackSessionAttributes

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

the class FeedbackResponseAdjustmentWorkerActionTest method allTests.

@Test
public void allTests() throws Exception {
    ______TS("typical case : existing student changes team");
    FeedbackSessionAttributes session = dataBundle.feedbackSessions.get("session2InCourse1");
    StudentAttributes student = dataBundle.students.get("student1InCourse1");
    // Verify pre-existing submissions and responses
    List<FeedbackResponseAttributes> oldResponsesForSession = getAllResponsesForStudentForSession(student, session.getFeedbackSessionName());
    assertFalse(oldResponsesForSession.isEmpty());
    String oldTeam = student.team;
    String oldSection = student.section;
    String newTeam = "Team 1.2";
    String newSection = "Section 2";
    student.team = newTeam;
    student.section = newSection;
    StudentEnrollDetails enrollDetails = new StudentEnrollDetails(StudentUpdateStatus.MODIFIED, student.course, student.email, oldTeam, newTeam, oldSection, newSection);
    List<StudentEnrollDetails> enrollList = new ArrayList<>();
    enrollList.add(enrollDetails);
    studentsLogic.updateStudentCascadeWithSubmissionAdjustmentScheduled(student.email, student, false);
    String[] submissionParams = new String[] { ParamsNames.COURSE_ID, student.course, ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), ParamsNames.ENROLLMENT_DETAILS, JsonUtils.toJson(enrollList) };
    FeedbackResponseAdjustmentWorkerAction action = getAction(submissionParams);
    action.execute();
    List<FeedbackResponseAttributes> newResponsesForSession = getAllResponsesForStudentForSession(student, session.getFeedbackSessionName());
    assertTrue(newResponsesForSession.isEmpty());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackResponseAdjustmentWorkerAction(teammates.ui.automated.FeedbackResponseAdjustmentWorkerAction) StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 9 with FeedbackSessionAttributes

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

the class FeedbackSessionClosedRemindersActionTest method allTests.

@Test
public void allTests() throws Exception {
    ______TS("default state of typical data bundle: 0 sessions closed recently");
    FeedbackSessionClosedRemindersAction action = getAction();
    action.execute();
    verifyNoTasksAdded(action);
    ______TS("1 session closed recently, 1 session closed recently with disabled closed reminder, " + "1 session closed recently but still in grace period");
    // Session is closed recently
    FeedbackSessionAttributes session1 = dataBundle.feedbackSessions.get("session1InCourse1");
    session1.setTimeZone(ZoneId.of("UTC"));
    session1.setStartTime(TimeHelper.getInstantDaysOffsetFromNow(-2));
    session1.setEndTime(TimeHelperExtension.getInstantHoursOffsetFromNow(-1));
    fsLogic.updateFeedbackSession(session1);
    verifyPresentInDatastore(session1);
    // Ditto, but with disabled closed reminder
    FeedbackSessionAttributes session2 = dataBundle.feedbackSessions.get("session2InCourse1");
    session2.setTimeZone(ZoneId.of("UTC"));
    session2.setStartTime(TimeHelper.getInstantDaysOffsetFromNow(-2));
    session2.setEndTime(TimeHelperExtension.getInstantHoursOffsetFromNow(-1));
    session2.setClosingEmailEnabled(false);
    fsLogic.updateFeedbackSession(session2);
    verifyPresentInDatastore(session2);
    // Still in grace period; closed reminder should not be sent
    FeedbackSessionAttributes session3 = dataBundle.feedbackSessions.get("gracePeriodSession");
    session3.setTimeZone(ZoneId.of("UTC"));
    session3.setStartTime(TimeHelper.getInstantDaysOffsetFromNow(-2));
    session3.setEndTime(Instant.now());
    fsLogic.updateFeedbackSession(session3);
    verifyPresentInDatastore(session3);
    action = getAction();
    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_CLOSED.getSubject(), courseName, session1.getSessionName()), paramMap.get(ParamsNames.EMAIL_SUBJECT)[0]);
    }
    ______TS("1 session closed recently with closed emails sent");
    session1.setSentClosedEmail(true);
    fsLogic.updateFeedbackSession(session1);
    action = getAction();
    action.execute();
    verifyNoTasksAdded(action);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) TaskWrapper(teammates.common.util.TaskWrapper) FeedbackSessionClosedRemindersAction(teammates.ui.automated.FeedbackSessionClosedRemindersAction) Test(org.testng.annotations.Test)

Example 10 with FeedbackSessionAttributes

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

the class FeedbackSessionClosingRemindersActionTest method allTests.

@Test
public void allTests() throws Exception {
    ______TS("default state of typical data bundle: 0 sessions closing soon");
    FeedbackSessionClosingRemindersAction action = getAction();
    action.execute();
    verifyNoTasksAdded(action);
    ______TS("1 session closing soon, 1 session closing soon with disabled closing reminder, " + "1 session closing soon but not yet opened");
    // Modify session to close in 24 hours
    FeedbackSessionAttributes session1 = dataBundle.feedbackSessions.get("session1InCourse1");
    session1.setTimeZone(ZoneId.of("UTC"));
    session1.setStartTime(TimeHelper.getInstantDaysOffsetFromNow(-1));
    session1.setEndTime(TimeHelper.getInstantDaysOffsetFromNow(1));
    fsLogic.updateFeedbackSession(session1);
    verifyPresentInDatastore(session1);
    // Ditto, but disable the closing reminder
    FeedbackSessionAttributes session2 = dataBundle.feedbackSessions.get("session2InCourse2");
    session2.setTimeZone(ZoneId.of("UTC"));
    session2.setStartTime(TimeHelper.getInstantDaysOffsetFromNow(-1));
    session2.setEndTime(TimeHelper.getInstantDaysOffsetFromNow(1));
    session2.setClosingEmailEnabled(false);
    fsLogic.updateFeedbackSession(session2);
    verifyPresentInDatastore(session2);
    // 1 session not yet opened; do not send the closing reminder
    FeedbackSessionAttributes session3 = dataBundle.feedbackSessions.get("gracePeriodSession");
    session3.setTimeZone(ZoneId.of("UTC"));
    session3.setStartTime(TimeHelperExtension.getInstantHoursOffsetFromNow(1));
    session3.setEndTime(TimeHelper.getInstantDaysOffsetFromNow(1));
    fsLogic.updateFeedbackSession(session3);
    verifyPresentInDatastore(session3);
    action = getAction();
    action.execute();
    // 5 students and 5 instructors in course1, 2 students have completed the feedback session
    verifySpecifiedTasksAdded(action, Const.TaskQueue.SEND_EMAIL_QUEUE_NAME, 8);
    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_CLOSING.getSubject(), courseName, session1.getSessionName()), paramMap.get(ParamsNames.EMAIL_SUBJECT)[0]);
    }
    ______TS("1 session closing soon with emails sent");
    session1.setSentClosingEmail(true);
    fsLogic.updateFeedbackSession(session1);
    action = getAction();
    action.execute();
    verifyNoTasksAdded(action);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackSessionClosingRemindersAction(teammates.ui.automated.FeedbackSessionClosingRemindersAction) TaskWrapper(teammates.common.util.TaskWrapper) 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