Search in sources :

Example 21 with CourseAttributes

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

the class InstructorStudentListPageAction method execute.

@Override
public ActionResult execute() {
    gateKeeper.verifyInstructorPrivileges(account);
    String searchKey = getRequestParamValue(Const.ParamsNames.SEARCH_KEY);
    Boolean displayArchive = getRequestParamAsBoolean(Const.ParamsNames.DISPLAY_ARCHIVE);
    Map<String, InstructorAttributes> instructors = new HashMap<>();
    List<CourseAttributes> courses = logic.getCoursesForInstructor(account.googleId);
    // Sort by creation date
    courses.sort(Comparator.comparing(course -> course.createdAt));
    // Get instructor attributes
    List<InstructorAttributes> instructorList = logic.getInstructorsForGoogleId(account.googleId);
    for (InstructorAttributes instructor : instructorList) {
        instructors.put(instructor.courseId, instructor);
    }
    if (courses.isEmpty()) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_NO_COURSE_AND_STUDENTS, StatusMessageColor.WARNING));
    }
    statusToAdmin = "instructorStudentList Page Load<br>" + "Total Courses: " + courses.size();
    List<InstructorStudentListPageCourseData> coursesToDisplay = new ArrayList<>();
    for (CourseAttributes course : courses) {
        InstructorAttributes instructor = instructors.get(course.getId());
        boolean isInstructorAllowedToModify = instructor.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
        boolean isCourseDisplayed = displayArchive || !instructor.isArchived;
        if (isCourseDisplayed) {
            coursesToDisplay.add(new InstructorStudentListPageCourseData(course, instructor.isArchived, isInstructorAllowedToModify));
        }
    }
    InstructorStudentListPageData data = new InstructorStudentListPageData(account, sessionToken, searchKey, displayArchive, coursesToDisplay);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_STUDENT_LIST, data);
}
Also used : List(java.util.List) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Const(teammates.common.util.Const) Map(java.util.Map) InstructorStudentListPageCourseData(teammates.ui.datatransfer.InstructorStudentListPageCourseData) StatusMessage(teammates.common.util.StatusMessage) HashMap(java.util.HashMap) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) StatusMessageColor(teammates.common.util.StatusMessageColor) Comparator(java.util.Comparator) InstructorStudentListPageData(teammates.ui.pagedata.InstructorStudentListPageData) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage) InstructorStudentListPageCourseData(teammates.ui.datatransfer.InstructorStudentListPageCourseData) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorStudentListPageData(teammates.ui.pagedata.InstructorStudentListPageData)

Example 22 with CourseAttributes

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

the class CoursesLogic method getCourseSummaryWithoutStatsForInstructor.

private Map<String, CourseSummaryBundle> getCourseSummaryWithoutStatsForInstructor(List<InstructorAttributes> instructorAttributesList) {
    HashMap<String, CourseSummaryBundle> courseSummaryList = new HashMap<>();
    List<String> courseIdList = new ArrayList<>();
    for (InstructorAttributes ia : instructorAttributesList) {
        courseIdList.add(ia.courseId);
    }
    List<CourseAttributes> courseList = coursesDb.getCourses(courseIdList);
    // Check that all courseIds queried returned a course.
    if (courseIdList.size() > courseList.size()) {
        for (CourseAttributes ca : courseList) {
            courseIdList.remove(ca.getId());
        }
        log.severe("Course(s) was deleted but the instructor still exists: " + System.lineSeparator() + courseIdList.toString());
    }
    for (CourseAttributes ca : courseList) {
        courseSummaryList.put(ca.getId(), getCourseSummaryWithoutStats(ca));
    }
    return courseSummaryList;
}
Also used : CourseSummaryBundle(teammates.common.datatransfer.CourseSummaryBundle) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 23 with CourseAttributes

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

the class CoursesLogic method getCoursesForInstructor.

/**
 * Returns a list of {@link CourseAttributes} for all courses for a given list of instructors.
 */
