Search in sources :

Example 21 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType 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 22 with FeedbackParticipantType

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

the class FeedbackSessionsLogic method addEmailNamePairsToTable.

private void addEmailNamePairsToTable(Map<String, String> emailNameTable, FeedbackResponseAttributes response, FeedbackQuestionAttributes question, CourseRoster roster, int pairType) {
    if (question.giverType == FeedbackParticipantType.TEAMS && roster.isStudentInCourse(response.giver)) {
        emailNameTable.putIfAbsent(response.giver + Const.TEAM_OF_EMAIL_OWNER, getNameTeamNamePairForEmail(question.giverType, response.giver, roster)[pairType]);
        StudentAttributes studentGiver = roster.getStudentForEmail(response.giver);
        if (studentGiver != null) {
            emailNameTable.putIfAbsent(studentGiver.team, getNameTeamNamePairForEmail(question.giverType, response.giver, roster)[pairType]);
        }
    } else {
        emailNameTable.putIfAbsent(response.giver, getNameTeamNamePairForEmail(question.giverType, response.giver, roster)[pairType]);
    }
    FeedbackParticipantType recipientType = null;
    if (question.recipientType == FeedbackParticipantType.SELF) {
        recipientType = question.giverType;
    } else {
        recipientType = question.recipientType;
    }
    emailNameTable.putIfAbsent(response.recipient, getNameTeamNamePairForEmail(recipientType, response.recipient, roster)[pairType]);
}
Also used : FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 23 with FeedbackParticipantType

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

the class InstructorFeedbackResultsPageData method getResponseVisibilityMap.

private Map<FeedbackParticipantType, Boolean> getResponseVisibilityMap(FeedbackQuestionAttributes question) {
    Map<FeedbackParticipantType, Boolean> responseVisibilityMap = new HashMap<>();
    FeedbackParticipantType[] relevantTypes = { FeedbackParticipantType.GIVER, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.OWN_TEAM_MEMBERS, FeedbackParticipantType.RECEIVER_TEAM_MEMBERS, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.INSTRUCTORS };
    for (FeedbackParticipantType participantType : relevantTypes) {
        responseVisibilityMap.put(participantType, isResponseVisibleTo(participantType, question));
    }
    return responseVisibilityMap;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Example 24 with FeedbackParticipantType

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

the class PageData method getTypeOfPeopleCanViewComment.

/**
 * Returns the type of people that can view the response comment.
 */
public String getTypeOfPeopleCanViewComment(FeedbackResponseCommentAttributes comment, FeedbackQuestionAttributes relatedQuestion) {
    StringBuilder peopleCanView = new StringBuilder(100);
    List<FeedbackParticipantType> showCommentTo;
    if (comment.isVisibilityFollowingFeedbackQuestion) {
        showCommentTo = relatedQuestion.showResponsesTo;
    } else {
        showCommentTo = comment.showCommentTo;
    }
    for (int i = 0; i < showCommentTo.size(); i++) {
        FeedbackParticipantType commentViewer = showCommentTo.get(i);
        if (i == showCommentTo.size() - 1 && showCommentTo.size() > 1) {
            peopleCanView.append("and ");
        }
        switch(commentViewer) {
            case GIVER:
                peopleCanView.append("response giver, ");
                break;
            case RECEIVER:
                peopleCanView.append("response recipient, ");
                break;
            case OWN_TEAM:
                peopleCanView.append("response giver's team, ");
                break;
            case RECEIVER_TEAM_MEMBERS:
                peopleCanView.append("response recipient's team, ");
                break;
            case STUDENTS:
                peopleCanView.append("other students in this course, ");
                break;
            case INSTRUCTORS:
                peopleCanView.append("instructors, ");
                break;
            default:
                break;
        }
    }
    String peopleCanViewString = peopleCanView.toString();
    return removeEndComma(peopleCanViewString);
}
Also used : FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Example 25 with FeedbackParticipantType

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

the class InstructorFeedbackEditPageData method configureVisibilitySettings.

private FeedbackQuestionVisibilitySettings configureVisibilitySettings(FeedbackQuestionAttributes question) {
    Map<String, Boolean> isGiverNameVisibleFor = new HashMap<>();
    for (FeedbackParticipantType giverType : question.showGiverNameTo) {
        isGiverNameVisibleFor.put(giverType.name(), true);
    }
    Map<String, Boolean> isRecipientNameVisibleFor = new HashMap<>();
    for (FeedbackParticipantType recipientType : question.showRecipientNameTo) {
        isRecipientNameVisibleFor.put(recipientType.name(), true);
    }
    Map<String, Boolean> isResponsesVisibleFor = new HashMap<>();
    for (FeedbackParticipantType participantType : question.showResponsesTo) {
        isResponsesVisibleFor.put(participantType.name(), true);
    }
    String dropdownMenuLabel = getDropdownMenuLabel(question);
    return new FeedbackQuestionVisibilitySettings(question.getVisibilityMessage(), isResponsesVisibleFor, isGiverNameVisibleFor, isRecipientNameVisibleFor, dropdownMenuLabel);
}
Also used : FeedbackQuestionVisibilitySettings(teammates.ui.template.FeedbackQuestionVisibilitySettings) HashMap(java.util.HashMap) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Aggregations

FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)25 ArrayList (java.util.ArrayList)8 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)8 HashMap (java.util.HashMap)7 Text (com.google.appengine.api.datastore.Text)4 LinkedHashMap (java.util.LinkedHashMap)4 FeedbackResponseCommentRow (teammates.ui.template.FeedbackResponseCommentRow)4 Map (java.util.Map)3 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)3 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)3 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 StudentResultSummary (teammates.common.datatransfer.StudentResultSummary)2 TeamEvalResult (teammates.common.datatransfer.TeamEvalResult)2 DecimalFormat (java.text.DecimalFormat)1 Matcher (java.util.regex.Matcher)1 WebElement (org.openqa.selenium.WebElement)1 Test (org.testng.annotations.Test)1 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)1