Search in sources :

Example 1 with StudentEnrollDetails

use of teammates.common.datatransfer.StudentEnrollDetails in project teammates by TEAMMATES.

the class FeedbackResponseAdjustmentWorkerActionTest method allTests.

@Test
public void allTests() throws Exception {
    ______TS("typical case : existing student changes team");
    FeedbackSessionAttributes session = dataBundle.feedbackSessions.get("session2InCourse1");
    StudentAttributes student = dataBundle.students.get("student1InCourse1");
    // Verify pre-existing submissions and responses
    List<FeedbackResponseAttributes> oldResponsesForSession = getAllResponsesForStudentForSession(student, session.getFeedbackSessionName());
    assertFalse(oldResponsesForSession.isEmpty());
    String oldTeam = student.team;
    String oldSection = student.section;
    String newTeam = "Team 1.2";
    String newSection = "Section 2";
    student.team = newTeam;
    student.section = newSection;
    StudentEnrollDetails enrollDetails = new StudentEnrollDetails(StudentUpdateStatus.MODIFIED, student.course, student.email, oldTeam, newTeam, oldSection, newSection);
    List<StudentEnrollDetails> enrollList = new ArrayList<>();
    enrollList.add(enrollDetails);
    studentsLogic.updateStudentCascadeWithSubmissionAdjustmentScheduled(student.email, student, false);
    String[] submissionParams = new String[] { ParamsNames.COURSE_ID, student.course, ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), ParamsNames.ENROLLMENT_DETAILS, JsonUtils.toJson(enrollList) };
    FeedbackResponseAdjustmentWorkerAction action = getAction(submissionParams);
    action.execute();
    List<FeedbackResponseAttributes> newResponsesForSession = getAllResponsesForStudentForSession(student, session.getFeedbackSessionName());
    assertTrue(newResponsesForSession.isEmpty());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackResponseAdjustmentWorkerAction(teammates.ui.automated.FeedbackResponseAdjustmentWorkerAction) StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 2 with StudentEnrollDetails

use of teammates.common.datatransfer.StudentEnrollDetails in project teammates by TEAMMATES.

the class FeedbackResponsesLogicTest method testUpdateFeedbackResponsesForChangingTeam_deleteNotLastResponse_sameResponseRate.

