Search in sources :

Example 6 with FeedbackSessionResponseStatus

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

the class FeedbackSessionsLogic method getFeedbackSessionResultsForQuestionId.

private FeedbackSessionResultsBundle getFeedbackSessionResultsForQuestionId(String feedbackSessionName, String courseId, String userEmail, UserRole role, CourseRoster roster, FeedbackSessionAttributes session, List<FeedbackQuestionAttributes> allQuestions, Map<String, FeedbackQuestionAttributes> relevantQuestions, boolean isIncludeResponseStatus, String section, String questionId) {
    List<FeedbackResponseAttributes> responses = new ArrayList<>();
    Map<String, String> emailNameTable = new HashMap<>();
    Map<String, String> emailLastNameTable = new HashMap<>();
    Map<String, String> emailTeamNameTable = new HashMap<>();
    Map<String, Set<String>> sectionTeamNameTable = new HashMap<>();
    Map<String, boolean[]> visibilityTable = new HashMap<>();
    Map<String, List<FeedbackResponseCommentAttributes>> responseComments = new HashMap<>();
    FeedbackSessionResponseStatus responseStatus = new FeedbackSessionResponseStatus();
    boolean isQueryingResponseRateStatus = questionId.equals(QUESTION_ID_FOR_RESPONSE_RATE);
    if (isQueryingResponseRateStatus) {
        responseStatus = section == null && isIncludeResponseStatus ? getFeedbackSessionResponseStatus(session, roster, allQuestions) : null;
    } else {
        FeedbackQuestionAttributes question = fqLogic.getFeedbackQuestion(questionId);
        if (question != null) {
            relevantQuestions.put(question.getId(), question);
            List<FeedbackResponseAttributes> responsesForThisQn;
            boolean isPrivateSessionCreatedByThisUser = session.isCreator(userEmail) && session.isPrivateSession();
            if (isPrivateSessionCreatedByThisUser) {
                responsesForThisQn = frLogic.getFeedbackResponsesForQuestion(question.getId());
            } else {
                responsesForThisQn = frLogic.getViewableFeedbackResponsesForQuestionInSection(question, userEmail, UserRole.INSTRUCTOR, section);
            }
            StudentAttributes student = getStudent(courseId, userEmail, role);
            Set<String> studentsEmailInTeam = getTeammateEmails(courseId, student);
            boolean hasResponses = !responsesForThisQn.isEmpty();
            if (hasResponses) {
                Map<String, FeedbackResponseAttributes> relevantResponse = new HashMap<>();
                for (FeedbackResponseAttributes response : responsesForThisQn) {
                    InstructorAttributes instructor = getInstructor(courseId, userEmail, role);
                    boolean isVisibleResponse = isResponseVisibleForUser(userEmail, role, null, null, response, question, instructor);
                    if (isVisibleResponse) {
                        relevantResponse.put(response.getId(), response);
                        relevantQuestions.put(question.getId(), question);
                        responses.add(response);
                        addEmailNamePairsToTable(emailNameTable, response, question, roster);
                        addEmailLastNamePairsToTable(emailLastNameTable, response, question, roster);
                        addEmailTeamNamePairsToTable(emailTeamNameTable, response, question, roster);
                        addVisibilityToTable(visibilityTable, question, response, userEmail, role, roster);
                    }
                }
                responseComments = getResponseComments(feedbackSessionName, courseId, userEmail, role, roster, relevantQuestions, section, student, studentsEmailInTeam, relevantResponse);
            }
        }
    }
    addSectionTeamNamesToTable(sectionTeamNameTable, roster, courseId, userEmail, role, feedbackSessionName, section);
    return new FeedbackSessionResultsBundle(session, responses, relevantQuestions, emailNameTable, emailLastNameTable, emailTeamNameTable, sectionTeamNameTable, visibilityTable, responseStatus, roster, responseComments, true);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) FeedbackSessionResultsBundle(teammates.common.datatransfer.FeedbackSessionResultsBundle) FeedbackSessionResponseStatus(teammates.common.datatransfer.FeedbackSessionResponseStatus) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with FeedbackSessionResponseStatus

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

the class FeedbackSessionsLogic method getFeedbackSessionResultsForUserInSectionByQuestions.

