Search in sources :

Example 6 with StudentEnrollDetails

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);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackResponsesLogic(teammates.logic.core.FeedbackResponsesLogic) FeedbackQuestionsLogic(teammates.logic.core.FeedbackQuestionsLogic) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 7 with StudentEnrollDetails

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);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) Text(com.google.appengine.api.datastore.Text) StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 8 with StudentEnrollDetails

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);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 9 with StudentEnrollDetails

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;
}
Also used : StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Aggregations

StudentEnrollDetails (teammates.common.datatransfer.StudentEnrollDetails)9 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)8 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)6 ArrayList (java.util.ArrayList)3 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)2 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)2 Text (com.google.appengine.api.datastore.Text)1 TypeToken (com.google.gson.reflect.TypeToken)1 Map (java.util.Map)1 Test (org.testng.annotations.Test)1 CourseEnrollmentResult (teammates.common.datatransfer.CourseEnrollmentResult)1 EnrollException (teammates.common.exception.EnrollException)1 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)1 LogMessageGenerator (teammates.common.util.LogMessageGenerator)1 FeedbackQuestionsLogic (teammates.logic.core.FeedbackQuestionsLogic)1 FeedbackResponsesLogic (teammates.logic.core.FeedbackResponsesLogic)1 FeedbackResponseAdjustmentWorkerAction (teammates.ui.automated.FeedbackResponseAdjustmentWorkerAction)1