use of teammates.common.datatransfer.StudentEnrollDetails in project teammates by TEAMMATES.
the class StudentsLogicTest method testAdjustFeedbackResponseForEnrollments.
private void testAdjustFeedbackResponseForEnrollments() throws Exception {
// the case below will not cause the response to be deleted
// because the studentEnrollDetails'email is not the same as giver or recipient
______TS("adjust feedback response: no change of team");
String course1Id = dataBundle.courses.get("typicalCourse1").getId();
StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
StudentAttributes student2InCourse1 = dataBundle.students.get("student2InCourse1");
ArrayList<StudentEnrollDetails> enrollmentList = new ArrayList<>();
StudentEnrollDetails studentDetails1 = new StudentEnrollDetails(StudentUpdateStatus.MODIFIED, course1Id, student1InCourse1.email, student1InCourse1.team, student1InCourse1.team + "tmp", student1InCourse1.section, student1InCourse1.section + "tmp");
enrollmentList.add(studentDetails1);
FeedbackResponseAttributes feedbackResponse1InBundle = dataBundle.feedbackResponses.get("response1ForQ2S2C1");
FeedbackResponsesLogic frLogic = FeedbackResponsesLogic.inst();
FeedbackQuestionsLogic fqLogic = FeedbackQuestionsLogic.inst();
FeedbackQuestionAttributes feedbackQuestionInDb = fqLogic.getFeedbackQuestion(feedbackResponse1InBundle.feedbackSessionName, feedbackResponse1InBundle.courseId, Integer.parseInt(feedbackResponse1InBundle.feedbackQuestionId));
FeedbackResponseAttributes responseBefore = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
studentsLogic.adjustFeedbackResponseForEnrollments(enrollmentList, responseBefore);
FeedbackResponseAttributes responseAfter = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
assertEquals(responseBefore.getId(), responseAfter.getId());
// the case below will not cause the response to be deleted
// because the studentEnrollDetails'email is not the same as giver or recipient
______TS("adjust feedback response: unmodified status");
enrollmentList = new ArrayList<>();
studentDetails1 = new StudentEnrollDetails(StudentUpdateStatus.UNMODIFIED, course1Id, student1InCourse1.email, student1InCourse1.team, student1InCourse1.team + "tmp", student1InCourse1.section, student1InCourse1.section + "tmp");
enrollmentList.add(studentDetails1);
feedbackQuestionInDb = fqLogic.getFeedbackQuestion(feedbackResponse1InBundle.feedbackSessionName, feedbackResponse1InBundle.courseId, Integer.parseInt(feedbackResponse1InBundle.feedbackQuestionId));
responseBefore = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
studentsLogic.adjustFeedbackResponseForEnrollments(enrollmentList, responseBefore);
responseAfter = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
assertEquals(responseBefore.getId(), responseAfter.getId());
// the code below will cause the feedback to be deleted because
// recipient's e-mail is the same as the one in studentEnrollDetails
// and the question's recipient's type is own team members
______TS("adjust feedback response: delete after adjustment");
studentDetails1 = new StudentEnrollDetails(StudentUpdateStatus.MODIFIED, course1Id, student2InCourse1.email, student1InCourse1.team, student1InCourse1.team + "tmp", student1InCourse1.section, student1InCourse1.section + "tmp");
enrollmentList = new ArrayList<>();
enrollmentList.add(studentDetails1);
feedbackQuestionInDb = fqLogic.getFeedbackQuestion(feedbackResponse1InBundle.feedbackSessionName, feedbackResponse1InBundle.courseId, Integer.parseInt(feedbackResponse1InBundle.feedbackQuestionId));
responseBefore = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
studentsLogic.adjustFeedbackResponseForEnrollments(enrollmentList, responseBefore);
responseAfter = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
assertNull(responseAfter);
}
use of teammates.common.datatransfer.StudentEnrollDetails 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.StudentEnrollDetails in project teammates by TEAMMATES.
the class FeedbackResponsesLogicTest method testUpdateFeedbackResponsesForChangingTeam_deleteLastResponse_decreaseResponseRate.
private void testUpdateFeedbackResponsesForChangingTeam_deleteLastResponse_decreaseResponseRate() throws Exception {
FeedbackResponseAttributes responseToBeDeleted = getResponseFromDatastore(questionTypeBundle, "response1ForQ1ContribSession2Course2");
// make sure it's the last response by the student
assertEquals(1, numResponsesFromGiverInSession(responseToBeDeleted.giver, responseToBeDeleted.feedbackSessionName, responseToBeDeleted.courseId));
StudentAttributes student = questionTypeBundle.students.get("student2InCourse2");
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 - 1, responseRateAfterDeletion);
// restore DataStore so other tests are unaffected
restoreStudentFeedbackResponseToDatastore(responseToBeDeleted);
}
use of teammates.common.datatransfer.StudentEnrollDetails in project teammates by TEAMMATES.
the class StudentsLogic method enrollStudent.
private StudentEnrollDetails enrollStudent(StudentAttributes validStudentAttributes, Boolean hasDocument) throws InvalidParametersException, EntityDoesNotExistException, EntityAlreadyExistsException {
StudentAttributes originalStudentAttributes = getStudentForEmail(validStudentAttributes.course, validStudentAttributes.email);
StudentEnrollDetails enrollmentDetails = new StudentEnrollDetails();
enrollmentDetails.course = validStudentAttributes.course;
enrollmentDetails.email = validStudentAttributes.email;
enrollmentDetails.newTeam = validStudentAttributes.team;
enrollmentDetails.newSection = validStudentAttributes.section;
boolean isModifyingExistingStudent = originalStudentAttributes != null;
if (validStudentAttributes.isEnrollInfoSameAs(originalStudentAttributes)) {
enrollmentDetails.updateStatus = StudentUpdateStatus.UNMODIFIED;
} else if (isModifyingExistingStudent) {
updateStudentCascadeWithSubmissionAdjustmentScheduled(originalStudentAttributes.email, validStudentAttributes, true);
enrollmentDetails.updateStatus = StudentUpdateStatus.MODIFIED;
if (!originalStudentAttributes.team.equals(validStudentAttributes.team)) {
enrollmentDetails.oldTeam = originalStudentAttributes.team;
}
if (!originalStudentAttributes.section.equals(validStudentAttributes.section)) {
enrollmentDetails.oldSection = originalStudentAttributes.section;
}
} else {
createStudentCascade(validStudentAttributes, hasDocument);
enrollmentDetails.updateStatus = StudentUpdateStatus.NEW;
}
return enrollmentDetails;
}
Aggregations