use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackQuestionsLogicTest method testIsQuestionAnswered.
private void testIsQuestionAnswered() throws Exception {
FeedbackQuestionAttributes question;
______TS("test question is fully answered by user");
question = getQuestionFromDatastore("qn1InSession1InCourse1");
assertTrue(fqLogic.isQuestionFullyAnsweredByUser(question, "student1InCourse1@gmail.tmt"));
assertFalse(fqLogic.isQuestionFullyAnsweredByUser(question, "studentWithNoResponses@gmail.tmt"));
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackQuestionsLogicTest method testCopyQuestion.
private void testCopyQuestion() throws Exception {
InstructorAttributes instructor2OfCourse1 = dataBundle.instructors.get("instructor2OfCourse1");
______TS("Typical case: copy question successfully");
FeedbackQuestionAttributes question1 = dataBundle.feedbackQuestions.get("qn1InSession1InCourse1");
question1 = fqLogic.getFeedbackQuestion(question1.feedbackSessionName, question1.courseId, question1.questionNumber);
FeedbackQuestionAttributes copiedQuestion = fqLogic.copyFeedbackQuestion(question1.getId(), question1.feedbackSessionName, question1.courseId, instructor2OfCourse1.email);
FeedbackQuestionDetails question1Details = question1.getQuestionDetails();
FeedbackQuestionDetails copiedQuestionDetails = copiedQuestion.getQuestionDetails();
assertEquals(question1.numberOfEntitiesToGiveFeedbackTo, copiedQuestion.numberOfEntitiesToGiveFeedbackTo);
assertEquals(question1.questionType, copiedQuestion.questionType);
assertEquals(question1.giverType, copiedQuestion.giverType);
assertEquals(question1.recipientType, copiedQuestion.recipientType);
assertEquals(question1Details.getQuestionText(), copiedQuestionDetails.getQuestionText());
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogicTest method testGetViewableResponsesForQuestionInSection.
private void testGetViewableResponsesForQuestionInSection() throws Exception {
______TS("success: GetViewableResponsesForQuestion - instructor");
InstructorAttributes instructor = dataBundle.instructors.get("instructor1OfCourse1");
FeedbackQuestionAttributes fq = getQuestionFromDatastore("qn3InSession1InCourse1");
List<FeedbackResponseAttributes> responses = frLogic.getViewableFeedbackResponsesForQuestionInSection(fq, instructor.email, UserRole.INSTRUCTOR, null);
assertEquals(responses.size(), 1);
______TS("success: GetViewableResponsesForQuestionInSection - instructor");
fq = getQuestionFromDatastore("qn2InSession1InCourse1");
responses = frLogic.getViewableFeedbackResponsesForQuestionInSection(fq, instructor.email, UserRole.INSTRUCTOR, "Section 1");
assertEquals(responses.size(), 3);
responses = frLogic.getViewableFeedbackResponsesForQuestionInSection(fq, instructor.email, UserRole.INSTRUCTOR, "Section 2");
assertEquals(responses.size(), 0);
______TS("success: GetViewableResponsesForQuestion - student");
StudentAttributes student = dataBundle.students.get("student1InCourse1");
fq = getQuestionFromDatastore("qn2InSession1InCourse1");
responses = frLogic.getViewableFeedbackResponsesForQuestionInSection(fq, student.email, UserRole.STUDENT, null);
assertEquals(responses.size(), 2);
fq = getQuestionFromDatastore("qn3InSession1InCourse1");
responses = frLogic.getViewableFeedbackResponsesForQuestionInSection(fq, student.email, UserRole.STUDENT, null);
assertEquals(responses.size(), 1);
fq.recipientType = FeedbackParticipantType.TEAMS;
fq.showResponsesTo.add(FeedbackParticipantType.RECEIVER);
fq.showResponsesTo.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
fq.showResponsesTo.remove(FeedbackParticipantType.STUDENTS);
FeedbackResponseAttributes fr = getResponseFromDatastore("response1ForQ3S1C1");
fr.recipient = student.email;
frLogic.updateFeedbackResponse(fr);
responses = frLogic.getViewableFeedbackResponsesForQuestionInSection(fq, student.email, UserRole.STUDENT, null);
assertEquals(responses.size(), 1);
______TS("success: Null student in response, should skip over null student");
fq = getQuestionFromDatastore("qn2InSession1InCourse1");
fq.showResponsesTo.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
FeedbackResponseAttributes existingResponse = getResponseFromDatastore("response1ForQ2S1C1");
// Create a "null" response to simulate trying to get a null student's response
FeedbackResponseAttributes newResponse = new FeedbackResponseAttributes(existingResponse.feedbackSessionName, "nullCourse", existingResponse.feedbackQuestionId, existingResponse.feedbackQuestionType, existingResponse.giver, "Section 1", "nullRecipient@gmail.tmt", "Section 1", existingResponse.responseMetaData);
frLogic.createFeedbackResponse(newResponse);
student = dataBundle.students.get("student2InCourse1");
responses = frLogic.getViewableFeedbackResponsesForQuestionInSection(fq, student.email, UserRole.STUDENT, null);
assertEquals(responses.size(), 4);
______TS("failure: GetViewableResponsesForQuestion invalid role");
try {
frLogic.getViewableFeedbackResponsesForQuestionInSection(fq, instructor.email, UserRole.ADMIN, null);
signalFailureToDetectException();
} catch (AssertionError e) {
assertEquals(e.getMessage(), "The role of the requesting use has to be Student or Instructor");
}
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogicTest method testUpdateFeedbackResponsesForChangingTeam.
private void testUpdateFeedbackResponsesForChangingTeam() throws Exception {
______TS("standard update team case");
StudentAttributes studentToUpdate = dataBundle.students.get("student4InCourse1");
// Student 4 has 1 responses to him from team members,
// 1 response from him a team member, and
// 1 team response from him to another team.
FeedbackQuestionAttributes teamQuestion = getQuestionFromDatastore("team.members.feedback");
assertEquals(frLogic.getFeedbackResponsesForReceiverForQuestion(teamQuestion.getId(), studentToUpdate.email).size(), 1);
assertEquals(frLogic.getFeedbackResponsesFromGiverForQuestion(teamQuestion.getId(), studentToUpdate.email).size(), 1);
teamQuestion = getQuestionFromDatastore("team.feedback");
assertEquals(frLogic.getFeedbackResponsesFromGiverForQuestion(teamQuestion.getId(), studentToUpdate.email).size(), 1);
// Add one more non-team response
FeedbackResponseAttributes responseToAdd = new FeedbackResponseAttributes("First feedback session", "idOfTypicalCourse1", getQuestionFromDatastore("qn1InSession1InCourse1").getId(), FeedbackQuestionType.TEXT, studentToUpdate.email, "Section 1", studentToUpdate.email, "Section 1", new Text("New Response to self"));
frLogic.createFeedbackResponse(responseToAdd);
// All these responses should be gone after he changes teams
frLogic.updateFeedbackResponsesForChangingTeam(studentToUpdate.course, studentToUpdate.email, studentToUpdate.team, "Team 1.2");
teamQuestion = getQuestionFromDatastore("team.members.feedback");
assertEquals(frLogic.getFeedbackResponsesForReceiverForQuestion(teamQuestion.getId(), studentToUpdate.email).size(), 0);
assertEquals(frLogic.getFeedbackResponsesFromGiverForQuestion(teamQuestion.getId(), studentToUpdate.email).size(), 0);
teamQuestion = getQuestionFromDatastore("team.feedback");
assertEquals(frLogic.getFeedbackResponsesForReceiverForQuestion(teamQuestion.getId(), studentToUpdate.email).size(), 0);
// Non-team response should remain
assertEquals(frLogic.getFeedbackResponsesFromGiverForQuestion(getQuestionFromDatastore("qn1InSession1InCourse1").getId(), studentToUpdate.email).size(), 1);
______TS("test updateFeedbackResponseForChangingTeam for recipient type = giver's team members including giver");
FeedbackQuestionAttributes questionToTeamMembersAndSelf = getQuestionFromDatastore(questionTypeBundle, "qn1InContribSession2InCourse2");
studentToUpdate = questionTypeBundle.students.get("student2InCourse2");
FeedbackResponseAttributes responseToBeDeleted = getResponseFromDatastore(questionTypeBundle, "response1ForQ1ContribSession2Course2");
StudentEnrollDetails studentDetails1 = new StudentEnrollDetails(StudentUpdateStatus.MODIFIED, studentToUpdate.course, studentToUpdate.email, studentToUpdate.team, studentToUpdate.team + "tmp", studentToUpdate.section, studentToUpdate.section + "tmp");
assertNotNull(frLogic.getFeedbackResponse(questionToTeamMembersAndSelf.getId(), responseToBeDeleted.giver, responseToBeDeleted.recipient));
assertTrue(frLogic.updateFeedbackResponseForChangingTeam(studentDetails1, responseToBeDeleted));
assertNull(frLogic.getFeedbackResponse(questionToTeamMembersAndSelf.getId(), responseToBeDeleted.giver, responseToBeDeleted.recipient));
// restore DataStore so other tests are unaffected
restoreStudentFeedbackResponseToDatastore(responseToBeDeleted);
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogicTest method testSpecialCharactersInTeamName.
private void testSpecialCharactersInTeamName() {
______TS("test special characters");
FeedbackQuestionAttributes question = fqLogic.getFeedbackQuestion("First Session", "FQLogicPCT.CS2104", 1);
// Alice will see 4 responses
assertEquals(frLogic.getViewableFeedbackResponsesForQuestionInSection(question, "FQLogicPCT.alice.b@gmail.tmt", UserRole.STUDENT, "First Session").size(), 4);
// Benny will see 4 responses
assertEquals(frLogic.getViewableFeedbackResponsesForQuestionInSection(question, "FQLogicPCT.benny.c@gmail.tmt", UserRole.STUDENT, "First Session").size(), 4);
// Charlie will see 3 responses
assertEquals(frLogic.getViewableFeedbackResponsesForQuestionInSection(question, "FQLogicPCT.charlie.d@gmail.tmt", UserRole.STUDENT, "First Session").size(), 3);
// Danny will see 3 responses
assertEquals(frLogic.getViewableFeedbackResponsesForQuestionInSection(question, "FQLogicPCT.danny.e@gmail.tmt", UserRole.STUDENT, "First Session").size(), 3);
// Emily will see 1 response
assertEquals(frLogic.getViewableFeedbackResponsesForQuestionInSection(question, "FQLogicPCT.emily.f@gmail.tmt", UserRole.STUDENT, "First Session").size(), 1);
}
Aggregations