Search in sources :

Example 76 with FeedbackResponseAttributes

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

the class StudentFeedbackResultsPageDataTest method testAll.

@Test
public void testAll() throws EntityDoesNotExistException {
    ______TS("typical success case");
    AccountAttributes account = dataBundle.accounts.get("student1InCourse1");
    StudentAttributes student = dataBundle.students.get("student1InCourse1");
    assertNotNull(student);
    String dummyKey = "key123";
    student.key = dummyKey;
    Logic logic = new Logic();
    StudentFeedbackResultsPageData pageData = new StudentFeedbackResultsPageData(account, student, dummySessionToken);
    Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> questionsWithResponses = new LinkedHashMap<>();
    FeedbackQuestionAttributes question1 = dataBundle.feedbackQuestions.get("qn1InSession1InCourse1");
    assertNotNull(question1);
    FeedbackQuestionAttributes question2 = dataBundle.feedbackQuestions.get("qn2InSession1InCourse1");
    assertNotNull(question2);
    List<FeedbackResponseAttributes> responsesForQ1 = new ArrayList<>();
    List<FeedbackResponseAttributes> responsesForQ2 = new ArrayList<>();
    /* Question 1 with responses */
    responsesForQ1.add(dataBundle.feedbackResponses.get("response1ForQ1S1C1"));
    questionsWithResponses.put(question1, responsesForQ1);
    /* Question 2 with responses */
    responsesForQ2.add(dataBundle.feedbackResponses.get("response1ForQ2S1C1"));
    responsesForQ2.add(dataBundle.feedbackResponses.get("response2ForQ2S1C1"));
    questionsWithResponses.put(question2, responsesForQ2);
    // need to obtain questionId and responseId as methods in FeedbackSessionResultsBundle require them
    questionsWithResponses = getActualQuestionsAndResponsesWithId(logic, questionsWithResponses);
    pageData.setBundle(logic.getFeedbackSessionResultsForStudent(question1.feedbackSessionName, question1.courseId, student.email));
    pageData.init(questionsWithResponses);
    StudentFeedbackResultsQuestionWithResponses questionBundle1 = pageData.getFeedbackResultsQuestionsWithResponses().get(0);
    StudentFeedbackResultsQuestionWithResponses questionBundle2 = pageData.getFeedbackResultsQuestionsWithResponses().get(1);
    assertNotNull(pageData.getFeedbackResultsQuestionsWithResponses());
    assertEquals(2, pageData.getFeedbackResultsQuestionsWithResponses().size());
    assertEquals("You are viewing feedback results as <span class='text-danger text-bold text-large'>" + "student1 In Course1</td></div>'\"</span>. You may submit feedback for sessions that are " + "currently open and view results without logging in. " + "To access other features you need <a href='/page/studentCourseJoinAuthentication?" + "key=" + StringHelper.encrypt(dummyKey) + "&studentemail=student1InCourse1%40gmail.tmt&courseid=idOfTypicalCourse1' class='link'>" + "to login using a Google account</a> (recommended).", pageData.getRegisterMessage());
    assertNotNull(questionBundle1.getQuestionDetails());
    assertNotNull(questionBundle2.getQuestionDetails());
    assertEquals("1", questionBundle1.getQuestionDetails().getQuestionIndex());
    assertEquals("2", questionBundle2.getQuestionDetails().getQuestionIndex());
    assertEquals("", questionBundle1.getQuestionDetails().getAdditionalInfo());
    assertEquals("", questionBundle2.getQuestionDetails().getAdditionalInfo());
    assertNotNull(questionBundle1.getResponseTables());
    assertNotNull(questionBundle2.getResponseTables());
    assertEquals("You", questionBundle1.getResponseTables().get(0).getRecipientName());
    assertNotNull(questionBundle1.getResponseTables().get(0).getResponses());
    assertEquals("You", questionBundle1.getResponseTables().get(0).getResponses().get(0).getGiverName());
    assertEquals("Student 1 self feedback.", questionBundle1.getResponseTables().get(0).getResponses().get(0).getAnswer());
    ______TS("student in unregistered course");
    student = dataBundle.students.get("student1InUnregisteredCourse");
    pageData = new StudentFeedbackResultsPageData(account, student, dummySessionToken);
    Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> questionsWithResponsesUnregistered = new LinkedHashMap<>();
    pageData.init(questionsWithResponsesUnregistered);
    assertTrue(pageData.getFeedbackResultsQuestionsWithResponses().isEmpty());
    assertEquals("regKeyForStuNotYetJoinCourse", student.key);
    assertEquals("idOfUnregisteredCourse", student.course);
    assertEquals("student1InUnregisteredCourse@gmail.tmt", student.email);
    assertEquals("You are viewing feedback results as " + "<span class='text-danger text-bold text-large'>student1 In " + "unregisteredCourse</span>. You may submit feedback for sessions that are currently open " + "and view results without logging in. To access other features you need " + "<a href='/page/studentCourseJoinAuthentication?key=" + StringHelper.encrypt("regKeyForStuNotYetJoinCourse") + "&studentemail=student1InUnregisteredCourse%40gmail.tmt&courseid=idOfUnregisteredCourse' " + "class='link'>to login using a Google account</a> (recommended).", pageData.getRegisterMessage());
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) ArrayList(java.util.ArrayList) StudentFeedbackResultsPageData(teammates.ui.pagedata.StudentFeedbackResultsPageData) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) LinkedHashMap(java.util.LinkedHashMap) StudentFeedbackResultsQuestionWithResponses(teammates.ui.template.StudentFeedbackResultsQuestionWithResponses) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) Logic(teammates.logic.api.Logic) Test(org.testng.annotations.Test)

