Skip to content

Commit

Permalink
[#11146] Student viewing responses: show self-response as 'given' AND…
Browse files Browse the repository at this point in the history
… 'received' (#11221)

* Update question responses to show self responses

* Hide num scale question stats when no responses

* Remove trailing whitespace

* Fix broken e2e test

* Fix failing e2e test

* Move check for show responses to frontend

* Update SessionResultsBundle.java

* Fix bug where empty responses displayed

* Hide statistics component when responses are hidden

Co-authored-by: Rahul Rajesh <[email protected]>
  • Loading branch information
samuelfangjw and rrtheonlyone authored Jul 11, 2021
1 parent 43735f6 commit a7a37fb
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 401 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ private List<FeedbackResponseAttributes> getGivenResponses(StudentAttributes cur
FeedbackQuestionAttributes question) {
List<FeedbackResponseAttributes> givenResponses = testData.feedbackResponses.values().stream()
.filter(f -> f.getFeedbackQuestionId().equals(Integer.toString(question.getQuestionNumber()))
&& f.getGiver().equals(currentStudent.getEmail())
&& !f.getRecipient().equals(currentStudent.getEmail()))
&& f.getGiver().equals(currentStudent.getEmail()))
.collect(Collectors.toList());
return editIdentifiers(currentStudent, givenResponses);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ private void verifyOtherResponses(FeedbackQuestionAttributes question, List<Feed
Set<String> recipients = getRecipients(otherResponses);
for (String recipient : recipients) {
List<FeedbackResponseAttributes> expectedResponses = otherResponses.stream()
.filter(r -> r.getRecipient().equals(recipient))
.filter(r -> r.getRecipient().equals(recipient)
&& (question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)
|| question.isResponseVisibleTo(FeedbackParticipantType.STUDENTS)
|| question.isResponseVisibleTo(FeedbackParticipantType.OWN_TEAM_MEMBERS)
|| question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS)))
.collect(Collectors.toList());

verifyResponseForRecipient(question, recipient, expectedResponses, visibleGivers, visibleRecipients);
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/teammates/ui/output/SessionResultsData.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,22 @@ public static SessionResultsData initForStudent(SessionResultsBundle bundle, Stu
boolean isUserGiver = student.getEmail().equals(response.getGiver());
boolean isUserRecipient = student.getEmail().equals(response.getRecipient());
ResponseOutput responseOutput = buildSingleResponseForStudent(response, bundle, student);

if (isUserRecipient) {
qnOutput.responsesToSelf.add(responseOutput);
} else if (isUserGiver) {
}

if (isUserGiver) {
qnOutput.responsesFromSelf.add(responseOutput);
} else {
}

if (!isUserRecipient && !isUserGiver) {
// we don't need care about the keys of the map here
// as only the values of the map will be used
otherResponsesMap.computeIfAbsent(response.getRecipient(), k -> new ArrayList<>())
.add(responseOutput);
}

qnOutput.allResponses.add(responseOutput);
}
}
Expand Down
Loading

0 comments on commit a7a37fb

Please sign in to comment.