/* Get the feedback results for user in a section iterated by questions */
private FeedbackSessionResultsBundle getFeedbackSessionResultsForUserInSectionByQuestions(String feedbackSessionName, String courseId, String userEmail, UserRole role, String section, CourseRoster roster) throws EntityDoesNotExistException {
    FeedbackSessionAttributes session = fsDb.getFeedbackSession(courseId, feedbackSessionName);
    if (session == null) {
        throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_VIEW + courseId + "/" + feedbackSessionName);
    }
    // create empty data containers to store results
    List<FeedbackResponseAttributes> responses = new ArrayList<>();
    Map<String, FeedbackQuestionAttributes> relevantQuestions = new HashMap<>();
    Map<String, String> emailNameTable = new HashMap<>();
    Map<String, String> emailLastNameTable = new HashMap<>();
    Map<String, String> emailTeamNameTable = new HashMap<>();
    Map<String, Set<String>> sectionTeamNameTable = new HashMap<>();
    Map<String, boolean[]> visibilityTable = new HashMap<>();
    Map<String, List<FeedbackResponseCommentAttributes>> responseComments = new HashMap<>();
    FeedbackSessionResponseStatus responseStatus = new FeedbackSessionResponseStatus();
    boolean isPrivateSessionNotCreatedByThisUser = session.isPrivateSession() && !session.isCreator(userEmail);
    if (isPrivateSessionNotCreatedByThisUser) {
        // return empty result set
        return new FeedbackSessionResultsBundle(session, responses, relevantQuestions, emailNameTable, emailLastNameTable, emailTeamNameTable, sectionTeamNameTable, visibilityTable, responseStatus, roster, responseComments);
    }
    List<FeedbackQuestionAttributes> allQuestions = fqLogic.getFeedbackQuestionsForSession(feedbackSessionName, courseId);
    Map<String, FeedbackResponseAttributes> relevantResponse = new HashMap<>();
    for (FeedbackQuestionAttributes question : allQuestions) {
        List<FeedbackResponseAttributes> responsesForThisQn;
        boolean isPrivateSessionCreatedByThisUser = session.isCreator(userEmail) && session.isPrivateSession();
        if (isPrivateSessionCreatedByThisUser) {
            responsesForThisQn = frLogic.getFeedbackResponsesForQuestion(question.getId());
        } else {
            responsesForThisQn = frLogic.getViewableFeedbackResponsesForQuestionInSection(question, userEmail, role, section);
        }
        boolean hasResponses = !responsesForThisQn.isEmpty();
        if (hasResponses) {
            relevantQuestions.put(question.getId(), question);
            responses.addAll(responsesForThisQn);
            for (FeedbackResponseAttributes response : responsesForThisQn) {
                relevantResponse.put(response.getId(), response);
                addEmailNamePairsToTable(emailNameTable, response, question, roster);
                addEmailLastNamePairsToTable(emailLastNameTable, response, question, roster);
                addEmailTeamNamePairsToTable(emailTeamNameTable, response, question, roster);
                addVisibilityToTable(visibilityTable, question, response, userEmail, role, roster);
            }
        }
    }
    StudentAttributes student = null;
    Set<String> studentsEmailInTeam = new HashSet<>();
    if (isStudent(role)) {
        student = studentsLogic.getStudentForEmail(courseId, userEmail);
        List<StudentAttributes> studentsInTeam = studentsLogic.getStudentsForTeam(student.team, courseId);
        for (StudentAttributes teammates : studentsInTeam) {
            studentsEmailInTeam.add(teammates.email);
        }
    }
    List<FeedbackResponseCommentAttributes> allResponseComments = frcLogic.getFeedbackResponseCommentForSession(courseId, feedbackSessionName);
    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;
            }
            if (responseComments.get(frc.feedbackResponseId) == null) {
                responseComments.put(frc.feedbackResponseId, new ArrayList<FeedbackResponseCommentAttributes>());
            }
            responseComments.get(frc.feedbackResponseId).add(frc);
        }
    }
    for (List<FeedbackResponseCommentAttributes> responseCommentList : responseComments.values()) {
        sortByCreatedDate(responseCommentList);
    }
    addSectionTeamNamesToTable(sectionTeamNameTable, roster, courseId, userEmail, role, feedbackSessionName, section);
    return new FeedbackSessionResultsBundle(session, responses, relevantQuestions, emailNameTable, emailLastNameTable, emailTeamNameTable, sectionTeamNameTable, visibilityTable, responseStatus, roster, responseComments);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) FeedbackSessionResultsBundle(teammates.common.datatransfer.FeedbackSessionResultsBundle) FeedbackSessionResponseStatus(teammates.common.datatransfer.FeedbackSessionResponseStatus) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Aggregations

FeedbackSessionResponseStatus (teammates.common.datatransfer.FeedbackSessionResponseStatus)7 ArrayList (java.util.ArrayList)4 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)4 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)4 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 FeedbackSessionResultsBundle (teammates.common.datatransfer.FeedbackSessionResultsBundle)3 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)3 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)3 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)2 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)1 InstructorFeedbackRemindParticularStudentsPageData (teammates.ui.pagedata.InstructorFeedbackRemindParticularStudentsPageData)1