Search in sources :

Example 91 with EntityDoesNotExistException

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);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 92 with EntityDoesNotExistException

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);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 93 with EntityDoesNotExistException

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);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) FeedbackSessionResultsBundle(teammates.common.datatransfer.FeedbackSessionResultsBundle) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) 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 94 with EntityDoesNotExistException

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

Example 95 with EntityDoesNotExistException

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);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) CourseRoster(teammates.common.datatransfer.CourseRoster) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Aggregations

EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)107 InvalidParametersException (teammates.common.exception.InvalidParametersException)35 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)29 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)26 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)24 ArrayList (java.util.ArrayList)21 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)17 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)15 List (java.util.List)10 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)10 HashMap (java.util.HashMap)9 Test (org.testng.annotations.Test)9 FeedbackSession (teammates.storage.entity.FeedbackSession)9 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)8 StatusMessage (teammates.common.util.StatusMessage)8 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)7 Text (com.google.appengine.api.datastore.Text)6 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)6 VoidWork (com.googlecode.objectify.VoidWork)4 HashSet (java.util.HashSet)4