Search in sources :

Example 56 with FeedbackResponseAttributes

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

the class FeedbackResponsesLogic method getViewableFeedbackResponsesForStudentForQuestion.

private List<FeedbackResponseAttributes> getViewableFeedbackResponsesForStudentForQuestion(FeedbackQuestionAttributes question, String studentEmail) {
    List<FeedbackResponseAttributes> viewableResponses = new ArrayList<>();
    if (question.isResponseVisibleTo(FeedbackParticipantType.STUDENTS)) {
        addNewResponses(viewableResponses, getFeedbackResponsesForQuestion(question.getId()));
        // Early return as STUDENTS covers all other student types.
        return viewableResponses;
    }
    StudentAttributes student = studentsLogic.getStudentForEmail(question.courseId, studentEmail);
    if (question.recipientType.isTeam() && question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)) {
        addNewResponses(viewableResponses, getFeedbackResponsesForReceiverForQuestion(question.getId(), student.team));
    }
    if (question.giverType == FeedbackParticipantType.TEAMS || question.isResponseVisibleTo(FeedbackParticipantType.OWN_TEAM_MEMBERS)) {
        addNewResponses(viewableResponses, getFeedbackResponsesFromTeamForQuestion(question.getId(), question.courseId, student.team));
    }
    if (question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS)) {
        addNewResponses(viewableResponses, getFeedbackResponsesForTeamMembersOfStudent(question.getId(), student));
    }
    return viewableResponses;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 57 with FeedbackResponseAttributes

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

the class FeedbackResponsesLogic method deleteResponsesFromUserToTeam.