public List<CourseAttributes> getCoursesForInstructor(List<InstructorAttributes> instructorList) {
    Assumption.assertNotNull("Supplied parameter was null", instructorList);
    List<String> courseIdList = new ArrayList<>();
    for (InstructorAttributes instructor : instructorList) {
        courseIdList.add(instructor.courseId);
    }
    List<CourseAttributes> courseList = coursesDb.getCourses(courseIdList);
    // Check that all courseIds queried returned a course.
    if (courseIdList.size() > courseList.size()) {
        for (CourseAttributes ca : courseList) {
            courseIdList.remove(ca.getId());
        }
        log.severe("Course(s) was deleted but the instructor still exists: " + System.lineSeparator() + courseIdList.toString());
    }
    return courseList;
}
Also used : ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 24 with CourseAttributes

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

the class EmailGenerator method generateFeedbackSubmissionConfirmationEmailForStudent.

/**
 * Generates the feedback submission confirmation email for the given {@code session} for {@code student}.
 */
public EmailWrapper generateFeedbackSubmissionConfirmationEmailForStudent(FeedbackSessionAttributes session, StudentAttributes student, Instant timestamp) {
    CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
    String submitUrl = Config.getAppUrl(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE).withCourseId(course.getId()).withSessionName(session.getFeedbackSessionName()).withRegistrationKey(StringHelper.encrypt(student.key)).withStudentEmail(student.email).toAbsoluteString();
    return generateSubmissionConfirmationEmail(course, session, submitUrl, student.name, student.email, timestamp);
}
Also used : CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 25 with CourseAttributes

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

the class EmailGenerator method generateFeedbackSessionReminderEmails.

/**
 * Generates the feedback session reminder emails for the given {@code session} for {@code students}
 * and {@code instructorsToRemind}. In addition, the emails will also be forwarded to {@code instructorsToNotify}.
 */
public List<EmailWrapper> generateFeedbackSessionReminderEmails(FeedbackSessionAttributes session, List<StudentAttributes> students, List<InstructorAttributes> instructorsToRemind, InstructorAttributes instructorToNotify) {
    CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
    String template = EmailTemplates.USER_FEEDBACK_SESSION.replace("${status}", FEEDBACK_STATUS_SESSION_OPEN);
    String additionalContactInformation = HTML_NO_ACTION_REQUIRED + getAdditionalContactInformationFragment(course);
    List<InstructorAttributes> instructorToNotifyAsList = new ArrayList<>();
    instructorToNotifyAsList.add(instructorToNotify);
    List<EmailWrapper> emails = generateFeedbackSessionEmailBasesForInstructorReminders(course, session, instructorsToRemind, template, EmailType.FEEDBACK_SESSION_REMINDER.getSubject(), additionalContactInformation);
    emails.addAll(generateFeedbackSessionEmailBases(course, session, students, instructorToNotifyAsList, template, EmailType.FEEDBACK_SESSION_REMINDER.getSubject(), FEEDBACK_ACTION_SUBMIT, additionalContactInformation));
    return emails;
}
Also used : ArrayList(java.util.ArrayList) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EmailWrapper(teammates.common.util.EmailWrapper)

Aggregations

CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)106 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)48 Test (org.testng.annotations.Test)40 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)33 ArrayList (java.util.ArrayList)31 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)19 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)16 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)15 EmailWrapper (teammates.common.util.EmailWrapper)15 HashMap (java.util.HashMap)12 InvalidParametersException (teammates.common.exception.InvalidParametersException)10 EmailGenerator (teammates.logic.api.EmailGenerator)10 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)8 StatusMessage (teammates.common.util.StatusMessage)6 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)5 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)4 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)4 EntityAlreadyExistsException (teammates.common.exception.EntityAlreadyExistsException)4 InstructorCoursesPageData (teammates.ui.pagedata.InstructorCoursesPageData)4 InstructorFeedbackSessionsPageData (teammates.ui.pagedata.InstructorFeedbackSessionsPageData)4