use of teammates.common.datatransfer.FeedbackSessionResultsBundle in project teammates by TEAMMATES.
the class InstructorFeedbackResultsPageAction method getBundleForQuestionView.
private FeedbackSessionResultsBundle getBundleForQuestionView(String needAjax, String courseId, String feedbackSessionName, InstructorAttributes instructor, InstructorFeedbackResultsPageData data, String selectedSection, String sortType, String questionId) throws EntityDoesNotExistException {
FeedbackSessionResultsBundle bundle;
if (questionId == null) {
if (ALL_SECTION_OPTION.equals(selectedSection)) {
// load page structure without responses
data.setLargeNumberOfRespondents(needAjax != null);
// all sections and all questions for question view
// set up question tables, responses to load by ajax
bundle = logic.getFeedbackSessionResultsForInstructorWithinRangeFromView(feedbackSessionName, courseId, instructor.email, 1, sortType);
// set isComplete to true to prevent behavior when there are too many responses,
// such as the display of warning messages
bundle.isComplete = true;
} else {
// bundle for all questions, with a selected section
bundle = logic.getFeedbackSessionResultsForInstructorInSection(feedbackSessionName, courseId, instructor.email, selectedSection);
}
} else {
if (ALL_SECTION_OPTION.equals(selectedSection)) {
// bundle for a specific question, with all sections
bundle = logic.getFeedbackSessionResultsForInstructorFromQuestion(feedbackSessionName, courseId, instructor.email, questionId);
} else {
// bundle for a specific question and a specific section
bundle = logic.getFeedbackSessionResultsForInstructorFromQuestionInSection(feedbackSessionName, courseId, instructor.email, questionId, selectedSection);
}
}
return bundle;
}
use of teammates.common.datatransfer.FeedbackSessionResultsBundle in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method getFeedbackSessionResultsForUserWithParams.
private FeedbackSessionResultsBundle getFeedbackSessionResultsForUserWithParams(String feedbackSessionName, String courseId, String userEmail, UserRole role, CourseRoster roster, Map<String, String> params) throws EntityDoesNotExistException {
FeedbackSessionAttributes session = fsDb.getFeedbackSession(courseId, feedbackSessionName);
if (session == null) {
throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_VIEW + courseId + "/" + feedbackSessionName);
}
List<FeedbackQuestionAttributes> allQuestions = fqLogic.getFeedbackQuestionsForSession(feedbackSessionName, courseId);
// Show all questions even if no responses, unless is an ajax request for a specific question.
Map<String, FeedbackQuestionAttributes> relevantQuestions = getAllQuestions(role, params, allQuestions);
boolean isPrivateSessionNotCreatedByThisUser = session.isPrivateSession() && !session.isCreator(userEmail);
if (isPrivateSessionNotCreatedByThisUser) {
// return empty result set
return new FeedbackSessionResultsBundle(session, relevantQuestions, roster);
}
boolean isIncludeResponseStatus = Boolean.parseBoolean(params.get(PARAM_IS_INCLUDE_RESPONSE_STATUS));
String section = params.get(PARAM_SECTION);
String questionId = params.get(PARAM_QUESTION_ID);
if (questionId != null) {
return getFeedbackSessionResultsForQuestionId(feedbackSessionName, courseId, userEmail, role, roster, session, allQuestions, relevantQuestions, isIncludeResponseStatus, section, questionId);
}
Map<String, FeedbackQuestionAttributes> allQuestionsMap = new HashMap<>();
putQuestionsIntoMap(allQuestions, allQuestionsMap);
List<FeedbackResponseAttributes> allResponses = getAllResponses(feedbackSessionName, courseId, params, section);
String rangeString = params.get(PARAM_RANGE);
boolean isComplete = rangeString == null || allResponses.size() <= Integer.parseInt(rangeString);
if (!isComplete) {
putQuestionsIntoMap(allQuestions, relevantQuestions);
}
// create empty data containers to store results
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<>();
FeedbackSessionResponseStatus responseStatus = section == null && isIncludeResponseStatus ? getFeedbackSessionResponseStatus(session, roster, allQuestions) : null;
StudentAttributes student = getStudent(courseId, userEmail, role);
Set<String> studentsEmailInTeam = getTeammateEmails(courseId, student);
InstructorAttributes instructor = getInstructor(courseId, userEmail, role);
Map<String, FeedbackResponseAttributes> relevantResponse = new HashMap<>();
for (FeedbackResponseAttributes response : allResponses) {
FeedbackQuestionAttributes relatedQuestion = allQuestionsMap.get(response.feedbackQuestionId);
if (relatedQuestion != null) {
boolean isVisibleResponse = isResponseVisibleForUser(userEmail, role, student, studentsEmailInTeam, response, relatedQuestion, instructor);
if (isVisibleResponse) {
responses.add(response);
relevantResponse.put(response.getId(), response);
relevantQuestions.put(relatedQuestion.getId(), relatedQuestion);
addEmailNamePairsToTable(emailNameTable, response, relatedQuestion, roster);
addEmailLastNamePairsToTable(emailLastNameTable, response, relatedQuestion, roster);
addEmailTeamNamePairsToTable(emailTeamNameTable, response, relatedQuestion, roster);
addVisibilityToTable(visibilityTable, relatedQuestion, response, userEmail, role, roster);
}
}
}
Map<String, List<FeedbackResponseCommentAttributes>> 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, isComplete);
}
use of teammates.common.datatransfer.FeedbackSessionResultsBundle 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.FeedbackSessionResultsBundle 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