use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method addInstructorRespondents.
public void addInstructorRespondents(List<String> emails, String feedbackSessionName, String courseId) throws EntityDoesNotExistException, InvalidParametersException {
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, feedbackSessionName);
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, courseId);
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, emails);
FeedbackSessionAttributes sessionToUpdate = getFeedbackSession(feedbackSessionName, courseId);
if (sessionToUpdate == null) {
throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_UPDATE + courseId + "/" + feedbackSessionName);
}
fsDb.addInstructorRespondents(emails, sessionToUpdate);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method addStudentRespondent.
public void addStudentRespondent(String email, String feedbackSessionName, String courseId) throws EntityDoesNotExistException, InvalidParametersException {
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, feedbackSessionName);
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, courseId);
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, email);
FeedbackSessionAttributes sessionToUpdate = getFeedbackSession(feedbackSessionName, courseId);
if (sessionToUpdate == null) {
throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_UPDATE + courseId + "/" + feedbackSessionName);
}
fsDb.addStudentRespondent(email, sessionToUpdate);
}
use of teammates.common.exception.EntityDoesNotExistException 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.exception.EntityDoesNotExistException 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);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method getFeedbackSessionResponseStatus.
/**
* Gets the response rate status for a session.
*/
public FeedbackSessionResponseStatus getFeedbackSessionResponseStatus(String feedbackSessionName, String courseId) 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);
CourseRoster roster = new CourseRoster(studentsLogic.getStudentsForCourse(courseId), instructorsLogic.getInstructorsForCourse(courseId));
return getFeedbackSessionResponseStatus(session, roster, allQuestions);
}
Aggregations