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);
}
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);
}
Aggregations