use of teammates.common.datatransfer.FeedbackSessionQuestionsBundle 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.FeedbackSessionQuestionsBundle 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());
}
}
use of teammates.common.datatransfer.FeedbackSessionQuestionsBundle in project teammates by TEAMMATES.
the class FeedbackSubmissionEditPageDataTest method createData.
private void createData(StudentAttributes student) {
FeedbackSessionAttributes feedbackSession = dataBundle.feedbackSessions.get("session1InCourse1");
question = dataBundle.feedbackQuestions.get("qn1InSession1InCourse1");
responses.add(dataBundle.feedbackResponses.get("response1ForQ1S1C1"));
responses.add(dataBundle.feedbackResponses.get("response2ForQ1S1C1"));
// create a dummy questionId for question,
// otherwise it would be uninitialised as this is normally done by the database
setDummyQuestionId(question, responses);
questionResponseBundle.put(question, responses);
recipients.put(student.email, Const.USER_NAME_FOR_SELF);
recipientList.put(question.getId(), recipients);
pageData.bundle = new FeedbackSessionQuestionsBundle(feedbackSession, questionResponseBundle, recipientList);
pageData.bundle.questionResponseBundle.put(question, responses);
}
use of teammates.common.datatransfer.FeedbackSessionQuestionsBundle in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method getFeedbackSessionQuestionsForStudent.
/**
* Gets {@code FeedbackQuestions} and previously filled
* {@code FeedbackResponses} that a student can view/submit as a
* {@link FeedbackSessionQuestionsBundle}.
*/
public FeedbackSessionQuestionsBundle getFeedbackSessionQuestionsForStudent(String feedbackSessionName, String courseId, String userEmail) throws EntityDoesNotExistException {
FeedbackSessionAttributes fsa = fsDb.getFeedbackSession(courseId, feedbackSessionName);
if (fsa == null) {
throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_GET + courseId + "/" + feedbackSessionName);
}
StudentAttributes student = studentsLogic.getStudentForEmail(courseId, userEmail);
if (student == null) {
throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_STUDENT);
}
Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> bundle = new HashMap<>();
Map<String, Map<String, String>> recipientList = new HashMap<>();
List<FeedbackQuestionAttributes> questions = fqLogic.getFeedbackQuestionsForStudents(feedbackSessionName, courseId);
Set<String> hiddenInstructorEmails = null;
for (FeedbackQuestionAttributes question : questions) {
if (question.getRecipientType() == FeedbackParticipantType.INSTRUCTORS) {
hiddenInstructorEmails = getHiddenInstructorEmails(courseId);
break;
}
}
for (FeedbackQuestionAttributes question : questions) {
updateBundleAndRecipientListWithResponsesForStudent(userEmail, student, bundle, recipientList, question, hiddenInstructorEmails);
}
return new FeedbackSessionQuestionsBundle(fsa, bundle, recipientList);
}
use of teammates.common.datatransfer.FeedbackSessionQuestionsBundle in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method getFeedbackSessionQuestionsForInstructor.
public FeedbackSessionQuestionsBundle getFeedbackSessionQuestionsForInstructor(String feedbackSessionName, String courseId, String feedbackQuestionId, String userEmail) throws EntityDoesNotExistException {
FeedbackSessionAttributes fsa = fsDb.getFeedbackSession(courseId, feedbackSessionName);
if (fsa == null) {
throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_GET + courseId + "/" + feedbackSessionName);
}
InstructorAttributes instructor = instructorsLogic.getInstructorForEmail(courseId, userEmail);
Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> bundle = new HashMap<>();
Map<String, Map<String, String>> recipientList = new HashMap<>();
FeedbackQuestionAttributes question = fqLogic.getFeedbackQuestion(feedbackQuestionId);
InstructorAttributes instructorGiver = instructor;
updateBundleAndRecipientListWithResponsesForInstructor(courseId, userEmail, fsa, instructor, bundle, recipientList, question, instructorGiver, null);
return new FeedbackSessionQuestionsBundle(fsa, bundle, recipientList);
}
Aggregations