Search in sources :

Example 11 with TeamDetailsBundle

use of teammates.common.datatransfer.TeamDetailsBundle in project teammates by TEAMMATES.

the class FeedbackMcqQuestionDetails method generateOptionList.

private List<String> generateOptionList(String courseId) {
    List<String> optionList = new ArrayList<>();
    switch(generateOptionsFor) {
        case NONE:
            optionList = mcqChoices;
            break;
        case STUDENTS:
        // fallthrough
        case STUDENTS_EXCLUDING_SELF:
            List<StudentAttributes> studentList = StudentsLogic.inst().getStudentsForCourse(courseId);
            if (generateOptionsFor == FeedbackParticipantType.STUDENTS_EXCLUDING_SELF) {
                studentList.removeIf(studentInList -> studentInList.email.equals(studentDoingQuestion.email));
            }
            for (StudentAttributes student : studentList) {
                optionList.add(student.name + " (" + student.team + ")");
            }
            optionList.sort(null);
            break;
        case TEAMS:
        // fallthrough
        case TEAMS_EXCLUDING_SELF:
            try {
                List<TeamDetailsBundle> teamList = CoursesLogic.inst().getTeamsForCourse(courseId);
                if (generateOptionsFor == FeedbackParticipantType.TEAMS_EXCLUDING_SELF) {
                    teamList.removeIf(teamInList -> teamInList.name.equals(studentDoingQuestion.team));
                }
                for (TeamDetailsBundle team : teamList) {
                    optionList.add(team.name);
                }
                optionList.sort(null);
            } catch (EntityDoesNotExistException e) {
                Assumption.fail("Course disappeared");
            }
            break;
        case INSTRUCTORS:
            List<InstructorAttributes> instructorList = InstructorsLogic.inst().getInstructorsForCourse(courseId);
            for (InstructorAttributes instructor : instructorList) {
                optionList.add(instructor.name);
            }
            optionList.sort(null);
            break;
        default:
            Assumption.fail("Trying to generate options for neither students, teams nor instructors");
            break;
    }
    return optionList;
}
Also used : TeamDetailsBundle(teammates.common.datatransfer.TeamDetailsBundle) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 12 with TeamDetailsBundle

use of teammates.common.datatransfer.TeamDetailsBundle in project teammates by TEAMMATES.

the class InstructorEditStudentFeedbackPageAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    String moderatedEntityIdentifier = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON);
    StudentAttributes studentUnderModeration = logic.getStudentForEmail(courseId, moderatedEntityIdentifier);
    if (studentUnderModeration == null) {
        List<TeamDetailsBundle> teams = logic.getTeamsForCourse(courseId);
        boolean isTeam = false;
        for (TeamDetailsBundle team : teams) {
            if (team.name.equals(moderatedEntityIdentifier)) {
                isTeam = true;
                studentUnderModeration = team.students.get(0);
                break;
            }
        }
        if (!isTeam) {
            throw new EntityDoesNotExistException("An entity with the identifier " + moderatedEntityIdentifier + " does not exist in " + courseId + ".");
        }
    }
    String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseId, account.googleId), logic.getFeedbackSession(feedbackSessionName, courseId), false, studentUnderModeration.section, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS);
    String moderatedQuestionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_MODERATED_QUESTION_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedEntityIdentifier);
    FeedbackSubmissionEditPageData data = new FeedbackSubmissionEditPageData(account, student, sessionToken);
    data.bundle = logic.getFeedbackSessionQuestionsBundleForStudent(feedbackSessionName, courseId, studentUnderModeration.email);
    Assumption.assertNotNull(data.bundle);
    data.setSessionOpenForSubmission(true);
    data.setModeration(true);
    data.setHeaderHidden(true);
    data.setStudentToViewPageAs(studentUnderModeration);
    data.setSubmitAction(Const.ActionURIs.INSTRUCTOR_EDIT_STUDENT_FEEDBACK_SAVE);
    if (moderatedQuestionId != null) {
        data.setModeratedQuestionId(moderatedQuestionId);
    }
    statusToAdmin = "Moderating feedback session for student (" + studentUnderModeration.email + ")<br>" + "Session Name: " + feedbackSessionName + "<br>" + "Course ID: " + courseId;
    data.bundle.hideUnmoderatableQuestions();
    data.init(courseId);
    return createShowPageResult(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, data);
}
Also used : TeamDetailsBundle(teammates.common.datatransfer.TeamDetailsBundle) FeedbackSubmissionEditPageData(teammates.ui.pagedata.FeedbackSubmissionEditPageData) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 13 with TeamDetailsBundle

use of teammates.common.datatransfer.TeamDetailsBundle in project teammates by TEAMMATES.

the class FeedbackQuestionsLogic method getRecipientsForQuestion.