Example 77 with FeedbackResponseAttributes

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

the class StudentFeedbackResultsPageDataTest method getActualQuestionsAndResponsesWithId.

private Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> getActualQuestionsAndResponsesWithId(Logic logic, Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> questionsWithResponses) {
    Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> actualQuestionsWithResponses = new LinkedHashMap<>();
    questionsWithResponses.forEach((dataBundleQuestion, dataBundleResponses) -> {
        FeedbackQuestionAttributes actualQuestion = logic.getFeedbackQuestion(dataBundleQuestion.feedbackSessionName, dataBundleQuestion.courseId, dataBundleQuestion.questionNumber);
        List<FeedbackResponseAttributes> actualResponses = new ArrayList<>();
        for (FeedbackResponseAttributes dataBundleResponse : dataBundleResponses) {
            FeedbackResponseAttributes actualResponse = logic.getFeedbackResponse(actualQuestion.getId(), dataBundleResponse.giver, dataBundleResponse.recipient);
            actualResponses.add(actualResponse);
        }
        actualQuestionsWithResponses.put(actualQuestion, actualResponses);
    });
    return actualQuestionsWithResponses;
}
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 78 with FeedbackResponseAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes 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 79 with FeedbackResponseAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes 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 80 with FeedbackResponseAttributes

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

the class FeedbackSessionResultsBundle method getResponsesSortedByGiver.

public Map<String, Map<String, List<FeedbackResponseAttributes>>> getResponsesSortedByGiver(boolean sortByTeam) {
    Map<String, Map<String, List<FeedbackResponseAttributes>>> sortedMap = new LinkedHashMap<>();
    if (sortByTeam) {
        responses.sort(compareByTeamGiverRecipientQuestion);
    } else {
        responses.sort(compareByGiverRecipientQuestion);
    }
    for (FeedbackResponseAttributes response : responses) {
        String giverName = this.getGiverNameForResponse(response);
        String giverTeamName = this.getTeamNameForEmail(response.giver);
        String giverNameWithTeam = this.appendTeamNameToName(giverName, giverTeamName);
        Map<String, List<FeedbackResponseAttributes>> responsesFromOneGiver = sortedMap.computeIfAbsent(giverNameWithTeam, key -> new LinkedHashMap<>());
        String recipientName = this.getRecipientNameForResponse(response);
        String recipientTeamName = this.getTeamNameForEmail(response.recipient);
        String recipientNameWithTeam = this.appendTeamNameToName(recipientName, recipientTeamName);
        responsesFromOneGiver.computeIfAbsent(recipientNameWithTeam, 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) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)143 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)70 ArrayList (java.util.ArrayList)63 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)36 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)35 List (java.util.List)29 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)28 HashMap (java.util.HashMap)27 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)22 HashSet (java.util.HashSet)20 LinkedHashMap (java.util.LinkedHashMap)20 Map (java.util.Map)18 Test (org.testng.annotations.Test)18 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)18 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)18 Text (com.google.appengine.api.datastore.Text)15 Set (java.util.Set)11 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)10 Comparator (java.util.Comparator)9 FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)9