Search in sources :

Example 66 with StudentAttributes

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

the class FeedbackResponsesLogicTest method testUpdateFeedbackResponsesForChangingTeam_deleteNotLastResponse_sameResponseRate.

private void testUpdateFeedbackResponsesForChangingTeam_deleteNotLastResponse_sameResponseRate() throws Exception {
    FeedbackResponseAttributes responseToBeDeleted = getResponseFromDatastore(questionTypeBundle, "response1ForQ1S5C1");
    // make sure it's not the last response by the student
    assertTrue(1 < numResponsesFromGiverInSession(responseToBeDeleted.giver, responseToBeDeleted.feedbackSessionName, responseToBeDeleted.courseId));
    StudentAttributes student = questionTypeBundle.students.get("student1InCourse1");
    StudentEnrollDetails enrollmentDetailsToTriggerDeletion = new StudentEnrollDetails(StudentUpdateStatus.MODIFIED, student.course, student.email, student.team, student.team + "tmp", student.section, student.section + "tmp");
    int originalResponseRate = getResponseRate(responseToBeDeleted.feedbackSessionName, responseToBeDeleted.courseId);
    assertTrue(frLogic.updateFeedbackResponseForChangingTeam(enrollmentDetailsToTriggerDeletion, responseToBeDeleted));
    int responseRateAfterDeletion = getResponseRate(responseToBeDeleted.feedbackSessionName, responseToBeDeleted.courseId);
    assertEquals(originalResponseRate, responseRateAfterDeletion);
    // restore DataStore so other tests are unaffected
    restoreStudentFeedbackResponseToDatastore(responseToBeDeleted);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 67 with StudentAttributes

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

the class FeedbackResponsesLogicTest method testIsNameVisibleTo.

private void testIsNameVisibleTo() {
    ______TS("testIsNameVisibleTo");
    InstructorAttributes instructor = dataBundle.instructors.get("instructor1OfCourse1");
    StudentAttributes student = dataBundle.students.get("student1InCourse1");
    StudentAttributes student2 = dataBundle.students.get("student2InCourse1");
    StudentAttributes student3 = dataBundle.students.get("student3InCourse1");
    StudentAttributes student5 = dataBundle.students.get("student5InCourse1");
    FeedbackQuestionAttributes fq = getQuestionFromDatastore("qn3InSession1InCourse1");
    FeedbackResponseAttributes fr = getResponseFromDatastore("response1ForQ3S1C1");
    CourseRoster roster = new CourseRoster(new StudentsDb().getStudentsForCourse(fq.courseId), new InstructorsDb().getInstructorsForCourse(fq.courseId));
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, instructor.email, UserRole.INSTRUCTOR, true, roster));
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, instructor.email, UserRole.INSTRUCTOR, false, roster));
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student.email, UserRole.STUDENT, false, roster));
    ______TS("test if visible to own team members");
    fr.giver = student.email;
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student.email, UserRole.STUDENT, false, roster));
    ______TS("test if visible to receiver/reciever team members");
    fq.recipientType = FeedbackParticipantType.TEAMS;
    fq.showRecipientNameTo.clear();
    fq.showRecipientNameTo.add(FeedbackParticipantType.RECEIVER);
    fr.recipient = student.team;
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student.email, UserRole.STUDENT, false, roster));
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student3.email, UserRole.STUDENT, false, roster));
    fq.recipientType = FeedbackParticipantType.STUDENTS;
    fr.recipient = student.email;
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student.email, UserRole.STUDENT, false, roster));
    assertFalse(frLogic.isNameVisibleToUser(fq, fr, student2.email, UserRole.STUDENT, false, roster));
    fq.recipientType = FeedbackParticipantType.TEAMS;
    fq.showRecipientNameTo.clear();
    fq.showRecipientNameTo.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    fr.recipient = student.team;
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student.email, UserRole.STUDENT, false, roster));
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student3.email, UserRole.STUDENT, false, roster));
    fq.recipientType = FeedbackParticipantType.STUDENTS;
    fr.recipient = student.email;
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student.email, UserRole.STUDENT, false, roster));
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student2.email, UserRole.STUDENT, false, roster));
    assertFalse(frLogic.isNameVisibleToUser(fq, fr, student5.email, UserRole.STUDENT, false, roster));
    ______TS("test anonymous team recipients");
    // Only members of the recipient team should be able to see the recipient name
    fq.recipientType = FeedbackParticipantType.TEAMS;
    fq.showRecipientNameTo.clear();
    fq.showRecipientNameTo.add(FeedbackParticipantType.RECEIVER);
    fq.showResponsesTo.add(FeedbackParticipantType.STUDENTS);
    fr.recipient = "Team 1.1";
    assertFalse(frLogic.isNameVisibleToUser(fq, fr, student5.email, UserRole.STUDENT, false, roster));
    ______TS("null question");
    assertFalse(frLogic.isNameVisibleToUser(null, fr, student.email, UserRole.STUDENT, false, roster));
}
Also used : InstructorsDb(teammates.storage.api.InstructorsDb) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) CourseRoster(teammates.common.datatransfer.CourseRoster) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) StudentsDb(teammates.storage.api.StudentsDb) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 68 with StudentAttributes

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