private void deleteResponsesFromUserToTeam(String courseId, String userEmail) {
    FeedbackQuestionAttributes question;
    List<FeedbackResponseAttributes> responsesFromUser = getFeedbackResponsesFromGiverForCourse(courseId, userEmail);
    for (FeedbackResponseAttributes response : responsesFromUser) {
        question = fqLogic.getFeedbackQuestion(response.feedbackQuestionId);
        if (question.giverType == FeedbackParticipantType.TEAMS || isRecipientTypeTeamMembers(question)) {
            frDb.deleteEntity(response);
        }
    }
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 58 with FeedbackResponseAttributes

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

the class FeedbackResponsesLogic method deleteFeedbackResponsesForStudentAndCascade.

public void deleteFeedbackResponsesForStudentAndCascade(String courseId, String studentEmail) {
    String studentTeam = "";
    StudentAttributes student = studentsLogic.getStudentForEmail(courseId, studentEmail);
    if (student != null) {
        studentTeam = student.team;
    }
    List<FeedbackResponseAttributes> responses = getFeedbackResponsesFromGiverForCourse(courseId, studentEmail);
    responses.addAll(getFeedbackResponsesForReceiverForCourse(courseId, studentEmail));
    // Delete responses to team as well if student is last person in team.
    if (studentsLogic.getStudentsForTeam(studentTeam, courseId).size() <= 1) {
        responses.addAll(getFeedbackResponsesForReceiverForCourse(courseId, studentTeam));
    }
    for (FeedbackResponseAttributes response : responses) {
        this.deleteFeedbackResponseAndCascade(response);
    }
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 59 with FeedbackResponseAttributes

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

the class FeedbackSessionsLogic method updateRespondentsForSession.

public void updateRespondentsForSession(String feedbackSessionName, String courseId) throws InvalidParametersException, EntityDoesNotExistException {
    clearInstructorRespondents(feedbackSessionName, courseId);
    clearStudentRespondents(feedbackSessionName, courseId);
    FeedbackSessionAttributes fsa = getFeedbackSession(feedbackSessionName, courseId);
    List<FeedbackQuestionAttributes> questions = fqLogic.getFeedbackQuestionsForSession(feedbackSessionName, courseId);
    List<InstructorAttributes> instructors = instructorsLogic.getInstructorsForCourse(courseId);
    Map<String, List<String>> instructorQuestionsMap = new HashMap<>();
    for (InstructorAttributes instructor : instructors) {
        List<FeedbackQuestionAttributes> instructorQns = fqLogic.getFeedbackQuestionsForInstructor(questions, fsa.isCreator(instructor.email));
        if (!instructorQns.isEmpty()) {
            List<String> questionIds = new ArrayList<>();
            for (FeedbackQuestionAttributes question : instructorQns) {
                questionIds.add(question.getId());
            }
            instructorQuestionsMap.put(instructor.email, questionIds);
        }
    }
    Set<String> respondingStudentList = new HashSet<>();
    Set<String> respondingInstructorList = new HashSet<>();
    List<FeedbackResponseAttributes> responses = frLogic.getFeedbackResponsesForSession(feedbackSessionName, courseId);
    for (FeedbackResponseAttributes response : responses) {
        List<String> instructorQuestions = instructorQuestionsMap.get(response.giver);
        if (instructorQuestions != null && instructorQuestions.contains(response.feedbackQuestionId)) {
            respondingInstructorList.add(response.giver);
        } else {
            respondingStudentList.add(response.giver);
        }
    }
    addInstructorRespondents(new ArrayList<>(respondingInstructorList), feedbackSessionName, courseId);
    addStudentRespondents(new ArrayList<>(respondingStudentList), feedbackSessionName, courseId);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Example 60 with FeedbackResponseAttributes

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

the class FeedbackSessionsLogic method getResponseComments.

private Map<String, List<FeedbackResponseCommentAttributes>> getResponseComments(String feedbackSessionName, String courseId, String userEmail, UserRole role, CourseRoster roster, Map<String, FeedbackQuestionAttributes> relevantQuestions, String section, StudentAttributes student, Set<String> studentsEmailInTeam, Map<String, FeedbackResponseAttributes> relevantResponse) {
    Map<String, List<FeedbackResponseCommentAttributes>> responseComments = new HashMap<>();
    List<FeedbackResponseCommentAttributes> allResponseComments = frcLogic.getFeedbackResponseCommentForSessionInSection(courseId, feedbackSessionName, section);
    for (FeedbackResponseCommentAttributes frc : allResponseComments) {
        FeedbackResponseAttributes relatedResponse = relevantResponse.get(frc.feedbackResponseId);
        FeedbackQuestionAttributes relatedQuestion = relevantQuestions.get(frc.feedbackQuestionId);
        boolean isVisibleResponseComment = frcLogic.isResponseCommentVisibleForUser(userEmail, role, student, studentsEmailInTeam, relatedResponse, relatedQuestion, frc);
        if (isVisibleResponseComment) {
            if (!frcLogic.isNameVisibleToUser(frc, relatedResponse, userEmail, roster)) {
                frc.giverEmail = Const.DISPLAYED_NAME_FOR_ANONYMOUS_PARTICIPANT;
            }
            List<FeedbackResponseCommentAttributes> frcList = responseComments.get(frc.feedbackResponseId);
            if (frcList == null) {
                frcList = new ArrayList<>();
                frcList.add(frc);
                responseComments.put(frc.feedbackResponseId, frcList);
            } else {
                frcList.add(frc);
            }
        }
    }
    for (List<FeedbackResponseCommentAttributes> responseCommentList : responseComments.values()) {
        sortByCreatedDate(responseCommentList);
    }
    return responseComments;
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) HashMap(java.util.HashMap) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)143 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)70 ArrayList (java.util.ArrayList)63 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)36 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)35 List (java.util.List)29 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)28 HashMap (java.util.HashMap)27 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)22 HashSet (java.util.HashSet)20 LinkedHashMap (java.util.LinkedHashMap)20 Map (java.util.Map)18 Test (org.testng.annotations.Test)18 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)18 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)18 Text (com.google.appengine.api.datastore.Text)15 Set (java.util.Set)11 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)10 Comparator (java.util.Comparator)9 FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)9