private void testUpdateFeedbackResponsesForChangingTeam_deleteNotLastResponse_sameResponseRate() throws Exception {
    FeedbackResponseAttributes responseToBeDeleted = getResponseFromDatastore(questionTypeBundle, "response1ForQ1S5C1");
    // make sure it's not the last response by the student
    assertTrue(1 < numResponsesFromGiverInSession(responseToBeDeleted.giver, responseToBeDeleted.feedbackSessionName, responseToBeDeleted.courseId));
    StudentAttributes student = questionTypeBundle.students.get("student1InCourse1");
    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, 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 3 with StudentEnrollDetails

use of teammates.common.datatransfer.StudentEnrollDetails in project teammates by TEAMMATES.

the class StudentsLogicTest method testEnrollStudent.

private void testEnrollStudent() throws Exception {
    String instructorId = "instructorForEnrollTesting";
    String instructorCourse = "courseForEnrollTesting";
    // delete leftover data, if any
    accountsLogic.deleteAccountCascade(instructorId);
    coursesLogic.deleteCourseCascade(instructorCourse);
    // create fresh test data
    accountsLogic.createAccount(AccountAttributes.builder().withGoogleId(instructorId).withName("ICET Instr Name").withEmail("instructor@icet.tmt").withInstitute("TEAMMATES Test Institute 1").withIsInstructor(true).withStudentProfileAttributes(StudentProfileAttributes.builder(instructorId).withShortName("ICET").build()).build());
    coursesLogic.createCourseAndInstructor(instructorId, instructorCourse, "Course for Enroll Testing", "UTC");
    ______TS("add student into empty course");
    StudentAttributes student1 = StudentAttributes.builder(instructorCourse, "n", "e@g").withSection("sect 1").withTeam("t1").withComments("c").build();
    // check if the course is empty
    assertEquals(0, studentsLogic.getStudentsForCourse(instructorCourse).size());
    // add a new student and verify it is added and treated as a new student
    StudentEnrollDetails enrollmentResult = enrollStudent(student1);
    assertEquals(1, studentsLogic.getStudentsForCourse(instructorCourse).size());
    verifyEnrollmentDetailsForStudent(student1, null, enrollmentResult, StudentUpdateStatus.NEW);
    verifyPresentInDatastore(student1);
    ______TS("add existing student");
    // Verify it was not added
    enrollmentResult = enrollStudent(student1);
    verifyEnrollmentDetailsForStudent(student1, null, enrollmentResult, StudentUpdateStatus.UNMODIFIED);
    assertEquals(1, studentsLogic.getStudentsForCourse(instructorCourse).size());
    ______TS("add student into non-empty course");
    StudentAttributes student2 = StudentAttributes.builder(instructorCourse, "n2", "e2@g").withSection("sect 1").withTeam("t1").withComments("c").build();
    enrollmentResult = enrollStudent(student2);
    verifyEnrollmentDetailsForStudent(student2, null, enrollmentResult, StudentUpdateStatus.NEW);
    // add some more students to the same course (we add more than one
    // because we can use them for testing cascade logic later in this test case)
    enrollStudent(StudentAttributes.builder(instructorCourse, "n3", "e3@g").withSection("sect 2").withTeam("t2").withComments("c").build());
    enrollStudent(StudentAttributes.builder(instructorCourse, "n4", "e4@g").withSection("sect 2").withTeam("t2").withComments("").build());
    assertEquals(4, studentsLogic.getStudentsForCourse(instructorCourse).size());
    ______TS("modify info of existing student");
    // add some more details to the student
    student1.googleId = "googleId";
    studentsLogic.updateStudentCascadeWithoutDocument(student1.email, student1);
}
Also used : StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 4 with StudentEnrollDetails

use of teammates.common.datatransfer.StudentEnrollDetails in project teammates by TEAMMATES.

the class StudentsLogic method enrollStudents.

private CourseEnrollmentResult enrollStudents(String enrollLines, String courseId, boolean hasDocument) throws EntityDoesNotExistException, EnrollException, InvalidParametersException, EntityAlreadyExistsException {
    if (!coursesLogic.isCoursePresent(courseId)) {
        throw new EntityDoesNotExistException("Course does not exist :" + courseId);
    }
    if (enrollLines.isEmpty()) {
        throw new EnrollException(Const.StatusMessages.ENROLL_LINE_EMPTY);
    }
    List<StudentAttributes> studentList = createStudents(enrollLines, courseId);
    ArrayList<StudentAttributes> returnList = new ArrayList<>();
    ArrayList<StudentEnrollDetails> enrollmentList = new ArrayList<>();
    verifyIsWithinSizeLimitPerEnrollment(studentList);
    validateSectionsAndTeams(studentList, courseId);
    // enroll all students
    for (StudentAttributes student : studentList) {
        StudentEnrollDetails enrollmentDetails;
        enrollmentDetails = enrollStudent(student, hasDocument);
        student.updateStatus = enrollmentDetails.updateStatus;
        enrollmentList.add(enrollmentDetails);
        returnList.add(student);
    }
    // add to return list students not included in the enroll list.
    List<StudentAttributes> studentsInCourse = getStudentsForCourse(courseId);
    for (StudentAttributes student : studentsInCourse) {
        if (!isInEnrollList(student, returnList)) {
            student.updateStatus = StudentUpdateStatus.NOT_IN_ENROLL_LIST;
            returnList.add(student);
        }
    }
    return new CourseEnrollmentResult(returnList, enrollmentList);
}
Also used : EnrollException(teammates.common.exception.EnrollException) CourseEnrollmentResult(teammates.common.datatransfer.CourseEnrollmentResult) ArrayList(java.util.ArrayList) StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 5 with StudentEnrollDetails

use of teammates.common.datatransfer.StudentEnrollDetails in project teammates by TEAMMATES.

the class FeedbackResponseAdjustmentWorkerAction method execute.

@Override
public void execute() {
    String courseId = getRequestParamValue(ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(ParamsNames.COURSE_ID, courseId);
    String sessionName = getRequestParamValue(ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(ParamsNames.FEEDBACK_SESSION_NAME, sessionName);
    String enrollmentDetails = getRequestParamValue(ParamsNames.ENROLLMENT_DETAILS);
    Assumption.assertPostParamNotNull(ParamsNames.ENROLLMENT_DETAILS, enrollmentDetails);
    log.info("Adjusting submissions for feedback session :" + sessionName + "in course : " + courseId);
    FeedbackSessionAttributes feedbackSession = logic.getFeedbackSession(sessionName, courseId);
    String errorString = "Error encountered while adjusting feedback session responses of %s in course %s: %s%n%s";
    if (feedbackSession == null) {
        log.severe(String.format(errorString, sessionName, courseId, "feedback session is null", ""));
        setForRetry();
        return;
    }
    List<FeedbackResponseAttributes> allResponses = logic.getFeedbackResponsesForSession(feedbackSession.getFeedbackSessionName(), feedbackSession.getCourseId());
    List<StudentEnrollDetails> enrollmentList = JsonUtils.fromJson(enrollmentDetails, new TypeToken<List<StudentEnrollDetails>>() {
    }.getType());
    for (FeedbackResponseAttributes response : allResponses) {
        try {
            logic.adjustFeedbackResponseForEnrollments(enrollmentList, response);
        } catch (Exception e) {
            String url = HttpRequestHelper.getRequestedUrl(request);
            Map<String, String[]> params = HttpRequestHelper.getParameterMap(request);
            // no logged-in user for worker
            String logMessage = new LogMessageGenerator().generateActionFailureLogMessage(url, params, e, null);
            log.severe(String.format(errorString, sessionName, courseId, e.getMessage(), logMessage));
            setForRetry();
            return;
        }
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) TypeToken(com.google.gson.reflect.TypeToken) LogMessageGenerator(teammates.common.util.LogMessageGenerator) StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) Map(java.util.Map)

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