the class FeedbackSessionsLogicTest method testIsFeedbackSessionFullyCompletedByStudent.

private void testIsFeedbackSessionFullyCompletedByStudent() throws Exception {
    FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("session1InCourse1");
    StudentAttributes student1OfCourse1 = dataBundle.students.get("student1InCourse1");
    StudentAttributes student3OfCourse1 = dataBundle.students.get("student3InCourse1");
    ______TS("failure: non-existent feedback session for student");
    try {
        fsLogic.isFeedbackSessionFullyCompletedByStudent("nonExistentFSName", fs.getCourseId(), "random.student@email");
        signalFailureToDetectException();
    } catch (EntityDoesNotExistException edne) {
        assertEquals("Trying to check a non-existent feedback session: " + fs.getCourseId() + "/" + "nonExistentFSName", edne.getMessage());
    }
    ______TS("success case: fully done by student 1");
    assertTrue(fsLogic.isFeedbackSessionFullyCompletedByStudent(fs.getFeedbackSessionName(), fs.getCourseId(), student1OfCourse1.email));
    ______TS("success case: partially done by student 3");
    assertFalse(fsLogic.isFeedbackSessionFullyCompletedByStudent(fs.getFeedbackSessionName(), fs.getCourseId(), student3OfCourse1.email));
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 69 with StudentAttributes

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

the class FeedbackSessionsLogicTest method testGetFeedbackSessionResultsForUser.

private void testGetFeedbackSessionResultsForUser() throws Exception {
    // This file contains a session with a private session + a standard
    // session which needs to have enough qn/response combinations to cover as much
    // of the SUT as possible
    DataBundle responseBundle = loadDataBundle("/FeedbackSessionResultsTest.json");
    removeAndRestoreDataBundle(responseBundle);
    ______TS("standard session with varied visibilities");
    FeedbackSessionAttributes session = responseBundle.feedbackSessions.get("standard.session");
    /**
     * Test result bundle for student1 **
     */
    StudentAttributes student = responseBundle.students.get("student1InCourse1");
    FeedbackSessionResultsBundle results = fsLogic.getFeedbackSessionResultsForStudent(session.getFeedbackSessionName(), session.getCourseId(), student.email);
    // We just check for correct session once
    assertEquals(session.toString(), results.feedbackSession.toString());
    // Student can see responses: q1r1, q2r1,3, q3r1, qr4r2-3, q5r1, q7r1-2, q8r1-2
    // We don't check the actual IDs as this is also implicitly tested
    // later when checking the visibility table.
    assertEquals(11, results.responses.size());
    assertEquals(7, results.questions.size());
    // Test the user email-name maps used for display purposes
    String mapString = results.emailNameTable.toString();
    List<String> expectedStrings = new ArrayList<>();
    String student2AnonEmail = getStudentAnonEmail(responseBundle, "student2InCourse1");
    String student2AnonName = getStudentAnonName(responseBundle, "student2InCourse1");
    String student4AnonEmail = getStudentAnonEmail(responseBundle, "student4InCourse1");
    String student4AnonName = getStudentAnonName(responseBundle, "student4InCourse1");
    Collections.addAll(expectedStrings, "FSRTest.student1InCourse1@gmail.tmt=student1 In Course1", "FSRTest.student2InCourse1@gmail.tmt=student2 In Course1", "FSRTest.student4InCourse1@gmail.tmt=student4 In Course1", "Team 1.1</td></div>'\"=Team 1.1</td></div>'\"", "Team 1.2=Team 1.2", "Team 1.3=Team 1.3", "Team 1.4=Team 1.4", "FSRTest.instr1@course1.tmt=Instructor1 Course1", "FSRTest.student1InCourse1@gmail.tmt" + Const.TEAM_OF_EMAIL_OWNER + "=Team 1.1", "FSRTest.student2InCourse1@gmail.tmt" + Const.TEAM_OF_EMAIL_OWNER + "=Team 1.1", "FSRTest.student4InCourse1@gmail.tmt" + Const.TEAM_OF_EMAIL_OWNER + "=Team 1.2", student2AnonEmail + "=" + student2AnonName, student4AnonEmail + "=" + student4AnonName);
    AssertHelper.assertContains(expectedStrings, mapString);
    assertEquals(13, results.emailNameTable.size());
    // Test the user email-teamName maps used for display purposes
    mapString = results.emailTeamNameTable.toString();
    expectedStrings.clear();
    Collections.addAll(expectedStrings, "FSRTest.student4InCourse1@gmail.tmt=Team 1.2", "FSRTest.student1InCourse1@gmail.tmt=Team 1.1</td></div>'\"", "FSRTest.student1InCourse1@gmail.tmt's Team=", "FSRTest.student2InCourse1@gmail.tmt's Team=", "FSRTest.student4InCourse1@gmail.tmt's Team=", "FSRTest.student2InCourse1@gmail.tmt=Team 1.1</td></div>'\"", "Team 1.1</td></div>'\"=", "Team 1.3=", "Team 1.2=", "Team 1.4=", "FSRTest.instr1@course1.tmt=Instructors", student2AnonEmail + "=" + student2AnonName + Const.TEAM_OF_EMAIL_OWNER, student4AnonEmail + "=" + student4AnonName + Const.TEAM_OF_EMAIL_OWNER);
    AssertHelper.assertContains(expectedStrings, mapString);
    assertEquals(13, results.emailTeamNameTable.size());
    // Test 'Append TeamName to Name' for display purposes with Typical Cases
    expectedStrings.clear();
    List<String> actualStrings = new ArrayList<>();
    for (FeedbackResponseAttributes response : results.responses) {
        String giverName = results.getNameForEmail(response.giver);
        String giverTeamName = results.getTeamNameForEmail(response.giver);
        giverName = results.appendTeamNameToName(giverName, giverTeamName);
        String recipientName = results.getNameForEmail(response.recipient);
        String recipientTeamName = results.getTeamNameForEmail(response.recipient);
        recipientName = results.appendTeamNameToName(recipientName, recipientTeamName);
        actualStrings.add(giverName);
        actualStrings.add(recipientName);
    }
    Collections.addAll(expectedStrings, getStudentAnonName(responseBundle, "student2InCourse1"), getStudentAnonName(responseBundle, "student4InCourse1"), "student1 In Course1</td></div>'\" (Team 1.1</td></div>'\")", "student2 In Course1 (Team 1.1</td></div>'\")", "student4 In Course1 (Team 1.2)", "Instructor1 Course1 (Instructors)", "Team 1.1</td></div>'\"", "Team 1.2", "Team 1.3", "Team 1.4");
    AssertHelper.assertContains(expectedStrings, actualStrings.toString());
    // Test 'Append TeamName to Name' for display purposes with Special Cases
    expectedStrings.clear();
    actualStrings.clear();
    // case: Unknown User
    String unknownUserName = Const.USER_UNKNOWN_TEXT;
    String someTeamName = "Some Team Name";
    unknownUserName = results.appendTeamNameToName(unknownUserName, someTeamName);
    actualStrings.add(unknownUserName);
    // case: Nobody
    String nobodyUserName = Const.USER_NOBODY_TEXT;
    nobodyUserName = results.appendTeamNameToName(nobodyUserName, someTeamName);
    actualStrings.add(nobodyUserName);
    // case: Anonymous User
    String anonymousUserName = Const.DISPLAYED_NAME_FOR_ANONYMOUS_PARTICIPANT + " " + System.currentTimeMillis();
    anonymousUserName = results.appendTeamNameToName(anonymousUserName, someTeamName);
    actualStrings.add(anonymousUserName);
    Collections.addAll(expectedStrings, Const.USER_UNKNOWN_TEXT, Const.USER_NOBODY_TEXT, anonymousUserName);
    assertEquals(expectedStrings.toString(), actualStrings.toString());
    // Test the generated response visibilityTable for userNames.
    mapString = tableToString(results.visibilityTable);
    expectedStrings.clear();
    Collections.addAll(expectedStrings, getResponseId("qn1.resp1", responseBundle) + "={true,true}", getResponseId("qn2.resp1", responseBundle) + "={true,true}", getResponseId("qn2.resp3", responseBundle) + "={true,true}", getResponseId("qn3.resp1", responseBundle) + "={true,true}", getResponseId("qn4.resp2", responseBundle) + "={true,true}", getResponseId("qn4.resp3", responseBundle) + "={false,true}", getResponseId("qn5.resp1", responseBundle) + "={true,false}", getResponseId("qn7.resp1", responseBundle) + "={true,true}", getResponseId("qn7.resp2", responseBundle) + "={true,true}", getResponseId("qn8.resp1", responseBundle) + "={true,true}", getResponseId("qn8.resp2", responseBundle) + "={true,true}");
    AssertHelper.assertContains(expectedStrings, mapString);
    assertEquals(11, results.visibilityTable.size());
    /**
     * Test result bundle for instructor1 within a course **
     */
    InstructorAttributes instructor = responseBundle.instructors.get("instructor1OfCourse1");
    results = fsLogic.getFeedbackSessionResultsForInstructor(session.getFeedbackSessionName(), session.getCourseId(), instructor.email);
    // Instructor can see responses: q2r1-3, q3r1-2, q4r1-3, q5r1, q6r1
    assertEquals(10, results.responses.size());
    // Instructor should still see all questions
    assertEquals(8, results.questions.size());
    // Test the user email-name maps used for display purposes
    mapString = results.emailNameTable.toString();
    expectedStrings.clear();
    String student1AnonEmail = getStudentAnonEmail(responseBundle, "student1InCourse1");
    String student1AnonName = getStudentAnonName(responseBundle, "student1InCourse1");
    String student3AnonEmail = getStudentAnonEmail(responseBundle, "student3InCourse1");
    String student3AnonName = getStudentAnonName(responseBundle, "student3InCourse1");
    String student6AnonEmail = getStudentAnonEmail(responseBundle, "student6InCourse1");
    String student6AnonName = getStudentAnonName(responseBundle, "student6InCourse1");
    String instructor1AnonEmail = FeedbackSessionResultsBundle.getAnonEmail(FeedbackParticipantType.INSTRUCTORS, responseBundle.instructors.get("instructor1OfCourse1").name);
    String instructor1AnonName = FeedbackSessionResultsBundle.getAnonName(FeedbackParticipantType.INSTRUCTORS, responseBundle.instructors.get("instructor1OfCourse1").name);
    String instructor2AnonEmail = FeedbackSessionResultsBundle.getAnonEmail(FeedbackParticipantType.INSTRUCTORS, responseBundle.instructors.get("instructor2OfCourse1").name);
    String instructor2AnonName = FeedbackSessionResultsBundle.getAnonName(FeedbackParticipantType.INSTRUCTORS, responseBundle.instructors.get("instructor2OfCourse1").name);
    Collections.addAll(expectedStrings, "%GENERAL%=%NOBODY%", "FSRTest.student1InCourse1@gmail.tmt=student1 In Course1</td></div>'\"", "FSRTest.student2InCourse1@gmail.tmt=student2 In Course1", "FSRTest.student3InCourse1@gmail.tmt=student3 In Course1", "FSRTest.student4InCourse1@gmail.tmt=student4 In Course1", "FSRTest.student5InCourse1@gmail.tmt=student5 In Course1", "FSRTest.student6InCourse1@gmail.tmt=student6 In Course1", "FSRTest.instr1@course1.tmt=Instructor1 Course1", "FSRTest.instr2@course1.tmt=Instructor2 Course1", student1AnonEmail + "=" + student1AnonName, student2AnonEmail + "=" + student2AnonName, student3AnonEmail + "=" + student3AnonName, student6AnonEmail + "=" + student6AnonName, instructor1AnonEmail + "=" + instructor1AnonName, instructor2AnonEmail + "=" + instructor2AnonName, "Team 1.2=Team 1.2", "Team 1.3=Team 1.3", "Team 1.4=Team 1.4");
    AssertHelper.assertContains(expectedStrings, mapString);
    assertEquals(18, results.emailNameTable.size());
    // Test the user email-teamName maps used for display purposes
    mapString = results.emailTeamNameTable.toString();
    expectedStrings.clear();
    Collections.addAll(expectedStrings, "%GENERAL%=", "FSRTest.student1InCourse1@gmail.tmt=Team 1.1</td></div>'\"", "FSRTest.student2InCourse1@gmail.tmt=Team 1.1</td></div>'\"", "FSRTest.student3InCourse1@gmail.tmt=Team 1.2", "FSRTest.student4InCourse1@gmail.tmt=Team 1.2", "FSRTest.student5InCourse1@gmail.tmt=Team 1.3", "FSRTest.student6InCourse1@gmail.tmt=Team 1.4", "FSRTest.instr2@course1.tmt=Instructors", "FSRTest.instr1@course1.tmt=Instructors", student1AnonEmail + "=" + student1AnonName + Const.TEAM_OF_EMAIL_OWNER, student2AnonEmail + "=" + student2AnonName + Const.TEAM_OF_EMAIL_OWNER, student3AnonEmail + "=" + student3AnonName + Const.TEAM_OF_EMAIL_OWNER, student6AnonEmail + "=" + student6AnonName + Const.TEAM_OF_EMAIL_OWNER, instructor1AnonEmail + "=" + instructor1AnonName + Const.TEAM_OF_EMAIL_OWNER, instructor2AnonEmail + "=" + instructor2AnonName + Const.TEAM_OF_EMAIL_OWNER, "Team 1.3=", "Team 1.2=", "Team 1.4=");
    AssertHelper.assertContains(expectedStrings, mapString);
    assertEquals(18, results.emailTeamNameTable.size());
    // Test the generated response visibilityTable for userNames.
    mapString = tableToString(results.visibilityTable);
    expectedStrings.clear();
    Collections.addAll(expectedStrings, getResponseId("qn2.resp1", responseBundle) + "={false,false}", getResponseId("qn2.resp2", responseBundle) + "={false,false}", getResponseId("qn2.resp3", responseBundle) + "={false,false}", getResponseId("qn3.resp1", responseBundle) + "={true,false}", getResponseId("qn3.resp2", responseBundle) + "={false,false}", getResponseId("qn4.resp1", responseBundle) + "={true,true}", getResponseId("qn4.resp2", responseBundle) + "={true,true}", getResponseId("qn4.resp3", responseBundle) + "={true,true}", getResponseId("qn5.resp1", responseBundle) + "={false,true}", getResponseId("qn6.resp1", responseBundle) + "={true,true}");
    AssertHelper.assertContains(expectedStrings, mapString);
    assertEquals(10, results.visibilityTable.size());
    /**
     * Test result bundle for instructor1 within a section **
     */
    results = fsLogic.getFeedbackSessionResultsForInstructorInSection(session.getFeedbackSessionName(), session.getCourseId(), instructor.email, "Section A");
    // Instructor can see responses: q2r1-3, q3r1-2, q4r1-3, q5r1, q6r1
    assertEquals(7, results.responses.size());
    // Instructor should still see all questions
    assertEquals(8, results.questions.size());
    // Test the user email-name maps used for display purposes
    mapString = results.emailNameTable.toString();
    expectedStrings.clear();
    Collections.addAll(expectedStrings, "FSRTest.student1InCourse1@gmail.tmt=student1 In Course1", student1AnonEmail + "=" + student1AnonName, student2AnonEmail + "=" + student2AnonName, student3AnonEmail + "=" + student3AnonName, student6AnonEmail + "=" + student6AnonName, instructor1AnonEmail + "=" + instructor1AnonName, "FSRTest.student2InCourse1@gmail.tmt=student2 In Course1", "Team 1.4=Team 1.4", "FSRTest.instr1@course1.tmt=Instructor1 Course1");
    AssertHelper.assertContains(expectedStrings, mapString);
    assertEquals(13, results.emailNameTable.size());
    // Test the user email-teamName maps used for display purposes
    mapString = results.emailTeamNameTable.toString();
    expectedStrings.clear();
    Collections.addAll(expectedStrings, "FSRTest.student1InCourse1@gmail.tmt=Team 1.1</td></div>'\"", student1AnonEmail + "=" + student1AnonName + Const.TEAM_OF_EMAIL_OWNER, student2AnonEmail + "=" + student2AnonName + Const.TEAM_OF_EMAIL_OWNER, student3AnonEmail + "=" + student3AnonName + Const.TEAM_OF_EMAIL_OWNER, student6AnonEmail + "=" + student6AnonName + Const.TEAM_OF_EMAIL_OWNER, instructor1AnonEmail + "=" + instructor1AnonName + Const.TEAM_OF_EMAIL_OWNER, "FSRTest.student2InCourse1@gmail.tmt=Team 1.1</td></div>'\"", "Team 1.4=", "FSRTest.instr1@course1.tmt=Instructors");
    AssertHelper.assertContains(expectedStrings, mapString);
    assertEquals(13, results.emailTeamNameTable.size());
    // Test the generated response visibilityTable for userNames.
    mapString = tableToString(results.visibilityTable);
    expectedStrings.clear();
    Collections.addAll(expectedStrings, getResponseId("qn3.resp1", responseBundle) + "={true,false}", getResponseId("qn4.resp3", responseBundle) + "={true,true}", getResponseId("qn2.resp3", responseBundle) + "={false,false}", getResponseId("qn2.resp1", responseBundle) + "={false,false}");
    AssertHelper.assertContains(expectedStrings, mapString);
    assertEquals(7, results.visibilityTable.size());
    // TODO: test student2 too.
    ______TS("private session");
    session = responseBundle.feedbackSessions.get("private.session");
    /**
     * Test result bundle for student1 **
     */
    student = responseBundle.students.get("student1InCourse1");
    results = fsLogic.getFeedbackSessionResultsForStudent(session.getFeedbackSessionName(), session.getCourseId(), student.email);
    assertEquals(0, results.questions.size());
    assertEquals(0, results.responses.size());
    assertEquals(0, results.emailNameTable.size());
    assertEquals(0, results.emailTeamNameTable.size());
    assertEquals(0, results.visibilityTable.size());
    /**
     * Test result bundle for instructor1 **
     */
    instructor = responseBundle.instructors.get("instructor1OfCourse1");
    results = fsLogic.getFeedbackSessionResultsForInstructor(session.getFeedbackSessionName(), session.getCourseId(), instructor.email);
    // Can see all responses regardless of visibility settings.
    assertEquals(2, results.questions.size());
    assertEquals(2, results.responses.size());
    // Test the user email-name maps used for display purposes
    mapString = results.emailNameTable.toString();
    expectedStrings.clear();
    Collections.addAll(expectedStrings, "FSRTest.student1InCourse1@gmail.tmt=student1 In Course1", "Team 1.2=Team 1.2", FeedbackSessionResultsBundle.getAnonEmail(FeedbackParticipantType.TEAMS, responseBundle.students.get("student3InCourse1").team), "FSRTest.instr1@course1.tmt=Instructor1 Course1");
    AssertHelper.assertContains(expectedStrings, mapString);
    assertEquals(4, results.emailNameTable.size());
    // Test the user email-teamName maps used for display purposes
    mapString = results.emailTeamNameTable.toString();
    expectedStrings.clear();
    Collections.addAll(expectedStrings, "FSRTest.student1InCourse1@gmail.tmt=Team 1.1</td></div>'\"", "Team 1.2=", FeedbackSessionResultsBundle.getAnonEmail(FeedbackParticipantType.TEAMS, responseBundle.students.get("student3InCourse1").team), "FSRTest.instr1@course1.tmt=Instructors");
    AssertHelper.assertContains(expectedStrings, mapString);
    assertEquals(4, results.emailTeamNameTable.size());
    // Test that name visibility is adhered to even when
    // it is a private session. (to protect anonymity during session type conversion)"
    mapString = tableToString(results.visibilityTable);
    expectedStrings.clear();
    Collections.addAll(expectedStrings, getResponseId("p.qn1.resp1", responseBundle) + "={true,true}", getResponseId("p.qn2.resp1", responseBundle) + "={true,false}");
    AssertHelper.assertContains(expectedStrings, mapString);
    assertEquals(2, results.visibilityTable.size());
    ______TS("failure: no session");
    try {
        fsLogic.getFeedbackSessionResultsForInstructor("invalid session", session.getCourseId(), instructor.email);
        signalFailureToDetectException("Did not detect that session does not exist.");
    } catch (EntityDoesNotExistException e) {
        assertEquals("Trying to view a non-existent feedback session: " + session.getCourseId() + "/" + "invalid session", e.getMessage());
    }
// TODO: check for cases where a person is both a student and an instructor
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) DataBundle(teammates.common.datatransfer.DataBundle) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) FeedbackSessionResultsBundle(teammates.common.datatransfer.FeedbackSessionResultsBundle) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 70 with StudentAttributes

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