public Map<String, String> getRecipientsForQuestion(FeedbackQuestionAttributes question, String giver, InstructorAttributes instructorGiver, StudentAttributes studentGiver) throws EntityDoesNotExistException {
    Map<String, String> recipients = new HashMap<>();
    FeedbackParticipantType recipientType = question.recipientType;
    String giverTeam = getGiverTeam(giver, instructorGiver, studentGiver);
    switch(recipientType) {
        case SELF:
            if (question.giverType == FeedbackParticipantType.TEAMS) {
                recipients.put(studentGiver.team, studentGiver.team);
            } else {
                recipients.put(giver, Const.USER_NAME_FOR_SELF);
            }
            break;
        case STUDENTS:
            List<StudentAttributes> studentsInCourse = studentsLogic.getStudentsForCourse(question.courseId);
            for (StudentAttributes student : studentsInCourse) {
                // Ensure student does not evaluate himself
                if (!giver.equals(student.email)) {
                    recipients.put(student.email, student.name);
                }
            }
            break;
        case INSTRUCTORS:
            List<InstructorAttributes> instructorsInCourse = instructorsLogic.getInstructorsForCourse(question.courseId);
            for (InstructorAttributes instr : instructorsInCourse) {
                // Ensure instructor does not evaluate himself
                if (!giver.equals(instr.email)) {
                    recipients.put(instr.email, instr.name);
                }
            }
            break;
        case TEAMS:
            List<TeamDetailsBundle> teams = coursesLogic.getTeamsForCourse(question.courseId);
            for (TeamDetailsBundle team : teams) {
                // Ensure student('s team) does not evaluate own team.
                if (!giverTeam.equals(team.name)) {
                    // recipientEmail doubles as team name in this case.
                    recipients.put(team.name, team.name);
                }
            }
            break;
        case OWN_TEAM:
            recipients.put(giverTeam, giverTeam);
            break;
        case OWN_TEAM_MEMBERS:
            List<StudentAttributes> students = studentsLogic.getStudentsForTeam(giverTeam, question.courseId);
            for (StudentAttributes student : students) {
                if (!student.email.equals(giver)) {
                    recipients.put(student.email, student.name);
                }
            }
            break;
        case OWN_TEAM_MEMBERS_INCLUDING_SELF:
            List<StudentAttributes> teamMembers = studentsLogic.getStudentsForTeam(giverTeam, question.courseId);
            for (StudentAttributes student : teamMembers) {
                // accepts self feedback too
                recipients.put(student.email, student.name);
            }
            break;
        case NONE:
            recipients.put(Const.GENERAL_QUESTION, Const.GENERAL_QUESTION);
            break;
        default:
            break;
    }
    return recipients;
}
Also used : TeamDetailsBundle(teammates.common.datatransfer.TeamDetailsBundle) HashMap(java.util.HashMap) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 14 with TeamDetailsBundle

use of teammates.common.datatransfer.TeamDetailsBundle in project teammates by TEAMMATES.

the class InstructorSearchPageData method createStudentRows.

private List<StudentListSectionData> createStudentRows(String courseId, StudentSearchResultBundle studentSearchResultBundle) {
    List<StudentListSectionData> rows = new ArrayList<>();
    List<StudentAttributes> studentsInCourse = filterStudentsByCourse(courseId, studentSearchResultBundle);
    Map<String, Set<String>> sectionNameToTeamNameMap = new HashMap<>();
    Map<String, List<StudentAttributes>> teamNameToStudentsMap = new HashMap<>();
    Map<String, String> emailToPhotoUrlMap = new HashMap<>();
    for (StudentAttributes student : studentsInCourse) {
        String teamName = student.team;
        String sectionName = student.section;
        String viewPhotoLink = addUserIdToUrl(student.getPublicProfilePictureUrl());
        emailToPhotoUrlMap.put(student.email, viewPhotoLink);
        teamNameToStudentsMap.computeIfAbsent(teamName, key -> new ArrayList<>()).add(student);
        sectionNameToTeamNameMap.computeIfAbsent(sectionName, key -> new HashSet<>()).add(teamName);
    }
    List<SectionDetailsBundle> sections = new ArrayList<>();
    sectionNameToTeamNameMap.forEach((sectionName, teamNameList) -> {
        SectionDetailsBundle sdb = new SectionDetailsBundle();
        sdb.name = sectionName;
        ArrayList<TeamDetailsBundle> teams = new ArrayList<>();
        for (String teamName : teamNameList) {
            TeamDetailsBundle tdb = new TeamDetailsBundle();
            tdb.name = teamName;
            tdb.students = teamNameToStudentsMap.get(teamName);
            teams.add(tdb);
        }
        sdb.teams = teams;
        sections.add(sdb);
    });
    for (SectionDetailsBundle section : sections) {
        InstructorAttributes instructor = studentSearchResultBundle.courseIdInstructorMap.get(courseId);
        boolean isAllowedToViewStudentInSection = instructor.isAllowedForPrivilege(section.name, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS);
        boolean isAllowedToModifyStudent = instructor.isAllowedForPrivilege(section.name, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
        rows.add(new StudentListSectionData(section, isAllowedToViewStudentInSection, isAllowedToModifyStudent, emailToPhotoUrlMap, account.googleId, getSessionToken()));
    }
    return rows;
}
Also used : InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Const(teammates.common.util.Const) SearchStudentsTable(teammates.ui.template.SearchStudentsTable) QuestionTable(teammates.ui.template.QuestionTable) HashMap(java.util.HashMap) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) FeedbackResponseCommentSearchResultBundle(teammates.common.datatransfer.FeedbackResponseCommentSearchResultBundle) Map(java.util.Map) StudentListSectionData(teammates.ui.template.StudentListSectionData) SectionDetailsBundle(teammates.common.datatransfer.SectionDetailsBundle) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) SearchFeedbackSessionDataTable(teammates.ui.template.SearchFeedbackSessionDataTable) Set(java.util.Set) AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) ZoneId(java.time.ZoneId) TeamDetailsBundle(teammates.common.datatransfer.TeamDetailsBundle) List(java.util.List) StudentSearchResultBundle(teammates.common.datatransfer.StudentSearchResultBundle) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) FeedbackSessionRow(teammates.ui.template.FeedbackSessionRow) FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow) ResponseRow(teammates.ui.template.ResponseRow) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) SectionDetailsBundle(teammates.common.datatransfer.SectionDetailsBundle) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) TeamDetailsBundle(teammates.common.datatransfer.TeamDetailsBundle) StudentListSectionData(teammates.ui.template.StudentListSectionData) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Example 15 with TeamDetailsBundle

