Search in sources :

Example 56 with StudentAttributes

use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.

the class CoursesLogic method getCourseStudentListAsCsv.

/**
 * Returns a CSV for the details (name, email, status) of all students belonging to a given course.
 */
public String getCourseStudentListAsCsv(String courseId, String googleId) throws EntityDoesNotExistException {
    Map<String, CourseDetailsBundle> courses = getCourseSummariesForInstructor(googleId, false);
    CourseDetailsBundle course = courses.get(courseId);
    boolean hasSection = hasIndicatedSections(courseId);
    StringBuilder export = new StringBuilder(100);
    String courseInfo = "Course ID," + SanitizationHelper.sanitizeForCsv(courseId) + System.lineSeparator() + "Course Name," + SanitizationHelper.sanitizeForCsv(course.course.getName()) + System.lineSeparator() + System.lineSeparator() + System.lineSeparator();
    export.append(courseInfo);
    String header = (hasSection ? "Section," : "") + "Team,Full Name,Last Name,Status,Email" + System.lineSeparator();
    export.append(header);
    for (SectionDetailsBundle section : course.sections) {
        for (TeamDetailsBundle team : section.teams) {
            for (StudentAttributes student : team.students) {
                String studentStatus = null;
                if (student.googleId == null || student.googleId.isEmpty()) {
                    studentStatus = Const.STUDENT_COURSE_STATUS_YET_TO_JOIN;
                } else {
                    studentStatus = Const.STUDENT_COURSE_STATUS_JOINED;
                }
                if (hasSection) {
                    export.append(SanitizationHelper.sanitizeForCsv(section.name)).append(',');
                }
                export.append(SanitizationHelper.sanitizeForCsv(team.name) + ',' + SanitizationHelper.sanitizeForCsv(StringHelper.removeExtraSpace(student.name)) + ',' + SanitizationHelper.sanitizeForCsv(StringHelper.removeExtraSpace(student.lastName)) + ',' + SanitizationHelper.sanitizeForCsv(studentStatus) + ',' + SanitizationHelper.sanitizeForCsv(student.email) + System.lineSeparator());
            }
        }
    }
    return export.toString();
}
Also used : CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) TeamDetailsBundle(teammates.common.datatransfer.TeamDetailsBundle) SectionDetailsBundle(teammates.common.datatransfer.SectionDetailsBundle) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 57 with StudentAttributes

use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.

the class EmailGenerator method generateFeedbackSessionPublishedEmails.

/**
 * Generates the feedback session published emails for the given {@code session}.
 */
public List<EmailWrapper> generateFeedbackSessionPublishedEmails(FeedbackSessionAttributes session) {
    String template = EmailTemplates.USER_FEEDBACK_SESSION_PUBLISHED;
    CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
    boolean isEmailNeeded = fsLogic.isFeedbackSessionViewableToStudents(session);
    List<InstructorAttributes> instructors = isEmailNeeded ? instructorsLogic.getInstructorsForCourse(session.getCourseId()) : new ArrayList<InstructorAttributes>();
    List<StudentAttributes> students = isEmailNeeded ? studentsLogic.getStudentsForCourse(session.getCourseId()) : new ArrayList<StudentAttributes>();
    String additionalContactInformation = getAdditionalContactInformationFragment(course);
    return generateFeedbackSessionEmailBases(course, session, students, instructors, template, EmailType.FEEDBACK_PUBLISHED.getSubject(), FEEDBACK_ACTION_VIEW, additionalContactInformation);
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 58 with StudentAttributes

use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.

the class EmailGenerator method generateFeedbackSessionUnpublishedEmails.

/**
 * Generates the feedback session published emails for the given {@code session}.
 */
public List<EmailWrapper> generateFeedbackSessionUnpublishedEmails(FeedbackSessionAttributes session) {
    String template = EmailTemplates.USER_FEEDBACK_SESSION_UNPUBLISHED;
    CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
    boolean isEmailNeeded = fsLogic.isFeedbackSessionViewableToStudents(session);
    List<InstructorAttributes> instructors = isEmailNeeded ? instructorsLogic.getInstructorsForCourse(session.getCourseId()) : new ArrayList<InstructorAttributes>();
    List<StudentAttributes> students = isEmailNeeded ? studentsLogic.getStudentsForCourse(session.getCourseId()) : new ArrayList<StudentAttributes>();
    return generateFeedbackSessionEmailBases(course, session, students, instructors, template, EmailType.FEEDBACK_UNPUBLISHED.getSubject());
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 59 with StudentAttributes

use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.

the class FeedbackSessionResultsBundle method getSortedListOfStudentEmails.

/**
 * Returns a list of student emails, sorted by section name.
 */
private List<String> getSortedListOfStudentEmails() {
    List<String> emailList = new ArrayList<>();
    List<StudentAttributes> students = roster.getStudents();
    StudentAttributes.sortBySectionName(students);
    for (StudentAttributes student : students) {
        emailList.add(student.email);
    }
    return emailList;
}
Also used : ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 60 with StudentAttributes

use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.

the class FeedbackSessionResultsBundle method getPossibleGivers.

/**
 * Get the possible givers for a recipient specified by its participant identifier for
 * a question.
 *
 * @return a list of participant identifiers that can give a response to the recipient specified
 */
public List<String> getPossibleGivers(FeedbackQuestionAttributes fqa, String recipientParticipantIdentifier) {
    if (recipientParticipantIdentifier.contains("@@")) {
        return new ArrayList<>();
    }
    if (isParticipantIdentifierStudent(recipientParticipantIdentifier)) {
        StudentAttributes student = roster.getStudentForEmail(recipientParticipantIdentifier);
        return getPossibleGivers(fqa, student);
    } else if (isParticipantIdentifierInstructor(recipientParticipantIdentifier)) {
        return getPossibleGivers(fqa);
    } else if (recipientParticipantIdentifier.equals(Const.GENERAL_QUESTION)) {
        switch(fqa.giverType) {
            case STUDENTS:
                return getSortedListOfStudentEmails();
            case TEAMS:
                return getSortedListOfTeams();
            case INSTRUCTORS:
                return getSortedListOfInstructorEmails();
            case SELF:
                List<String> creatorEmail = new ArrayList<>();
                creatorEmail.add(fqa.creatorEmail);
                return creatorEmail;
            default:
                log.severe("Invalid giver type specified");
                return new ArrayList<>();
        }
    } else {
        return getPossibleGiversForTeam(fqa, recipientParticipantIdentifier);
    }
}
Also used : ArrayList(java.util.ArrayList) 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