Search in sources :

Example 31 with FeedbackQuestionAttributes

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

the class BackDoorLogic method processQuestionsAndPopulateMap.

private void processQuestionsAndPopulateMap(Collection<FeedbackQuestionAttributes> questions, SetMultimap<String, FeedbackQuestionAttributes> sessionQuestionsMap) {
    for (FeedbackQuestionAttributes question : questions) {
        question.removeIrrelevantVisibilityOptions();
        String sessionKey = makeSessionKey(question.feedbackSessionName, question.courseId);
        sessionQuestionsMap.put(sessionKey, question);
    }
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 32 with FeedbackQuestionAttributes

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

the class BackDoorLogic method makeQuestionKeys.

private List<String> makeQuestionKeys(List<FeedbackQuestionAttributes> questions, String sessionKey) {
    List<String> questionKeys = new ArrayList<>();
    for (FeedbackQuestionAttributes question : questions) {
        String questionKey = makeQuestionKey(sessionKey, question.questionNumber);
        questionKeys.add(questionKey);
    }
    return questionKeys;
}
Also used : ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 33 with FeedbackQuestionAttributes

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

the class BackDoorLogic method editFeedbackQuestionAsJson.

public void editFeedbackQuestionAsJson(String feedbackQuestionJson) throws InvalidParametersException, EntityDoesNotExistException {
    FeedbackQuestionAttributes feedbackQuestion = JsonUtils.fromJson(feedbackQuestionJson, FeedbackQuestionAttributes.class);
    updateFeedbackQuestion(feedbackQuestion);
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 34 with FeedbackQuestionAttributes

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

the class BackDoorLogic method updateRespondents.

private void updateRespondents(FeedbackSessionAttributes session, Set<InstructorAttributes> courseInstructors, Set<FeedbackQuestionAttributes> sessionQuestions, Set<FeedbackResponseAttributes> sessionResponses) {
    String sessionKey = makeSessionKey(session.getFeedbackSessionName(), session.getCourseId());
    SetMultimap<String, String> instructorQuestionKeysMap = HashMultimap.create();
    for (InstructorAttributes instructor : courseInstructors) {
        List<FeedbackQuestionAttributes> questionsForInstructor = feedbackQuestionsLogic.getFeedbackQuestionsForInstructor(new ArrayList<>(sessionQuestions), session.isCreator(instructor.email));
        List<String> questionKeys = makeQuestionKeys(questionsForInstructor, sessionKey);
        instructorQuestionKeysMap.putAll(instructor.email, questionKeys);
    }
    Set<String> respondingInstructors = new HashSet<>();
    Set<String> respondingStudents = new HashSet<>();
    for (FeedbackResponseAttributes response : sessionResponses) {
        String respondent = response.giver;
        // contains question number before injection
        String responseQuestionNumber = response.feedbackQuestionId;
        String responseQuestionKey = makeQuestionKey(sessionKey, responseQuestionNumber);
        Set<String> instructorQuestionKeys = instructorQuestionKeysMap.get(respondent);
        if (instructorQuestionKeys.contains(responseQuestionKey)) {
            respondingInstructors.add(respondent);
        } else {
            respondingStudents.add(respondent);
        }
    }
    session.setRespondingInstructorList(respondingInstructors);
    session.setRespondingStudentList(respondingStudents);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) HashSet(java.util.HashSet)

Example 35 with FeedbackQuestionAttributes

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

the class FeedbackSessionQuestionsBundle method hideUnmoderatableQuestions.

/**
 * Removes question from the bundle if the question has givers or recipients that are anonymous to the instructor
 * or responses that are hidden from the instructor.
 */
public void hideUnmoderatableQuestions() {
    List<FeedbackQuestionAttributes> questionsToHide = new ArrayList<>();
    for (FeedbackQuestionAttributes question : questionResponseBundle.keySet()) {
        boolean isGiverVisibleToInstructor = question.showGiverNameTo.contains(FeedbackParticipantType.INSTRUCTORS);
        boolean isRecipientVisibleToInstructor = question.showRecipientNameTo.contains(FeedbackParticipantType.INSTRUCTORS);
        boolean isResponseVisibleToInstructor = question.showResponsesTo.contains(FeedbackParticipantType.INSTRUCTORS);
        if (!isResponseVisibleToInstructor || !isGiverVisibleToInstructor || !isRecipientVisibleToInstructor) {
            questionsToHide.add(question);
            questionResponseBundle.put(question, new ArrayList<FeedbackResponseAttributes>());
        }
    }
    questionResponseBundle.keySet().removeAll(questionsToHide);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

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