Search in sources :

Example 96 with StudentAttributes

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

Example 97 with StudentAttributes

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

Example 98 with StudentAttributes

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

Example 99 with StudentAttributes

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);
}
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 100 with StudentAttributes

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

Aggregations

StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)241 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)85 Test (org.testng.annotations.Test)80 ArrayList (java.util.ArrayList)55 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)33 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)33 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)30 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)27 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)22 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)17 ShowPageResult (teammates.ui.controller.ShowPageResult)15 HashMap (java.util.HashMap)14 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)14 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 EmailWrapper (teammates.common.util.EmailWrapper)13 RedirectResult (teammates.ui.controller.RedirectResult)12 List (java.util.List)11 StatusMessage (teammates.common.util.StatusMessage)10 HashSet (java.util.HashSet)9 StudentEnrollDetails (teammates.common.datatransfer.StudentEnrollDetails)9