Search in sources :

Example 71 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method updateRespondentsForSession.

public void updateRespondentsForSession(String feedbackSessionName, String courseId) throws InvalidParametersException, EntityDoesNotExistException {
    clearInstructorRespondents(feedbackSessionName, courseId);
    clearStudentRespondents(feedbackSessionName, courseId);
    FeedbackSessionAttributes fsa = getFeedbackSession(feedbackSessionName, courseId);
    List<FeedbackQuestionAttributes> questions = fqLogic.getFeedbackQuestionsForSession(feedbackSessionName, courseId);
    List<InstructorAttributes> instructors = instructorsLogic.getInstructorsForCourse(courseId);
    Map<String, List<String>> instructorQuestionsMap = new HashMap<>();
    for (InstructorAttributes instructor : instructors) {
        List<FeedbackQuestionAttributes> instructorQns = fqLogic.getFeedbackQuestionsForInstructor(questions, fsa.isCreator(instructor.email));
        if (!instructorQns.isEmpty()) {
            List<String> questionIds = new ArrayList<>();
            for (FeedbackQuestionAttributes question : instructorQns) {
                questionIds.add(question.getId());
            }
            instructorQuestionsMap.put(instructor.email, questionIds);
        }
    }
    Set<String> respondingStudentList = new HashSet<>();
    Set<String> respondingInstructorList = new HashSet<>();
    List<FeedbackResponseAttributes> responses = frLogic.getFeedbackResponsesForSession(feedbackSessionName, courseId);
    for (FeedbackResponseAttributes response : responses) {
        List<String> instructorQuestions = instructorQuestionsMap.get(response.giver);
        if (instructorQuestions != null && instructorQuestions.contains(response.feedbackQuestionId)) {
            respondingInstructorList.add(response.giver);
        } else {
            respondingStudentList.add(response.giver);
        }
    }
    addInstructorRespondents(new ArrayList<>(respondingInstructorList), feedbackSessionName, courseId);
    addStudentRespondents(new ArrayList<>(respondingStudentList), feedbackSessionName, courseId);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Example 72 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method isFeedbackSessionViewableToStudents.

public boolean isFeedbackSessionViewableToStudents(FeedbackSessionAttributes session) {
    // Allow students to view the feedback session if there are questions for them
    List<FeedbackQuestionAttributes> questionsToAnswer = fqLogic.getFeedbackQuestionsForStudents(session.getFeedbackSessionName(), session.getCourseId());
    if (session.isVisible() && !questionsToAnswer.isEmpty()) {
        return true;
    }
    // Allow students to view the feedback session
    // if there are any questions for instructors to answer
    // where the responses of the questions are visible to the students
    List<FeedbackQuestionAttributes> questionsWithVisibleResponses = new ArrayList<>();
    List<FeedbackQuestionAttributes> questionsForInstructors = fqLogic.getFeedbackQuestionsForCreatorInstructor(session);
    for (FeedbackQuestionAttributes question : questionsForInstructors) {
        if (frLogic.isResponseOfFeedbackQuestionVisibleToStudent(question)) {
            questionsWithVisibleResponses.add(question);
        }
    }
    return session.isVisible() && !questionsWithVisibleResponses.isEmpty();
}
Also used : ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 73 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method getResponseComments.

private Map<String, List<FeedbackResponseCommentAttributes>> getResponseComments(String feedbackSessionName, String courseId, String userEmail, UserRole role, CourseRoster roster, Map<String, FeedbackQuestionAttributes> relevantQuestions, String section, StudentAttributes student, Set<String> studentsEmailInTeam, Map<String, FeedbackResponseAttributes> relevantResponse) {
    Map<String, List<FeedbackResponseCommentAttributes>> responseComments = new HashMap<>();
    List<FeedbackResponseCommentAttributes> allResponseComments = frcLogic.getFeedbackResponseCommentForSessionInSection(courseId, feedbackSessionName, section);
    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;
            }
            List<FeedbackResponseCommentAttributes> frcList = responseComments.get(frc.feedbackResponseId);
            if (frcList == null) {
                frcList = new ArrayList<>();
                frcList.add(frc);
                responseComments.put(frc.feedbackResponseId, frcList);
            } else {
                frcList.add(frc);
            }
        }
    }
    for (List<FeedbackResponseCommentAttributes> responseCommentList : responseComments.values()) {
        sortByCreatedDate(responseCommentList);
    }
    return responseComments;
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) HashMap(java.util.HashMap) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List)

Example 74 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method getFeedbackSessionResultsSummaryInSectionAsCsv.

