use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackResponseCommentsLogicTest method getQuestionIdInDataBundle.
private String getQuestionIdInDataBundle(String questionInDataBundle) {
FeedbackQuestionAttributes question = dataBundle.feedbackQuestions.get(questionInDataBundle);
question = fqLogic.getFeedbackQuestion(question.feedbackSessionName, question.courseId, question.questionNumber);
return question.getId();
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogicTest method getQuestionFromDatastore.
private FeedbackQuestionAttributes getQuestionFromDatastore(DataBundle dataBundle, String jsonId) {
FeedbackQuestionAttributes questionToGet = dataBundle.feedbackQuestions.get(jsonId);
questionToGet = fqLogic.getFeedbackQuestion(questionToGet.feedbackSessionName, questionToGet.courseId, questionToGet.questionNumber);
return questionToGet;
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes 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));
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogicTest method testGetFeedbackSessionQuestionsForInstructor.
private void testGetFeedbackSessionQuestionsForInstructor() throws Exception {
______TS("standard test");
FeedbackSessionQuestionsBundle actual = fsLogic.getFeedbackSessionQuestionsForInstructor("Instructor feedback session", "idOfTypicalCourse2", "instructor1@course2.tmt");
// We just test this once.
assertEquals(dataBundle.feedbackSessions.get("session2InCourse2").toString(), actual.feedbackSession.toString());
// There should be 2 question for students to do in session 1.
// The final question is set for SELF (creator) only.
assertEquals(2, actual.questionResponseBundle.size());
// Question 1
FeedbackQuestionAttributes expectedQuestion = getQuestionFromDatastore("qn1InSession2InCourse2");
assertTrue(actual.questionResponseBundle.containsKey(expectedQuestion));
String expectedResponsesString = getResponseFromDatastore("response1ForQ1S2C2", dataBundle).toString();
List<String> actualResponses = new ArrayList<>();
for (FeedbackResponseAttributes responsesForQn : actual.questionResponseBundle.get(expectedQuestion)) {
actualResponses.add(responsesForQn.toString());
}
assertEquals(1, actualResponses.size());
AssertHelper.assertContains(actualResponses, expectedResponsesString);
// Question 2
expectedQuestion = getQuestionFromDatastore("qn2InSession2InCourse2");
assertTrue(actual.questionResponseBundle.containsKey(expectedQuestion));
assertTrue(actual.questionResponseBundle.get(expectedQuestion).isEmpty());
______TS("private test: not creator");
actual = fsLogic.getFeedbackSessionQuestionsForInstructor("Private feedback session", "idOfTypicalCourse2", "instructor2@course2.tmt");
assertEquals(0, actual.questionResponseBundle.size());
______TS("private test: is creator");
actual = fsLogic.getFeedbackSessionQuestionsForInstructor("Private feedback session", "idOfTypicalCourse2", "instructor1@course2.tmt");
assertEquals(1, actual.questionResponseBundle.size());
expectedQuestion = getQuestionFromDatastore("qn1InSession1InCourse2");
assertTrue(actual.questionResponseBundle.containsKey(expectedQuestion));
______TS("failure: invalid session");
try {
fsLogic.getFeedbackSessionQuestionsForInstructor("invalid session", "idOfTypicalCourse1", "instructor1@course1.tmt");
signalFailureToDetectException("Did not detect that session does not exist.");
} catch (EntityDoesNotExistException e) {
assertEquals("Trying to get a non-existent feedback session: " + "idOfTypicalCourse1" + "/" + "invalid session", e.getMessage());
}
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogicTest method testGetFeedbackSessionQuestionsForStudent.
private void testGetFeedbackSessionQuestionsForStudent() throws Exception {
______TS("standard test");
FeedbackSessionQuestionsBundle actual = fsLogic.getFeedbackSessionQuestionsForStudent("First feedback session", "idOfTypicalCourse1", "student1InCourse1@gmail.tmt");
// We just test this once.
assertEquals(actual.feedbackSession.toString(), dataBundle.feedbackSessions.get("session1InCourse1").toString());
// There should be 3 questions for students to do in session 1.
// Other questions are set for instructors.
assertEquals(3, actual.questionResponseBundle.size());
// Question 1
FeedbackQuestionAttributes expectedQuestion = getQuestionFromDatastore("qn1InSession1InCourse1");
assertTrue(actual.questionResponseBundle.containsKey(expectedQuestion));
String expectedResponsesString = getResponseFromDatastore("response1ForQ1S1C1", dataBundle).toString();
List<String> actualResponses = new ArrayList<>();
for (FeedbackResponseAttributes responsesForQn : actual.questionResponseBundle.get(expectedQuestion)) {
actualResponses.add(responsesForQn.toString());
}
assertEquals(1, actualResponses.size());
AssertHelper.assertContains(actualResponses, expectedResponsesString);
// Question 2
expectedQuestion = getQuestionFromDatastore("qn2InSession1InCourse1");
assertTrue(actual.questionResponseBundle.containsKey(expectedQuestion));
expectedResponsesString = getResponseFromDatastore("response2ForQ2S1C1", dataBundle).toString();
actualResponses.clear();
for (FeedbackResponseAttributes responsesForQn : actual.questionResponseBundle.get(expectedQuestion)) {
actualResponses.add(responsesForQn.toString());
}
assertEquals(1, actualResponses.size());
AssertHelper.assertContains(actualResponses, expectedResponsesString);
// Question for students to instructors
expectedQuestion = getQuestionFromDatastore("qn5InSession1InCourse1");
assertTrue(actual.questionResponseBundle.containsKey(expectedQuestion));
// Check that instructors (except the one who is not displayed to student) appear as recipients
Map<String, String> recipients = actual.recipientList.get(expectedQuestion.getId());
assertTrue(recipients.containsKey("instructor1@course1.tmt"));
assertTrue(recipients.containsKey("instructor2@course1.tmt"));
assertTrue(recipients.containsKey("instructor3@course1.tmt"));
assertTrue(recipients.containsKey("instructorNotYetJoinedCourse1@email.tmt"));
assertFalse(recipients.containsKey("helper@course1.tmt"));
______TS("team feedback test");
// Check that student3 get team member's (student4) feedback response as well (for team question).
actual = fsLogic.getFeedbackSessionQuestionsForStudent("Second feedback session", "idOfTypicalCourse1", "student3InCourse1@gmail.tmt");
assertEquals(2, actual.questionResponseBundle.size());
// Question 1
expectedQuestion = getQuestionFromDatastore("team.feedback");
assertTrue(actual.questionResponseBundle.containsKey(expectedQuestion));
expectedResponsesString = getResponseFromDatastore("response1ForQ1S2C1", dataBundle).toString();
actualResponses.clear();
for (FeedbackResponseAttributes responsesForQn : actual.questionResponseBundle.get(expectedQuestion)) {
actualResponses.add(responsesForQn.toString());
}
assertEquals(1, actualResponses.size());
AssertHelper.assertContains(actualResponses, expectedResponsesString);
// Question 2, no responses from this student yet
expectedQuestion = getQuestionFromDatastore("team.members.feedback");
assertTrue(actual.questionResponseBundle.containsKey(expectedQuestion));
assertTrue(actual.questionResponseBundle.get(expectedQuestion).isEmpty());
______TS("failure: invalid session");
try {
fsLogic.getFeedbackSessionQuestionsForStudent("invalid session", "idOfTypicalCourse1", "student3InCourse1@gmail.tmt");
signalFailureToDetectException("Did not detect that session does not exist.");
} catch (EntityDoesNotExistException e) {
assertEquals("Trying to get a non-existent feedback session: " + "idOfTypicalCourse1" + "/" + "invalid session", e.getMessage());
}
______TS("failure: non-existent student");
try {
fsLogic.getFeedbackSessionQuestionsForStudent("Second feedback session", "idOfTypicalCourse1", "randomUserId");
signalFailureToDetectException("Did not detect that student does not exist.");
} catch (EntityDoesNotExistException edne) {
assertEquals("Error getting feedback session(s): Student does not exist.", edne.getMessage());
}
}
Aggregations