use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class AdminAccountDeleteAction method execute.
@Override
protected ActionResult execute() {
gateKeeper.verifyAdminPrivileges(account);
String instructorId = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_ID);
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String account = getRequestParamValue("account");
// TODO: We should extract these into separate actions e.g., AdminInstructorDowngradeAction
if (courseId == null && account == null) {
// delete instructor status
logic.downgradeInstructorToStudentCascade(instructorId);
statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_STATUS_DELETED, StatusMessageColor.SUCCESS));
statusToAdmin = "Instructor Status for <span class=\"bold\">" + instructorId + "</span> has been deleted.";
return createRedirectResult(Const.ActionURIs.ADMIN_ACCOUNT_MANAGEMENT_PAGE);
}
if (courseId == null && account != null) {
// delete entire account
logic.deleteAccount(instructorId);
statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_ACCOUNT_DELETED, StatusMessageColor.SUCCESS));
statusToAdmin = "Instructor Account for <span class=\"bold\">" + instructorId + "</span> has been deleted.";
return createRedirectResult(Const.ActionURIs.ADMIN_ACCOUNT_MANAGEMENT_PAGE);
}
String studentId = getRequestParamValue(Const.ParamsNames.STUDENT_ID);
if (courseId != null && studentId != null) {
// remove student from course
StudentAttributes student = logic.getStudentForGoogleId(courseId, studentId);
logic.deleteStudent(courseId, student.email);
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_DELETED, StatusMessageColor.SUCCESS));
statusToAdmin = "Instructor <span class=\"bold\">" + instructorId + "</span>'s student status in Course" + "<span class=\"bold\">[" + courseId + "]</span> has been deleted";
return createRedirectResult(Const.ActionURIs.ADMIN_ACCOUNT_DETAILS_PAGE + "?instructorid=" + studentId);
}
// remove instructor from course
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, instructorId);
logic.deleteInstructor(courseId, instructor.email);
statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_REMOVED_FROM_COURSE, StatusMessageColor.SUCCESS));
statusToAdmin = "Instructor <span class=\"bold\">" + instructorId + "</span> has been deleted from Course<span class=\"bold\">[" + courseId + "]</span>";
return createRedirectResult(Const.ActionURIs.ADMIN_ACCOUNT_DETAILS_PAGE + "?instructorid=" + instructorId);
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class StudentsLogic method getSectionInvalidityInfo.
private String getSectionInvalidityInfo(List<StudentAttributes> mergedList) {
StudentAttributes.sortBySectionName(mergedList);
List<String> invalidSectionList = new ArrayList<>();
int studentsCount = 1;
for (int i = 1; i < mergedList.size(); i++) {
StudentAttributes currentStudent = mergedList.get(i);
StudentAttributes previousStudent = mergedList.get(i - 1);
if (currentStudent.section.equals(previousStudent.section)) {
studentsCount++;
} else {
if (studentsCount > SECTION_SIZE_LIMIT) {
invalidSectionList.add(previousStudent.section);
}
studentsCount = 1;
}
if (i == mergedList.size() - 1 && studentsCount > SECTION_SIZE_LIMIT) {
invalidSectionList.add(currentStudent.section);
}
}
StringBuilder errorMessage = new StringBuilder();
for (String section : invalidSectionList) {
errorMessage.append(String.format(Const.StatusMessages.SECTION_QUOTA_EXCEED, section));
}
return errorMessage.toString();
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class StudentsLogic method deleteStudentsForGoogleIdWithoutDocument.
public void deleteStudentsForGoogleIdWithoutDocument(String googleId) {
List<StudentAttributes> students = studentsDb.getStudentsForGoogleId(googleId);
for (StudentAttributes student : students) {
fsLogic.deleteStudentFromRespondentsList(student);
}
studentsDb.deleteStudentsForGoogleIdWithoutDocument(googleId);
}
use of teammates.common.datatransfer.attributes.StudentAttributes 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.attributes.StudentAttributes in project teammates by TEAMMATES.
the class StudentsLogic method deleteStudentsForGoogleId.
public void deleteStudentsForGoogleId(String googleId) {
List<StudentAttributes> students = studentsDb.getStudentsForGoogleId(googleId);
for (StudentAttributes student : students) {
fsLogic.deleteStudentFromRespondentsList(student);
}
studentsDb.deleteStudentsForGoogleId(googleId);
}
Aggregations