Search in sources :

Example 91 with FeedbackQuestionAttributes

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

the class BackDoorTest method testCreateFeedbackResponse.

@Test
public void testCreateFeedbackResponse() {
    FeedbackResponseAttributes fr = new FeedbackResponseAttributes();
    FeedbackQuestionAttributes fq = dataBundle.feedbackQuestions.get("qn1InSession1InCourse1");
    StudentAttributes student = dataBundle.students.get("student3InCourse1");
    fq = BackDoor.getFeedbackQuestion(fq.courseId, fq.feedbackSessionName, fq.questionNumber);
    fr.feedbackSessionName = fq.feedbackSessionName;
    fr.courseId = fq.courseId;
    fr.feedbackQuestionId = fq.getId();
    fr.feedbackQuestionType = fq.questionType;
    fr.giver = student.email;
    fr.giverSection = student.section;
    fr.recipient = student.email;
    fr.recipientSection = student.section;
    fr.responseMetaData = new Text("Student 3 self feedback");
    fr.setId(fq.getId() + "%" + fr.giver + "%" + fr.recipient);
    // Make sure not already inside
    BackDoor.deleteFeedbackResponse(fr.feedbackQuestionId, fr.giver, fr.recipient);
    verifyAbsentInDatastore(fr);
    // Perform creation
    BackDoor.createFeedbackResponse(fr);
    verifyPresentInDatastore(fr);
    // Clean up
    BackDoor.deleteFeedbackResponse(fr.feedbackQuestionId, fr.giver, fr.recipient);
    verifyAbsentInDatastore(fr);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) Text(com.google.appengine.api.datastore.Text) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 92 with FeedbackQuestionAttributes

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

the class FeedbackSessionResultsBundle method getQuestionResponseMapByGiverTeam.

/**
 * Returns an ordered Map with {@code giverTeam} name as key
 * sorted by giverTeam > question > giverName > recipientTeam > recipientName.
 */
public Map<String, Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> getQuestionResponseMapByGiverTeam() {
    LinkedHashMap<String, Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> sortedMap = new LinkedHashMap<>();
    responses.sort(compareByTeamQuestionGiverTeamRecipient);
    for (FeedbackResponseAttributes response : responses) {
        String giverTeam = getTeamNameForEmail(response.giver);
        if (giverTeam.isEmpty()) {
            giverTeam = getNameForEmail(response.giver);
        }
        Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> responsesFromOneGiver = sortedMap.computeIfAbsent(giverTeam, key -> new LinkedHashMap<>());
        FeedbackQuestionAttributes question = questions.get(response.feedbackQuestionId);
        responsesFromOneGiver.computeIfAbsent(question, key -> new ArrayList<>()).add(response);
    }
    return sortedMap;
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Const(teammates.common.util.Const) Set(java.util.Set) SanitizationHelper(teammates.common.util.SanitizationHelper) HashMap(java.util.HashMap) StringHelper(teammates.common.util.StringHelper) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) ZoneId(java.time.ZoneId) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) Map(java.util.Map) Element(org.jsoup.nodes.Element) Text(com.google.appengine.api.datastore.Text) Jsoup(org.jsoup.Jsoup) Elements(org.jsoup.select.Elements) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) Comparator(java.util.Comparator) Logger(teammates.common.util.Logger) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 93 with FeedbackQuestionAttributes

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

the class FeedbackSessionResultsBundle method hideResponsesGiverRecipient.

/**
 * Hides response names/emails and teams that are not visible to the current user.
 * Replaces the giver/recipient email in responses to an email with two "@@"s
 * to indicate it is invalid and should not be displayed.
 */
private void hideResponsesGiverRecipient() {
    for (FeedbackResponseAttributes response : responses) {
        // Hide recipient details if its not visible to the current user
        String name = emailNameTable.get(response.recipient);
        FeedbackQuestionAttributes question = questions.get(response.feedbackQuestionId);
        FeedbackParticipantType participantType = question.recipientType;
        if (participantType == FeedbackParticipantType.SELF) {
            // recipient type for self-feedback is the same as the giver type
            participantType = question.giverType;
        }
        if (!isRecipientVisible(response)) {
            String anonEmail = getAnonEmail(participantType, name);
            name = getAnonName(participantType, name);
            emailNameTable.put(anonEmail, name);
            emailTeamNameTable.put(anonEmail, name + Const.TEAM_OF_EMAIL_OWNER);
            response.recipient = anonEmail;
        }
        // Hide giver details if its not visible to the current user
        name = emailNameTable.get(response.giver);
        participantType = question.giverType;
        if (!isGiverVisible(response)) {
            String anonEmail = getAnonEmail(participantType, name);
            name = getAnonName(participantType, name);
            emailNameTable.put(anonEmail, name);
            emailTeamNameTable.put(anonEmail, name + Const.TEAM_OF_EMAIL_OWNER);
            if (participantType == FeedbackParticipantType.TEAMS) {
                emailTeamNameTable.put(anonEmail, name);
            }
            response.giver = anonEmail;
        }
    }
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 94 with FeedbackQuestionAttributes

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

the class FeedbackSessionResultsBundle method getQuestionResponseMap.

// TODO: make responses to the student calling this method always on top.
/**
 * Gets the questions and responses in this bundle as a map.
 *
 * @return An ordered {@code Map} with keys as {@link FeedbackQuestionAttributes}
 *         sorted by questionNumber.
 *         The mapped values for each key are the corresponding
 *         {@link FeedbackResponseAttributes} as a {@code List}.
 */
public Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> getQuestionResponseMap() {
    if (questions == null || responses == null) {
        return null;
    }
    Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> sortedMap = new LinkedHashMap<>();
    List<FeedbackQuestionAttributes> sortedQuestions = new ArrayList<>(questions.values());
    // sorts the questions by its natural ordering, which is by question number
    sortedQuestions.sort(null);
    for (FeedbackQuestionAttributes question : sortedQuestions) {
        sortedMap.put(question, new ArrayList<FeedbackResponseAttributes>());
    }
    for (FeedbackResponseAttributes response : responses) {
        FeedbackQuestionAttributes question = questions.get(response.feedbackQuestionId);
        List<FeedbackResponseAttributes> responsesForQuestion = sortedMap.get(question);
        responsesForQuestion.add(response);
    }
    for (List<FeedbackResponseAttributes> responsesForQuestion : sortedMap.values()) {
        responsesForQuestion.sort(compareByGiverRecipient);
    }
    return sortedMap;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap)

Example 95 with FeedbackQuestionAttributes

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

the class DataBundleRegenerator method regenerateSessionTemplateJson.

private static void regenerateSessionTemplateJson() throws IOException {
    File file = new File("./src/main/resources/feedbackSessionTeamEvaluationTemplate.json");
    regenerateGenericJson(file);
    String jsonString = FileHelper.readFile(file.getCanonicalPath());
    List<FeedbackQuestionAttributes> template = JsonUtils.fromJson(jsonString, new TypeToken<List<FeedbackQuestionAttributes>>() {
    }.getType());
    for (FeedbackQuestionAttributes question : template) {
        fixQuestion(question);
    }
    String regeneratedJsonString = JsonUtils.toJson(template).replace("+0000", "UTC");
    saveFile(file.getCanonicalPath(), regeneratedJsonString + System.lineSeparator());
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) File(java.io.File)

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