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());
}
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;
}
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);
}
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;
}
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;
}
Aggregations