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());
}
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);
}
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);
}
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);
}
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;
}
}
}
Aggregations