the class StudentsLogicTest method testDeleteStudent.

private void testDeleteStudent() {
    ______TS("typical delete");
    // this is the student to be deleted
    StudentAttributes student2InCourse1 = dataBundle.students.get("student2InCourse1");
    verifyPresentInDatastore(student2InCourse1);
    studentsLogic.deleteStudentCascadeWithoutDocument(student2InCourse1.course, student2InCourse1.email);
    verifyAbsentInDatastore(student2InCourse1);
    // verify that other students in the course are intact
    StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
    verifyPresentInDatastore(student1InCourse1);
    ______TS("delete non-existent student");
    // should fail silently.
    studentsLogic.deleteStudentCascadeWithoutDocument(student2InCourse1.course, student2InCourse1.email);
    ______TS("null parameters");
    try {
        studentsLogic.deleteStudentCascadeWithoutDocument(null, "valid@email.tmt");
        signalFailureToDetectException();
    } catch (AssertionError ae) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
    }
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Aggregations

StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)241 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)85 Test (org.testng.annotations.Test)80 ArrayList (java.util.ArrayList)55 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)33 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)33 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)30 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)27 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)22 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)17 ShowPageResult (teammates.ui.controller.ShowPageResult)15 HashMap (java.util.HashMap)14 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)14 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 EmailWrapper (teammates.common.util.EmailWrapper)13 RedirectResult (teammates.ui.controller.RedirectResult)12 List (java.util.List)11 StatusMessage (teammates.common.util.StatusMessage)10 HashSet (java.util.HashSet)9 StudentEnrollDetails (teammates.common.datatransfer.StudentEnrollDetails)9