Search in sources :

Example 86 with EntityDoesNotExistException

use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.

the class FeedbackResponsesLogic method deleteFeedbackResponsesForQuestionAndCascade.

public void deleteFeedbackResponsesForQuestionAndCascade(String feedbackQuestionId, boolean hasResponseRateUpdate) {
    List<FeedbackResponseAttributes> responsesForQuestion = getFeedbackResponsesForQuestion(feedbackQuestionId);
    Set<String> emails = new HashSet<>();
    for (FeedbackResponseAttributes response : responsesForQuestion) {
        this.deleteFeedbackResponseAndCascade(response);
        emails.add(response.giver);
    }
    if (!hasResponseRateUpdate) {
        return;
    }
    try {
        FeedbackQuestionAttributes question = fqLogic.getFeedbackQuestion(feedbackQuestionId);
        boolean isInstructor = question.giverType == FeedbackParticipantType.SELF || question.giverType == FeedbackParticipantType.INSTRUCTORS;
        for (String email : emails) {
            boolean hasResponses = hasGiverRespondedForSession(email, question.feedbackSessionName, question.courseId);
            if (!hasResponses) {
                if (isInstructor) {
                    fsLogic.deleteInstructorRespondent(email, question.feedbackSessionName, question.courseId);
                } else {
                    fsLogic.deleteStudentFromRespondentList(email, question.feedbackSessionName, question.courseId);
                }
            }
        }
    } catch (InvalidParametersException | EntityDoesNotExistException e) {
        Assumption.fail("Fail to delete respondent");
    }
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) InvalidParametersException(teammates.common.exception.InvalidParametersException) HashSet(java.util.HashSet) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 87 with EntityDoesNotExistException

use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method clearStudentRespondents.

public void clearStudentRespondents(String feedbackSessionName, String courseId) throws EntityDoesNotExistException, InvalidParametersException {
    Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, feedbackSessionName);
    Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, courseId);
    FeedbackSessionAttributes sessionToUpdate = getFeedbackSession(feedbackSessionName, courseId);
    if (sessionToUpdate == null) {
        throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_UPDATE + courseId + "/" + feedbackSessionName);
    }
    fsDb.clearStudentRespondents(sessionToUpdate);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 88 with EntityDoesNotExistException

use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method addStudentRespondents.

public void addStudentRespondents(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.addStudentRespondents(emails, sessionToUpdate);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 89 with EntityDoesNotExistException

use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method deleteStudentFromRespondentList.

public void deleteStudentFromRespondentList(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.deleteStudentRespondent(email, sessionToUpdate);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 90 with EntityDoesNotExistException

use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method getFeedbackSessionQuestionsForStudent.

/**
 * Gets {@code FeedbackQuestions} and previously filled
 * {@code FeedbackResponses} that a student can view/submit as a
 * {@link FeedbackSessionQuestionsBundle}.
 */
public FeedbackSessionQuestionsBundle getFeedbackSessionQuestionsForStudent(String feedbackSessionName, String courseId, String userEmail) throws EntityDoesNotExistException {
    FeedbackSessionAttributes fsa = fsDb.getFeedbackSession(courseId, feedbackSessionName);
    if (fsa == null) {
        throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_GET + courseId + "/" + feedbackSessionName);
    }
    StudentAttributes student = studentsLogic.getStudentForEmail(courseId, userEmail);
    if (student == null) {
        throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_STUDENT);
    }
    Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> bundle = new HashMap<>();
    Map<String, Map<String, String>> recipientList = new HashMap<>();
    List<FeedbackQuestionAttributes> questions = fqLogic.getFeedbackQuestionsForStudents(feedbackSessionName, courseId);
    Set<String> hiddenInstructorEmails = null;
    for (FeedbackQuestionAttributes question : questions) {
        if (question.getRecipientType() == FeedbackParticipantType.INSTRUCTORS) {
            hiddenInstructorEmails = getHiddenInstructorEmails(courseId);
            break;
        }
    }
    for (FeedbackQuestionAttributes question : questions) {
        updateBundleAndRecipientListWithResponsesForStudent(userEmail, student, bundle, recipientList, question, hiddenInstructorEmails);
    }
    return new FeedbackSessionQuestionsBundle(fsa, bundle, recipientList);
}
Also used : HashMap(java.util.HashMap) FeedbackSessionQuestionsBundle(teammates.common.datatransfer.FeedbackSessionQuestionsBundle) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

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