public String getFeedbackSessionResultsSummaryInSectionAsCsv(String feedbackSessionName, String courseId, String userEmail, String section, String questionId, boolean isMissingResponsesShown, boolean isStatsShown) throws EntityDoesNotExistException, ExceedingRangeException {
    FeedbackSessionResultsBundle results;
    int indicatedRange = section == null ? Const.INSTRUCTOR_VIEW_RESPONSE_LIMIT : -1;
    if (questionId == null) {
        results = getFeedbackSessionResultsForInstructorInSectionWithinRangeFromView(feedbackSessionName, courseId, userEmail, section, indicatedRange, Const.FeedbackSessionResults.GRQ_SORT_TYPE);
    } else if (section == null) {
        results = getFeedbackSessionResultsForInstructorFromQuestion(feedbackSessionName, courseId, userEmail, questionId);
    } else {
        results = getFeedbackSessionResultsForInstructorFromQuestionInSection(feedbackSessionName, courseId, userEmail, questionId, section);
    }
    if (!results.isComplete) {
        throw new ExceedingRangeException(ERROR_NUMBER_OF_RESPONSES_EXCEEDS_RANGE);
    }
    // sort responses by giver > recipient > qnNumber
    results.responses.sort(results.compareByGiverRecipientQuestion);
    StringBuilder exportBuilder = new StringBuilder(100);
    exportBuilder.append(String.format("Course,%s", SanitizationHelper.sanitizeForCsv(results.feedbackSession.getCourseId()))).append(System.lineSeparator()).append(String.format("Session Name,%s", SanitizationHelper.sanitizeForCsv(results.feedbackSession.getFeedbackSessionName()))).append(System.lineSeparator());
    if (section != null) {
        exportBuilder.append(String.format("Section Name,%s", SanitizationHelper.sanitizeForCsv(section))).append(System.lineSeparator());
    }
    exportBuilder.append(System.lineSeparator()).append(System.lineSeparator());
    Set<Entry<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> entrySet = results.getQuestionResponseMap().entrySet();
    for (Map.Entry<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> entry : entrySet) {
        exportBuilder.append(getFeedbackSessionResultsForQuestionInCsvFormat(results, entry, isMissingResponsesShown, isStatsShown, section));
    }
    return exportBuilder.toString();
}
Also used : Entry(java.util.Map.Entry) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ExceedingRangeException(teammates.common.exception.ExceedingRangeException) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) FeedbackSessionResultsBundle(teammates.common.datatransfer.FeedbackSessionResultsBundle)

Example 75 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionsLogicTest method testCopyFeedbackSession.

private void testCopyFeedbackSession() throws Exception {
    ______TS("Test copy");
    FeedbackSessionAttributes session1InCourse1 = dataBundle.feedbackSessions.get("session1InCourse1");
    InstructorAttributes instructor2OfCourse1 = dataBundle.instructors.get("instructor2OfCourse1");
    CourseAttributes typicalCourse2 = dataBundle.courses.get("typicalCourse2");
    FeedbackSessionAttributes copiedSession = fsLogic.copyFeedbackSession("Copied Session", typicalCourse2.getId(), session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId(), instructor2OfCourse1.email);
    verifyPresentInDatastore(copiedSession);
    assertEquals("Copied Session", copiedSession.getFeedbackSessionName());
    assertEquals(typicalCourse2.getId(), copiedSession.getCourseId());
    List<FeedbackQuestionAttributes> questions1 = fqLogic.getFeedbackQuestionsForSession(session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId());
    List<FeedbackQuestionAttributes> questions2 = fqLogic.getFeedbackQuestionsForSession(copiedSession.getFeedbackSessionName(), copiedSession.getCourseId());
    assertEquals(questions1.size(), questions2.size());
    for (int i = 0; i < questions1.size(); i++) {
        FeedbackQuestionAttributes question1 = questions1.get(i);
        FeedbackQuestionDetails questionDetails1 = question1.getQuestionDetails();
        FeedbackQuestionAttributes question2 = questions2.get(i);
        FeedbackQuestionDetails questionDetails2 = question2.getQuestionDetails();
        assertEquals(questionDetails1.getQuestionText(), questionDetails2.getQuestionText());
        assertEquals(question1.giverType, question2.giverType);
        assertEquals(question1.recipientType, question2.recipientType);
        assertEquals(question1.questionType, question2.questionType);
        assertEquals(question1.numberOfEntitiesToGiveFeedbackTo, question2.numberOfEntitiesToGiveFeedbackTo);
    }
    assertEquals(0, copiedSession.getRespondingInstructorList().size());
    assertEquals(0, copiedSession.getRespondingStudentList().size());
    ______TS("Failure case: duplicate session");
    try {
        fsLogic.copyFeedbackSession(session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId(), session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId(), instructor2OfCourse1.email);
        signalFailureToDetectException();
    } catch (EntityAlreadyExistsException e) {
        ignoreExpectedException();
    }
    fsLogic.deleteFeedbackSessionCascade(copiedSession.getFeedbackSessionName(), copiedSession.getCourseId());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) EntityAlreadyExistsException(teammates.common.exception.EntityAlreadyExistsException) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Aggregations

FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)154 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)64 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)48 ArrayList (java.util.ArrayList)47 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)38 Test (org.testng.annotations.Test)35 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)25 List (java.util.List)23 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)23 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)19 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)18 HashMap (java.util.HashMap)17 RedirectResult (teammates.ui.controller.RedirectResult)17 HashSet (java.util.HashSet)12 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)12 Text (com.google.appengine.api.datastore.Text)11 Map (java.util.Map)10 FeedbackQuestionDetails (teammates.common.datatransfer.questions.FeedbackQuestionDetails)10 LinkedHashMap (java.util.LinkedHashMap)9 DataBundle (teammates.common.datatransfer.DataBundle)9