use of teammates.common.datatransfer.TeamDetailsBundle in project teammates by TEAMMATES.

the class InstructorStudentListAjaxPageAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    String courseIndexString = getRequestParamValue(Const.ParamsNames.COURSE_INDEX);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_INDEX, courseIndexString);
    gateKeeper.verifyInstructorPrivileges(account);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    CourseAttributes course = logic.getCourse(courseId);
    gateKeeper.verifyAccessible(instructor, course);
    List<SectionDetailsBundle> courseSectionDetails = logic.getSectionsForCourse(courseId);
    int courseIndex = Integer.parseInt(courseIndexString);
    boolean hasSection = logic.hasIndicatedSections(courseId);
    Map<String, String> emailPhotoUrlMapping = new HashMap<>();
    Map<String, Map<String, Boolean>> sectionPrivileges = new HashMap<>();
    for (SectionDetailsBundle sectionDetails : courseSectionDetails) {
        for (TeamDetailsBundle teamDetails : sectionDetails.teams) {
            for (StudentAttributes student : teamDetails.students) {
                String studentPhotoUrl = student.getPublicProfilePictureUrl();
                studentPhotoUrl = Url.addParamToUrl(studentPhotoUrl, Const.ParamsNames.USER_ID, account.googleId);
                emailPhotoUrlMapping.put(student.email, studentPhotoUrl);
            }
        }
        Map<String, Boolean> sectionPrivilege = new HashMap<>();
        sectionPrivilege.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS, instructor.isAllowedForPrivilege(sectionDetails.name, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS));
        sectionPrivilege.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT, instructor.isAllowedForPrivilege(sectionDetails.name, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT));
        sectionPrivileges.put(sectionDetails.name, sectionPrivilege);
    }
    InstructorStudentListAjaxPageData data = new InstructorStudentListAjaxPageData(account, sessionToken, courseId, courseIndex, hasSection, courseSectionDetails, sectionPrivileges, emailPhotoUrlMapping);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_STUDENT_LIST_AJAX, data);
}
Also used : HashMap(java.util.HashMap) InstructorStudentListAjaxPageData(teammates.ui.pagedata.InstructorStudentListAjaxPageData) SectionDetailsBundle(teammates.common.datatransfer.SectionDetailsBundle) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) TeamDetailsBundle(teammates.common.datatransfer.TeamDetailsBundle) HashMap(java.util.HashMap) Map(java.util.Map) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Aggregations

TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)16 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)13 ArrayList (java.util.ArrayList)8 SectionDetailsBundle (teammates.common.datatransfer.SectionDetailsBundle)7 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)6 HashMap (java.util.HashMap)5 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)5 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)3 Map (java.util.Map)2 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)2 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)2 InstructorStudentListAjaxPageData (teammates.ui.pagedata.InstructorStudentListAjaxPageData)2 StudentListSectionData (teammates.ui.template.StudentListSectionData)2 ZoneId (java.time.ZoneId)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Test (org.testng.annotations.Test)1 FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)1 FeedbackResponseCommentSearchResultBundle (teammates.common.datatransfer.FeedbackResponseCommentSearchResultBundle)1